@iqai/adk 0.0.2 → 0.0.3
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 +6 -0
- package/dist/index.d.mts +178 -2
- package/dist/index.d.ts +178 -2
- package/dist/index.js +805 -93
- package/dist/index.mjs +713 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
2
|
+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
1
3
|
import { AxiosInstance } from 'axios';
|
|
2
4
|
import OpenAI from 'openai';
|
|
3
5
|
import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';
|
|
@@ -2665,6 +2667,169 @@ declare class LoadMemoryTool extends BaseTool {
|
|
|
2665
2667
|
}, context: ToolContext): Promise<any>;
|
|
2666
2668
|
}
|
|
2667
2669
|
|
|
2670
|
+
type McpConfig = {
|
|
2671
|
+
name: string;
|
|
2672
|
+
description: string;
|
|
2673
|
+
transport: McpTransportType;
|
|
2674
|
+
timeout?: number;
|
|
2675
|
+
retryOptions?: {
|
|
2676
|
+
maxRetries?: number;
|
|
2677
|
+
initialDelay?: number;
|
|
2678
|
+
maxDelay?: number;
|
|
2679
|
+
};
|
|
2680
|
+
headers?: Record<string, string>;
|
|
2681
|
+
cacheConfig?: {
|
|
2682
|
+
enabled?: boolean;
|
|
2683
|
+
maxAge?: number;
|
|
2684
|
+
maxSize?: number;
|
|
2685
|
+
};
|
|
2686
|
+
debug?: boolean;
|
|
2687
|
+
};
|
|
2688
|
+
type McpTransportType = {
|
|
2689
|
+
mode: "stdio";
|
|
2690
|
+
command: string;
|
|
2691
|
+
args: string[];
|
|
2692
|
+
env?: Record<string, string>;
|
|
2693
|
+
} | {
|
|
2694
|
+
mode: "sse";
|
|
2695
|
+
serverUrl: string;
|
|
2696
|
+
headers?: HeadersInit;
|
|
2697
|
+
};
|
|
2698
|
+
/**
|
|
2699
|
+
* Error types specific to the MCP client
|
|
2700
|
+
*/
|
|
2701
|
+
declare enum McpErrorType {
|
|
2702
|
+
CONNECTION_ERROR = "connection_error",
|
|
2703
|
+
TOOL_EXECUTION_ERROR = "tool_execution_error",
|
|
2704
|
+
RESOURCE_CLOSED_ERROR = "resource_closed_error",
|
|
2705
|
+
TIMEOUT_ERROR = "timeout_error",
|
|
2706
|
+
INVALID_SCHEMA_ERROR = "invalid_schema_error"
|
|
2707
|
+
}
|
|
2708
|
+
/**
|
|
2709
|
+
* Custom error class for MCP-related errors
|
|
2710
|
+
*/
|
|
2711
|
+
declare class McpError extends Error {
|
|
2712
|
+
type: McpErrorType;
|
|
2713
|
+
originalError?: Error;
|
|
2714
|
+
constructor(message: string, type: McpErrorType, originalError?: Error);
|
|
2715
|
+
}
|
|
2716
|
+
|
|
2717
|
+
declare class McpClientService {
|
|
2718
|
+
private config;
|
|
2719
|
+
private client;
|
|
2720
|
+
private transport;
|
|
2721
|
+
private isClosing;
|
|
2722
|
+
constructor(config: McpConfig);
|
|
2723
|
+
/**
|
|
2724
|
+
* Initializes and returns an MCP client based on configuration.
|
|
2725
|
+
* Will create a new client if one doesn't exist yet.
|
|
2726
|
+
*/
|
|
2727
|
+
initialize(): Promise<Client>;
|
|
2728
|
+
/**
|
|
2729
|
+
* Creates a transport based on the configuration.
|
|
2730
|
+
*/
|
|
2731
|
+
private createTransport;
|
|
2732
|
+
/**
|
|
2733
|
+
* Re-initializes the MCP client when a session is closed.
|
|
2734
|
+
* Used by the retry mechanism.
|
|
2735
|
+
*/
|
|
2736
|
+
reinitialize(): Promise<void>;
|
|
2737
|
+
/**
|
|
2738
|
+
* Cleans up resources associated with this client service.
|
|
2739
|
+
* Similar to Python's AsyncExitStack.aclose() functionality.
|
|
2740
|
+
*/
|
|
2741
|
+
private cleanupResources;
|
|
2742
|
+
/**
|
|
2743
|
+
* Call an MCP tool with retry capability if the session is closed.
|
|
2744
|
+
*/
|
|
2745
|
+
callTool(name: string, args: Record<string, any>): Promise<any>;
|
|
2746
|
+
/**
|
|
2747
|
+
* Closes and cleans up all resources.
|
|
2748
|
+
* Should be called when the service is no longer needed.
|
|
2749
|
+
* Similar to Python's close() method.
|
|
2750
|
+
*/
|
|
2751
|
+
close(): Promise<void>;
|
|
2752
|
+
/**
|
|
2753
|
+
* Checks if the client is currently connected
|
|
2754
|
+
*/
|
|
2755
|
+
isConnected(): boolean;
|
|
2756
|
+
}
|
|
2757
|
+
|
|
2758
|
+
/**
|
|
2759
|
+
* Converts an ADK-style BaseTool to an MCP tool format
|
|
2760
|
+
* Similar to Python's adk_to_mcp_tool_type function
|
|
2761
|
+
*/
|
|
2762
|
+
declare function adkToMcpToolType(tool: BaseTool): Tool;
|
|
2763
|
+
/**
|
|
2764
|
+
* Converts MCP JSONSchema to ADK's FunctionDeclaration format
|
|
2765
|
+
* Similar to handling in McpToolAdapter's getDeclaration
|
|
2766
|
+
*/
|
|
2767
|
+
declare function jsonSchemaToDeclaration(name: string, description: string, schema: Record<string, any> | undefined): FunctionDeclaration;
|
|
2768
|
+
/**
|
|
2769
|
+
* Normalizes a JSON Schema to ensure it's properly formatted
|
|
2770
|
+
* Handles edge cases and ensures consistency
|
|
2771
|
+
*/
|
|
2772
|
+
declare function normalizeJsonSchema(schema: Record<string, any>): JSONSchema;
|
|
2773
|
+
/**
|
|
2774
|
+
* Converts MCP tool inputSchema to parameters format expected by BaseTool
|
|
2775
|
+
*/
|
|
2776
|
+
declare function mcpSchemaToParameters(mcpTool: Tool): JSONSchema;
|
|
2777
|
+
|
|
2778
|
+
/**
|
|
2779
|
+
* A class for managing MCP tools similar to Python's MCPToolset.
|
|
2780
|
+
* Provides functionality to retrieve and use tools from an MCP server.
|
|
2781
|
+
*/
|
|
2782
|
+
declare class McpToolset {
|
|
2783
|
+
private config;
|
|
2784
|
+
private clientService;
|
|
2785
|
+
private toolFilter;
|
|
2786
|
+
private tools;
|
|
2787
|
+
private isClosing;
|
|
2788
|
+
constructor(config: McpConfig, toolFilter?: string[] | ((tool: any, context?: ToolContext) => boolean) | null);
|
|
2789
|
+
/**
|
|
2790
|
+
* Checks if a tool should be included based on the tool filter.
|
|
2791
|
+
* Similar to Python's _is_selected method.
|
|
2792
|
+
*/
|
|
2793
|
+
private isSelected;
|
|
2794
|
+
/**
|
|
2795
|
+
* Initializes the client service and establishes a connection.
|
|
2796
|
+
*/
|
|
2797
|
+
initialize(): Promise<McpClientService>;
|
|
2798
|
+
/**
|
|
2799
|
+
* Retrieves tools from the MCP server and converts them to BaseTool instances.
|
|
2800
|
+
* Similar to Python's get_tools method.
|
|
2801
|
+
*/
|
|
2802
|
+
getTools(context?: ToolContext): Promise<BaseTool[]>;
|
|
2803
|
+
/**
|
|
2804
|
+
* Converts ADK tools to MCP tool format for bidirectional support
|
|
2805
|
+
*/
|
|
2806
|
+
convertADKToolsToMCP(tools: BaseTool[]): any[];
|
|
2807
|
+
/**
|
|
2808
|
+
* Refreshes the tool cache by clearing it and fetching tools again
|
|
2809
|
+
*/
|
|
2810
|
+
refreshTools(context?: ToolContext): Promise<BaseTool[]>;
|
|
2811
|
+
/**
|
|
2812
|
+
* Closes the connection to the MCP server.
|
|
2813
|
+
* Similar to Python's close method.
|
|
2814
|
+
*/
|
|
2815
|
+
close(): Promise<void>;
|
|
2816
|
+
/**
|
|
2817
|
+
* Disposes of all resources. This method should be called when the toolset is no longer needed.
|
|
2818
|
+
* Provides alignment with disposal patterns common in TypeScript.
|
|
2819
|
+
*/
|
|
2820
|
+
dispose(): Promise<void>;
|
|
2821
|
+
}
|
|
2822
|
+
/**
|
|
2823
|
+
* Retrieves and converts tools from an MCP server.
|
|
2824
|
+
*
|
|
2825
|
+
* This function:
|
|
2826
|
+
* 1. Connects to the MCP server (local or sse).
|
|
2827
|
+
* 2. Retrieves all available tools.
|
|
2828
|
+
* 3. Converts them into BaseTool instances.
|
|
2829
|
+
* 4. Returns them as a BaseTool array.
|
|
2830
|
+
*/
|
|
2831
|
+
declare function getMcpTools(config: McpConfig, toolFilter?: string[] | ((tool: any, context?: ToolContext) => boolean)): Promise<BaseTool[]>;
|
|
2832
|
+
|
|
2668
2833
|
/**
|
|
2669
2834
|
* Tools module exports
|
|
2670
2835
|
*/
|
|
@@ -2687,6 +2852,12 @@ declare const index$2_HttpRequestTool: typeof HttpRequestTool;
|
|
|
2687
2852
|
type index$2_IToolContext = IToolContext;
|
|
2688
2853
|
type index$2_LoadMemoryTool = LoadMemoryTool;
|
|
2689
2854
|
declare const index$2_LoadMemoryTool: typeof LoadMemoryTool;
|
|
2855
|
+
type index$2_McpError = McpError;
|
|
2856
|
+
declare const index$2_McpError: typeof McpError;
|
|
2857
|
+
type index$2_McpErrorType = McpErrorType;
|
|
2858
|
+
declare const index$2_McpErrorType: typeof McpErrorType;
|
|
2859
|
+
type index$2_McpToolset = McpToolset;
|
|
2860
|
+
declare const index$2_McpToolset: typeof McpToolset;
|
|
2690
2861
|
type index$2_ToolConfig = ToolConfig;
|
|
2691
2862
|
type index$2_ToolContext = ToolContext;
|
|
2692
2863
|
declare const index$2_ToolContext: typeof ToolContext;
|
|
@@ -2694,10 +2865,15 @@ type index$2_TransferToAgentTool = TransferToAgentTool;
|
|
|
2694
2865
|
declare const index$2_TransferToAgentTool: typeof TransferToAgentTool;
|
|
2695
2866
|
type index$2_UserInteractionTool = UserInteractionTool;
|
|
2696
2867
|
declare const index$2_UserInteractionTool: typeof UserInteractionTool;
|
|
2868
|
+
declare const index$2_adkToMcpToolType: typeof adkToMcpToolType;
|
|
2697
2869
|
declare const index$2_buildFunctionDeclaration: typeof buildFunctionDeclaration;
|
|
2698
2870
|
declare const index$2_createFunctionTool: typeof createFunctionTool;
|
|
2871
|
+
declare const index$2_getMcpTools: typeof getMcpTools;
|
|
2872
|
+
declare const index$2_jsonSchemaToDeclaration: typeof jsonSchemaToDeclaration;
|
|
2873
|
+
declare const index$2_mcpSchemaToParameters: typeof mcpSchemaToParameters;
|
|
2874
|
+
declare const index$2_normalizeJsonSchema: typeof normalizeJsonSchema;
|
|
2699
2875
|
declare namespace index$2 {
|
|
2700
|
-
export { index$2_BaseTool as BaseTool, type index$2_BuildFunctionDeclarationOptions as BuildFunctionDeclarationOptions, index$2_ExitLoopTool as ExitLoopTool, index$2_FileOperationsTool as FileOperationsTool, index$2_FunctionTool as FunctionTool, index$2_GetUserChoiceTool as GetUserChoiceTool, index$2_GoogleSearch as GoogleSearch, index$2_HttpRequestTool as HttpRequestTool, type index$2_IToolContext as IToolContext, index$2_LoadMemoryTool as LoadMemoryTool, type index$2_ToolConfig as ToolConfig, index$2_ToolContext as ToolContext, index$2_TransferToAgentTool as TransferToAgentTool, index$2_UserInteractionTool as UserInteractionTool, index$2_buildFunctionDeclaration as buildFunctionDeclaration, index$2_createFunctionTool as createFunctionTool };
|
|
2876
|
+
export { index$2_BaseTool as BaseTool, type index$2_BuildFunctionDeclarationOptions as BuildFunctionDeclarationOptions, index$2_ExitLoopTool as ExitLoopTool, index$2_FileOperationsTool as FileOperationsTool, index$2_FunctionTool as FunctionTool, index$2_GetUserChoiceTool as GetUserChoiceTool, index$2_GoogleSearch as GoogleSearch, index$2_HttpRequestTool as HttpRequestTool, type index$2_IToolContext as IToolContext, index$2_LoadMemoryTool as LoadMemoryTool, index$2_McpError as McpError, index$2_McpErrorType as McpErrorType, index$2_McpToolset as McpToolset, type index$2_ToolConfig as ToolConfig, index$2_ToolContext as ToolContext, index$2_TransferToAgentTool as TransferToAgentTool, index$2_UserInteractionTool as UserInteractionTool, index$2_adkToMcpToolType as adkToMcpToolType, index$2_buildFunctionDeclaration as buildFunctionDeclaration, index$2_createFunctionTool as createFunctionTool, index$2_getMcpTools as getMcpTools, index$2_jsonSchemaToDeclaration as jsonSchemaToDeclaration, index$2_mcpSchemaToParameters as mcpSchemaToParameters, index$2_normalizeJsonSchema as normalizeJsonSchema };
|
|
2701
2877
|
}
|
|
2702
2878
|
|
|
2703
2879
|
/**
|
|
@@ -3365,4 +3541,4 @@ declare class InMemoryRunner extends Runner {
|
|
|
3365
3541
|
|
|
3366
3542
|
declare const VERSION = "0.1.0";
|
|
3367
3543
|
|
|
3368
|
-
export { Agent, type AgentConfig, index$3 as Agents, AnthropicLLM, type AnthropicLLMConfig, AnthropicLLMConnection, ApiKeyCredential, ApiKeyScheme, type AudioTranscriptionConfig, AuthConfig, AuthCredential, AuthCredentialType, AuthHandler, AuthScheme, AuthSchemeType, BaseAgent, BaseLLM, BaseLLMConnection, type BaseMemoryService, BaseTool, BasicAuthCredential, BearerTokenCredential, type BuildFunctionDeclarationOptions, ExitLoopTool, FileOperationsTool, type FunctionCall, type FunctionDeclaration, FunctionTool, GetUserChoiceTool, GoogleLLM, type GoogleLLMConfig, GoogleSearch, HttpRequestTool, HttpScheme, type IToolContext, type ImageContent, InMemoryMemoryService, InMemoryRunner, InMemorySessionService, InvocationContext, type JSONSchema, LLMRegistry, LLMRequest, type LLMRequestConfig, LLMResponse, LangGraphAgent, type LangGraphAgentConfig, type LangGraphNode, type ListSessionOptions, LoadMemoryTool, LoopAgent, type LoopAgentConfig, index$1 as Memory, type MemoryResult, type Message, type MessageContent, type MessageRole, index$4 as Models, OAuth2Credential, OAuth2Scheme, type OAuthFlow, type OAuthFlows, OpenAILLM, type OpenAILLMConfig, OpenAILLMConnection, OpenIdConnectScheme, ParallelAgent, type ParallelAgentConfig, PersistentMemoryService, PgLiteSessionService, PostgresSessionService, RunConfig, Runner, type SearchMemoryOptions, type SearchMemoryResponse, SequentialAgent, type SequentialAgentConfig, type Session, type SessionService, SessionState, index as Sessions, type SpeechConfig, StreamingMode, type TextContent, type ToolCall, type ToolConfig, ToolContext, index$2 as Tools, TransferToAgentTool, UserInteractionTool, VERSION, buildFunctionDeclaration, cloneSession, createFunctionTool, generateSessionId, registerProviders, validateSession };
|
|
3544
|
+
export { Agent, type AgentConfig, index$3 as Agents, AnthropicLLM, type AnthropicLLMConfig, AnthropicLLMConnection, ApiKeyCredential, ApiKeyScheme, type AudioTranscriptionConfig, AuthConfig, AuthCredential, AuthCredentialType, AuthHandler, AuthScheme, AuthSchemeType, BaseAgent, BaseLLM, BaseLLMConnection, type BaseMemoryService, BaseTool, BasicAuthCredential, BearerTokenCredential, type BuildFunctionDeclarationOptions, ExitLoopTool, FileOperationsTool, type FunctionCall, type FunctionDeclaration, FunctionTool, GetUserChoiceTool, GoogleLLM, type GoogleLLMConfig, GoogleSearch, HttpRequestTool, HttpScheme, type IToolContext, type ImageContent, InMemoryMemoryService, InMemoryRunner, InMemorySessionService, InvocationContext, type JSONSchema, LLMRegistry, LLMRequest, type LLMRequestConfig, LLMResponse, LangGraphAgent, type LangGraphAgentConfig, type LangGraphNode, type ListSessionOptions, LoadMemoryTool, LoopAgent, type LoopAgentConfig, McpError, McpErrorType, McpToolset, index$1 as Memory, type MemoryResult, type Message, type MessageContent, type MessageRole, index$4 as Models, OAuth2Credential, OAuth2Scheme, type OAuthFlow, type OAuthFlows, OpenAILLM, type OpenAILLMConfig, OpenAILLMConnection, OpenIdConnectScheme, ParallelAgent, type ParallelAgentConfig, PersistentMemoryService, PgLiteSessionService, PostgresSessionService, RunConfig, Runner, type SearchMemoryOptions, type SearchMemoryResponse, SequentialAgent, type SequentialAgentConfig, type Session, type SessionService, SessionState, index as Sessions, type SpeechConfig, StreamingMode, type TextContent, type ToolCall, type ToolConfig, ToolContext, index$2 as Tools, TransferToAgentTool, UserInteractionTool, VERSION, adkToMcpToolType, buildFunctionDeclaration, cloneSession, createFunctionTool, generateSessionId, getMcpTools, jsonSchemaToDeclaration, mcpSchemaToParameters, normalizeJsonSchema, registerProviders, validateSession };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
2
|
+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
1
3
|
import { AxiosInstance } from 'axios';
|
|
2
4
|
import OpenAI from 'openai';
|
|
3
5
|
import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';
|
|
@@ -2665,6 +2667,169 @@ declare class LoadMemoryTool extends BaseTool {
|
|
|
2665
2667
|
}, context: ToolContext): Promise<any>;
|
|
2666
2668
|
}
|
|
2667
2669
|
|
|
2670
|
+
type McpConfig = {
|
|
2671
|
+
name: string;
|
|
2672
|
+
description: string;
|
|
2673
|
+
transport: McpTransportType;
|
|
2674
|
+
timeout?: number;
|
|
2675
|
+
retryOptions?: {
|
|
2676
|
+
maxRetries?: number;
|
|
2677
|
+
initialDelay?: number;
|
|
2678
|
+
maxDelay?: number;
|
|
2679
|
+
};
|
|
2680
|
+
headers?: Record<string, string>;
|
|
2681
|
+
cacheConfig?: {
|
|
2682
|
+
enabled?: boolean;
|
|
2683
|
+
maxAge?: number;
|
|
2684
|
+
maxSize?: number;
|
|
2685
|
+
};
|
|
2686
|
+
debug?: boolean;
|
|
2687
|
+
};
|
|
2688
|
+
type McpTransportType = {
|
|
2689
|
+
mode: "stdio";
|
|
2690
|
+
command: string;
|
|
2691
|
+
args: string[];
|
|
2692
|
+
env?: Record<string, string>;
|
|
2693
|
+
} | {
|
|
2694
|
+
mode: "sse";
|
|
2695
|
+
serverUrl: string;
|
|
2696
|
+
headers?: HeadersInit;
|
|
2697
|
+
};
|
|
2698
|
+
/**
|
|
2699
|
+
* Error types specific to the MCP client
|
|
2700
|
+
*/
|
|
2701
|
+
declare enum McpErrorType {
|
|
2702
|
+
CONNECTION_ERROR = "connection_error",
|
|
2703
|
+
TOOL_EXECUTION_ERROR = "tool_execution_error",
|
|
2704
|
+
RESOURCE_CLOSED_ERROR = "resource_closed_error",
|
|
2705
|
+
TIMEOUT_ERROR = "timeout_error",
|
|
2706
|
+
INVALID_SCHEMA_ERROR = "invalid_schema_error"
|
|
2707
|
+
}
|
|
2708
|
+
/**
|
|
2709
|
+
* Custom error class for MCP-related errors
|
|
2710
|
+
*/
|
|
2711
|
+
declare class McpError extends Error {
|
|
2712
|
+
type: McpErrorType;
|
|
2713
|
+
originalError?: Error;
|
|
2714
|
+
constructor(message: string, type: McpErrorType, originalError?: Error);
|
|
2715
|
+
}
|
|
2716
|
+
|
|
2717
|
+
declare class McpClientService {
|
|
2718
|
+
private config;
|
|
2719
|
+
private client;
|
|
2720
|
+
private transport;
|
|
2721
|
+
private isClosing;
|
|
2722
|
+
constructor(config: McpConfig);
|
|
2723
|
+
/**
|
|
2724
|
+
* Initializes and returns an MCP client based on configuration.
|
|
2725
|
+
* Will create a new client if one doesn't exist yet.
|
|
2726
|
+
*/
|
|
2727
|
+
initialize(): Promise<Client>;
|
|
2728
|
+
/**
|
|
2729
|
+
* Creates a transport based on the configuration.
|
|
2730
|
+
*/
|
|
2731
|
+
private createTransport;
|
|
2732
|
+
/**
|
|
2733
|
+
* Re-initializes the MCP client when a session is closed.
|
|
2734
|
+
* Used by the retry mechanism.
|
|
2735
|
+
*/
|
|
2736
|
+
reinitialize(): Promise<void>;
|
|
2737
|
+
/**
|
|
2738
|
+
* Cleans up resources associated with this client service.
|
|
2739
|
+
* Similar to Python's AsyncExitStack.aclose() functionality.
|
|
2740
|
+
*/
|
|
2741
|
+
private cleanupResources;
|
|
2742
|
+
/**
|
|
2743
|
+
* Call an MCP tool with retry capability if the session is closed.
|
|
2744
|
+
*/
|
|
2745
|
+
callTool(name: string, args: Record<string, any>): Promise<any>;
|
|
2746
|
+
/**
|
|
2747
|
+
* Closes and cleans up all resources.
|
|
2748
|
+
* Should be called when the service is no longer needed.
|
|
2749
|
+
* Similar to Python's close() method.
|
|
2750
|
+
*/
|
|
2751
|
+
close(): Promise<void>;
|
|
2752
|
+
/**
|
|
2753
|
+
* Checks if the client is currently connected
|
|
2754
|
+
*/
|
|
2755
|
+
isConnected(): boolean;
|
|
2756
|
+
}
|
|
2757
|
+
|
|
2758
|
+
/**
|
|
2759
|
+
* Converts an ADK-style BaseTool to an MCP tool format
|
|
2760
|
+
* Similar to Python's adk_to_mcp_tool_type function
|
|
2761
|
+
*/
|
|
2762
|
+
declare function adkToMcpToolType(tool: BaseTool): Tool;
|
|
2763
|
+
/**
|
|
2764
|
+
* Converts MCP JSONSchema to ADK's FunctionDeclaration format
|
|
2765
|
+
* Similar to handling in McpToolAdapter's getDeclaration
|
|
2766
|
+
*/
|
|
2767
|
+
declare function jsonSchemaToDeclaration(name: string, description: string, schema: Record<string, any> | undefined): FunctionDeclaration;
|
|
2768
|
+
/**
|
|
2769
|
+
* Normalizes a JSON Schema to ensure it's properly formatted
|
|
2770
|
+
* Handles edge cases and ensures consistency
|
|
2771
|
+
*/
|
|
2772
|
+
declare function normalizeJsonSchema(schema: Record<string, any>): JSONSchema;
|
|
2773
|
+
/**
|
|
2774
|
+
* Converts MCP tool inputSchema to parameters format expected by BaseTool
|
|
2775
|
+
*/
|
|
2776
|
+
declare function mcpSchemaToParameters(mcpTool: Tool): JSONSchema;
|
|
2777
|
+
|
|
2778
|
+
/**
|
|
2779
|
+
* A class for managing MCP tools similar to Python's MCPToolset.
|
|
2780
|
+
* Provides functionality to retrieve and use tools from an MCP server.
|
|
2781
|
+
*/
|
|
2782
|
+
declare class McpToolset {
|
|
2783
|
+
private config;
|
|
2784
|
+
private clientService;
|
|
2785
|
+
private toolFilter;
|
|
2786
|
+
private tools;
|
|
2787
|
+
private isClosing;
|
|
2788
|
+
constructor(config: McpConfig, toolFilter?: string[] | ((tool: any, context?: ToolContext) => boolean) | null);
|
|
2789
|
+
/**
|
|
2790
|
+
* Checks if a tool should be included based on the tool filter.
|
|
2791
|
+
* Similar to Python's _is_selected method.
|
|
2792
|
+
*/
|
|
2793
|
+
private isSelected;
|
|
2794
|
+
/**
|
|
2795
|
+
* Initializes the client service and establishes a connection.
|
|
2796
|
+
*/
|
|
2797
|
+
initialize(): Promise<McpClientService>;
|
|
2798
|
+
/**
|
|
2799
|
+
* Retrieves tools from the MCP server and converts them to BaseTool instances.
|
|
2800
|
+
* Similar to Python's get_tools method.
|
|
2801
|
+
*/
|
|
2802
|
+
getTools(context?: ToolContext): Promise<BaseTool[]>;
|
|
2803
|
+
/**
|
|
2804
|
+
* Converts ADK tools to MCP tool format for bidirectional support
|
|
2805
|
+
*/
|
|
2806
|
+
convertADKToolsToMCP(tools: BaseTool[]): any[];
|
|
2807
|
+
/**
|
|
2808
|
+
* Refreshes the tool cache by clearing it and fetching tools again
|
|
2809
|
+
*/
|
|
2810
|
+
refreshTools(context?: ToolContext): Promise<BaseTool[]>;
|
|
2811
|
+
/**
|
|
2812
|
+
* Closes the connection to the MCP server.
|
|
2813
|
+
* Similar to Python's close method.
|
|
2814
|
+
*/
|
|
2815
|
+
close(): Promise<void>;
|
|
2816
|
+
/**
|
|
2817
|
+
* Disposes of all resources. This method should be called when the toolset is no longer needed.
|
|
2818
|
+
* Provides alignment with disposal patterns common in TypeScript.
|
|
2819
|
+
*/
|
|
2820
|
+
dispose(): Promise<void>;
|
|
2821
|
+
}
|
|
2822
|
+
/**
|
|
2823
|
+
* Retrieves and converts tools from an MCP server.
|
|
2824
|
+
*
|
|
2825
|
+
* This function:
|
|
2826
|
+
* 1. Connects to the MCP server (local or sse).
|
|
2827
|
+
* 2. Retrieves all available tools.
|
|
2828
|
+
* 3. Converts them into BaseTool instances.
|
|
2829
|
+
* 4. Returns them as a BaseTool array.
|
|
2830
|
+
*/
|
|
2831
|
+
declare function getMcpTools(config: McpConfig, toolFilter?: string[] | ((tool: any, context?: ToolContext) => boolean)): Promise<BaseTool[]>;
|
|
2832
|
+
|
|
2668
2833
|
/**
|
|
2669
2834
|
* Tools module exports
|
|
2670
2835
|
*/
|
|
@@ -2687,6 +2852,12 @@ declare const index$2_HttpRequestTool: typeof HttpRequestTool;
|
|
|
2687
2852
|
type index$2_IToolContext = IToolContext;
|
|
2688
2853
|
type index$2_LoadMemoryTool = LoadMemoryTool;
|
|
2689
2854
|
declare const index$2_LoadMemoryTool: typeof LoadMemoryTool;
|
|
2855
|
+
type index$2_McpError = McpError;
|
|
2856
|
+
declare const index$2_McpError: typeof McpError;
|
|
2857
|
+
type index$2_McpErrorType = McpErrorType;
|
|
2858
|
+
declare const index$2_McpErrorType: typeof McpErrorType;
|
|
2859
|
+
type index$2_McpToolset = McpToolset;
|
|
2860
|
+
declare const index$2_McpToolset: typeof McpToolset;
|
|
2690
2861
|
type index$2_ToolConfig = ToolConfig;
|
|
2691
2862
|
type index$2_ToolContext = ToolContext;
|
|
2692
2863
|
declare const index$2_ToolContext: typeof ToolContext;
|
|
@@ -2694,10 +2865,15 @@ type index$2_TransferToAgentTool = TransferToAgentTool;
|
|
|
2694
2865
|
declare const index$2_TransferToAgentTool: typeof TransferToAgentTool;
|
|
2695
2866
|
type index$2_UserInteractionTool = UserInteractionTool;
|
|
2696
2867
|
declare const index$2_UserInteractionTool: typeof UserInteractionTool;
|
|
2868
|
+
declare const index$2_adkToMcpToolType: typeof adkToMcpToolType;
|
|
2697
2869
|
declare const index$2_buildFunctionDeclaration: typeof buildFunctionDeclaration;
|
|
2698
2870
|
declare const index$2_createFunctionTool: typeof createFunctionTool;
|
|
2871
|
+
declare const index$2_getMcpTools: typeof getMcpTools;
|
|
2872
|
+
declare const index$2_jsonSchemaToDeclaration: typeof jsonSchemaToDeclaration;
|
|
2873
|
+
declare const index$2_mcpSchemaToParameters: typeof mcpSchemaToParameters;
|
|
2874
|
+
declare const index$2_normalizeJsonSchema: typeof normalizeJsonSchema;
|
|
2699
2875
|
declare namespace index$2 {
|
|
2700
|
-
export { index$2_BaseTool as BaseTool, type index$2_BuildFunctionDeclarationOptions as BuildFunctionDeclarationOptions, index$2_ExitLoopTool as ExitLoopTool, index$2_FileOperationsTool as FileOperationsTool, index$2_FunctionTool as FunctionTool, index$2_GetUserChoiceTool as GetUserChoiceTool, index$2_GoogleSearch as GoogleSearch, index$2_HttpRequestTool as HttpRequestTool, type index$2_IToolContext as IToolContext, index$2_LoadMemoryTool as LoadMemoryTool, type index$2_ToolConfig as ToolConfig, index$2_ToolContext as ToolContext, index$2_TransferToAgentTool as TransferToAgentTool, index$2_UserInteractionTool as UserInteractionTool, index$2_buildFunctionDeclaration as buildFunctionDeclaration, index$2_createFunctionTool as createFunctionTool };
|
|
2876
|
+
export { index$2_BaseTool as BaseTool, type index$2_BuildFunctionDeclarationOptions as BuildFunctionDeclarationOptions, index$2_ExitLoopTool as ExitLoopTool, index$2_FileOperationsTool as FileOperationsTool, index$2_FunctionTool as FunctionTool, index$2_GetUserChoiceTool as GetUserChoiceTool, index$2_GoogleSearch as GoogleSearch, index$2_HttpRequestTool as HttpRequestTool, type index$2_IToolContext as IToolContext, index$2_LoadMemoryTool as LoadMemoryTool, index$2_McpError as McpError, index$2_McpErrorType as McpErrorType, index$2_McpToolset as McpToolset, type index$2_ToolConfig as ToolConfig, index$2_ToolContext as ToolContext, index$2_TransferToAgentTool as TransferToAgentTool, index$2_UserInteractionTool as UserInteractionTool, index$2_adkToMcpToolType as adkToMcpToolType, index$2_buildFunctionDeclaration as buildFunctionDeclaration, index$2_createFunctionTool as createFunctionTool, index$2_getMcpTools as getMcpTools, index$2_jsonSchemaToDeclaration as jsonSchemaToDeclaration, index$2_mcpSchemaToParameters as mcpSchemaToParameters, index$2_normalizeJsonSchema as normalizeJsonSchema };
|
|
2701
2877
|
}
|
|
2702
2878
|
|
|
2703
2879
|
/**
|
|
@@ -3365,4 +3541,4 @@ declare class InMemoryRunner extends Runner {
|
|
|
3365
3541
|
|
|
3366
3542
|
declare const VERSION = "0.1.0";
|
|
3367
3543
|
|
|
3368
|
-
export { Agent, type AgentConfig, index$3 as Agents, AnthropicLLM, type AnthropicLLMConfig, AnthropicLLMConnection, ApiKeyCredential, ApiKeyScheme, type AudioTranscriptionConfig, AuthConfig, AuthCredential, AuthCredentialType, AuthHandler, AuthScheme, AuthSchemeType, BaseAgent, BaseLLM, BaseLLMConnection, type BaseMemoryService, BaseTool, BasicAuthCredential, BearerTokenCredential, type BuildFunctionDeclarationOptions, ExitLoopTool, FileOperationsTool, type FunctionCall, type FunctionDeclaration, FunctionTool, GetUserChoiceTool, GoogleLLM, type GoogleLLMConfig, GoogleSearch, HttpRequestTool, HttpScheme, type IToolContext, type ImageContent, InMemoryMemoryService, InMemoryRunner, InMemorySessionService, InvocationContext, type JSONSchema, LLMRegistry, LLMRequest, type LLMRequestConfig, LLMResponse, LangGraphAgent, type LangGraphAgentConfig, type LangGraphNode, type ListSessionOptions, LoadMemoryTool, LoopAgent, type LoopAgentConfig, index$1 as Memory, type MemoryResult, type Message, type MessageContent, type MessageRole, index$4 as Models, OAuth2Credential, OAuth2Scheme, type OAuthFlow, type OAuthFlows, OpenAILLM, type OpenAILLMConfig, OpenAILLMConnection, OpenIdConnectScheme, ParallelAgent, type ParallelAgentConfig, PersistentMemoryService, PgLiteSessionService, PostgresSessionService, RunConfig, Runner, type SearchMemoryOptions, type SearchMemoryResponse, SequentialAgent, type SequentialAgentConfig, type Session, type SessionService, SessionState, index as Sessions, type SpeechConfig, StreamingMode, type TextContent, type ToolCall, type ToolConfig, ToolContext, index$2 as Tools, TransferToAgentTool, UserInteractionTool, VERSION, buildFunctionDeclaration, cloneSession, createFunctionTool, generateSessionId, registerProviders, validateSession };
|
|
3544
|
+
export { Agent, type AgentConfig, index$3 as Agents, AnthropicLLM, type AnthropicLLMConfig, AnthropicLLMConnection, ApiKeyCredential, ApiKeyScheme, type AudioTranscriptionConfig, AuthConfig, AuthCredential, AuthCredentialType, AuthHandler, AuthScheme, AuthSchemeType, BaseAgent, BaseLLM, BaseLLMConnection, type BaseMemoryService, BaseTool, BasicAuthCredential, BearerTokenCredential, type BuildFunctionDeclarationOptions, ExitLoopTool, FileOperationsTool, type FunctionCall, type FunctionDeclaration, FunctionTool, GetUserChoiceTool, GoogleLLM, type GoogleLLMConfig, GoogleSearch, HttpRequestTool, HttpScheme, type IToolContext, type ImageContent, InMemoryMemoryService, InMemoryRunner, InMemorySessionService, InvocationContext, type JSONSchema, LLMRegistry, LLMRequest, type LLMRequestConfig, LLMResponse, LangGraphAgent, type LangGraphAgentConfig, type LangGraphNode, type ListSessionOptions, LoadMemoryTool, LoopAgent, type LoopAgentConfig, McpError, McpErrorType, McpToolset, index$1 as Memory, type MemoryResult, type Message, type MessageContent, type MessageRole, index$4 as Models, OAuth2Credential, OAuth2Scheme, type OAuthFlow, type OAuthFlows, OpenAILLM, type OpenAILLMConfig, OpenAILLMConnection, OpenIdConnectScheme, ParallelAgent, type ParallelAgentConfig, PersistentMemoryService, PgLiteSessionService, PostgresSessionService, RunConfig, Runner, type SearchMemoryOptions, type SearchMemoryResponse, SequentialAgent, type SequentialAgentConfig, type Session, type SessionService, SessionState, index as Sessions, type SpeechConfig, StreamingMode, type TextContent, type ToolCall, type ToolConfig, ToolContext, index$2 as Tools, TransferToAgentTool, UserInteractionTool, VERSION, adkToMcpToolType, buildFunctionDeclaration, cloneSession, createFunctionTool, generateSessionId, getMcpTools, jsonSchemaToDeclaration, mcpSchemaToParameters, normalizeJsonSchema, registerProviders, validateSession };
|