@iqai/adk 0.0.9 → 0.0.10

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @iqai/adk
2
2
 
3
+ ## 0.0.10
4
+
5
+ ### Patch Changes
6
+
7
+ - cb16b0c: Adds helper functions for creating sampling handlers
8
+
3
9
  ## 0.0.9
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -2699,6 +2699,11 @@ type McpConfig = {
2699
2699
  maxSize?: number;
2700
2700
  };
2701
2701
  debug?: boolean;
2702
+ /**
2703
+ * Sampling handler for processing MCP sampling requests.
2704
+ * This allows MCP servers to request LLM completions through your ADK agent.
2705
+ */
2706
+ samplingHandler?: ADKSamplingHandler;
2702
2707
  };
2703
2708
  type McpTransportType = {
2704
2709
  mode: "stdio";
@@ -2732,7 +2737,7 @@ declare class McpError extends Error {
2732
2737
  }
2733
2738
  type SamplingRequest = z.infer<typeof CreateMessageRequestSchema>;
2734
2739
  type SamplingResponse = z.infer<typeof CreateMessageResultSchema>;
2735
-
2740
+ type SamplingHandler = (request: SamplingRequest) => Promise<SamplingResponse>;
2736
2741
  /**
2737
2742
  * ADK sampling request format - what we pass to the user's handler
2738
2743
  */
@@ -2809,7 +2814,7 @@ declare class McpClientService {
2809
2814
  isConnected(): boolean;
2810
2815
  private setupSamplingHandler;
2811
2816
  /**
2812
- * Set an ADK sampling handler
2817
+ * Set a new ADK sampling handler
2813
2818
  */
2814
2819
  setSamplingHandler(handler: ADKSamplingHandler): void;
2815
2820
  /**
@@ -2838,6 +2843,68 @@ declare function normalizeJsonSchema(schema: Record<string, any>): JSONSchema;
2838
2843
  */
2839
2844
  declare function mcpSchemaToParameters(mcpTool: Tool): JSONSchema;
2840
2845
 
2846
+ /**
2847
+ * MCP Sampling Handler class that handles message format conversion
2848
+ * between MCP format and ADK format
2849
+ */
2850
+ declare class McpSamplingHandler {
2851
+ private logger;
2852
+ private adkHandler;
2853
+ constructor(adkHandler: ADKSamplingHandler);
2854
+ /**
2855
+ * Handle MCP sampling request and convert between formats
2856
+ */
2857
+ handleSamplingRequest(request: SamplingRequest): Promise<SamplingResponse>;
2858
+ /**
2859
+ * Convert MCP messages to ADK message format
2860
+ */
2861
+ private convertMcpMessagesToADK;
2862
+ /**
2863
+ * Convert ADK response to MCP response format
2864
+ */
2865
+ private convertADKResponseToMcp;
2866
+ /**
2867
+ * Update the ADK handler
2868
+ */
2869
+ updateHandler(handler: ADKSamplingHandler): void;
2870
+ }
2871
+ /**
2872
+ * Helper function to create a sampling handler with proper TypeScript types.
2873
+ *
2874
+ * @param handler - Function that handles sampling requests
2875
+ * @returns Properly typed ADK sampling handler
2876
+ *
2877
+ * @example
2878
+ * ```typescript
2879
+ * import { createSamplingHandler, GoogleLLM, LLMRequest } from "@iqai/adk";
2880
+ *
2881
+ * const llm = new GoogleLLM("gemini-2.5-flash-preview-05-20");
2882
+ *
2883
+ * const samplingHandler = createSamplingHandler(async (request) => {
2884
+ * // request is properly typed with all the fields
2885
+ * const llmRequest = new LLMRequest({
2886
+ * messages: request.messages,
2887
+ * config: {
2888
+ * temperature: request.temperature || 0.7,
2889
+ * max_tokens: request.maxTokens,
2890
+ * }
2891
+ * });
2892
+ *
2893
+ * const responses = [];
2894
+ * for await (const response of llm.generateContentAsync(llmRequest)) {
2895
+ * responses.push(response);
2896
+ * }
2897
+ *
2898
+ * return {
2899
+ * model: llm.model,
2900
+ * content: responses[responses.length - 1].content,
2901
+ * stopReason: "endTurn"
2902
+ * };
2903
+ * });
2904
+ * ```
2905
+ */
2906
+ declare function createSamplingHandler(handler: (request: ADKSamplingRequest) => Promise<ADKSamplingResponse>): ADKSamplingHandler;
2907
+
2841
2908
  /**
2842
2909
  * A class for managing MCP tools similar to Python's MCPToolset.
2843
2910
  * Provides functionality to retrieve and use tools from an MCP server.
@@ -2858,6 +2925,17 @@ declare class McpToolset {
2858
2925
  * Initializes the client service and establishes a connection.
2859
2926
  */
2860
2927
  initialize(): Promise<McpClientService>;
2928
+ /**
2929
+ * Set a sampling handler for this MCP toolset.
2930
+ * This allows MCP servers to request LLM completions through your ADK agent.
2931
+ *
2932
+ * @param handler - ADK sampling handler that receives ADK-formatted messages
2933
+ */
2934
+ setSamplingHandler(handler: ADKSamplingHandler): void;
2935
+ /**
2936
+ * Remove the sampling handler
2937
+ */
2938
+ removeSamplingHandler(): void;
2861
2939
  /**
2862
2940
  * Retrieves tools from the MCP server and converts them to BaseTool instances.
2863
2941
  * Similar to Python's get_tools method.
@@ -2897,6 +2975,9 @@ declare function getMcpTools(config: McpConfig, toolFilter?: string[] | ((tool:
2897
2975
  * Tools module exports
2898
2976
  */
2899
2977
 
2978
+ type index$2_ADKSamplingHandler = ADKSamplingHandler;
2979
+ type index$2_ADKSamplingRequest = ADKSamplingRequest;
2980
+ type index$2_ADKSamplingResponse = ADKSamplingResponse;
2900
2981
  type index$2_BaseTool = BaseTool;
2901
2982
  declare const index$2_BaseTool: typeof BaseTool;
2902
2983
  type index$2_BuildFunctionDeclarationOptions = BuildFunctionDeclarationOptions;
@@ -2920,9 +3001,12 @@ type index$2_McpError = McpError;
2920
3001
  declare const index$2_McpError: typeof McpError;
2921
3002
  type index$2_McpErrorType = McpErrorType;
2922
3003
  declare const index$2_McpErrorType: typeof McpErrorType;
3004
+ type index$2_McpSamplingHandler = McpSamplingHandler;
3005
+ declare const index$2_McpSamplingHandler: typeof McpSamplingHandler;
2923
3006
  type index$2_McpToolset = McpToolset;
2924
3007
  declare const index$2_McpToolset: typeof McpToolset;
2925
3008
  type index$2_McpTransportType = McpTransportType;
3009
+ type index$2_SamplingHandler = SamplingHandler;
2926
3010
  type index$2_SamplingRequest = SamplingRequest;
2927
3011
  type index$2_SamplingResponse = SamplingResponse;
2928
3012
  type index$2_ToolConfig = ToolConfig;
@@ -2935,12 +3019,13 @@ declare const index$2_UserInteractionTool: typeof UserInteractionTool;
2935
3019
  declare const index$2_adkToMcpToolType: typeof adkToMcpToolType;
2936
3020
  declare const index$2_buildFunctionDeclaration: typeof buildFunctionDeclaration;
2937
3021
  declare const index$2_createFunctionTool: typeof createFunctionTool;
3022
+ declare const index$2_createSamplingHandler: typeof createSamplingHandler;
2938
3023
  declare const index$2_getMcpTools: typeof getMcpTools;
2939
3024
  declare const index$2_jsonSchemaToDeclaration: typeof jsonSchemaToDeclaration;
2940
3025
  declare const index$2_mcpSchemaToParameters: typeof mcpSchemaToParameters;
2941
3026
  declare const index$2_normalizeJsonSchema: typeof normalizeJsonSchema;
2942
3027
  declare namespace index$2 {
2943
- 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_McpConfig as McpConfig, index$2_McpError as McpError, index$2_McpErrorType as McpErrorType, index$2_McpToolset as McpToolset, type index$2_McpTransportType as McpTransportType, type index$2_SamplingRequest as SamplingRequest, type index$2_SamplingResponse as SamplingResponse, 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 };
3028
+ export { type index$2_ADKSamplingHandler as ADKSamplingHandler, type index$2_ADKSamplingRequest as ADKSamplingRequest, type index$2_ADKSamplingResponse as ADKSamplingResponse, 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_McpConfig as McpConfig, index$2_McpError as McpError, index$2_McpErrorType as McpErrorType, index$2_McpSamplingHandler as McpSamplingHandler, index$2_McpToolset as McpToolset, type index$2_McpTransportType as McpTransportType, type index$2_SamplingHandler as SamplingHandler, type index$2_SamplingRequest as SamplingRequest, type index$2_SamplingResponse as SamplingResponse, 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_createSamplingHandler as createSamplingHandler, index$2_getMcpTools as getMcpTools, index$2_jsonSchemaToDeclaration as jsonSchemaToDeclaration, index$2_mcpSchemaToParameters as mcpSchemaToParameters, index$2_normalizeJsonSchema as normalizeJsonSchema };
2944
3029
  }
2945
3030
 
2946
3031
  /**
@@ -3499,4 +3584,4 @@ declare class InMemoryRunner extends Runner {
3499
3584
 
3500
3585
  declare const VERSION = "0.1.0";
3501
3586
 
3502
- 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, type McpConfig, McpError, McpErrorType, McpToolset, type McpTransportType, 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 SamplingRequest, type SamplingResponse, type SearchMemoryOptions, type SearchMemoryResponse, SequentialAgent, type SequentialAgentConfig, type Session, type SessionService, SessionState, index as Sessions, type SpeechConfig, SqliteSessionService, 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 };
3587
+ export { type ADKSamplingHandler, type ADKSamplingRequest, type ADKSamplingResponse, 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, type McpConfig, McpError, McpErrorType, McpSamplingHandler, McpToolset, type McpTransportType, 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 SamplingHandler, type SamplingRequest, type SamplingResponse, type SearchMemoryOptions, type SearchMemoryResponse, SequentialAgent, type SequentialAgentConfig, type Session, type SessionService, SessionState, index as Sessions, type SpeechConfig, SqliteSessionService, StreamingMode, type TextContent, type ToolCall, type ToolConfig, ToolContext, index$2 as Tools, TransferToAgentTool, UserInteractionTool, VERSION, adkToMcpToolType, buildFunctionDeclaration, cloneSession, createFunctionTool, createSamplingHandler, generateSessionId, getMcpTools, jsonSchemaToDeclaration, mcpSchemaToParameters, normalizeJsonSchema, registerProviders, validateSession };
package/dist/index.d.ts CHANGED
@@ -2699,6 +2699,11 @@ type McpConfig = {
2699
2699
  maxSize?: number;
2700
2700
  };
2701
2701
  debug?: boolean;
2702
+ /**
2703
+ * Sampling handler for processing MCP sampling requests.
2704
+ * This allows MCP servers to request LLM completions through your ADK agent.
2705
+ */
2706
+ samplingHandler?: ADKSamplingHandler;
2702
2707
  };
2703
2708
  type McpTransportType = {
2704
2709
  mode: "stdio";
@@ -2732,7 +2737,7 @@ declare class McpError extends Error {
2732
2737
  }
2733
2738
  type SamplingRequest = z.infer<typeof CreateMessageRequestSchema>;
2734
2739
  type SamplingResponse = z.infer<typeof CreateMessageResultSchema>;
2735
-
2740
+ type SamplingHandler = (request: SamplingRequest) => Promise<SamplingResponse>;
2736
2741
  /**
2737
2742
  * ADK sampling request format - what we pass to the user's handler
2738
2743
  */
@@ -2809,7 +2814,7 @@ declare class McpClientService {
2809
2814
  isConnected(): boolean;
2810
2815
  private setupSamplingHandler;
2811
2816
  /**
2812
- * Set an ADK sampling handler
2817
+ * Set a new ADK sampling handler
2813
2818
  */
2814
2819
  setSamplingHandler(handler: ADKSamplingHandler): void;
2815
2820
  /**
@@ -2838,6 +2843,68 @@ declare function normalizeJsonSchema(schema: Record<string, any>): JSONSchema;
2838
2843
  */
2839
2844
  declare function mcpSchemaToParameters(mcpTool: Tool): JSONSchema;
2840
2845
 
2846
+ /**
2847
+ * MCP Sampling Handler class that handles message format conversion
2848
+ * between MCP format and ADK format
2849
+ */
2850
+ declare class McpSamplingHandler {
2851
+ private logger;
2852
+ private adkHandler;
2853
+ constructor(adkHandler: ADKSamplingHandler);
2854
+ /**
2855
+ * Handle MCP sampling request and convert between formats
2856
+ */
2857
+ handleSamplingRequest(request: SamplingRequest): Promise<SamplingResponse>;
2858
+ /**
2859
+ * Convert MCP messages to ADK message format
2860
+ */
2861
+ private convertMcpMessagesToADK;
2862
+ /**
2863
+ * Convert ADK response to MCP response format
2864
+ */
2865
+ private convertADKResponseToMcp;
2866
+ /**
2867
+ * Update the ADK handler
2868
+ */
2869
+ updateHandler(handler: ADKSamplingHandler): void;
2870
+ }
2871
+ /**
2872
+ * Helper function to create a sampling handler with proper TypeScript types.
2873
+ *
2874
+ * @param handler - Function that handles sampling requests
2875
+ * @returns Properly typed ADK sampling handler
2876
+ *
2877
+ * @example
2878
+ * ```typescript
2879
+ * import { createSamplingHandler, GoogleLLM, LLMRequest } from "@iqai/adk";
2880
+ *
2881
+ * const llm = new GoogleLLM("gemini-2.5-flash-preview-05-20");
2882
+ *
2883
+ * const samplingHandler = createSamplingHandler(async (request) => {
2884
+ * // request is properly typed with all the fields
2885
+ * const llmRequest = new LLMRequest({
2886
+ * messages: request.messages,
2887
+ * config: {
2888
+ * temperature: request.temperature || 0.7,
2889
+ * max_tokens: request.maxTokens,
2890
+ * }
2891
+ * });
2892
+ *
2893
+ * const responses = [];
2894
+ * for await (const response of llm.generateContentAsync(llmRequest)) {
2895
+ * responses.push(response);
2896
+ * }
2897
+ *
2898
+ * return {
2899
+ * model: llm.model,
2900
+ * content: responses[responses.length - 1].content,
2901
+ * stopReason: "endTurn"
2902
+ * };
2903
+ * });
2904
+ * ```
2905
+ */
2906
+ declare function createSamplingHandler(handler: (request: ADKSamplingRequest) => Promise<ADKSamplingResponse>): ADKSamplingHandler;
2907
+
2841
2908
  /**
2842
2909
  * A class for managing MCP tools similar to Python's MCPToolset.
2843
2910
  * Provides functionality to retrieve and use tools from an MCP server.
@@ -2858,6 +2925,17 @@ declare class McpToolset {
2858
2925
  * Initializes the client service and establishes a connection.
2859
2926
  */
2860
2927
  initialize(): Promise<McpClientService>;
2928
+ /**
2929
+ * Set a sampling handler for this MCP toolset.
2930
+ * This allows MCP servers to request LLM completions through your ADK agent.
2931
+ *
2932
+ * @param handler - ADK sampling handler that receives ADK-formatted messages
2933
+ */
2934
+ setSamplingHandler(handler: ADKSamplingHandler): void;
2935
+ /**
2936
+ * Remove the sampling handler
2937
+ */
2938
+ removeSamplingHandler(): void;
2861
2939
  /**
2862
2940
  * Retrieves tools from the MCP server and converts them to BaseTool instances.
2863
2941
  * Similar to Python's get_tools method.
@@ -2897,6 +2975,9 @@ declare function getMcpTools(config: McpConfig, toolFilter?: string[] | ((tool:
2897
2975
  * Tools module exports
2898
2976
  */
2899
2977
 
2978
+ type index$2_ADKSamplingHandler = ADKSamplingHandler;
2979
+ type index$2_ADKSamplingRequest = ADKSamplingRequest;
2980
+ type index$2_ADKSamplingResponse = ADKSamplingResponse;
2900
2981
  type index$2_BaseTool = BaseTool;
2901
2982
  declare const index$2_BaseTool: typeof BaseTool;
2902
2983
  type index$2_BuildFunctionDeclarationOptions = BuildFunctionDeclarationOptions;
@@ -2920,9 +3001,12 @@ type index$2_McpError = McpError;
2920
3001
  declare const index$2_McpError: typeof McpError;
2921
3002
  type index$2_McpErrorType = McpErrorType;
2922
3003
  declare const index$2_McpErrorType: typeof McpErrorType;
3004
+ type index$2_McpSamplingHandler = McpSamplingHandler;
3005
+ declare const index$2_McpSamplingHandler: typeof McpSamplingHandler;
2923
3006
  type index$2_McpToolset = McpToolset;
2924
3007
  declare const index$2_McpToolset: typeof McpToolset;
2925
3008
  type index$2_McpTransportType = McpTransportType;
3009
+ type index$2_SamplingHandler = SamplingHandler;
2926
3010
  type index$2_SamplingRequest = SamplingRequest;
2927
3011
  type index$2_SamplingResponse = SamplingResponse;
2928
3012
  type index$2_ToolConfig = ToolConfig;
@@ -2935,12 +3019,13 @@ declare const index$2_UserInteractionTool: typeof UserInteractionTool;
2935
3019
  declare const index$2_adkToMcpToolType: typeof adkToMcpToolType;
2936
3020
  declare const index$2_buildFunctionDeclaration: typeof buildFunctionDeclaration;
2937
3021
  declare const index$2_createFunctionTool: typeof createFunctionTool;
3022
+ declare const index$2_createSamplingHandler: typeof createSamplingHandler;
2938
3023
  declare const index$2_getMcpTools: typeof getMcpTools;
2939
3024
  declare const index$2_jsonSchemaToDeclaration: typeof jsonSchemaToDeclaration;
2940
3025
  declare const index$2_mcpSchemaToParameters: typeof mcpSchemaToParameters;
2941
3026
  declare const index$2_normalizeJsonSchema: typeof normalizeJsonSchema;
2942
3027
  declare namespace index$2 {
2943
- 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_McpConfig as McpConfig, index$2_McpError as McpError, index$2_McpErrorType as McpErrorType, index$2_McpToolset as McpToolset, type index$2_McpTransportType as McpTransportType, type index$2_SamplingRequest as SamplingRequest, type index$2_SamplingResponse as SamplingResponse, 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 };
3028
+ export { type index$2_ADKSamplingHandler as ADKSamplingHandler, type index$2_ADKSamplingRequest as ADKSamplingRequest, type index$2_ADKSamplingResponse as ADKSamplingResponse, 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_McpConfig as McpConfig, index$2_McpError as McpError, index$2_McpErrorType as McpErrorType, index$2_McpSamplingHandler as McpSamplingHandler, index$2_McpToolset as McpToolset, type index$2_McpTransportType as McpTransportType, type index$2_SamplingHandler as SamplingHandler, type index$2_SamplingRequest as SamplingRequest, type index$2_SamplingResponse as SamplingResponse, 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_createSamplingHandler as createSamplingHandler, index$2_getMcpTools as getMcpTools, index$2_jsonSchemaToDeclaration as jsonSchemaToDeclaration, index$2_mcpSchemaToParameters as mcpSchemaToParameters, index$2_normalizeJsonSchema as normalizeJsonSchema };
2944
3029
  }
2945
3030
 
2946
3031
  /**
@@ -3499,4 +3584,4 @@ declare class InMemoryRunner extends Runner {
3499
3584
 
3500
3585
  declare const VERSION = "0.1.0";
3501
3586
 
3502
- 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, type McpConfig, McpError, McpErrorType, McpToolset, type McpTransportType, 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 SamplingRequest, type SamplingResponse, type SearchMemoryOptions, type SearchMemoryResponse, SequentialAgent, type SequentialAgentConfig, type Session, type SessionService, SessionState, index as Sessions, type SpeechConfig, SqliteSessionService, 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 };
3587
+ export { type ADKSamplingHandler, type ADKSamplingRequest, type ADKSamplingResponse, 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, type McpConfig, McpError, McpErrorType, McpSamplingHandler, McpToolset, type McpTransportType, 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 SamplingHandler, type SamplingRequest, type SamplingResponse, type SearchMemoryOptions, type SearchMemoryResponse, SequentialAgent, type SequentialAgentConfig, type Session, type SessionService, SessionState, index as Sessions, type SpeechConfig, SqliteSessionService, StreamingMode, type TextContent, type ToolCall, type ToolConfig, ToolContext, index$2 as Tools, TransferToAgentTool, UserInteractionTool, VERSION, adkToMcpToolType, buildFunctionDeclaration, cloneSession, createFunctionTool, createSamplingHandler, generateSessionId, getMcpTools, jsonSchemaToDeclaration, mcpSchemaToParameters, normalizeJsonSchema, registerProviders, validateSession };
package/dist/index.js CHANGED
@@ -2186,6 +2186,7 @@ __export(tools_exports, {
2186
2186
  LoadMemoryTool: () => LoadMemoryTool,
2187
2187
  McpError: () => McpError,
2188
2188
  McpErrorType: () => McpErrorType,
2189
+ McpSamplingHandler: () => McpSamplingHandler,
2189
2190
  McpToolset: () => McpToolset,
2190
2191
  ToolContext: () => ToolContext,
2191
2192
  TransferToAgentTool: () => TransferToAgentTool,
@@ -2193,6 +2194,7 @@ __export(tools_exports, {
2193
2194
  adkToMcpToolType: () => adkToMcpToolType,
2194
2195
  buildFunctionDeclaration: () => buildFunctionDeclaration,
2195
2196
  createFunctionTool: () => createFunctionTool,
2197
+ createSamplingHandler: () => createSamplingHandler,
2196
2198
  getMcpTools: () => getMcpTools,
2197
2199
  jsonSchemaToDeclaration: () => jsonSchemaToDeclaration,
2198
2200
  mcpSchemaToParameters: () => mcpSchemaToParameters,
@@ -2988,6 +2990,15 @@ var McpSamplingHandler = (_class17 = class {
2988
2990
  */
2989
2991
  async handleSamplingRequest(request) {
2990
2992
  try {
2993
+ if (request.method !== "sampling/createMessage") {
2994
+ this.logger.error(
2995
+ `Invalid method for sampling handler: ${request.method}. Expected: sampling/createMessage`
2996
+ );
2997
+ throw new McpError(
2998
+ `Invalid method: ${request.method}. This handler only processes sampling/createMessage requests.`,
2999
+ "INVALID_REQUEST_ERROR" /* INVALID_REQUEST_ERROR */
3000
+ );
3001
+ }
2991
3002
  const validationResult = _typesjs.CreateMessageRequestSchema.safeParse(request);
2992
3003
  if (!validationResult.success) {
2993
3004
  this.logger.error(
@@ -3123,6 +3134,9 @@ var McpSamplingHandler = (_class17 = class {
3123
3134
  this.logger.debug("ADK sampling handler updated");
3124
3135
  }
3125
3136
  }, _class17);
3137
+ function createSamplingHandler(handler) {
3138
+ return handler;
3139
+ }
3126
3140
 
3127
3141
  // src/tools/mcp/utils.ts
3128
3142
  function withRetry(fn, instance, reinitMethod, maxRetries = 1) {
@@ -3162,6 +3176,9 @@ var McpClientService = (_class18 = class {
3162
3176
  __init25() {this.logger = new Logger({ name: "McpClientService" })}
3163
3177
  constructor(config) {;_class18.prototype.__init21.call(this);_class18.prototype.__init22.call(this);_class18.prototype.__init23.call(this);_class18.prototype.__init24.call(this);_class18.prototype.__init25.call(this);
3164
3178
  this.config = config;
3179
+ if (config.samplingHandler) {
3180
+ this.mcpSamplingHandler = new McpSamplingHandler(config.samplingHandler);
3181
+ }
3165
3182
  }
3166
3183
  /**
3167
3184
  * Initializes and returns an MCP client based on configuration.
@@ -3190,7 +3207,9 @@ var McpClientService = (_class18 = class {
3190
3207
  capabilities: {
3191
3208
  prompts: {},
3192
3209
  resources: {},
3193
- tools: {}
3210
+ tools: {},
3211
+ sampling: {}
3212
+ // Enable sampling capability
3194
3213
  }
3195
3214
  }
3196
3215
  );
@@ -3396,13 +3415,13 @@ var McpClientService = (_class18 = class {
3396
3415
  }
3397
3416
  }
3398
3417
  /**
3399
- * Set an ADK sampling handler
3418
+ * Set a new ADK sampling handler
3400
3419
  */
3401
3420
  setSamplingHandler(handler) {
3402
3421
  this.mcpSamplingHandler = new McpSamplingHandler(handler);
3403
3422
  if (this.client) {
3404
3423
  this.setupSamplingHandler(this.client).catch((error) => {
3405
- console.error("Failed to update sampling handler:", error);
3424
+ console.error("Failed to update ADK sampling handler:", error);
3406
3425
  });
3407
3426
  }
3408
3427
  }
@@ -3753,6 +3772,32 @@ var McpToolset = (_class20 = class {
3753
3772
  await this.clientService.initialize();
3754
3773
  return this.clientService;
3755
3774
  }
3775
+ /**
3776
+ * Set a sampling handler for this MCP toolset.
3777
+ * This allows MCP servers to request LLM completions through your ADK agent.
3778
+ *
3779
+ * @param handler - ADK sampling handler that receives ADK-formatted messages
3780
+ */
3781
+ setSamplingHandler(handler) {
3782
+ if (!this.clientService) {
3783
+ this.clientService = new McpClientService(this.config);
3784
+ }
3785
+ this.clientService.setSamplingHandler(handler);
3786
+ if (this.config.debug) {
3787
+ console.log("\u{1F3AF} Sampling handler set for MCP toolset");
3788
+ }
3789
+ }
3790
+ /**
3791
+ * Remove the sampling handler
3792
+ */
3793
+ removeSamplingHandler() {
3794
+ if (this.clientService) {
3795
+ this.clientService.removeSamplingHandler();
3796
+ if (this.config.debug) {
3797
+ console.log("\u{1F6AB} Sampling handler removed from MCP toolset");
3798
+ }
3799
+ }
3800
+ }
3756
3801
  /**
3757
3802
  * Retrieves tools from the MCP server and converts them to BaseTool instances.
3758
3803
  * Similar to Python's get_tools method.
@@ -7202,4 +7247,6 @@ var VERSION = "0.1.0";
7202
7247
 
7203
7248
 
7204
7249
 
7205
- exports.Agent = Agent; exports.Agents = agents_exports; exports.AnthropicLLM = AnthropicLLM; exports.AnthropicLLMConnection = AnthropicLLMConnection; 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.BaseAgent = BaseAgent; exports.BaseLLM = BaseLLM; exports.BaseLLMConnection = BaseLLMConnection; exports.BaseTool = BaseTool; exports.BasicAuthCredential = BasicAuthCredential; exports.BearerTokenCredential = BearerTokenCredential; exports.ExitLoopTool = ExitLoopTool; exports.FileOperationsTool = FileOperationsTool; exports.FunctionTool = FunctionTool; exports.GetUserChoiceTool = GetUserChoiceTool; exports.GoogleLLM = GoogleLLM; exports.GoogleSearch = GoogleSearch; exports.HttpRequestTool = HttpRequestTool; exports.HttpScheme = HttpScheme; exports.InMemoryMemoryService = InMemoryMemoryService; exports.InMemoryRunner = InMemoryRunner; exports.InMemorySessionService = InMemorySessionService; exports.InvocationContext = InvocationContext; exports.LLMRegistry = LLMRegistry; exports.LLMRequest = LLMRequest; exports.LLMResponse = LLMResponse; exports.LangGraphAgent = LangGraphAgent; exports.LoadMemoryTool = LoadMemoryTool; exports.LoopAgent = LoopAgent; exports.McpError = McpError; exports.McpErrorType = McpErrorType; exports.McpToolset = McpToolset; exports.Memory = memory_exports; exports.Models = models_exports; exports.OAuth2Credential = OAuth2Credential; exports.OAuth2Scheme = OAuth2Scheme; exports.OpenAILLM = OpenAILLM; exports.OpenAILLMConnection = OpenAILLMConnection; exports.OpenIdConnectScheme = OpenIdConnectScheme; exports.ParallelAgent = ParallelAgent; exports.PersistentMemoryService = PersistentMemoryService; exports.PgLiteSessionService = PgLiteSessionService; exports.PostgresSessionService = PostgresSessionService; exports.RunConfig = RunConfig; exports.Runner = Runner; exports.SequentialAgent = SequentialAgent; exports.SessionState = SessionState; exports.Sessions = sessions_exports; exports.SqliteSessionService = SqliteSessionService; exports.StreamingMode = StreamingMode; exports.ToolContext = ToolContext; exports.Tools = tools_exports; exports.TransferToAgentTool = TransferToAgentTool; exports.UserInteractionTool = UserInteractionTool; exports.VERSION = VERSION; exports.adkToMcpToolType = adkToMcpToolType; exports.buildFunctionDeclaration = buildFunctionDeclaration; exports.cloneSession = cloneSession; exports.createFunctionTool = createFunctionTool; exports.generateSessionId = generateSessionId; exports.getMcpTools = getMcpTools; exports.jsonSchemaToDeclaration = jsonSchemaToDeclaration; exports.mcpSchemaToParameters = mcpSchemaToParameters; exports.normalizeJsonSchema = normalizeJsonSchema; exports.registerProviders = registerProviders; exports.validateSession = validateSession;
7250
+
7251
+
7252
+ exports.Agent = Agent; exports.Agents = agents_exports; exports.AnthropicLLM = AnthropicLLM; exports.AnthropicLLMConnection = AnthropicLLMConnection; 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.BaseAgent = BaseAgent; exports.BaseLLM = BaseLLM; exports.BaseLLMConnection = BaseLLMConnection; exports.BaseTool = BaseTool; exports.BasicAuthCredential = BasicAuthCredential; exports.BearerTokenCredential = BearerTokenCredential; exports.ExitLoopTool = ExitLoopTool; exports.FileOperationsTool = FileOperationsTool; exports.FunctionTool = FunctionTool; exports.GetUserChoiceTool = GetUserChoiceTool; exports.GoogleLLM = GoogleLLM; exports.GoogleSearch = GoogleSearch; exports.HttpRequestTool = HttpRequestTool; exports.HttpScheme = HttpScheme; exports.InMemoryMemoryService = InMemoryMemoryService; exports.InMemoryRunner = InMemoryRunner; exports.InMemorySessionService = InMemorySessionService; exports.InvocationContext = InvocationContext; exports.LLMRegistry = LLMRegistry; exports.LLMRequest = LLMRequest; exports.LLMResponse = LLMResponse; exports.LangGraphAgent = LangGraphAgent; exports.LoadMemoryTool = LoadMemoryTool; exports.LoopAgent = LoopAgent; exports.McpError = McpError; exports.McpErrorType = McpErrorType; exports.McpSamplingHandler = McpSamplingHandler; exports.McpToolset = McpToolset; exports.Memory = memory_exports; exports.Models = models_exports; exports.OAuth2Credential = OAuth2Credential; exports.OAuth2Scheme = OAuth2Scheme; exports.OpenAILLM = OpenAILLM; exports.OpenAILLMConnection = OpenAILLMConnection; exports.OpenIdConnectScheme = OpenIdConnectScheme; exports.ParallelAgent = ParallelAgent; exports.PersistentMemoryService = PersistentMemoryService; exports.PgLiteSessionService = PgLiteSessionService; exports.PostgresSessionService = PostgresSessionService; exports.RunConfig = RunConfig; exports.Runner = Runner; exports.SequentialAgent = SequentialAgent; exports.SessionState = SessionState; exports.Sessions = sessions_exports; exports.SqliteSessionService = SqliteSessionService; exports.StreamingMode = StreamingMode; exports.ToolContext = ToolContext; exports.Tools = tools_exports; exports.TransferToAgentTool = TransferToAgentTool; exports.UserInteractionTool = UserInteractionTool; exports.VERSION = VERSION; exports.adkToMcpToolType = adkToMcpToolType; exports.buildFunctionDeclaration = buildFunctionDeclaration; exports.cloneSession = cloneSession; exports.createFunctionTool = createFunctionTool; exports.createSamplingHandler = createSamplingHandler; exports.generateSessionId = generateSessionId; exports.getMcpTools = getMcpTools; exports.jsonSchemaToDeclaration = jsonSchemaToDeclaration; exports.mcpSchemaToParameters = mcpSchemaToParameters; exports.normalizeJsonSchema = normalizeJsonSchema; exports.registerProviders = registerProviders; exports.validateSession = validateSession;
package/dist/index.mjs CHANGED
@@ -2186,6 +2186,7 @@ __export(tools_exports, {
2186
2186
  LoadMemoryTool: () => LoadMemoryTool,
2187
2187
  McpError: () => McpError,
2188
2188
  McpErrorType: () => McpErrorType,
2189
+ McpSamplingHandler: () => McpSamplingHandler,
2189
2190
  McpToolset: () => McpToolset,
2190
2191
  ToolContext: () => ToolContext,
2191
2192
  TransferToAgentTool: () => TransferToAgentTool,
@@ -2193,6 +2194,7 @@ __export(tools_exports, {
2193
2194
  adkToMcpToolType: () => adkToMcpToolType,
2194
2195
  buildFunctionDeclaration: () => buildFunctionDeclaration,
2195
2196
  createFunctionTool: () => createFunctionTool,
2197
+ createSamplingHandler: () => createSamplingHandler,
2196
2198
  getMcpTools: () => getMcpTools,
2197
2199
  jsonSchemaToDeclaration: () => jsonSchemaToDeclaration,
2198
2200
  mcpSchemaToParameters: () => mcpSchemaToParameters,
@@ -2988,6 +2990,15 @@ var McpSamplingHandler = class {
2988
2990
  */
2989
2991
  async handleSamplingRequest(request) {
2990
2992
  try {
2993
+ if (request.method !== "sampling/createMessage") {
2994
+ this.logger.error(
2995
+ `Invalid method for sampling handler: ${request.method}. Expected: sampling/createMessage`
2996
+ );
2997
+ throw new McpError(
2998
+ `Invalid method: ${request.method}. This handler only processes sampling/createMessage requests.`,
2999
+ "INVALID_REQUEST_ERROR" /* INVALID_REQUEST_ERROR */
3000
+ );
3001
+ }
2991
3002
  const validationResult = CreateMessageRequestSchema.safeParse(request);
2992
3003
  if (!validationResult.success) {
2993
3004
  this.logger.error(
@@ -3123,6 +3134,9 @@ var McpSamplingHandler = class {
3123
3134
  this.logger.debug("ADK sampling handler updated");
3124
3135
  }
3125
3136
  };
3137
+ function createSamplingHandler(handler) {
3138
+ return handler;
3139
+ }
3126
3140
 
3127
3141
  // src/tools/mcp/utils.ts
3128
3142
  function withRetry(fn, instance, reinitMethod, maxRetries = 1) {
@@ -3162,6 +3176,9 @@ var McpClientService = class {
3162
3176
  logger = new Logger({ name: "McpClientService" });
3163
3177
  constructor(config) {
3164
3178
  this.config = config;
3179
+ if (config.samplingHandler) {
3180
+ this.mcpSamplingHandler = new McpSamplingHandler(config.samplingHandler);
3181
+ }
3165
3182
  }
3166
3183
  /**
3167
3184
  * Initializes and returns an MCP client based on configuration.
@@ -3190,7 +3207,9 @@ var McpClientService = class {
3190
3207
  capabilities: {
3191
3208
  prompts: {},
3192
3209
  resources: {},
3193
- tools: {}
3210
+ tools: {},
3211
+ sampling: {}
3212
+ // Enable sampling capability
3194
3213
  }
3195
3214
  }
3196
3215
  );
@@ -3396,13 +3415,13 @@ var McpClientService = class {
3396
3415
  }
3397
3416
  }
3398
3417
  /**
3399
- * Set an ADK sampling handler
3418
+ * Set a new ADK sampling handler
3400
3419
  */
3401
3420
  setSamplingHandler(handler) {
3402
3421
  this.mcpSamplingHandler = new McpSamplingHandler(handler);
3403
3422
  if (this.client) {
3404
3423
  this.setupSamplingHandler(this.client).catch((error) => {
3405
- console.error("Failed to update sampling handler:", error);
3424
+ console.error("Failed to update ADK sampling handler:", error);
3406
3425
  });
3407
3426
  }
3408
3427
  }
@@ -3753,6 +3772,32 @@ var McpToolset = class {
3753
3772
  await this.clientService.initialize();
3754
3773
  return this.clientService;
3755
3774
  }
3775
+ /**
3776
+ * Set a sampling handler for this MCP toolset.
3777
+ * This allows MCP servers to request LLM completions through your ADK agent.
3778
+ *
3779
+ * @param handler - ADK sampling handler that receives ADK-formatted messages
3780
+ */
3781
+ setSamplingHandler(handler) {
3782
+ if (!this.clientService) {
3783
+ this.clientService = new McpClientService(this.config);
3784
+ }
3785
+ this.clientService.setSamplingHandler(handler);
3786
+ if (this.config.debug) {
3787
+ console.log("\u{1F3AF} Sampling handler set for MCP toolset");
3788
+ }
3789
+ }
3790
+ /**
3791
+ * Remove the sampling handler
3792
+ */
3793
+ removeSamplingHandler() {
3794
+ if (this.clientService) {
3795
+ this.clientService.removeSamplingHandler();
3796
+ if (this.config.debug) {
3797
+ console.log("\u{1F6AB} Sampling handler removed from MCP toolset");
3798
+ }
3799
+ }
3800
+ }
3756
3801
  /**
3757
3802
  * Retrieves tools from the MCP server and converts them to BaseTool instances.
3758
3803
  * Similar to Python's get_tools method.
@@ -7167,6 +7212,7 @@ export {
7167
7212
  LoopAgent,
7168
7213
  McpError,
7169
7214
  McpErrorType,
7215
+ McpSamplingHandler,
7170
7216
  McpToolset,
7171
7217
  memory_exports as Memory,
7172
7218
  models_exports as Models,
@@ -7195,6 +7241,7 @@ export {
7195
7241
  buildFunctionDeclaration,
7196
7242
  cloneSession,
7197
7243
  createFunctionTool,
7244
+ createSamplingHandler,
7198
7245
  generateSessionId,
7199
7246
  getMcpTools,
7200
7247
  jsonSchemaToDeclaration,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iqai/adk",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
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",