@langchain/anthropic 1.2.3 → 1.3.0-dev-1765432861398

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.
Files changed (112) hide show
  1. package/README.md +620 -3
  2. package/dist/chat_models.cjs +8 -5
  3. package/dist/chat_models.cjs.map +1 -1
  4. package/dist/chat_models.d.cts +13 -16
  5. package/dist/chat_models.d.cts.map +1 -0
  6. package/dist/chat_models.d.ts +13 -16
  7. package/dist/chat_models.d.ts.map +1 -0
  8. package/dist/chat_models.js +7 -4
  9. package/dist/chat_models.js.map +1 -1
  10. package/dist/index.cjs +3 -1
  11. package/dist/index.d.cts +12 -2
  12. package/dist/index.d.ts +12 -2
  13. package/dist/index.js +2 -1
  14. package/dist/tools/bash.cjs +95 -0
  15. package/dist/tools/bash.cjs.map +1 -0
  16. package/dist/tools/bash.d.cts +99 -0
  17. package/dist/tools/bash.d.cts.map +1 -0
  18. package/dist/tools/bash.d.ts +99 -0
  19. package/dist/tools/bash.d.ts.map +1 -0
  20. package/dist/tools/bash.js +94 -0
  21. package/dist/tools/bash.js.map +1 -0
  22. package/dist/tools/codeExecution.cjs +70 -0
  23. package/dist/tools/codeExecution.cjs.map +1 -0
  24. package/dist/tools/codeExecution.d.cts +75 -0
  25. package/dist/tools/codeExecution.d.cts.map +1 -0
  26. package/dist/tools/codeExecution.d.ts +75 -0
  27. package/dist/tools/codeExecution.d.ts.map +1 -0
  28. package/dist/tools/codeExecution.js +69 -0
  29. package/dist/tools/codeExecution.js.map +1 -0
  30. package/dist/tools/computer.cjs +161 -0
  31. package/dist/tools/computer.cjs.map +1 -0
  32. package/dist/tools/computer.d.cts +289 -0
  33. package/dist/tools/computer.d.cts.map +1 -0
  34. package/dist/tools/computer.d.ts +289 -0
  35. package/dist/tools/computer.d.ts.map +1 -0
  36. package/dist/tools/computer.js +159 -0
  37. package/dist/tools/computer.js.map +1 -0
  38. package/dist/tools/index.cjs +28 -0
  39. package/dist/tools/index.cjs.map +1 -0
  40. package/dist/tools/index.d.cts +28 -0
  41. package/dist/tools/index.d.cts.map +1 -0
  42. package/dist/tools/index.d.ts +28 -0
  43. package/dist/tools/index.d.ts.map +1 -0
  44. package/dist/tools/index.js +28 -0
  45. package/dist/tools/index.js.map +1 -0
  46. package/dist/tools/mcpToolset.cjs +111 -0
  47. package/dist/tools/mcpToolset.cjs.map +1 -0
  48. package/dist/tools/mcpToolset.d.cts +141 -0
  49. package/dist/tools/mcpToolset.d.cts.map +1 -0
  50. package/dist/tools/mcpToolset.d.ts +141 -0
  51. package/dist/tools/mcpToolset.d.ts.map +1 -0
  52. package/dist/tools/mcpToolset.js +110 -0
  53. package/dist/tools/mcpToolset.js.map +1 -0
  54. package/dist/tools/memory.cjs +56 -0
  55. package/dist/tools/memory.cjs.map +1 -0
  56. package/dist/tools/memory.d.cts +92 -0
  57. package/dist/tools/memory.d.cts.map +1 -0
  58. package/dist/tools/memory.d.ts +92 -0
  59. package/dist/tools/memory.d.ts.map +1 -0
  60. package/dist/tools/memory.js +55 -0
  61. package/dist/tools/memory.js.map +1 -0
  62. package/dist/tools/textEditor.cjs +79 -0
  63. package/dist/tools/textEditor.cjs.map +1 -0
  64. package/dist/tools/textEditor.d.cts +114 -0
  65. package/dist/tools/textEditor.d.cts.map +1 -0
  66. package/dist/tools/textEditor.d.ts +114 -0
  67. package/dist/tools/textEditor.d.ts.map +1 -0
  68. package/dist/tools/textEditor.js +78 -0
  69. package/dist/tools/textEditor.js.map +1 -0
  70. package/dist/tools/toolSearch.cjs +110 -0
  71. package/dist/tools/toolSearch.cjs.map +1 -0
  72. package/dist/tools/toolSearch.d.cts +108 -0
  73. package/dist/tools/toolSearch.d.cts.map +1 -0
  74. package/dist/tools/toolSearch.d.ts +108 -0
  75. package/dist/tools/toolSearch.d.ts.map +1 -0
  76. package/dist/tools/toolSearch.js +108 -0
  77. package/dist/tools/toolSearch.js.map +1 -0
  78. package/dist/tools/types.cjs +204 -0
  79. package/dist/tools/types.cjs.map +1 -0
  80. package/dist/tools/types.d.cts +366 -0
  81. package/dist/tools/types.d.cts.map +1 -0
  82. package/dist/tools/types.d.ts +366 -0
  83. package/dist/tools/types.d.ts.map +1 -0
  84. package/dist/tools/types.js +199 -0
  85. package/dist/tools/types.js.map +1 -0
  86. package/dist/tools/webFetch.cjs +70 -0
  87. package/dist/tools/webFetch.cjs.map +1 -0
  88. package/dist/tools/webFetch.d.cts +96 -0
  89. package/dist/tools/webFetch.d.cts.map +1 -0
  90. package/dist/tools/webFetch.d.ts +96 -0
  91. package/dist/tools/webFetch.d.ts.map +1 -0
  92. package/dist/tools/webFetch.js +69 -0
  93. package/dist/tools/webFetch.js.map +1 -0
  94. package/dist/tools/webSearch.cjs +57 -0
  95. package/dist/tools/webSearch.cjs.map +1 -0
  96. package/dist/tools/webSearch.d.cts +84 -0
  97. package/dist/tools/webSearch.d.cts.map +1 -0
  98. package/dist/tools/webSearch.d.ts +84 -0
  99. package/dist/tools/webSearch.d.ts.map +1 -0
  100. package/dist/tools/webSearch.js +56 -0
  101. package/dist/tools/webSearch.js.map +1 -0
  102. package/dist/types.d.cts +2 -3
  103. package/dist/types.d.cts.map +1 -0
  104. package/dist/types.d.ts +2 -3
  105. package/dist/types.d.ts.map +1 -0
  106. package/dist/utils/prompts.d.cts.map +1 -0
  107. package/dist/utils/prompts.d.ts.map +1 -0
  108. package/dist/utils/tools.cjs +9 -2
  109. package/dist/utils/tools.cjs.map +1 -1
  110. package/dist/utils/tools.js +13 -6
  111. package/dist/utils/tools.js.map +1 -1
  112. package/package.json +8 -7
@@ -0,0 +1,28 @@
1
+ import { memory_20250818 } from "./memory.js";
2
+ import { webSearch_20250305 } from "./webSearch.js";
3
+ import { webFetch_20250910 } from "./webFetch.js";
4
+ import { toolSearchBM25_20251119, toolSearchRegex_20251119 } from "./toolSearch.js";
5
+ import { textEditor_20250728 } from "./textEditor.js";
6
+ import { computer_20250124, computer_20251124 } from "./computer.js";
7
+ import { codeExecution_20250825 } from "./codeExecution.js";
8
+ import { bash_20250124 } from "./bash.js";
9
+ import { mcpToolset_20251120 } from "./mcpToolset.js";
10
+
11
+ //#region src/tools/index.ts
12
+ const tools = {
13
+ memory_20250818,
14
+ webSearch_20250305,
15
+ webFetch_20250910,
16
+ toolSearchRegex_20251119,
17
+ toolSearchBM25_20251119,
18
+ textEditor_20250728,
19
+ computer_20251124,
20
+ computer_20250124,
21
+ codeExecution_20250825,
22
+ bash_20250124,
23
+ mcpToolset_20251120
24
+ };
25
+
26
+ //#endregion
27
+ export { tools };
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/tools/index.ts"],"sourcesContent":["import { memory_20250818 } from \"./memory.js\";\nimport {\n webSearch_20250305,\n type WebSearch20250305Options,\n} from \"./webSearch.js\";\nimport { webFetch_20250910, type WebFetch20250910Options } from \"./webFetch.js\";\nimport {\n toolSearchRegex_20251119,\n toolSearchBM25_20251119,\n type ToolSearchOptions,\n} from \"./toolSearch.js\";\nimport {\n textEditor_20250728,\n type TextEditor20250728Options,\n} from \"./textEditor.js\";\nimport {\n computer_20251124,\n computer_20250124,\n type Computer20251124Options,\n type Computer20250124Options,\n type ComputerUseReturnType,\n} from \"./computer.js\";\nimport {\n codeExecution_20250825,\n type CodeExecution20250825Options,\n} from \"./codeExecution.js\";\nimport { bash_20250124, type Bash20250124Options } from \"./bash.js\";\nimport { mcpToolset_20251120, type MCPToolsetOptions } from \"./mcpToolset.js\";\n\nexport const tools = {\n memory_20250818,\n webSearch_20250305,\n webFetch_20250910,\n toolSearchRegex_20251119,\n toolSearchBM25_20251119,\n textEditor_20250728,\n computer_20251124,\n computer_20250124,\n codeExecution_20250825,\n bash_20250124,\n mcpToolset_20251120,\n};\n\nexport type {\n MCPToolsetOptions,\n Bash20250124Options,\n Computer20251124Options,\n Computer20250124Options,\n ComputerUseReturnType,\n CodeExecution20250825Options,\n TextEditor20250728Options,\n ToolSearchOptions,\n WebFetch20250910Options,\n WebSearch20250305Options,\n};\n\nexport type * from \"./types.js\";\n"],"mappings":";;;;;;;;;;;AA6BA,MAAa,QAAQ;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD"}
@@ -0,0 +1,111 @@
1
+
2
+ //#region src/tools/mcpToolset.ts
3
+ /**
4
+ * Creates an MCP toolset that connects to a remote MCP server to access its tools.
5
+ * This enables Claude to use tools from MCP servers without implementing a separate MCP client.
6
+ *
7
+ * @note This tool requires the beta header `mcp-client-2025-11-20` in API requests.
8
+ * The header is automatically added when using this tool.
9
+ *
10
+ * @see {@link https://docs.anthropic.com/en/docs/agents-and-tools/mcp-connector | Anthropic MCP Connector Documentation}
11
+ * @param options - Configuration options for the MCP toolset
12
+ * @returns An MCP toolset definition to be passed to the Anthropic API tools array
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * import { ChatAnthropic, tools } from "@langchain/anthropic";
17
+ *
18
+ * const model = new ChatAnthropic({
19
+ * model: "claude-sonnet-4-5-20250929",
20
+ * });
21
+ *
22
+ * // Basic usage - enable all tools from an MCP server
23
+ * const response = await model.invoke("What tools do you have available?", {
24
+ * mcp_servers: [{
25
+ * type: "url",
26
+ * url: "https://example-server.modelcontextprotocol.io/sse",
27
+ * name: "example-mcp",
28
+ * authorization_token: "YOUR_TOKEN",
29
+ * }],
30
+ * tools: [
31
+ * tools.mcpToolset_20251120({ serverName: "example-mcp" }),
32
+ * ],
33
+ * });
34
+ *
35
+ * // Allowlist pattern - enable only specific tools
36
+ * const responseAllowlist = await model.invoke("Search for events", {
37
+ * mcp_servers: [{
38
+ * type: "url",
39
+ * url: "https://calendar.example.com/sse",
40
+ * name: "google-calendar-mcp",
41
+ * authorization_token: "YOUR_TOKEN",
42
+ * }],
43
+ * tools: [
44
+ * tools.mcpToolset_20251120({
45
+ * serverName: "google-calendar-mcp",
46
+ * defaultConfig: { enabled: false },
47
+ * configs: {
48
+ * search_events: { enabled: true },
49
+ * create_event: { enabled: true },
50
+ * },
51
+ * }),
52
+ * ],
53
+ * });
54
+ *
55
+ * // Denylist pattern - disable specific tools
56
+ * const responseDenylist = await model.invoke("List my events", {
57
+ * mcp_servers: [{
58
+ * type: "url",
59
+ * url: "https://calendar.example.com/sse",
60
+ * name: "google-calendar-mcp",
61
+ * authorization_token: "YOUR_TOKEN",
62
+ * }],
63
+ * tools: [
64
+ * tools.mcpToolset_20251120({
65
+ * serverName: "google-calendar-mcp",
66
+ * configs: {
67
+ * delete_all_events: { enabled: false },
68
+ * share_calendar_publicly: { enabled: false },
69
+ * },
70
+ * }),
71
+ * ],
72
+ * });
73
+ *
74
+ * // With deferred loading for use with Tool Search Tool
75
+ * const responseDeferred = await model.invoke("Search for tools", {
76
+ * mcp_servers: [{
77
+ * type: "url",
78
+ * url: "https://example.com/sse",
79
+ * name: "example-mcp",
80
+ * }],
81
+ * tools: [
82
+ * tools.toolSearchRegex_20251119(),
83
+ * tools.mcpToolset_20251120({
84
+ * serverName: "example-mcp",
85
+ * defaultConfig: { deferLoading: true },
86
+ * }),
87
+ * ],
88
+ * });
89
+ * ```
90
+ */
91
+ function mcpToolset_20251120(options) {
92
+ const defaultConfig = options.defaultConfig?.enabled !== void 0 || options.defaultConfig?.deferLoading !== void 0 ? {
93
+ enabled: options.defaultConfig?.enabled,
94
+ defer_loading: options.defaultConfig?.deferLoading
95
+ } : void 0;
96
+ const configs = options.configs ? Object.fromEntries(Object.entries(options.configs).map(([toolName, config]) => [toolName, {
97
+ enabled: config.enabled,
98
+ defer_loading: config.deferLoading
99
+ }])) : void 0;
100
+ return {
101
+ type: "mcp_toolset",
102
+ mcp_server_name: options.serverName,
103
+ default_config: defaultConfig,
104
+ configs,
105
+ cache_control: options.cacheControl
106
+ };
107
+ }
108
+
109
+ //#endregion
110
+ exports.mcpToolset_20251120 = mcpToolset_20251120;
111
+ //# sourceMappingURL=mcpToolset.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcpToolset.cjs","names":["options: MCPToolsetOptions"],"sources":["../../src/tools/mcpToolset.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { type ServerTool } from \"@langchain/core/tools\";\n\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/**\n * Per-tool configuration overrides.\n * Keys are tool names, values are configuration objects.\n */\nexport type MCPToolConfigs = Record<string, MCPToolConfig>;\n\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/**\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 function mcpToolset_20251120(options: MCPToolsetOptions): ServerTool {\n const defaultConfig =\n options.defaultConfig?.enabled !== undefined ||\n options.defaultConfig?.deferLoading !== undefined\n ? {\n enabled: options.defaultConfig?.enabled,\n defer_loading: options.defaultConfig?.deferLoading,\n }\n : undefined;\n\n const configs = options.configs\n ? Object.fromEntries(\n Object.entries(options.configs).map(([toolName, config]) => [\n toolName,\n {\n enabled: config.enabled,\n defer_loading: config.deferLoading,\n },\n ])\n )\n : undefined;\n\n return {\n type: \"mcp_toolset\",\n mcp_server_name: options.serverName,\n default_config: defaultConfig,\n configs,\n cache_control: options.cacheControl,\n } satisfies Anthropic.Beta.BetaMCPToolset;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0IA,SAAgB,oBAAoBA,SAAwC;CAC1E,MAAM,gBACJ,QAAQ,eAAe,YAAY,UACnC,QAAQ,eAAe,iBAAiB,SACpC;EACE,SAAS,QAAQ,eAAe;EAChC,eAAe,QAAQ,eAAe;CACvC,IACD;CAEN,MAAM,UAAU,QAAQ,UACpB,OAAO,YACL,OAAO,QAAQ,QAAQ,QAAQ,CAAC,IAAI,CAAC,CAAC,UAAU,OAAO,KAAK,CAC1D,UACA;EACE,SAAS,OAAO;EAChB,eAAe,OAAO;CACvB,CACF,EAAC,CACH,GACD;AAEJ,QAAO;EACL,MAAM;EACN,iBAAiB,QAAQ;EACzB,gBAAgB;EAChB;EACA,eAAe,QAAQ;CACxB;AACF"}
@@ -0,0 +1,141 @@
1
+ import Anthropic from "@anthropic-ai/sdk";
2
+ import { ServerTool } from "@langchain/core/tools";
3
+
4
+ //#region src/tools/mcpToolset.d.ts
5
+
6
+ /**
7
+ * Configuration for a single tool in the MCP toolset.
8
+ */
9
+ interface MCPToolConfig {
10
+ /**
11
+ * Whether this tool is enabled.
12
+ * @default true
13
+ */
14
+ enabled?: boolean;
15
+ /**
16
+ * If true, tool description is not sent to the model initially.
17
+ * Used with Tool Search Tool for on-demand loading.
18
+ * @default false
19
+ */
20
+ deferLoading?: boolean;
21
+ }
22
+ /**
23
+ * Per-tool configuration overrides.
24
+ * Keys are tool names, values are configuration objects.
25
+ */
26
+ type MCPToolConfigs = Record<string, MCPToolConfig>;
27
+ /**
28
+ * Options for creating an MCP toolset.
29
+ */
30
+ interface MCPToolsetOptions {
31
+ /**
32
+ * Must match a server name defined in the `mcp_servers` array in call options.
33
+ */
34
+ serverName: string;
35
+ /**
36
+ * Default configuration applied to all tools in this toolset.
37
+ * Individual tool configs will override these defaults.
38
+ */
39
+ defaultConfig?: MCPToolConfig;
40
+ /**
41
+ * Per-tool configuration overrides.
42
+ * Keys are tool names, values are configuration objects.
43
+ */
44
+ configs?: MCPToolConfigs;
45
+ /**
46
+ * Create a cache control breakpoint at this content block.
47
+ */
48
+ cacheControl?: Anthropic.Beta.BetaCacheControlEphemeral;
49
+ }
50
+ /**
51
+ * Creates an MCP toolset that connects to a remote MCP server to access its tools.
52
+ * This enables Claude to use tools from MCP servers without implementing a separate MCP client.
53
+ *
54
+ * @note This tool requires the beta header `mcp-client-2025-11-20` in API requests.
55
+ * The header is automatically added when using this tool.
56
+ *
57
+ * @see {@link https://docs.anthropic.com/en/docs/agents-and-tools/mcp-connector | Anthropic MCP Connector Documentation}
58
+ * @param options - Configuration options for the MCP toolset
59
+ * @returns An MCP toolset definition to be passed to the Anthropic API tools array
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * import { ChatAnthropic, tools } from "@langchain/anthropic";
64
+ *
65
+ * const model = new ChatAnthropic({
66
+ * model: "claude-sonnet-4-5-20250929",
67
+ * });
68
+ *
69
+ * // Basic usage - enable all tools from an MCP server
70
+ * const response = await model.invoke("What tools do you have available?", {
71
+ * mcp_servers: [{
72
+ * type: "url",
73
+ * url: "https://example-server.modelcontextprotocol.io/sse",
74
+ * name: "example-mcp",
75
+ * authorization_token: "YOUR_TOKEN",
76
+ * }],
77
+ * tools: [
78
+ * tools.mcpToolset_20251120({ serverName: "example-mcp" }),
79
+ * ],
80
+ * });
81
+ *
82
+ * // Allowlist pattern - enable only specific tools
83
+ * const responseAllowlist = await model.invoke("Search for events", {
84
+ * mcp_servers: [{
85
+ * type: "url",
86
+ * url: "https://calendar.example.com/sse",
87
+ * name: "google-calendar-mcp",
88
+ * authorization_token: "YOUR_TOKEN",
89
+ * }],
90
+ * tools: [
91
+ * tools.mcpToolset_20251120({
92
+ * serverName: "google-calendar-mcp",
93
+ * defaultConfig: { enabled: false },
94
+ * configs: {
95
+ * search_events: { enabled: true },
96
+ * create_event: { enabled: true },
97
+ * },
98
+ * }),
99
+ * ],
100
+ * });
101
+ *
102
+ * // Denylist pattern - disable specific tools
103
+ * const responseDenylist = await model.invoke("List my events", {
104
+ * mcp_servers: [{
105
+ * type: "url",
106
+ * url: "https://calendar.example.com/sse",
107
+ * name: "google-calendar-mcp",
108
+ * authorization_token: "YOUR_TOKEN",
109
+ * }],
110
+ * tools: [
111
+ * tools.mcpToolset_20251120({
112
+ * serverName: "google-calendar-mcp",
113
+ * configs: {
114
+ * delete_all_events: { enabled: false },
115
+ * share_calendar_publicly: { enabled: false },
116
+ * },
117
+ * }),
118
+ * ],
119
+ * });
120
+ *
121
+ * // With deferred loading for use with Tool Search Tool
122
+ * const responseDeferred = await model.invoke("Search for tools", {
123
+ * mcp_servers: [{
124
+ * type: "url",
125
+ * url: "https://example.com/sse",
126
+ * name: "example-mcp",
127
+ * }],
128
+ * tools: [
129
+ * tools.toolSearchRegex_20251119(),
130
+ * tools.mcpToolset_20251120({
131
+ * serverName: "example-mcp",
132
+ * defaultConfig: { deferLoading: true },
133
+ * }),
134
+ * ],
135
+ * });
136
+ * ```
137
+ */
138
+ declare function mcpToolset_20251120(options: MCPToolsetOptions): ServerTool;
139
+ //#endregion
140
+ export { MCPToolsetOptions, mcpToolset_20251120 };
141
+ //# sourceMappingURL=mcpToolset.d.cts.map
@@ -0,0 +1 @@
1
+ {"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"}
@@ -0,0 +1,141 @@
1
+ import Anthropic from "@anthropic-ai/sdk";
2
+ import { ServerTool } from "@langchain/core/tools";
3
+
4
+ //#region src/tools/mcpToolset.d.ts
5
+
6
+ /**
7
+ * Configuration for a single tool in the MCP toolset.
8
+ */
9
+ interface MCPToolConfig {
10
+ /**
11
+ * Whether this tool is enabled.
12
+ * @default true
13
+ */
14
+ enabled?: boolean;
15
+ /**
16
+ * If true, tool description is not sent to the model initially.
17
+ * Used with Tool Search Tool for on-demand loading.
18
+ * @default false
19
+ */
20
+ deferLoading?: boolean;
21
+ }
22
+ /**
23
+ * Per-tool configuration overrides.
24
+ * Keys are tool names, values are configuration objects.
25
+ */
26
+ type MCPToolConfigs = Record<string, MCPToolConfig>;
27
+ /**
28
+ * Options for creating an MCP toolset.
29
+ */
30
+ interface MCPToolsetOptions {
31
+ /**
32
+ * Must match a server name defined in the `mcp_servers` array in call options.
33
+ */
34
+ serverName: string;
35
+ /**
36
+ * Default configuration applied to all tools in this toolset.
37
+ * Individual tool configs will override these defaults.
38
+ */
39
+ defaultConfig?: MCPToolConfig;
40
+ /**
41
+ * Per-tool configuration overrides.
42
+ * Keys are tool names, values are configuration objects.
43
+ */
44
+ configs?: MCPToolConfigs;
45
+ /**
46
+ * Create a cache control breakpoint at this content block.
47
+ */
48
+ cacheControl?: Anthropic.Beta.BetaCacheControlEphemeral;
49
+ }
50
+ /**
51
+ * Creates an MCP toolset that connects to a remote MCP server to access its tools.
52
+ * This enables Claude to use tools from MCP servers without implementing a separate MCP client.
53
+ *
54
+ * @note This tool requires the beta header `mcp-client-2025-11-20` in API requests.
55
+ * The header is automatically added when using this tool.
56
+ *
57
+ * @see {@link https://docs.anthropic.com/en/docs/agents-and-tools/mcp-connector | Anthropic MCP Connector Documentation}
58
+ * @param options - Configuration options for the MCP toolset
59
+ * @returns An MCP toolset definition to be passed to the Anthropic API tools array
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * import { ChatAnthropic, tools } from "@langchain/anthropic";
64
+ *
65
+ * const model = new ChatAnthropic({
66
+ * model: "claude-sonnet-4-5-20250929",
67
+ * });
68
+ *
69
+ * // Basic usage - enable all tools from an MCP server
70
+ * const response = await model.invoke("What tools do you have available?", {
71
+ * mcp_servers: [{
72
+ * type: "url",
73
+ * url: "https://example-server.modelcontextprotocol.io/sse",
74
+ * name: "example-mcp",
75
+ * authorization_token: "YOUR_TOKEN",
76
+ * }],
77
+ * tools: [
78
+ * tools.mcpToolset_20251120({ serverName: "example-mcp" }),
79
+ * ],
80
+ * });
81
+ *
82
+ * // Allowlist pattern - enable only specific tools
83
+ * const responseAllowlist = await model.invoke("Search for events", {
84
+ * mcp_servers: [{
85
+ * type: "url",
86
+ * url: "https://calendar.example.com/sse",
87
+ * name: "google-calendar-mcp",
88
+ * authorization_token: "YOUR_TOKEN",
89
+ * }],
90
+ * tools: [
91
+ * tools.mcpToolset_20251120({
92
+ * serverName: "google-calendar-mcp",
93
+ * defaultConfig: { enabled: false },
94
+ * configs: {
95
+ * search_events: { enabled: true },
96
+ * create_event: { enabled: true },
97
+ * },
98
+ * }),
99
+ * ],
100
+ * });
101
+ *
102
+ * // Denylist pattern - disable specific tools
103
+ * const responseDenylist = await model.invoke("List my events", {
104
+ * mcp_servers: [{
105
+ * type: "url",
106
+ * url: "https://calendar.example.com/sse",
107
+ * name: "google-calendar-mcp",
108
+ * authorization_token: "YOUR_TOKEN",
109
+ * }],
110
+ * tools: [
111
+ * tools.mcpToolset_20251120({
112
+ * serverName: "google-calendar-mcp",
113
+ * configs: {
114
+ * delete_all_events: { enabled: false },
115
+ * share_calendar_publicly: { enabled: false },
116
+ * },
117
+ * }),
118
+ * ],
119
+ * });
120
+ *
121
+ * // With deferred loading for use with Tool Search Tool
122
+ * const responseDeferred = await model.invoke("Search for tools", {
123
+ * mcp_servers: [{
124
+ * type: "url",
125
+ * url: "https://example.com/sse",
126
+ * name: "example-mcp",
127
+ * }],
128
+ * tools: [
129
+ * tools.toolSearchRegex_20251119(),
130
+ * tools.mcpToolset_20251120({
131
+ * serverName: "example-mcp",
132
+ * defaultConfig: { deferLoading: true },
133
+ * }),
134
+ * ],
135
+ * });
136
+ * ```
137
+ */
138
+ declare function mcpToolset_20251120(options: MCPToolsetOptions): ServerTool;
139
+ //#endregion
140
+ export { MCPToolsetOptions, mcpToolset_20251120 };
141
+ //# sourceMappingURL=mcpToolset.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcpToolset.d.ts","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"}
@@ -0,0 +1,110 @@
1
+ //#region src/tools/mcpToolset.ts
2
+ /**
3
+ * Creates an MCP toolset that connects to a remote MCP server to access its tools.
4
+ * This enables Claude to use tools from MCP servers without implementing a separate MCP client.
5
+ *
6
+ * @note This tool requires the beta header `mcp-client-2025-11-20` in API requests.
7
+ * The header is automatically added when using this tool.
8
+ *
9
+ * @see {@link https://docs.anthropic.com/en/docs/agents-and-tools/mcp-connector | Anthropic MCP Connector Documentation}
10
+ * @param options - Configuration options for the MCP toolset
11
+ * @returns An MCP toolset definition to be passed to the Anthropic API tools array
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * import { ChatAnthropic, tools } from "@langchain/anthropic";
16
+ *
17
+ * const model = new ChatAnthropic({
18
+ * model: "claude-sonnet-4-5-20250929",
19
+ * });
20
+ *
21
+ * // Basic usage - enable all tools from an MCP server
22
+ * const response = await model.invoke("What tools do you have available?", {
23
+ * mcp_servers: [{
24
+ * type: "url",
25
+ * url: "https://example-server.modelcontextprotocol.io/sse",
26
+ * name: "example-mcp",
27
+ * authorization_token: "YOUR_TOKEN",
28
+ * }],
29
+ * tools: [
30
+ * tools.mcpToolset_20251120({ serverName: "example-mcp" }),
31
+ * ],
32
+ * });
33
+ *
34
+ * // Allowlist pattern - enable only specific tools
35
+ * const responseAllowlist = await model.invoke("Search for events", {
36
+ * mcp_servers: [{
37
+ * type: "url",
38
+ * url: "https://calendar.example.com/sse",
39
+ * name: "google-calendar-mcp",
40
+ * authorization_token: "YOUR_TOKEN",
41
+ * }],
42
+ * tools: [
43
+ * tools.mcpToolset_20251120({
44
+ * serverName: "google-calendar-mcp",
45
+ * defaultConfig: { enabled: false },
46
+ * configs: {
47
+ * search_events: { enabled: true },
48
+ * create_event: { enabled: true },
49
+ * },
50
+ * }),
51
+ * ],
52
+ * });
53
+ *
54
+ * // Denylist pattern - disable specific tools
55
+ * const responseDenylist = await model.invoke("List my events", {
56
+ * mcp_servers: [{
57
+ * type: "url",
58
+ * url: "https://calendar.example.com/sse",
59
+ * name: "google-calendar-mcp",
60
+ * authorization_token: "YOUR_TOKEN",
61
+ * }],
62
+ * tools: [
63
+ * tools.mcpToolset_20251120({
64
+ * serverName: "google-calendar-mcp",
65
+ * configs: {
66
+ * delete_all_events: { enabled: false },
67
+ * share_calendar_publicly: { enabled: false },
68
+ * },
69
+ * }),
70
+ * ],
71
+ * });
72
+ *
73
+ * // With deferred loading for use with Tool Search Tool
74
+ * const responseDeferred = await model.invoke("Search for tools", {
75
+ * mcp_servers: [{
76
+ * type: "url",
77
+ * url: "https://example.com/sse",
78
+ * name: "example-mcp",
79
+ * }],
80
+ * tools: [
81
+ * tools.toolSearchRegex_20251119(),
82
+ * tools.mcpToolset_20251120({
83
+ * serverName: "example-mcp",
84
+ * defaultConfig: { deferLoading: true },
85
+ * }),
86
+ * ],
87
+ * });
88
+ * ```
89
+ */
90
+ function mcpToolset_20251120(options) {
91
+ const defaultConfig = options.defaultConfig?.enabled !== void 0 || options.defaultConfig?.deferLoading !== void 0 ? {
92
+ enabled: options.defaultConfig?.enabled,
93
+ defer_loading: options.defaultConfig?.deferLoading
94
+ } : void 0;
95
+ const configs = options.configs ? Object.fromEntries(Object.entries(options.configs).map(([toolName, config]) => [toolName, {
96
+ enabled: config.enabled,
97
+ defer_loading: config.deferLoading
98
+ }])) : void 0;
99
+ return {
100
+ type: "mcp_toolset",
101
+ mcp_server_name: options.serverName,
102
+ default_config: defaultConfig,
103
+ configs,
104
+ cache_control: options.cacheControl
105
+ };
106
+ }
107
+
108
+ //#endregion
109
+ export { mcpToolset_20251120 };
110
+ //# sourceMappingURL=mcpToolset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcpToolset.js","names":["options: MCPToolsetOptions"],"sources":["../../src/tools/mcpToolset.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { type ServerTool } from \"@langchain/core/tools\";\n\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/**\n * Per-tool configuration overrides.\n * Keys are tool names, values are configuration objects.\n */\nexport type MCPToolConfigs = Record<string, MCPToolConfig>;\n\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/**\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 function mcpToolset_20251120(options: MCPToolsetOptions): ServerTool {\n const defaultConfig =\n options.defaultConfig?.enabled !== undefined ||\n options.defaultConfig?.deferLoading !== undefined\n ? {\n enabled: options.defaultConfig?.enabled,\n defer_loading: options.defaultConfig?.deferLoading,\n }\n : undefined;\n\n const configs = options.configs\n ? Object.fromEntries(\n Object.entries(options.configs).map(([toolName, config]) => [\n toolName,\n {\n enabled: config.enabled,\n defer_loading: config.deferLoading,\n },\n ])\n )\n : undefined;\n\n return {\n type: \"mcp_toolset\",\n mcp_server_name: options.serverName,\n default_config: defaultConfig,\n configs,\n cache_control: options.cacheControl,\n } satisfies Anthropic.Beta.BetaMCPToolset;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0IA,SAAgB,oBAAoBA,SAAwC;CAC1E,MAAM,gBACJ,QAAQ,eAAe,YAAY,UACnC,QAAQ,eAAe,iBAAiB,SACpC;EACE,SAAS,QAAQ,eAAe;EAChC,eAAe,QAAQ,eAAe;CACvC,IACD;CAEN,MAAM,UAAU,QAAQ,UACpB,OAAO,YACL,OAAO,QAAQ,QAAQ,QAAQ,CAAC,IAAI,CAAC,CAAC,UAAU,OAAO,KAAK,CAC1D,UACA;EACE,SAAS,OAAO;EAChB,eAAe,OAAO;CACvB,CACF,EAAC,CACH,GACD;AAEJ,QAAO;EACL,MAAM;EACN,iBAAiB,QAAQ;EACzB,gBAAgB;EAChB;EACA,eAAe,QAAQ;CACxB;AACF"}
@@ -0,0 +1,56 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_types = require('./types.cjs');
3
+ const __langchain_core_tools = require_rolldown_runtime.__toESM(require("@langchain/core/tools"));
4
+
5
+ //#region src/tools/memory.ts
6
+ /**
7
+ * Creates an Anthropic memory tool that can be used with ChatAnthropic.
8
+ *
9
+ * The memory tool enables Claude to store and retrieve information across conversations
10
+ * through a memory file directory. Claude can create, read, update, and delete files that
11
+ * persist between sessions, allowing it to build knowledge over time without keeping
12
+ * everything in the context window.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * import { ChatAnthropic, memory_20250818 } from "@langchain/anthropic";
17
+ *
18
+ * const llm = new ChatAnthropic({
19
+ * model: "claude-sonnet-4-5-20250929"
20
+ * });
21
+ *
22
+ * const memory = memory_20250818({
23
+ * execute: async (args) => {
24
+ * // handle memory command execution
25
+ * // ...
26
+ * },
27
+ * });
28
+ * const llmWithMemory = llm.bindTools([memory]);
29
+ *
30
+ * const response = await llmWithMemory.invoke("Remember that I like Python");
31
+ * ```
32
+ *
33
+ * @param options - Optional configuration for the memory tool (currently unused)
34
+ * @param options.execute - Optional execute function that handles memory command execution.
35
+ * @returns The memory tool object that can be passed to `bindTools`
36
+ *
37
+ * @see https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/memory-tool
38
+ */
39
+ function memory_20250818(options) {
40
+ const memoryTool = (0, __langchain_core_tools.tool)(options?.execute, {
41
+ name: "memory",
42
+ schema: require_types.Memory20250818CommandSchema
43
+ });
44
+ memoryTool.extras = {
45
+ ...memoryTool.extras ?? {},
46
+ providerToolDefinition: {
47
+ type: "memory_20250818",
48
+ name: "memory"
49
+ }
50
+ };
51
+ return memoryTool;
52
+ }
53
+
54
+ //#endregion
55
+ exports.memory_20250818 = memory_20250818;
56
+ //# sourceMappingURL=memory.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.cjs","names":["options?: MemoryTool20250818Options","Memory20250818CommandSchema"],"sources":["../../src/tools/memory.ts"],"sourcesContent":["import Anthropic from \"@anthropic-ai/sdk\";\nimport { tool } from \"@langchain/core/tools\";\nimport type { DynamicStructuredTool, ToolRuntime } from \"@langchain/core/tools\";\n\nimport {\n Memory20250818CommandSchema,\n type MemoryTool20250818Options,\n type Memory20250818Command,\n} from \"./types.js\";\n\n/**\n * Creates an Anthropic memory tool that can be used with ChatAnthropic.\n *\n * The memory tool enables Claude to store and retrieve information across conversations\n * through a memory file directory. Claude can create, read, update, and delete files that\n * persist between sessions, allowing it to build knowledge over time without keeping\n * everything in the context window.\n *\n * @example\n * ```typescript\n * import { ChatAnthropic, memory_20250818 } from \"@langchain/anthropic\";\n *\n * const llm = new ChatAnthropic({\n * model: \"claude-sonnet-4-5-20250929\"\n * });\n *\n * const memory = memory_20250818({\n * execute: async (args) => {\n * // handle memory command execution\n * // ...\n * },\n * });\n * const llmWithMemory = llm.bindTools([memory]);\n *\n * const response = await llmWithMemory.invoke(\"Remember that I like Python\");\n * ```\n *\n * @param options - Optional configuration for the memory tool (currently unused)\n * @param options.execute - Optional execute function that handles memory command execution.\n * @returns The memory tool object that can be passed to `bindTools`\n *\n * @see https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/memory-tool\n */\nexport function memory_20250818(options?: MemoryTool20250818Options) {\n const memoryTool = tool(\n options?.execute as (\n input: unknown,\n runtime: ToolRuntime<unknown, unknown>\n ) => string | Promise<string>,\n {\n name: \"memory\",\n schema: Memory20250818CommandSchema,\n }\n );\n\n memoryTool.extras = {\n ...(memoryTool.extras ?? {}),\n providerToolDefinition: {\n type: \"memory_20250818\",\n name: \"memory\",\n } satisfies Anthropic.Beta.BetaMemoryTool20250818,\n };\n\n return memoryTool as DynamicStructuredTool<\n typeof Memory20250818CommandSchema,\n Memory20250818Command,\n unknown,\n string | Promise<string>\n >;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,SAAgB,gBAAgBA,SAAqC;CACnE,MAAM,8CACJ,SAAS,SAIT;EACE,MAAM;EACN,QAAQC;CACT,EACF;CAED,WAAW,SAAS;EAClB,GAAI,WAAW,UAAU,CAAE;EAC3B,wBAAwB;GACtB,MAAM;GACN,MAAM;EACP;CACF;AAED,QAAO;AAMR"}