@iqai/adk 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/index.d.mts +183 -2
- package/dist/index.d.ts +183 -2
- package/dist/index.js +176 -24
- package/dist/index.mjs +175 -23
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1431,6 +1431,174 @@ declare class McpSamplingHandler {
|
|
|
1431
1431
|
*/
|
|
1432
1432
|
declare function createSamplingHandler(handler: SamplingHandler): SamplingHandler;
|
|
1433
1433
|
|
|
1434
|
+
/**
|
|
1435
|
+
* Simplified MCP Server Wrappers
|
|
1436
|
+
*
|
|
1437
|
+
* This module provides simplified wrapper functions for IQAI MCP servers and popular third-party MCP servers.
|
|
1438
|
+
* Instead of manually configuring McpToolset with verbose configuration objects, you can use these
|
|
1439
|
+
* convenience functions with flexible configuration objects.
|
|
1440
|
+
*
|
|
1441
|
+
* @example
|
|
1442
|
+
* ```typescript
|
|
1443
|
+
* // Old verbose way:
|
|
1444
|
+
* const toolset = new McpToolset({
|
|
1445
|
+
* name: "Near Intent Swaps MCP Client",
|
|
1446
|
+
* description: "Client for Near Intent Swaps",
|
|
1447
|
+
* debug: env.DEBUG,
|
|
1448
|
+
* retryOptions: { maxRetries: 2, initialDelay: 200 },
|
|
1449
|
+
* transport: {
|
|
1450
|
+
* mode: "stdio",
|
|
1451
|
+
* command: "npx",
|
|
1452
|
+
* args: ["-y", "@iqai/mcp-near"],
|
|
1453
|
+
* env: {
|
|
1454
|
+
* ACCOUNT_ID: env.ACCOUNT_ID,
|
|
1455
|
+
* ACCOUNT_KEY: env.ACCOUNT_KEY,
|
|
1456
|
+
* NEAR_NETWORK_ID: "testnet",
|
|
1457
|
+
* PATH: env.PATH
|
|
1458
|
+
* },
|
|
1459
|
+
* },
|
|
1460
|
+
* });
|
|
1461
|
+
*
|
|
1462
|
+
* // New simplified way:
|
|
1463
|
+
* const toolset = McpNearAgent({
|
|
1464
|
+
* env: {
|
|
1465
|
+
* ACCOUNT_ID: env.ACCOUNT_ID,
|
|
1466
|
+
* ACCOUNT_KEY: env.ACCOUNT_KEY,
|
|
1467
|
+
* NEAR_NETWORK_ID: "testnet",
|
|
1468
|
+
* PATH: env.PATH
|
|
1469
|
+
* }
|
|
1470
|
+
* });
|
|
1471
|
+
*
|
|
1472
|
+
* // Usage with LLM Agent:
|
|
1473
|
+
* const nearTools = await toolset.getTools();
|
|
1474
|
+
* const agent = new LlmAgent({
|
|
1475
|
+
* name: "near_assistant",
|
|
1476
|
+
* model: "gemini-2.5-flash",
|
|
1477
|
+
* tools: nearTools,
|
|
1478
|
+
* });
|
|
1479
|
+
* ```
|
|
1480
|
+
*
|
|
1481
|
+
* @example
|
|
1482
|
+
* ```typescript
|
|
1483
|
+
* // Multiple MCP servers:
|
|
1484
|
+
* const atpTools = await McpAtp({
|
|
1485
|
+
* env: {
|
|
1486
|
+
* ATP_WALLET_PRIVATE_KEY: env.WALLET_PRIVATE_KEY,
|
|
1487
|
+
* ATP_API_KEY: env.ATP_API_KEY
|
|
1488
|
+
* }
|
|
1489
|
+
* }).getTools();
|
|
1490
|
+
*
|
|
1491
|
+
* const fraxlendTools = await McpFraxlend({
|
|
1492
|
+
* env: {
|
|
1493
|
+
* WALLET_PRIVATE_KEY: env.WALLET_PRIVATE_KEY
|
|
1494
|
+
* }
|
|
1495
|
+
* }).getTools();
|
|
1496
|
+
*
|
|
1497
|
+
* const agent = new LlmAgent({
|
|
1498
|
+
* name: "defi_assistant",
|
|
1499
|
+
* model: "gemini-2.5-flash",
|
|
1500
|
+
* tools: [...atpTools, ...fraxlendTools],
|
|
1501
|
+
* });
|
|
1502
|
+
* ```
|
|
1503
|
+
*/
|
|
1504
|
+
/**
|
|
1505
|
+
* Base configuration interface for MCP servers
|
|
1506
|
+
*/
|
|
1507
|
+
interface McpServerConfig {
|
|
1508
|
+
/** Environment variables to pass to the MCP server */
|
|
1509
|
+
env?: Record<string, any>;
|
|
1510
|
+
/** Enable debug logging */
|
|
1511
|
+
debug?: boolean;
|
|
1512
|
+
/** Custom description for the MCP server */
|
|
1513
|
+
description?: string;
|
|
1514
|
+
/** Retry configuration */
|
|
1515
|
+
retryOptions?: {
|
|
1516
|
+
maxRetries?: number;
|
|
1517
|
+
initialDelay?: number;
|
|
1518
|
+
};
|
|
1519
|
+
}
|
|
1520
|
+
/**
|
|
1521
|
+
* MCP ABI - Smart contract ABI interactions for Ethereum-compatible blockchains
|
|
1522
|
+
*
|
|
1523
|
+
* Required env vars: CONTRACT_ABI, CONTRACT_ADDRESS
|
|
1524
|
+
* Optional env vars: CONTRACT_NAME, CHAIN_ID, RPC_URL, WALLET_PRIVATE_KEY
|
|
1525
|
+
*/
|
|
1526
|
+
declare function McpAbi(config: McpServerConfig): McpToolset;
|
|
1527
|
+
/**
|
|
1528
|
+
* MCP ATP - Interact with the IQ AI Agent Tokenization Platform
|
|
1529
|
+
*
|
|
1530
|
+
* Required env vars: ATP_WALLET_PRIVATE_KEY, ATP_API_KEY
|
|
1531
|
+
*/
|
|
1532
|
+
declare function McpAtp(config: McpServerConfig): McpToolset;
|
|
1533
|
+
/**
|
|
1534
|
+
* MCP BAMM - Borrow Automated Market Maker operations on Fraxtal
|
|
1535
|
+
*
|
|
1536
|
+
* Required env vars: WALLET_PRIVATE_KEY
|
|
1537
|
+
*/
|
|
1538
|
+
declare function McpBamm(config: McpServerConfig): McpToolset;
|
|
1539
|
+
/**
|
|
1540
|
+
* MCP FRAXLEND - Interact with the Fraxlend lending platform
|
|
1541
|
+
*
|
|
1542
|
+
* Required env vars: WALLET_PRIVATE_KEY
|
|
1543
|
+
*/
|
|
1544
|
+
declare function McpFraxlend(config: McpServerConfig): McpToolset;
|
|
1545
|
+
/**
|
|
1546
|
+
* MCP IQWiki - Access and manage IQ.wiki data and user activities
|
|
1547
|
+
*
|
|
1548
|
+
* No required env vars
|
|
1549
|
+
*/
|
|
1550
|
+
declare function McpIqWiki(config?: McpServerConfig): McpToolset;
|
|
1551
|
+
/**
|
|
1552
|
+
* MCP NEAR Agent - NEAR Protocol blockchain integration with AI-driven event processing
|
|
1553
|
+
*
|
|
1554
|
+
* Required env vars: ACCOUNT_ID, ACCOUNT_KEY
|
|
1555
|
+
* Optional env vars: NEAR_NETWORK_ID, NEAR_NODE_URL, NEAR_GAS_LIMIT
|
|
1556
|
+
*/
|
|
1557
|
+
declare function McpNearAgent(config: McpServerConfig): McpToolset;
|
|
1558
|
+
/**
|
|
1559
|
+
* MCP NEAR Intent Swaps - NEAR Protocol intent swaps functionality
|
|
1560
|
+
*
|
|
1561
|
+
* Required env vars: ACCOUNT_ID, ACCOUNT_KEY
|
|
1562
|
+
* Optional env vars: NEAR_NETWORK_ID, NEAR_NODE_URL, NEAR_GAS_LIMIT
|
|
1563
|
+
*/
|
|
1564
|
+
declare function McpNearIntentSwaps(config: McpServerConfig): McpToolset;
|
|
1565
|
+
/**
|
|
1566
|
+
* MCP ODOS - Interact with decentralized exchanges through ODOS aggregation
|
|
1567
|
+
*
|
|
1568
|
+
* Required env vars: WALLET_PRIVATE_KEY
|
|
1569
|
+
*/
|
|
1570
|
+
declare function McpOdos(config: McpServerConfig): McpToolset;
|
|
1571
|
+
/**
|
|
1572
|
+
* MCP Telegram - Interact with Telegram bots and channels
|
|
1573
|
+
*
|
|
1574
|
+
* Required env vars: TELEGRAM_BOT_TOKEN
|
|
1575
|
+
*/
|
|
1576
|
+
declare function McpTelegram(config: McpServerConfig): McpToolset;
|
|
1577
|
+
/**
|
|
1578
|
+
* Popular third-party MCP servers
|
|
1579
|
+
* These can be added as we expand support for community MCP servers
|
|
1580
|
+
*/
|
|
1581
|
+
/**
|
|
1582
|
+
* MCP Filesystem - File system operations (third-party)
|
|
1583
|
+
*
|
|
1584
|
+
* Optional env vars: ALLOWED_DIRECTORIES (comma-separated list)
|
|
1585
|
+
*/
|
|
1586
|
+
declare function McpFilesystem(config?: McpServerConfig): McpToolset;
|
|
1587
|
+
/**
|
|
1588
|
+
* MCP Memory - Memory and note-taking capabilities (third-party)
|
|
1589
|
+
*
|
|
1590
|
+
* No required env vars
|
|
1591
|
+
*/
|
|
1592
|
+
declare function McpMemory(config?: McpServerConfig): McpToolset;
|
|
1593
|
+
/**
|
|
1594
|
+
* Generic MCP server function for any package
|
|
1595
|
+
*
|
|
1596
|
+
* @param packageName The npm package name of the MCP server
|
|
1597
|
+
* @param config Configuration object with environment variables
|
|
1598
|
+
* @param name Optional custom name for the client
|
|
1599
|
+
*/
|
|
1600
|
+
declare function McpGeneric(packageName: string, config?: McpServerConfig, name?: string): McpToolset;
|
|
1601
|
+
|
|
1434
1602
|
/**
|
|
1435
1603
|
* A class for managing MCP tools similar to Python's MCPToolset.
|
|
1436
1604
|
* Provides functionality to retrieve and use tools from an MCP server.
|
|
@@ -1520,15 +1688,28 @@ type index$6_LoadArtifactsTool = LoadArtifactsTool;
|
|
|
1520
1688
|
declare const index$6_LoadArtifactsTool: typeof LoadArtifactsTool;
|
|
1521
1689
|
type index$6_LoadMemoryTool = LoadMemoryTool;
|
|
1522
1690
|
declare const index$6_LoadMemoryTool: typeof LoadMemoryTool;
|
|
1691
|
+
declare const index$6_McpAbi: typeof McpAbi;
|
|
1692
|
+
declare const index$6_McpAtp: typeof McpAtp;
|
|
1693
|
+
declare const index$6_McpBamm: typeof McpBamm;
|
|
1523
1694
|
type index$6_McpConfig = McpConfig;
|
|
1524
1695
|
type index$6_McpError = McpError;
|
|
1525
1696
|
declare const index$6_McpError: typeof McpError;
|
|
1526
1697
|
type index$6_McpErrorType = McpErrorType;
|
|
1527
1698
|
declare const index$6_McpErrorType: typeof McpErrorType;
|
|
1699
|
+
declare const index$6_McpFilesystem: typeof McpFilesystem;
|
|
1700
|
+
declare const index$6_McpFraxlend: typeof McpFraxlend;
|
|
1701
|
+
declare const index$6_McpGeneric: typeof McpGeneric;
|
|
1702
|
+
declare const index$6_McpIqWiki: typeof McpIqWiki;
|
|
1703
|
+
declare const index$6_McpMemory: typeof McpMemory;
|
|
1704
|
+
declare const index$6_McpNearAgent: typeof McpNearAgent;
|
|
1705
|
+
declare const index$6_McpNearIntentSwaps: typeof McpNearIntentSwaps;
|
|
1706
|
+
declare const index$6_McpOdos: typeof McpOdos;
|
|
1528
1707
|
type index$6_McpSamplingHandler = McpSamplingHandler;
|
|
1529
1708
|
declare const index$6_McpSamplingHandler: typeof McpSamplingHandler;
|
|
1530
1709
|
type index$6_McpSamplingRequest = McpSamplingRequest;
|
|
1531
1710
|
type index$6_McpSamplingResponse = McpSamplingResponse;
|
|
1711
|
+
type index$6_McpServerConfig = McpServerConfig;
|
|
1712
|
+
declare const index$6_McpTelegram: typeof McpTelegram;
|
|
1532
1713
|
type index$6_McpToolset = McpToolset;
|
|
1533
1714
|
declare const index$6_McpToolset: typeof McpToolset;
|
|
1534
1715
|
type index$6_McpTransportType = McpTransportType;
|
|
@@ -1549,7 +1730,7 @@ declare const index$6_jsonSchemaToDeclaration: typeof jsonSchemaToDeclaration;
|
|
|
1549
1730
|
declare const index$6_mcpSchemaToParameters: typeof mcpSchemaToParameters;
|
|
1550
1731
|
declare const index$6_normalizeJsonSchema: typeof normalizeJsonSchema;
|
|
1551
1732
|
declare namespace index$6 {
|
|
1552
|
-
export { index$6_BaseTool as BaseTool, type index$6_BuildFunctionDeclarationOptions as BuildFunctionDeclarationOptions, index$6_ExitLoopTool as ExitLoopTool, index$6_FileOperationsTool as FileOperationsTool, index$6_FunctionTool as FunctionTool, index$6_GetUserChoiceTool as GetUserChoiceTool, index$6_GoogleSearch as GoogleSearch, index$6_HttpRequestTool as HttpRequestTool, index$6_LoadArtifactsTool as LoadArtifactsTool, index$6_LoadMemoryTool as LoadMemoryTool, type index$6_McpConfig as McpConfig, index$6_McpError as McpError, index$6_McpErrorType as McpErrorType, index$6_McpSamplingHandler as McpSamplingHandler, type index$6_McpSamplingRequest as McpSamplingRequest, type index$6_McpSamplingResponse as McpSamplingResponse, index$6_McpToolset as McpToolset, type index$6_McpTransportType as McpTransportType, type index$6_SamplingHandler as SamplingHandler, type index$6_ToolConfig as ToolConfig, index$6_ToolContext as ToolContext, index$6_TransferToAgentTool as TransferToAgentTool, index$6_UserInteractionTool as UserInteractionTool, index$6_adkToMcpToolType as adkToMcpToolType, index$6_buildFunctionDeclaration as buildFunctionDeclaration, index$6_createFunctionTool as createFunctionTool, index$6_createSamplingHandler as createSamplingHandler, index$6_getMcpTools as getMcpTools, index$6_jsonSchemaToDeclaration as jsonSchemaToDeclaration, index$6_mcpSchemaToParameters as mcpSchemaToParameters, index$6_normalizeJsonSchema as normalizeJsonSchema };
|
|
1733
|
+
export { index$6_BaseTool as BaseTool, type index$6_BuildFunctionDeclarationOptions as BuildFunctionDeclarationOptions, index$6_ExitLoopTool as ExitLoopTool, index$6_FileOperationsTool as FileOperationsTool, index$6_FunctionTool as FunctionTool, index$6_GetUserChoiceTool as GetUserChoiceTool, index$6_GoogleSearch as GoogleSearch, index$6_HttpRequestTool as HttpRequestTool, index$6_LoadArtifactsTool as LoadArtifactsTool, index$6_LoadMemoryTool as LoadMemoryTool, index$6_McpAbi as McpAbi, index$6_McpAtp as McpAtp, index$6_McpBamm as McpBamm, type index$6_McpConfig as McpConfig, index$6_McpError as McpError, index$6_McpErrorType as McpErrorType, index$6_McpFilesystem as McpFilesystem, index$6_McpFraxlend as McpFraxlend, index$6_McpGeneric as McpGeneric, index$6_McpIqWiki as McpIqWiki, index$6_McpMemory as McpMemory, index$6_McpNearAgent as McpNearAgent, index$6_McpNearIntentSwaps as McpNearIntentSwaps, index$6_McpOdos as McpOdos, index$6_McpSamplingHandler as McpSamplingHandler, type index$6_McpSamplingRequest as McpSamplingRequest, type index$6_McpSamplingResponse as McpSamplingResponse, type index$6_McpServerConfig as McpServerConfig, index$6_McpTelegram as McpTelegram, index$6_McpToolset as McpToolset, type index$6_McpTransportType as McpTransportType, type index$6_SamplingHandler as SamplingHandler, type index$6_ToolConfig as ToolConfig, index$6_ToolContext as ToolContext, index$6_TransferToAgentTool as TransferToAgentTool, index$6_UserInteractionTool as UserInteractionTool, index$6_adkToMcpToolType as adkToMcpToolType, index$6_buildFunctionDeclaration as buildFunctionDeclaration, index$6_createFunctionTool as createFunctionTool, index$6_createSamplingHandler as createSamplingHandler, index$6_getMcpTools as getMcpTools, index$6_jsonSchemaToDeclaration as jsonSchemaToDeclaration, index$6_mcpSchemaToParameters as mcpSchemaToParameters, index$6_normalizeJsonSchema as normalizeJsonSchema };
|
|
1553
1734
|
}
|
|
1554
1735
|
|
|
1555
1736
|
/**
|
|
@@ -4453,4 +4634,4 @@ declare const traceLlmCall: (invocationContext: InvocationContext, eventId: stri
|
|
|
4453
4634
|
|
|
4454
4635
|
declare const VERSION = "0.1.0";
|
|
4455
4636
|
|
|
4456
|
-
export { AF_FUNCTION_CALL_ID_PREFIX, type AfterAgentCallback, LlmAgent as Agent, AgentBuilder, type AgentBuilderConfig, type AgentType, index$4 as Agents, AnthropicLlm, ApiKeyCredential, ApiKeyScheme, AuthConfig, AuthCredential, AuthCredentialType, AuthHandler, AuthScheme, AuthSchemeType, AuthTool, type AuthToolArguments, AutoFlow, BaseAgent, BaseLLMConnection, BaseLlm, BaseLlmFlow, BaseLlmRequestProcessor, BaseLlmResponseProcessor, type BaseMemoryService, BasePlanner, BaseSessionService, BaseTool, BasicAuthCredential, BearerTokenCredential, type BeforeAgentCallback, type BuildFunctionDeclarationOptions, type BuiltAgent, BuiltInPlanner, CallbackContext, DatabaseSessionService, EnhancedAuthConfig, Event, EventActions, index$1 as Events, ExitLoopTool, FileOperationsTool, index as Flows, type FunctionDeclaration, FunctionTool, GcsArtifactService, type GetSessionConfig, GetUserChoiceTool, GoogleLlm, GoogleSearch, HttpRequestTool, HttpScheme, InMemoryArtifactService, InMemoryMemoryService, InMemoryRunner, InMemorySessionService, type InstructionProvider, InvocationContext, type JSONSchema, LLMRegistry, LangGraphAgent, type LangGraphAgentConfig, type LangGraphNode, type ListSessionsResponse, LlmAgent, type LlmAgentConfig, LlmCallsLimitExceededError, LlmRequest, LlmResponse, LoadArtifactsTool, LoadMemoryTool, LoopAgent, type LoopAgentConfig, type McpConfig, McpError, McpErrorType, McpSamplingHandler, type McpSamplingRequest, type McpSamplingResponse, McpToolset, type McpTransportType, index$3 as Memory, index$5 as Models, OAuth2Credential, OAuth2Scheme, type OAuthFlow, type OAuthFlows, OpenAiLlm, OpenIdConnectScheme, ParallelAgent, type ParallelAgentConfig, PlanReActPlanner, REQUEST_EUC_FUNCTION_CALL_NAME, ReadonlyContext, RunConfig, Runner, type SamplingHandler, type SearchMemoryResponse, SequentialAgent, type SequentialAgentConfig, type Session, type SessionConfig, index$2 as Sessions, type SingleAgentCallback, SingleFlow, State, StreamingMode, type TelemetryConfig, TelemetryService, type ThinkingConfig, type ToolConfig, ToolContext, type ToolUnion, index$6 as Tools, TransferToAgentTool, UserInteractionTool, VERSION, VertexAiSessionService, adkToMcpToolType, requestProcessor$2 as agentTransferRequestProcessor, requestProcessor$6 as basicRequestProcessor, buildFunctionDeclaration, requestProcessor as codeExecutionRequestProcessor, responseProcessor as codeExecutionResponseProcessor, requestProcessor$3 as contentRequestProcessor, createAuthToolArguments, createDatabaseSessionService, createFunctionTool, createMysqlSessionService, createPostgresSessionService, createSamplingHandler, createSqliteSessionService, generateAuthEvent, generateClientFunctionCallId, getLongRunningFunctionCalls, getMcpTools, handleFunctionCallsAsync, handleFunctionCallsLive, requestProcessor$5 as identityRequestProcessor, initializeTelemetry, injectSessionState, requestProcessor$4 as instructionsRequestProcessor, isEnhancedAuthConfig, jsonSchemaToDeclaration, mcpSchemaToParameters, mergeParallelFunctionResponseEvents, newInvocationContextId, requestProcessor$1 as nlPlanningRequestProcessor, responseProcessor$1 as nlPlanningResponseProcessor, normalizeJsonSchema, populateClientFunctionCallId, registerProviders, removeClientFunctionCallId, requestProcessor$7 as requestProcessor, shutdownTelemetry, telemetryService, traceLlmCall, traceToolCall, tracer };
|
|
4637
|
+
export { AF_FUNCTION_CALL_ID_PREFIX, type AfterAgentCallback, LlmAgent as Agent, AgentBuilder, type AgentBuilderConfig, type AgentType, index$4 as Agents, AnthropicLlm, ApiKeyCredential, ApiKeyScheme, AuthConfig, AuthCredential, AuthCredentialType, AuthHandler, AuthScheme, AuthSchemeType, AuthTool, type AuthToolArguments, AutoFlow, BaseAgent, BaseLLMConnection, BaseLlm, BaseLlmFlow, BaseLlmRequestProcessor, BaseLlmResponseProcessor, type BaseMemoryService, BasePlanner, BaseSessionService, BaseTool, BasicAuthCredential, BearerTokenCredential, type BeforeAgentCallback, type BuildFunctionDeclarationOptions, type BuiltAgent, BuiltInPlanner, CallbackContext, DatabaseSessionService, EnhancedAuthConfig, Event, EventActions, index$1 as Events, ExitLoopTool, FileOperationsTool, index as Flows, type FunctionDeclaration, FunctionTool, GcsArtifactService, type GetSessionConfig, GetUserChoiceTool, GoogleLlm, GoogleSearch, HttpRequestTool, HttpScheme, InMemoryArtifactService, InMemoryMemoryService, InMemoryRunner, InMemorySessionService, type InstructionProvider, InvocationContext, type JSONSchema, LLMRegistry, LangGraphAgent, type LangGraphAgentConfig, type LangGraphNode, type ListSessionsResponse, LlmAgent, type LlmAgentConfig, LlmCallsLimitExceededError, LlmRequest, LlmResponse, LoadArtifactsTool, LoadMemoryTool, LoopAgent, type LoopAgentConfig, McpAbi, McpAtp, McpBamm, type McpConfig, McpError, McpErrorType, McpFilesystem, McpFraxlend, McpGeneric, McpIqWiki, McpMemory, McpNearAgent, McpNearIntentSwaps, McpOdos, McpSamplingHandler, type McpSamplingRequest, type McpSamplingResponse, type McpServerConfig, McpTelegram, McpToolset, type McpTransportType, index$3 as Memory, index$5 as Models, OAuth2Credential, OAuth2Scheme, type OAuthFlow, type OAuthFlows, OpenAiLlm, OpenIdConnectScheme, ParallelAgent, type ParallelAgentConfig, PlanReActPlanner, REQUEST_EUC_FUNCTION_CALL_NAME, ReadonlyContext, RunConfig, Runner, type SamplingHandler, type SearchMemoryResponse, SequentialAgent, type SequentialAgentConfig, type Session, type SessionConfig, index$2 as Sessions, type SingleAgentCallback, SingleFlow, State, StreamingMode, type TelemetryConfig, TelemetryService, type ThinkingConfig, type ToolConfig, ToolContext, type ToolUnion, index$6 as Tools, TransferToAgentTool, UserInteractionTool, VERSION, VertexAiSessionService, adkToMcpToolType, requestProcessor$2 as agentTransferRequestProcessor, requestProcessor$6 as basicRequestProcessor, buildFunctionDeclaration, requestProcessor as codeExecutionRequestProcessor, responseProcessor as codeExecutionResponseProcessor, requestProcessor$3 as contentRequestProcessor, createAuthToolArguments, createDatabaseSessionService, createFunctionTool, createMysqlSessionService, createPostgresSessionService, createSamplingHandler, createSqliteSessionService, generateAuthEvent, generateClientFunctionCallId, getLongRunningFunctionCalls, getMcpTools, handleFunctionCallsAsync, handleFunctionCallsLive, requestProcessor$5 as identityRequestProcessor, initializeTelemetry, injectSessionState, requestProcessor$4 as instructionsRequestProcessor, isEnhancedAuthConfig, jsonSchemaToDeclaration, mcpSchemaToParameters, mergeParallelFunctionResponseEvents, newInvocationContextId, requestProcessor$1 as nlPlanningRequestProcessor, responseProcessor$1 as nlPlanningResponseProcessor, normalizeJsonSchema, populateClientFunctionCallId, registerProviders, removeClientFunctionCallId, requestProcessor$7 as requestProcessor, shutdownTelemetry, telemetryService, traceLlmCall, traceToolCall, tracer };
|
package/dist/index.d.ts
CHANGED
|
@@ -1431,6 +1431,174 @@ declare class McpSamplingHandler {
|
|
|
1431
1431
|
*/
|
|
1432
1432
|
declare function createSamplingHandler(handler: SamplingHandler): SamplingHandler;
|
|
1433
1433
|
|
|
1434
|
+
/**
|
|
1435
|
+
* Simplified MCP Server Wrappers
|
|
1436
|
+
*
|
|
1437
|
+
* This module provides simplified wrapper functions for IQAI MCP servers and popular third-party MCP servers.
|
|
1438
|
+
* Instead of manually configuring McpToolset with verbose configuration objects, you can use these
|
|
1439
|
+
* convenience functions with flexible configuration objects.
|
|
1440
|
+
*
|
|
1441
|
+
* @example
|
|
1442
|
+
* ```typescript
|
|
1443
|
+
* // Old verbose way:
|
|
1444
|
+
* const toolset = new McpToolset({
|
|
1445
|
+
* name: "Near Intent Swaps MCP Client",
|
|
1446
|
+
* description: "Client for Near Intent Swaps",
|
|
1447
|
+
* debug: env.DEBUG,
|
|
1448
|
+
* retryOptions: { maxRetries: 2, initialDelay: 200 },
|
|
1449
|
+
* transport: {
|
|
1450
|
+
* mode: "stdio",
|
|
1451
|
+
* command: "npx",
|
|
1452
|
+
* args: ["-y", "@iqai/mcp-near"],
|
|
1453
|
+
* env: {
|
|
1454
|
+
* ACCOUNT_ID: env.ACCOUNT_ID,
|
|
1455
|
+
* ACCOUNT_KEY: env.ACCOUNT_KEY,
|
|
1456
|
+
* NEAR_NETWORK_ID: "testnet",
|
|
1457
|
+
* PATH: env.PATH
|
|
1458
|
+
* },
|
|
1459
|
+
* },
|
|
1460
|
+
* });
|
|
1461
|
+
*
|
|
1462
|
+
* // New simplified way:
|
|
1463
|
+
* const toolset = McpNearAgent({
|
|
1464
|
+
* env: {
|
|
1465
|
+
* ACCOUNT_ID: env.ACCOUNT_ID,
|
|
1466
|
+
* ACCOUNT_KEY: env.ACCOUNT_KEY,
|
|
1467
|
+
* NEAR_NETWORK_ID: "testnet",
|
|
1468
|
+
* PATH: env.PATH
|
|
1469
|
+
* }
|
|
1470
|
+
* });
|
|
1471
|
+
*
|
|
1472
|
+
* // Usage with LLM Agent:
|
|
1473
|
+
* const nearTools = await toolset.getTools();
|
|
1474
|
+
* const agent = new LlmAgent({
|
|
1475
|
+
* name: "near_assistant",
|
|
1476
|
+
* model: "gemini-2.5-flash",
|
|
1477
|
+
* tools: nearTools,
|
|
1478
|
+
* });
|
|
1479
|
+
* ```
|
|
1480
|
+
*
|
|
1481
|
+
* @example
|
|
1482
|
+
* ```typescript
|
|
1483
|
+
* // Multiple MCP servers:
|
|
1484
|
+
* const atpTools = await McpAtp({
|
|
1485
|
+
* env: {
|
|
1486
|
+
* ATP_WALLET_PRIVATE_KEY: env.WALLET_PRIVATE_KEY,
|
|
1487
|
+
* ATP_API_KEY: env.ATP_API_KEY
|
|
1488
|
+
* }
|
|
1489
|
+
* }).getTools();
|
|
1490
|
+
*
|
|
1491
|
+
* const fraxlendTools = await McpFraxlend({
|
|
1492
|
+
* env: {
|
|
1493
|
+
* WALLET_PRIVATE_KEY: env.WALLET_PRIVATE_KEY
|
|
1494
|
+
* }
|
|
1495
|
+
* }).getTools();
|
|
1496
|
+
*
|
|
1497
|
+
* const agent = new LlmAgent({
|
|
1498
|
+
* name: "defi_assistant",
|
|
1499
|
+
* model: "gemini-2.5-flash",
|
|
1500
|
+
* tools: [...atpTools, ...fraxlendTools],
|
|
1501
|
+
* });
|
|
1502
|
+
* ```
|
|
1503
|
+
*/
|
|
1504
|
+
/**
|
|
1505
|
+
* Base configuration interface for MCP servers
|
|
1506
|
+
*/
|
|
1507
|
+
interface McpServerConfig {
|
|
1508
|
+
/** Environment variables to pass to the MCP server */
|
|
1509
|
+
env?: Record<string, any>;
|
|
1510
|
+
/** Enable debug logging */
|
|
1511
|
+
debug?: boolean;
|
|
1512
|
+
/** Custom description for the MCP server */
|
|
1513
|
+
description?: string;
|
|
1514
|
+
/** Retry configuration */
|
|
1515
|
+
retryOptions?: {
|
|
1516
|
+
maxRetries?: number;
|
|
1517
|
+
initialDelay?: number;
|
|
1518
|
+
};
|
|
1519
|
+
}
|
|
1520
|
+
/**
|
|
1521
|
+
* MCP ABI - Smart contract ABI interactions for Ethereum-compatible blockchains
|
|
1522
|
+
*
|
|
1523
|
+
* Required env vars: CONTRACT_ABI, CONTRACT_ADDRESS
|
|
1524
|
+
* Optional env vars: CONTRACT_NAME, CHAIN_ID, RPC_URL, WALLET_PRIVATE_KEY
|
|
1525
|
+
*/
|
|
1526
|
+
declare function McpAbi(config: McpServerConfig): McpToolset;
|
|
1527
|
+
/**
|
|
1528
|
+
* MCP ATP - Interact with the IQ AI Agent Tokenization Platform
|
|
1529
|
+
*
|
|
1530
|
+
* Required env vars: ATP_WALLET_PRIVATE_KEY, ATP_API_KEY
|
|
1531
|
+
*/
|
|
1532
|
+
declare function McpAtp(config: McpServerConfig): McpToolset;
|
|
1533
|
+
/**
|
|
1534
|
+
* MCP BAMM - Borrow Automated Market Maker operations on Fraxtal
|
|
1535
|
+
*
|
|
1536
|
+
* Required env vars: WALLET_PRIVATE_KEY
|
|
1537
|
+
*/
|
|
1538
|
+
declare function McpBamm(config: McpServerConfig): McpToolset;
|
|
1539
|
+
/**
|
|
1540
|
+
* MCP FRAXLEND - Interact with the Fraxlend lending platform
|
|
1541
|
+
*
|
|
1542
|
+
* Required env vars: WALLET_PRIVATE_KEY
|
|
1543
|
+
*/
|
|
1544
|
+
declare function McpFraxlend(config: McpServerConfig): McpToolset;
|
|
1545
|
+
/**
|
|
1546
|
+
* MCP IQWiki - Access and manage IQ.wiki data and user activities
|
|
1547
|
+
*
|
|
1548
|
+
* No required env vars
|
|
1549
|
+
*/
|
|
1550
|
+
declare function McpIqWiki(config?: McpServerConfig): McpToolset;
|
|
1551
|
+
/**
|
|
1552
|
+
* MCP NEAR Agent - NEAR Protocol blockchain integration with AI-driven event processing
|
|
1553
|
+
*
|
|
1554
|
+
* Required env vars: ACCOUNT_ID, ACCOUNT_KEY
|
|
1555
|
+
* Optional env vars: NEAR_NETWORK_ID, NEAR_NODE_URL, NEAR_GAS_LIMIT
|
|
1556
|
+
*/
|
|
1557
|
+
declare function McpNearAgent(config: McpServerConfig): McpToolset;
|
|
1558
|
+
/**
|
|
1559
|
+
* MCP NEAR Intent Swaps - NEAR Protocol intent swaps functionality
|
|
1560
|
+
*
|
|
1561
|
+
* Required env vars: ACCOUNT_ID, ACCOUNT_KEY
|
|
1562
|
+
* Optional env vars: NEAR_NETWORK_ID, NEAR_NODE_URL, NEAR_GAS_LIMIT
|
|
1563
|
+
*/
|
|
1564
|
+
declare function McpNearIntentSwaps(config: McpServerConfig): McpToolset;
|
|
1565
|
+
/**
|
|
1566
|
+
* MCP ODOS - Interact with decentralized exchanges through ODOS aggregation
|
|
1567
|
+
*
|
|
1568
|
+
* Required env vars: WALLET_PRIVATE_KEY
|
|
1569
|
+
*/
|
|
1570
|
+
declare function McpOdos(config: McpServerConfig): McpToolset;
|
|
1571
|
+
/**
|
|
1572
|
+
* MCP Telegram - Interact with Telegram bots and channels
|
|
1573
|
+
*
|
|
1574
|
+
* Required env vars: TELEGRAM_BOT_TOKEN
|
|
1575
|
+
*/
|
|
1576
|
+
declare function McpTelegram(config: McpServerConfig): McpToolset;
|
|
1577
|
+
/**
|
|
1578
|
+
* Popular third-party MCP servers
|
|
1579
|
+
* These can be added as we expand support for community MCP servers
|
|
1580
|
+
*/
|
|
1581
|
+
/**
|
|
1582
|
+
* MCP Filesystem - File system operations (third-party)
|
|
1583
|
+
*
|
|
1584
|
+
* Optional env vars: ALLOWED_DIRECTORIES (comma-separated list)
|
|
1585
|
+
*/
|
|
1586
|
+
declare function McpFilesystem(config?: McpServerConfig): McpToolset;
|
|
1587
|
+
/**
|
|
1588
|
+
* MCP Memory - Memory and note-taking capabilities (third-party)
|
|
1589
|
+
*
|
|
1590
|
+
* No required env vars
|
|
1591
|
+
*/
|
|
1592
|
+
declare function McpMemory(config?: McpServerConfig): McpToolset;
|
|
1593
|
+
/**
|
|
1594
|
+
* Generic MCP server function for any package
|
|
1595
|
+
*
|
|
1596
|
+
* @param packageName The npm package name of the MCP server
|
|
1597
|
+
* @param config Configuration object with environment variables
|
|
1598
|
+
* @param name Optional custom name for the client
|
|
1599
|
+
*/
|
|
1600
|
+
declare function McpGeneric(packageName: string, config?: McpServerConfig, name?: string): McpToolset;
|
|
1601
|
+
|
|
1434
1602
|
/**
|
|
1435
1603
|
* A class for managing MCP tools similar to Python's MCPToolset.
|
|
1436
1604
|
* Provides functionality to retrieve and use tools from an MCP server.
|
|
@@ -1520,15 +1688,28 @@ type index$6_LoadArtifactsTool = LoadArtifactsTool;
|
|
|
1520
1688
|
declare const index$6_LoadArtifactsTool: typeof LoadArtifactsTool;
|
|
1521
1689
|
type index$6_LoadMemoryTool = LoadMemoryTool;
|
|
1522
1690
|
declare const index$6_LoadMemoryTool: typeof LoadMemoryTool;
|
|
1691
|
+
declare const index$6_McpAbi: typeof McpAbi;
|
|
1692
|
+
declare const index$6_McpAtp: typeof McpAtp;
|
|
1693
|
+
declare const index$6_McpBamm: typeof McpBamm;
|
|
1523
1694
|
type index$6_McpConfig = McpConfig;
|
|
1524
1695
|
type index$6_McpError = McpError;
|
|
1525
1696
|
declare const index$6_McpError: typeof McpError;
|
|
1526
1697
|
type index$6_McpErrorType = McpErrorType;
|
|
1527
1698
|
declare const index$6_McpErrorType: typeof McpErrorType;
|
|
1699
|
+
declare const index$6_McpFilesystem: typeof McpFilesystem;
|
|
1700
|
+
declare const index$6_McpFraxlend: typeof McpFraxlend;
|
|
1701
|
+
declare const index$6_McpGeneric: typeof McpGeneric;
|
|
1702
|
+
declare const index$6_McpIqWiki: typeof McpIqWiki;
|
|
1703
|
+
declare const index$6_McpMemory: typeof McpMemory;
|
|
1704
|
+
declare const index$6_McpNearAgent: typeof McpNearAgent;
|
|
1705
|
+
declare const index$6_McpNearIntentSwaps: typeof McpNearIntentSwaps;
|
|
1706
|
+
declare const index$6_McpOdos: typeof McpOdos;
|
|
1528
1707
|
type index$6_McpSamplingHandler = McpSamplingHandler;
|
|
1529
1708
|
declare const index$6_McpSamplingHandler: typeof McpSamplingHandler;
|
|
1530
1709
|
type index$6_McpSamplingRequest = McpSamplingRequest;
|
|
1531
1710
|
type index$6_McpSamplingResponse = McpSamplingResponse;
|
|
1711
|
+
type index$6_McpServerConfig = McpServerConfig;
|
|
1712
|
+
declare const index$6_McpTelegram: typeof McpTelegram;
|
|
1532
1713
|
type index$6_McpToolset = McpToolset;
|
|
1533
1714
|
declare const index$6_McpToolset: typeof McpToolset;
|
|
1534
1715
|
type index$6_McpTransportType = McpTransportType;
|
|
@@ -1549,7 +1730,7 @@ declare const index$6_jsonSchemaToDeclaration: typeof jsonSchemaToDeclaration;
|
|
|
1549
1730
|
declare const index$6_mcpSchemaToParameters: typeof mcpSchemaToParameters;
|
|
1550
1731
|
declare const index$6_normalizeJsonSchema: typeof normalizeJsonSchema;
|
|
1551
1732
|
declare namespace index$6 {
|
|
1552
|
-
export { index$6_BaseTool as BaseTool, type index$6_BuildFunctionDeclarationOptions as BuildFunctionDeclarationOptions, index$6_ExitLoopTool as ExitLoopTool, index$6_FileOperationsTool as FileOperationsTool, index$6_FunctionTool as FunctionTool, index$6_GetUserChoiceTool as GetUserChoiceTool, index$6_GoogleSearch as GoogleSearch, index$6_HttpRequestTool as HttpRequestTool, index$6_LoadArtifactsTool as LoadArtifactsTool, index$6_LoadMemoryTool as LoadMemoryTool, type index$6_McpConfig as McpConfig, index$6_McpError as McpError, index$6_McpErrorType as McpErrorType, index$6_McpSamplingHandler as McpSamplingHandler, type index$6_McpSamplingRequest as McpSamplingRequest, type index$6_McpSamplingResponse as McpSamplingResponse, index$6_McpToolset as McpToolset, type index$6_McpTransportType as McpTransportType, type index$6_SamplingHandler as SamplingHandler, type index$6_ToolConfig as ToolConfig, index$6_ToolContext as ToolContext, index$6_TransferToAgentTool as TransferToAgentTool, index$6_UserInteractionTool as UserInteractionTool, index$6_adkToMcpToolType as adkToMcpToolType, index$6_buildFunctionDeclaration as buildFunctionDeclaration, index$6_createFunctionTool as createFunctionTool, index$6_createSamplingHandler as createSamplingHandler, index$6_getMcpTools as getMcpTools, index$6_jsonSchemaToDeclaration as jsonSchemaToDeclaration, index$6_mcpSchemaToParameters as mcpSchemaToParameters, index$6_normalizeJsonSchema as normalizeJsonSchema };
|
|
1733
|
+
export { index$6_BaseTool as BaseTool, type index$6_BuildFunctionDeclarationOptions as BuildFunctionDeclarationOptions, index$6_ExitLoopTool as ExitLoopTool, index$6_FileOperationsTool as FileOperationsTool, index$6_FunctionTool as FunctionTool, index$6_GetUserChoiceTool as GetUserChoiceTool, index$6_GoogleSearch as GoogleSearch, index$6_HttpRequestTool as HttpRequestTool, index$6_LoadArtifactsTool as LoadArtifactsTool, index$6_LoadMemoryTool as LoadMemoryTool, index$6_McpAbi as McpAbi, index$6_McpAtp as McpAtp, index$6_McpBamm as McpBamm, type index$6_McpConfig as McpConfig, index$6_McpError as McpError, index$6_McpErrorType as McpErrorType, index$6_McpFilesystem as McpFilesystem, index$6_McpFraxlend as McpFraxlend, index$6_McpGeneric as McpGeneric, index$6_McpIqWiki as McpIqWiki, index$6_McpMemory as McpMemory, index$6_McpNearAgent as McpNearAgent, index$6_McpNearIntentSwaps as McpNearIntentSwaps, index$6_McpOdos as McpOdos, index$6_McpSamplingHandler as McpSamplingHandler, type index$6_McpSamplingRequest as McpSamplingRequest, type index$6_McpSamplingResponse as McpSamplingResponse, type index$6_McpServerConfig as McpServerConfig, index$6_McpTelegram as McpTelegram, index$6_McpToolset as McpToolset, type index$6_McpTransportType as McpTransportType, type index$6_SamplingHandler as SamplingHandler, type index$6_ToolConfig as ToolConfig, index$6_ToolContext as ToolContext, index$6_TransferToAgentTool as TransferToAgentTool, index$6_UserInteractionTool as UserInteractionTool, index$6_adkToMcpToolType as adkToMcpToolType, index$6_buildFunctionDeclaration as buildFunctionDeclaration, index$6_createFunctionTool as createFunctionTool, index$6_createSamplingHandler as createSamplingHandler, index$6_getMcpTools as getMcpTools, index$6_jsonSchemaToDeclaration as jsonSchemaToDeclaration, index$6_mcpSchemaToParameters as mcpSchemaToParameters, index$6_normalizeJsonSchema as normalizeJsonSchema };
|
|
1553
1734
|
}
|
|
1554
1735
|
|
|
1555
1736
|
/**
|
|
@@ -4453,4 +4634,4 @@ declare const traceLlmCall: (invocationContext: InvocationContext, eventId: stri
|
|
|
4453
4634
|
|
|
4454
4635
|
declare const VERSION = "0.1.0";
|
|
4455
4636
|
|
|
4456
|
-
export { AF_FUNCTION_CALL_ID_PREFIX, type AfterAgentCallback, LlmAgent as Agent, AgentBuilder, type AgentBuilderConfig, type AgentType, index$4 as Agents, AnthropicLlm, ApiKeyCredential, ApiKeyScheme, AuthConfig, AuthCredential, AuthCredentialType, AuthHandler, AuthScheme, AuthSchemeType, AuthTool, type AuthToolArguments, AutoFlow, BaseAgent, BaseLLMConnection, BaseLlm, BaseLlmFlow, BaseLlmRequestProcessor, BaseLlmResponseProcessor, type BaseMemoryService, BasePlanner, BaseSessionService, BaseTool, BasicAuthCredential, BearerTokenCredential, type BeforeAgentCallback, type BuildFunctionDeclarationOptions, type BuiltAgent, BuiltInPlanner, CallbackContext, DatabaseSessionService, EnhancedAuthConfig, Event, EventActions, index$1 as Events, ExitLoopTool, FileOperationsTool, index as Flows, type FunctionDeclaration, FunctionTool, GcsArtifactService, type GetSessionConfig, GetUserChoiceTool, GoogleLlm, GoogleSearch, HttpRequestTool, HttpScheme, InMemoryArtifactService, InMemoryMemoryService, InMemoryRunner, InMemorySessionService, type InstructionProvider, InvocationContext, type JSONSchema, LLMRegistry, LangGraphAgent, type LangGraphAgentConfig, type LangGraphNode, type ListSessionsResponse, LlmAgent, type LlmAgentConfig, LlmCallsLimitExceededError, LlmRequest, LlmResponse, LoadArtifactsTool, LoadMemoryTool, LoopAgent, type LoopAgentConfig, type McpConfig, McpError, McpErrorType, McpSamplingHandler, type McpSamplingRequest, type McpSamplingResponse, McpToolset, type McpTransportType, index$3 as Memory, index$5 as Models, OAuth2Credential, OAuth2Scheme, type OAuthFlow, type OAuthFlows, OpenAiLlm, OpenIdConnectScheme, ParallelAgent, type ParallelAgentConfig, PlanReActPlanner, REQUEST_EUC_FUNCTION_CALL_NAME, ReadonlyContext, RunConfig, Runner, type SamplingHandler, type SearchMemoryResponse, SequentialAgent, type SequentialAgentConfig, type Session, type SessionConfig, index$2 as Sessions, type SingleAgentCallback, SingleFlow, State, StreamingMode, type TelemetryConfig, TelemetryService, type ThinkingConfig, type ToolConfig, ToolContext, type ToolUnion, index$6 as Tools, TransferToAgentTool, UserInteractionTool, VERSION, VertexAiSessionService, adkToMcpToolType, requestProcessor$2 as agentTransferRequestProcessor, requestProcessor$6 as basicRequestProcessor, buildFunctionDeclaration, requestProcessor as codeExecutionRequestProcessor, responseProcessor as codeExecutionResponseProcessor, requestProcessor$3 as contentRequestProcessor, createAuthToolArguments, createDatabaseSessionService, createFunctionTool, createMysqlSessionService, createPostgresSessionService, createSamplingHandler, createSqliteSessionService, generateAuthEvent, generateClientFunctionCallId, getLongRunningFunctionCalls, getMcpTools, handleFunctionCallsAsync, handleFunctionCallsLive, requestProcessor$5 as identityRequestProcessor, initializeTelemetry, injectSessionState, requestProcessor$4 as instructionsRequestProcessor, isEnhancedAuthConfig, jsonSchemaToDeclaration, mcpSchemaToParameters, mergeParallelFunctionResponseEvents, newInvocationContextId, requestProcessor$1 as nlPlanningRequestProcessor, responseProcessor$1 as nlPlanningResponseProcessor, normalizeJsonSchema, populateClientFunctionCallId, registerProviders, removeClientFunctionCallId, requestProcessor$7 as requestProcessor, shutdownTelemetry, telemetryService, traceLlmCall, traceToolCall, tracer };
|
|
4637
|
+
export { AF_FUNCTION_CALL_ID_PREFIX, type AfterAgentCallback, LlmAgent as Agent, AgentBuilder, type AgentBuilderConfig, type AgentType, index$4 as Agents, AnthropicLlm, ApiKeyCredential, ApiKeyScheme, AuthConfig, AuthCredential, AuthCredentialType, AuthHandler, AuthScheme, AuthSchemeType, AuthTool, type AuthToolArguments, AutoFlow, BaseAgent, BaseLLMConnection, BaseLlm, BaseLlmFlow, BaseLlmRequestProcessor, BaseLlmResponseProcessor, type BaseMemoryService, BasePlanner, BaseSessionService, BaseTool, BasicAuthCredential, BearerTokenCredential, type BeforeAgentCallback, type BuildFunctionDeclarationOptions, type BuiltAgent, BuiltInPlanner, CallbackContext, DatabaseSessionService, EnhancedAuthConfig, Event, EventActions, index$1 as Events, ExitLoopTool, FileOperationsTool, index as Flows, type FunctionDeclaration, FunctionTool, GcsArtifactService, type GetSessionConfig, GetUserChoiceTool, GoogleLlm, GoogleSearch, HttpRequestTool, HttpScheme, InMemoryArtifactService, InMemoryMemoryService, InMemoryRunner, InMemorySessionService, type InstructionProvider, InvocationContext, type JSONSchema, LLMRegistry, LangGraphAgent, type LangGraphAgentConfig, type LangGraphNode, type ListSessionsResponse, LlmAgent, type LlmAgentConfig, LlmCallsLimitExceededError, LlmRequest, LlmResponse, LoadArtifactsTool, LoadMemoryTool, LoopAgent, type LoopAgentConfig, McpAbi, McpAtp, McpBamm, type McpConfig, McpError, McpErrorType, McpFilesystem, McpFraxlend, McpGeneric, McpIqWiki, McpMemory, McpNearAgent, McpNearIntentSwaps, McpOdos, McpSamplingHandler, type McpSamplingRequest, type McpSamplingResponse, type McpServerConfig, McpTelegram, McpToolset, type McpTransportType, index$3 as Memory, index$5 as Models, OAuth2Credential, OAuth2Scheme, type OAuthFlow, type OAuthFlows, OpenAiLlm, OpenIdConnectScheme, ParallelAgent, type ParallelAgentConfig, PlanReActPlanner, REQUEST_EUC_FUNCTION_CALL_NAME, ReadonlyContext, RunConfig, Runner, type SamplingHandler, type SearchMemoryResponse, SequentialAgent, type SequentialAgentConfig, type Session, type SessionConfig, index$2 as Sessions, type SingleAgentCallback, SingleFlow, State, StreamingMode, type TelemetryConfig, TelemetryService, type ThinkingConfig, type ToolConfig, ToolContext, type ToolUnion, index$6 as Tools, TransferToAgentTool, UserInteractionTool, VERSION, VertexAiSessionService, adkToMcpToolType, requestProcessor$2 as agentTransferRequestProcessor, requestProcessor$6 as basicRequestProcessor, buildFunctionDeclaration, requestProcessor as codeExecutionRequestProcessor, responseProcessor as codeExecutionResponseProcessor, requestProcessor$3 as contentRequestProcessor, createAuthToolArguments, createDatabaseSessionService, createFunctionTool, createMysqlSessionService, createPostgresSessionService, createSamplingHandler, createSqliteSessionService, generateAuthEvent, generateClientFunctionCallId, getLongRunningFunctionCalls, getMcpTools, handleFunctionCallsAsync, handleFunctionCallsLive, requestProcessor$5 as identityRequestProcessor, initializeTelemetry, injectSessionState, requestProcessor$4 as instructionsRequestProcessor, isEnhancedAuthConfig, jsonSchemaToDeclaration, mcpSchemaToParameters, mergeParallelFunctionResponseEvents, newInvocationContextId, requestProcessor$1 as nlPlanningRequestProcessor, responseProcessor$1 as nlPlanningResponseProcessor, normalizeJsonSchema, populateClientFunctionCallId, registerProviders, removeClientFunctionCallId, requestProcessor$7 as requestProcessor, shutdownTelemetry, telemetryService, traceLlmCall, traceToolCall, tracer };
|
package/dist/index.js
CHANGED
|
@@ -3476,9 +3476,21 @@ __export(tools_exports, {
|
|
|
3476
3476
|
HttpRequestTool: () => HttpRequestTool,
|
|
3477
3477
|
LoadArtifactsTool: () => LoadArtifactsTool,
|
|
3478
3478
|
LoadMemoryTool: () => LoadMemoryTool,
|
|
3479
|
+
McpAbi: () => McpAbi,
|
|
3480
|
+
McpAtp: () => McpAtp,
|
|
3481
|
+
McpBamm: () => McpBamm,
|
|
3479
3482
|
McpError: () => McpError,
|
|
3480
3483
|
McpErrorType: () => McpErrorType,
|
|
3484
|
+
McpFilesystem: () => McpFilesystem,
|
|
3485
|
+
McpFraxlend: () => McpFraxlend,
|
|
3486
|
+
McpGeneric: () => McpGeneric,
|
|
3487
|
+
McpIqWiki: () => McpIqWiki,
|
|
3488
|
+
McpMemory: () => McpMemory,
|
|
3489
|
+
McpNearAgent: () => McpNearAgent,
|
|
3490
|
+
McpNearIntentSwaps: () => McpNearIntentSwaps,
|
|
3491
|
+
McpOdos: () => McpOdos,
|
|
3481
3492
|
McpSamplingHandler: () => McpSamplingHandler,
|
|
3493
|
+
McpTelegram: () => McpTelegram,
|
|
3482
3494
|
McpToolset: () => McpToolset,
|
|
3483
3495
|
ToolContext: () => ToolContext,
|
|
3484
3496
|
TransferToAgentTool: () => TransferToAgentTool,
|
|
@@ -4421,9 +4433,9 @@ var McpSamplingHandler = (_class16 = class {
|
|
|
4421
4433
|
mcpParams.messages,
|
|
4422
4434
|
mcpParams.systemPrompt
|
|
4423
4435
|
);
|
|
4436
|
+
const requestModel = mcpParams.model || "gemini-2.0-flash";
|
|
4424
4437
|
const adkRequest = new LlmRequest({
|
|
4425
|
-
model:
|
|
4426
|
-
// TODO: Implement model passing from context
|
|
4438
|
+
model: requestModel,
|
|
4427
4439
|
contents: adkContents,
|
|
4428
4440
|
config: {
|
|
4429
4441
|
temperature: mcpParams.temperature,
|
|
@@ -4433,7 +4445,10 @@ var McpSamplingHandler = (_class16 = class {
|
|
|
4433
4445
|
this.logger.debug("Calling ADK sampling handler");
|
|
4434
4446
|
const adkResponse = await this.samplingHandler(adkRequest);
|
|
4435
4447
|
this.logger.debug("Converting ADK response to MCP format");
|
|
4436
|
-
const mcpResponse = this.convertADKResponseToMcp(
|
|
4448
|
+
const mcpResponse = this.convertADKResponseToMcp(
|
|
4449
|
+
adkResponse,
|
|
4450
|
+
requestModel
|
|
4451
|
+
);
|
|
4437
4452
|
const responseValidation = _typesjs.CreateMessageResultSchema.safeParse(mcpResponse);
|
|
4438
4453
|
if (!responseValidation.success) {
|
|
4439
4454
|
this.logger.error(
|
|
@@ -4522,7 +4537,7 @@ var McpSamplingHandler = (_class16 = class {
|
|
|
4522
4537
|
/**
|
|
4523
4538
|
* Convert ADK response to MCP response format
|
|
4524
4539
|
*/
|
|
4525
|
-
convertADKResponseToMcp(adkResponse) {
|
|
4540
|
+
convertADKResponseToMcp(adkResponse, model) {
|
|
4526
4541
|
let responseText = "";
|
|
4527
4542
|
if (adkResponse.content) {
|
|
4528
4543
|
if (typeof adkResponse.content === "string") {
|
|
@@ -4534,6 +4549,8 @@ var McpSamplingHandler = (_class16 = class {
|
|
|
4534
4549
|
}
|
|
4535
4550
|
}
|
|
4536
4551
|
const mcpResponse = {
|
|
4552
|
+
model,
|
|
4553
|
+
// Use the model from the request
|
|
4537
4554
|
role: "assistant",
|
|
4538
4555
|
// ADK responses are always from assistant
|
|
4539
4556
|
content: {
|
|
@@ -4808,28 +4825,40 @@ var McpClientService = (_class17 = class {
|
|
|
4808
4825
|
}
|
|
4809
4826
|
return;
|
|
4810
4827
|
}
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4828
|
+
try {
|
|
4829
|
+
client.setRequestHandler(
|
|
4830
|
+
_typesjs.CreateMessageRequestSchema,
|
|
4831
|
+
async (request) => {
|
|
4832
|
+
try {
|
|
4833
|
+
this.logger.debug("Received sampling request:", request);
|
|
4834
|
+
const response = await this.mcpSamplingHandler.handleSamplingRequest(request);
|
|
4835
|
+
if (this.config.debug) {
|
|
4836
|
+
console.log("\u2705 Sampling request completed successfully");
|
|
4837
|
+
}
|
|
4838
|
+
return response;
|
|
4839
|
+
} catch (error) {
|
|
4840
|
+
console.error("\u274C Error handling sampling request:", error);
|
|
4841
|
+
if (error instanceof McpError) {
|
|
4842
|
+
throw error;
|
|
4843
|
+
}
|
|
4844
|
+
throw new McpError(
|
|
4845
|
+
`Sampling request failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
4846
|
+
"SAMPLING_ERROR" /* SAMPLING_ERROR */,
|
|
4847
|
+
error instanceof Error ? error : void 0
|
|
4848
|
+
);
|
|
4849
|
+
}
|
|
4823
4850
|
}
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4851
|
+
);
|
|
4852
|
+
if (this.config.debug) {
|
|
4853
|
+
console.log("\u{1F3AF} Sampling handler registered successfully");
|
|
4854
|
+
}
|
|
4855
|
+
} catch (error) {
|
|
4856
|
+
console.error("Failed to setup sampling handler:", error);
|
|
4857
|
+
if (this.config.debug) {
|
|
4858
|
+
console.log(
|
|
4859
|
+
"\u26A0\uFE0F Sampling handler registration failed, continuing without sampling support"
|
|
4828
4860
|
);
|
|
4829
4861
|
}
|
|
4830
|
-
});
|
|
4831
|
-
if (this.config.debug) {
|
|
4832
|
-
console.log("\u{1F3AF} Sampling handler registered successfully");
|
|
4833
4862
|
}
|
|
4834
4863
|
}
|
|
4835
4864
|
/**
|
|
@@ -5146,6 +5175,117 @@ var McpToolAdapter = (_class18 = class extends BaseTool {
|
|
|
5146
5175
|
}
|
|
5147
5176
|
}, _class18);
|
|
5148
5177
|
|
|
5178
|
+
// src/tools/mcp/servers.ts
|
|
5179
|
+
function createMcpConfig(name, packageName, config) {
|
|
5180
|
+
const { debug, description, retryOptions, env: envVars = {} } = config;
|
|
5181
|
+
const env = {};
|
|
5182
|
+
for (const [key, value] of Object.entries(envVars)) {
|
|
5183
|
+
if (value !== void 0) {
|
|
5184
|
+
env[key] = String(value);
|
|
5185
|
+
}
|
|
5186
|
+
}
|
|
5187
|
+
if (!env.PATH) {
|
|
5188
|
+
env.PATH = process.env.PATH || "";
|
|
5189
|
+
}
|
|
5190
|
+
return {
|
|
5191
|
+
name,
|
|
5192
|
+
description: description || `Client for ${name}`,
|
|
5193
|
+
debug: debug || false,
|
|
5194
|
+
retryOptions: retryOptions || { maxRetries: 2, initialDelay: 200 },
|
|
5195
|
+
transport: {
|
|
5196
|
+
mode: "stdio",
|
|
5197
|
+
command: "npx",
|
|
5198
|
+
args: ["-y", packageName],
|
|
5199
|
+
env
|
|
5200
|
+
}
|
|
5201
|
+
};
|
|
5202
|
+
}
|
|
5203
|
+
function McpAbi(config) {
|
|
5204
|
+
const mcpConfig = createMcpConfig("ABI MCP Client", "@iqai/mcp-abi", config);
|
|
5205
|
+
return new McpToolset(mcpConfig);
|
|
5206
|
+
}
|
|
5207
|
+
function McpAtp(config) {
|
|
5208
|
+
const mcpConfig = createMcpConfig("ATP MCP Client", "@iqai/mcp-atp", config);
|
|
5209
|
+
return new McpToolset(mcpConfig);
|
|
5210
|
+
}
|
|
5211
|
+
function McpBamm(config) {
|
|
5212
|
+
const mcpConfig = createMcpConfig(
|
|
5213
|
+
"BAMM MCP Client",
|
|
5214
|
+
"@iqai/mcp-bamm",
|
|
5215
|
+
config
|
|
5216
|
+
);
|
|
5217
|
+
return new McpToolset(mcpConfig);
|
|
5218
|
+
}
|
|
5219
|
+
function McpFraxlend(config) {
|
|
5220
|
+
const mcpConfig = createMcpConfig(
|
|
5221
|
+
"Fraxlend MCP Client",
|
|
5222
|
+
"@iqai/mcp-fraxlend",
|
|
5223
|
+
config
|
|
5224
|
+
);
|
|
5225
|
+
return new McpToolset(mcpConfig);
|
|
5226
|
+
}
|
|
5227
|
+
function McpIqWiki(config = {}) {
|
|
5228
|
+
const mcpConfig = createMcpConfig(
|
|
5229
|
+
"IQWiki MCP Client",
|
|
5230
|
+
"@iqai/mcp-iqwiki",
|
|
5231
|
+
config
|
|
5232
|
+
);
|
|
5233
|
+
return new McpToolset(mcpConfig);
|
|
5234
|
+
}
|
|
5235
|
+
function McpNearAgent(config) {
|
|
5236
|
+
const mcpConfig = createMcpConfig(
|
|
5237
|
+
"NEAR Agent MCP Client",
|
|
5238
|
+
"@iqai/mcp-near-agent",
|
|
5239
|
+
config
|
|
5240
|
+
);
|
|
5241
|
+
return new McpToolset(mcpConfig);
|
|
5242
|
+
}
|
|
5243
|
+
function McpNearIntentSwaps(config) {
|
|
5244
|
+
const mcpConfig = createMcpConfig(
|
|
5245
|
+
"NEAR Intent Swaps MCP Client",
|
|
5246
|
+
"@iqai/mcp-near-intent-swaps",
|
|
5247
|
+
config
|
|
5248
|
+
);
|
|
5249
|
+
return new McpToolset(mcpConfig);
|
|
5250
|
+
}
|
|
5251
|
+
function McpOdos(config) {
|
|
5252
|
+
const mcpConfig = createMcpConfig(
|
|
5253
|
+
"ODOS MCP Client",
|
|
5254
|
+
"@iqai/mcp-odos",
|
|
5255
|
+
config
|
|
5256
|
+
);
|
|
5257
|
+
return new McpToolset(mcpConfig);
|
|
5258
|
+
}
|
|
5259
|
+
function McpTelegram(config) {
|
|
5260
|
+
const mcpConfig = createMcpConfig(
|
|
5261
|
+
"Telegram MCP Client",
|
|
5262
|
+
"@iqai/mcp-telegram",
|
|
5263
|
+
config
|
|
5264
|
+
);
|
|
5265
|
+
return new McpToolset(mcpConfig);
|
|
5266
|
+
}
|
|
5267
|
+
function McpFilesystem(config = {}) {
|
|
5268
|
+
const mcpConfig = createMcpConfig(
|
|
5269
|
+
"Filesystem MCP Client",
|
|
5270
|
+
"@modelcontextprotocol/server-filesystem",
|
|
5271
|
+
config
|
|
5272
|
+
);
|
|
5273
|
+
return new McpToolset(mcpConfig);
|
|
5274
|
+
}
|
|
5275
|
+
function McpMemory(config = {}) {
|
|
5276
|
+
const mcpConfig = createMcpConfig(
|
|
5277
|
+
"Memory MCP Client",
|
|
5278
|
+
"@modelcontextprotocol/server-memory",
|
|
5279
|
+
config
|
|
5280
|
+
);
|
|
5281
|
+
return new McpToolset(mcpConfig);
|
|
5282
|
+
}
|
|
5283
|
+
function McpGeneric(packageName, config = {}, name) {
|
|
5284
|
+
const clientName = name || `${packageName} Client`;
|
|
5285
|
+
const mcpConfig = createMcpConfig(clientName, packageName, config);
|
|
5286
|
+
return new McpToolset(mcpConfig);
|
|
5287
|
+
}
|
|
5288
|
+
|
|
5149
5289
|
// src/tools/mcp/index.ts
|
|
5150
5290
|
var McpToolset = (_class19 = class {
|
|
5151
5291
|
|
|
@@ -10297,4 +10437,16 @@ var VERSION = "0.1.0";
|
|
|
10297
10437
|
|
|
10298
10438
|
|
|
10299
10439
|
|
|
10300
|
-
|
|
10440
|
+
|
|
10441
|
+
|
|
10442
|
+
|
|
10443
|
+
|
|
10444
|
+
|
|
10445
|
+
|
|
10446
|
+
|
|
10447
|
+
|
|
10448
|
+
|
|
10449
|
+
|
|
10450
|
+
|
|
10451
|
+
|
|
10452
|
+
exports.AF_FUNCTION_CALL_ID_PREFIX = AF_FUNCTION_CALL_ID_PREFIX; exports.Agent = LlmAgent; exports.AgentBuilder = AgentBuilder; exports.Agents = agents_exports; exports.AnthropicLlm = AnthropicLlm; exports.ApiKeyCredential = ApiKeyCredential; exports.ApiKeyScheme = ApiKeyScheme; exports.AuthConfig = AuthConfig; exports.AuthCredential = AuthCredential; exports.AuthCredentialType = AuthCredentialType; exports.AuthHandler = AuthHandler; exports.AuthScheme = AuthScheme; exports.AuthSchemeType = AuthSchemeType; exports.AuthTool = AuthTool; exports.AutoFlow = AutoFlow; exports.BaseAgent = BaseAgent; exports.BaseLLMConnection = BaseLLMConnection; exports.BaseLlm = BaseLlm; exports.BaseLlmFlow = BaseLlmFlow; exports.BaseLlmRequestProcessor = BaseLlmRequestProcessor; exports.BaseLlmResponseProcessor = BaseLlmResponseProcessor; exports.BasePlanner = BasePlanner; exports.BaseSessionService = BaseSessionService; exports.BaseTool = BaseTool; exports.BasicAuthCredential = BasicAuthCredential; exports.BearerTokenCredential = BearerTokenCredential; exports.BuiltInPlanner = BuiltInPlanner; exports.CallbackContext = CallbackContext; exports.DatabaseSessionService = DatabaseSessionService; exports.EnhancedAuthConfig = EnhancedAuthConfig; exports.Event = Event; exports.EventActions = EventActions; exports.Events = events_exports; exports.ExitLoopTool = ExitLoopTool; exports.FileOperationsTool = FileOperationsTool; exports.Flows = flows_exports; exports.FunctionTool = FunctionTool; exports.GcsArtifactService = GcsArtifactService; exports.GetUserChoiceTool = GetUserChoiceTool; exports.GoogleLlm = GoogleLlm; exports.GoogleSearch = GoogleSearch; exports.HttpRequestTool = HttpRequestTool; exports.HttpScheme = HttpScheme; exports.InMemoryArtifactService = InMemoryArtifactService; exports.InMemoryMemoryService = InMemoryMemoryService; exports.InMemoryRunner = InMemoryRunner; exports.InMemorySessionService = InMemorySessionService; exports.InvocationContext = InvocationContext; exports.LLMRegistry = LLMRegistry; exports.LangGraphAgent = LangGraphAgent; exports.LlmAgent = LlmAgent; exports.LlmCallsLimitExceededError = LlmCallsLimitExceededError; exports.LlmRequest = LlmRequest; exports.LlmResponse = LlmResponse; exports.LoadArtifactsTool = LoadArtifactsTool; exports.LoadMemoryTool = LoadMemoryTool; exports.LoopAgent = LoopAgent; exports.McpAbi = McpAbi; exports.McpAtp = McpAtp; exports.McpBamm = McpBamm; exports.McpError = McpError; exports.McpErrorType = McpErrorType; exports.McpFilesystem = McpFilesystem; exports.McpFraxlend = McpFraxlend; exports.McpGeneric = McpGeneric; exports.McpIqWiki = McpIqWiki; exports.McpMemory = McpMemory; exports.McpNearAgent = McpNearAgent; exports.McpNearIntentSwaps = McpNearIntentSwaps; exports.McpOdos = McpOdos; exports.McpSamplingHandler = McpSamplingHandler; exports.McpTelegram = McpTelegram; exports.McpToolset = McpToolset; exports.Memory = memory_exports; exports.Models = models_exports; exports.OAuth2Credential = OAuth2Credential; exports.OAuth2Scheme = OAuth2Scheme; exports.OpenAiLlm = OpenAiLlm; exports.OpenIdConnectScheme = OpenIdConnectScheme; exports.ParallelAgent = ParallelAgent; exports.PlanReActPlanner = PlanReActPlanner; exports.REQUEST_EUC_FUNCTION_CALL_NAME = REQUEST_EUC_FUNCTION_CALL_NAME; exports.ReadonlyContext = ReadonlyContext; exports.RunConfig = RunConfig; exports.Runner = Runner; exports.SequentialAgent = SequentialAgent; exports.Sessions = sessions_exports; exports.SingleFlow = SingleFlow; exports.State = State; exports.StreamingMode = StreamingMode; exports.TelemetryService = TelemetryService; exports.ToolContext = ToolContext; exports.Tools = tools_exports; exports.TransferToAgentTool = TransferToAgentTool; exports.UserInteractionTool = UserInteractionTool; exports.VERSION = VERSION; exports.VertexAiSessionService = VertexAiSessionService; exports.adkToMcpToolType = adkToMcpToolType; exports.agentTransferRequestProcessor = requestProcessor8; exports.basicRequestProcessor = requestProcessor; exports.buildFunctionDeclaration = buildFunctionDeclaration; exports.codeExecutionRequestProcessor = requestProcessor7; exports.codeExecutionResponseProcessor = responseProcessor2; exports.contentRequestProcessor = requestProcessor5; exports.createAuthToolArguments = createAuthToolArguments; exports.createDatabaseSessionService = createDatabaseSessionService; exports.createFunctionTool = createFunctionTool; exports.createMysqlSessionService = createMysqlSessionService; exports.createPostgresSessionService = createPostgresSessionService; exports.createSamplingHandler = createSamplingHandler; exports.createSqliteSessionService = createSqliteSessionService; exports.generateAuthEvent = generateAuthEvent; exports.generateClientFunctionCallId = generateClientFunctionCallId; exports.getLongRunningFunctionCalls = getLongRunningFunctionCalls; exports.getMcpTools = getMcpTools; exports.handleFunctionCallsAsync = handleFunctionCallsAsync; exports.handleFunctionCallsLive = handleFunctionCallsLive; exports.identityRequestProcessor = requestProcessor3; exports.initializeTelemetry = initializeTelemetry; exports.injectSessionState = injectSessionState; exports.instructionsRequestProcessor = requestProcessor4; exports.isEnhancedAuthConfig = isEnhancedAuthConfig; exports.jsonSchemaToDeclaration = jsonSchemaToDeclaration; exports.mcpSchemaToParameters = mcpSchemaToParameters; exports.mergeParallelFunctionResponseEvents = mergeParallelFunctionResponseEvents; exports.newInvocationContextId = newInvocationContextId; exports.nlPlanningRequestProcessor = requestProcessor6; exports.nlPlanningResponseProcessor = responseProcessor; exports.normalizeJsonSchema = normalizeJsonSchema; exports.populateClientFunctionCallId = populateClientFunctionCallId; exports.registerProviders = registerProviders; exports.removeClientFunctionCallId = removeClientFunctionCallId; exports.requestProcessor = requestProcessor2; exports.shutdownTelemetry = shutdownTelemetry; exports.telemetryService = telemetryService; exports.traceLlmCall = traceLlmCall; exports.traceToolCall = traceToolCall; exports.tracer = tracer;
|
package/dist/index.mjs
CHANGED
|
@@ -3476,9 +3476,21 @@ __export(tools_exports, {
|
|
|
3476
3476
|
HttpRequestTool: () => HttpRequestTool,
|
|
3477
3477
|
LoadArtifactsTool: () => LoadArtifactsTool,
|
|
3478
3478
|
LoadMemoryTool: () => LoadMemoryTool,
|
|
3479
|
+
McpAbi: () => McpAbi,
|
|
3480
|
+
McpAtp: () => McpAtp,
|
|
3481
|
+
McpBamm: () => McpBamm,
|
|
3479
3482
|
McpError: () => McpError,
|
|
3480
3483
|
McpErrorType: () => McpErrorType,
|
|
3484
|
+
McpFilesystem: () => McpFilesystem,
|
|
3485
|
+
McpFraxlend: () => McpFraxlend,
|
|
3486
|
+
McpGeneric: () => McpGeneric,
|
|
3487
|
+
McpIqWiki: () => McpIqWiki,
|
|
3488
|
+
McpMemory: () => McpMemory,
|
|
3489
|
+
McpNearAgent: () => McpNearAgent,
|
|
3490
|
+
McpNearIntentSwaps: () => McpNearIntentSwaps,
|
|
3491
|
+
McpOdos: () => McpOdos,
|
|
3481
3492
|
McpSamplingHandler: () => McpSamplingHandler,
|
|
3493
|
+
McpTelegram: () => McpTelegram,
|
|
3482
3494
|
McpToolset: () => McpToolset,
|
|
3483
3495
|
ToolContext: () => ToolContext,
|
|
3484
3496
|
TransferToAgentTool: () => TransferToAgentTool,
|
|
@@ -4421,9 +4433,9 @@ var McpSamplingHandler = class {
|
|
|
4421
4433
|
mcpParams.messages,
|
|
4422
4434
|
mcpParams.systemPrompt
|
|
4423
4435
|
);
|
|
4436
|
+
const requestModel = mcpParams.model || "gemini-2.0-flash";
|
|
4424
4437
|
const adkRequest = new LlmRequest({
|
|
4425
|
-
model:
|
|
4426
|
-
// TODO: Implement model passing from context
|
|
4438
|
+
model: requestModel,
|
|
4427
4439
|
contents: adkContents,
|
|
4428
4440
|
config: {
|
|
4429
4441
|
temperature: mcpParams.temperature,
|
|
@@ -4433,7 +4445,10 @@ var McpSamplingHandler = class {
|
|
|
4433
4445
|
this.logger.debug("Calling ADK sampling handler");
|
|
4434
4446
|
const adkResponse = await this.samplingHandler(adkRequest);
|
|
4435
4447
|
this.logger.debug("Converting ADK response to MCP format");
|
|
4436
|
-
const mcpResponse = this.convertADKResponseToMcp(
|
|
4448
|
+
const mcpResponse = this.convertADKResponseToMcp(
|
|
4449
|
+
adkResponse,
|
|
4450
|
+
requestModel
|
|
4451
|
+
);
|
|
4437
4452
|
const responseValidation = CreateMessageResultSchema.safeParse(mcpResponse);
|
|
4438
4453
|
if (!responseValidation.success) {
|
|
4439
4454
|
this.logger.error(
|
|
@@ -4522,7 +4537,7 @@ var McpSamplingHandler = class {
|
|
|
4522
4537
|
/**
|
|
4523
4538
|
* Convert ADK response to MCP response format
|
|
4524
4539
|
*/
|
|
4525
|
-
convertADKResponseToMcp(adkResponse) {
|
|
4540
|
+
convertADKResponseToMcp(adkResponse, model) {
|
|
4526
4541
|
let responseText = "";
|
|
4527
4542
|
if (adkResponse.content) {
|
|
4528
4543
|
if (typeof adkResponse.content === "string") {
|
|
@@ -4534,6 +4549,8 @@ var McpSamplingHandler = class {
|
|
|
4534
4549
|
}
|
|
4535
4550
|
}
|
|
4536
4551
|
const mcpResponse = {
|
|
4552
|
+
model,
|
|
4553
|
+
// Use the model from the request
|
|
4537
4554
|
role: "assistant",
|
|
4538
4555
|
// ADK responses are always from assistant
|
|
4539
4556
|
content: {
|
|
@@ -4808,28 +4825,40 @@ var McpClientService = class {
|
|
|
4808
4825
|
}
|
|
4809
4826
|
return;
|
|
4810
4827
|
}
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4828
|
+
try {
|
|
4829
|
+
client.setRequestHandler(
|
|
4830
|
+
CreateMessageRequestSchema2,
|
|
4831
|
+
async (request) => {
|
|
4832
|
+
try {
|
|
4833
|
+
this.logger.debug("Received sampling request:", request);
|
|
4834
|
+
const response = await this.mcpSamplingHandler.handleSamplingRequest(request);
|
|
4835
|
+
if (this.config.debug) {
|
|
4836
|
+
console.log("\u2705 Sampling request completed successfully");
|
|
4837
|
+
}
|
|
4838
|
+
return response;
|
|
4839
|
+
} catch (error) {
|
|
4840
|
+
console.error("\u274C Error handling sampling request:", error);
|
|
4841
|
+
if (error instanceof McpError) {
|
|
4842
|
+
throw error;
|
|
4843
|
+
}
|
|
4844
|
+
throw new McpError(
|
|
4845
|
+
`Sampling request failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
4846
|
+
"SAMPLING_ERROR" /* SAMPLING_ERROR */,
|
|
4847
|
+
error instanceof Error ? error : void 0
|
|
4848
|
+
);
|
|
4849
|
+
}
|
|
4823
4850
|
}
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4851
|
+
);
|
|
4852
|
+
if (this.config.debug) {
|
|
4853
|
+
console.log("\u{1F3AF} Sampling handler registered successfully");
|
|
4854
|
+
}
|
|
4855
|
+
} catch (error) {
|
|
4856
|
+
console.error("Failed to setup sampling handler:", error);
|
|
4857
|
+
if (this.config.debug) {
|
|
4858
|
+
console.log(
|
|
4859
|
+
"\u26A0\uFE0F Sampling handler registration failed, continuing without sampling support"
|
|
4828
4860
|
);
|
|
4829
4861
|
}
|
|
4830
|
-
});
|
|
4831
|
-
if (this.config.debug) {
|
|
4832
|
-
console.log("\u{1F3AF} Sampling handler registered successfully");
|
|
4833
4862
|
}
|
|
4834
4863
|
}
|
|
4835
4864
|
/**
|
|
@@ -5146,6 +5175,117 @@ var McpToolAdapter = class extends BaseTool {
|
|
|
5146
5175
|
}
|
|
5147
5176
|
};
|
|
5148
5177
|
|
|
5178
|
+
// src/tools/mcp/servers.ts
|
|
5179
|
+
function createMcpConfig(name, packageName, config) {
|
|
5180
|
+
const { debug, description, retryOptions, env: envVars = {} } = config;
|
|
5181
|
+
const env = {};
|
|
5182
|
+
for (const [key, value] of Object.entries(envVars)) {
|
|
5183
|
+
if (value !== void 0) {
|
|
5184
|
+
env[key] = String(value);
|
|
5185
|
+
}
|
|
5186
|
+
}
|
|
5187
|
+
if (!env.PATH) {
|
|
5188
|
+
env.PATH = process.env.PATH || "";
|
|
5189
|
+
}
|
|
5190
|
+
return {
|
|
5191
|
+
name,
|
|
5192
|
+
description: description || `Client for ${name}`,
|
|
5193
|
+
debug: debug || false,
|
|
5194
|
+
retryOptions: retryOptions || { maxRetries: 2, initialDelay: 200 },
|
|
5195
|
+
transport: {
|
|
5196
|
+
mode: "stdio",
|
|
5197
|
+
command: "npx",
|
|
5198
|
+
args: ["-y", packageName],
|
|
5199
|
+
env
|
|
5200
|
+
}
|
|
5201
|
+
};
|
|
5202
|
+
}
|
|
5203
|
+
function McpAbi(config) {
|
|
5204
|
+
const mcpConfig = createMcpConfig("ABI MCP Client", "@iqai/mcp-abi", config);
|
|
5205
|
+
return new McpToolset(mcpConfig);
|
|
5206
|
+
}
|
|
5207
|
+
function McpAtp(config) {
|
|
5208
|
+
const mcpConfig = createMcpConfig("ATP MCP Client", "@iqai/mcp-atp", config);
|
|
5209
|
+
return new McpToolset(mcpConfig);
|
|
5210
|
+
}
|
|
5211
|
+
function McpBamm(config) {
|
|
5212
|
+
const mcpConfig = createMcpConfig(
|
|
5213
|
+
"BAMM MCP Client",
|
|
5214
|
+
"@iqai/mcp-bamm",
|
|
5215
|
+
config
|
|
5216
|
+
);
|
|
5217
|
+
return new McpToolset(mcpConfig);
|
|
5218
|
+
}
|
|
5219
|
+
function McpFraxlend(config) {
|
|
5220
|
+
const mcpConfig = createMcpConfig(
|
|
5221
|
+
"Fraxlend MCP Client",
|
|
5222
|
+
"@iqai/mcp-fraxlend",
|
|
5223
|
+
config
|
|
5224
|
+
);
|
|
5225
|
+
return new McpToolset(mcpConfig);
|
|
5226
|
+
}
|
|
5227
|
+
function McpIqWiki(config = {}) {
|
|
5228
|
+
const mcpConfig = createMcpConfig(
|
|
5229
|
+
"IQWiki MCP Client",
|
|
5230
|
+
"@iqai/mcp-iqwiki",
|
|
5231
|
+
config
|
|
5232
|
+
);
|
|
5233
|
+
return new McpToolset(mcpConfig);
|
|
5234
|
+
}
|
|
5235
|
+
function McpNearAgent(config) {
|
|
5236
|
+
const mcpConfig = createMcpConfig(
|
|
5237
|
+
"NEAR Agent MCP Client",
|
|
5238
|
+
"@iqai/mcp-near-agent",
|
|
5239
|
+
config
|
|
5240
|
+
);
|
|
5241
|
+
return new McpToolset(mcpConfig);
|
|
5242
|
+
}
|
|
5243
|
+
function McpNearIntentSwaps(config) {
|
|
5244
|
+
const mcpConfig = createMcpConfig(
|
|
5245
|
+
"NEAR Intent Swaps MCP Client",
|
|
5246
|
+
"@iqai/mcp-near-intent-swaps",
|
|
5247
|
+
config
|
|
5248
|
+
);
|
|
5249
|
+
return new McpToolset(mcpConfig);
|
|
5250
|
+
}
|
|
5251
|
+
function McpOdos(config) {
|
|
5252
|
+
const mcpConfig = createMcpConfig(
|
|
5253
|
+
"ODOS MCP Client",
|
|
5254
|
+
"@iqai/mcp-odos",
|
|
5255
|
+
config
|
|
5256
|
+
);
|
|
5257
|
+
return new McpToolset(mcpConfig);
|
|
5258
|
+
}
|
|
5259
|
+
function McpTelegram(config) {
|
|
5260
|
+
const mcpConfig = createMcpConfig(
|
|
5261
|
+
"Telegram MCP Client",
|
|
5262
|
+
"@iqai/mcp-telegram",
|
|
5263
|
+
config
|
|
5264
|
+
);
|
|
5265
|
+
return new McpToolset(mcpConfig);
|
|
5266
|
+
}
|
|
5267
|
+
function McpFilesystem(config = {}) {
|
|
5268
|
+
const mcpConfig = createMcpConfig(
|
|
5269
|
+
"Filesystem MCP Client",
|
|
5270
|
+
"@modelcontextprotocol/server-filesystem",
|
|
5271
|
+
config
|
|
5272
|
+
);
|
|
5273
|
+
return new McpToolset(mcpConfig);
|
|
5274
|
+
}
|
|
5275
|
+
function McpMemory(config = {}) {
|
|
5276
|
+
const mcpConfig = createMcpConfig(
|
|
5277
|
+
"Memory MCP Client",
|
|
5278
|
+
"@modelcontextprotocol/server-memory",
|
|
5279
|
+
config
|
|
5280
|
+
);
|
|
5281
|
+
return new McpToolset(mcpConfig);
|
|
5282
|
+
}
|
|
5283
|
+
function McpGeneric(packageName, config = {}, name) {
|
|
5284
|
+
const clientName = name || `${packageName} Client`;
|
|
5285
|
+
const mcpConfig = createMcpConfig(clientName, packageName, config);
|
|
5286
|
+
return new McpToolset(mcpConfig);
|
|
5287
|
+
}
|
|
5288
|
+
|
|
5149
5289
|
// src/tools/mcp/index.ts
|
|
5150
5290
|
var McpToolset = class {
|
|
5151
5291
|
config;
|
|
@@ -10228,9 +10368,21 @@ export {
|
|
|
10228
10368
|
LoadArtifactsTool,
|
|
10229
10369
|
LoadMemoryTool,
|
|
10230
10370
|
LoopAgent,
|
|
10371
|
+
McpAbi,
|
|
10372
|
+
McpAtp,
|
|
10373
|
+
McpBamm,
|
|
10231
10374
|
McpError,
|
|
10232
10375
|
McpErrorType,
|
|
10376
|
+
McpFilesystem,
|
|
10377
|
+
McpFraxlend,
|
|
10378
|
+
McpGeneric,
|
|
10379
|
+
McpIqWiki,
|
|
10380
|
+
McpMemory,
|
|
10381
|
+
McpNearAgent,
|
|
10382
|
+
McpNearIntentSwaps,
|
|
10383
|
+
McpOdos,
|
|
10233
10384
|
McpSamplingHandler,
|
|
10385
|
+
McpTelegram,
|
|
10234
10386
|
McpToolset,
|
|
10235
10387
|
memory_exports as Memory,
|
|
10236
10388
|
models_exports as Models,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iqai/adk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Agent Development Kit for TypeScript with multi-provider LLM support",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"kysely": "^0.28.2",
|
|
42
42
|
"openai": "^4.93.0",
|
|
43
43
|
"uuid": "^11.1.0",
|
|
44
|
-
"zod": "^3.
|
|
44
|
+
"zod": "^3.25.67"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"better-sqlite3": "^11.10.0",
|