@langchain/anthropic
Version:
Anthropic integrations for LangChain.js
1 lines • 5.03 kB
Source Map (JSON)
{"version":3,"file":"mcpToolset.d.cts","names":["Anthropic","ServerTool","MCPToolConfig","MCPToolConfigs","Record","MCPToolsetOptions","Beta","BetaCacheControlEphemeral","mcpToolset_20251120"],"sources":["../../src/tools/mcpToolset.d.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { type ServerTool } from \"@langchain/core/tools\";\n/**\n * Configuration for a single tool in the MCP toolset.\n */\nexport interface MCPToolConfig {\n /**\n * Whether this tool is enabled.\n * @default true\n */\n enabled?: boolean;\n /**\n * If true, tool description is not sent to the model initially.\n * Used with Tool Search Tool for on-demand loading.\n * @default false\n */\n deferLoading?: boolean;\n}\n/**\n * Per-tool configuration overrides.\n * Keys are tool names, values are configuration objects.\n */\nexport type MCPToolConfigs = Record<string, MCPToolConfig>;\n/**\n * Options for creating an MCP toolset.\n */\nexport interface MCPToolsetOptions {\n /**\n * Must match a server name defined in the `mcp_servers` array in call options.\n */\n serverName: string;\n /**\n * Default configuration applied to all tools in this toolset.\n * Individual tool configs will override these defaults.\n */\n defaultConfig?: MCPToolConfig;\n /**\n * Per-tool configuration overrides.\n * Keys are tool names, values are configuration objects.\n */\n configs?: MCPToolConfigs;\n /**\n * Create a cache control breakpoint at this content block.\n */\n cacheControl?: Anthropic.Beta.BetaCacheControlEphemeral;\n}\n/**\n * Creates an MCP toolset that connects to a remote MCP server to access its tools.\n * This enables Claude to use tools from MCP servers without implementing a separate MCP client.\n *\n * @note This tool requires the beta header `mcp-client-2025-11-20` in API requests.\n * The header is automatically added when using this tool.\n *\n * @see {@link https://docs.anthropic.com/en/docs/agents-and-tools/mcp-connector | Anthropic MCP Connector Documentation}\n * @param options - Configuration options for the MCP toolset\n * @returns An MCP toolset definition to be passed to the Anthropic API tools array\n *\n * @example\n * ```typescript\n * import { ChatAnthropic, tools } from \"@langchain/anthropic\";\n *\n * const model = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\",\n * });\n *\n * // Basic usage - enable all tools from an MCP server\n * const response = await model.invoke(\"What tools do you have available?\", {\n * mcp_servers: [{\n * type: \"url\",\n * url: \"https://example-server.modelcontextprotocol.io/sse\",\n * name: \"example-mcp\",\n * authorization_token: \"YOUR_TOKEN\",\n * }],\n * tools: [\n * tools.mcpToolset_20251120({ serverName: \"example-mcp\" }),\n * ],\n * });\n *\n * // Allowlist pattern - enable only specific tools\n * const responseAllowlist = await model.invoke(\"Search for events\", {\n * mcp_servers: [{\n * type: \"url\",\n * url: \"https://calendar.example.com/sse\",\n * name: \"google-calendar-mcp\",\n * authorization_token: \"YOUR_TOKEN\",\n * }],\n * tools: [\n * tools.mcpToolset_20251120({\n * serverName: \"google-calendar-mcp\",\n * defaultConfig: { enabled: false },\n * configs: {\n * search_events: { enabled: true },\n * create_event: { enabled: true },\n * },\n * }),\n * ],\n * });\n *\n * // Denylist pattern - disable specific tools\n * const responseDenylist = await model.invoke(\"List my events\", {\n * mcp_servers: [{\n * type: \"url\",\n * url: \"https://calendar.example.com/sse\",\n * name: \"google-calendar-mcp\",\n * authorization_token: \"YOUR_TOKEN\",\n * }],\n * tools: [\n * tools.mcpToolset_20251120({\n * serverName: \"google-calendar-mcp\",\n * configs: {\n * delete_all_events: { enabled: false },\n * share_calendar_publicly: { enabled: false },\n * },\n * }),\n * ],\n * });\n *\n * // With deferred loading for use with Tool Search Tool\n * const responseDeferred = await model.invoke(\"Search for tools\", {\n * mcp_servers: [{\n * type: \"url\",\n * url: \"https://example.com/sse\",\n * name: \"example-mcp\",\n * }],\n * tools: [\n * tools.toolSearchRegex_20251119(),\n * tools.mcpToolset_20251120({\n * serverName: \"example-mcp\",\n * defaultConfig: { deferLoading: true },\n * }),\n * ],\n * });\n * ```\n */\nexport declare function mcpToolset_20251120(options: MCPToolsetOptions): ServerTool;\n//# sourceMappingURL=mcpToolset.d.ts.map"],"mappings":";;;;;;;AAKA;AAiBYG,UAjBKD,aAAAA,CAiBS;EAITG;;;;EAkB0C,OAAA,CAAA,EAAA,OAAA;EA0FnCG;;;;;;;;;;;KAhHZL,cAAAA,GAAiBC,eAAeF;;;;UAI3BG,iBAAAA;;;;;;;;;kBASGH;;;;;YAKNC;;;;iBAIKH,SAAAA,CAAUM,IAAAA,CAAKC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0FVC,mBAAAA,UAA6BH,oBAAoBJ"}