@langchain/openai 1.1.2 → 1.2.0-dev-1765431816670

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 (207) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +583 -2
  3. package/dist/azure/chat_models/common.d.cts.map +1 -1
  4. package/dist/azure/chat_models/common.d.ts +1 -0
  5. package/dist/azure/chat_models/common.d.ts.map +1 -1
  6. package/dist/azure/chat_models/completions.d.cts.map +1 -1
  7. package/dist/azure/chat_models/completions.d.ts.map +1 -1
  8. package/dist/azure/chat_models/index.d.cts +1 -1
  9. package/dist/azure/chat_models/index.d.cts.map +1 -1
  10. package/dist/azure/chat_models/index.d.ts.map +1 -1
  11. package/dist/azure/chat_models/responses.d.cts.map +1 -1
  12. package/dist/azure/chat_models/responses.d.ts.map +1 -1
  13. package/dist/azure/embeddings.d.cts.map +1 -1
  14. package/dist/azure/embeddings.d.ts.map +1 -1
  15. package/dist/azure/llms.d.cts +0 -1
  16. package/dist/azure/llms.d.cts.map +1 -1
  17. package/dist/azure/llms.d.ts +0 -1
  18. package/dist/azure/llms.d.ts.map +1 -1
  19. package/dist/chat_models/base.cjs +5 -1
  20. package/dist/chat_models/base.cjs.map +1 -1
  21. package/dist/chat_models/base.d.cts +8 -22
  22. package/dist/chat_models/base.d.cts.map +1 -1
  23. package/dist/chat_models/base.d.ts +6 -20
  24. package/dist/chat_models/base.d.ts.map +1 -1
  25. package/dist/chat_models/base.js +6 -2
  26. package/dist/chat_models/base.js.map +1 -1
  27. package/dist/chat_models/completions.cjs.map +1 -1
  28. package/dist/chat_models/completions.d.cts +1 -3
  29. package/dist/chat_models/completions.d.cts.map +1 -1
  30. package/dist/chat_models/completions.d.ts +1 -3
  31. package/dist/chat_models/completions.d.ts.map +1 -1
  32. package/dist/chat_models/completions.js.map +1 -1
  33. package/dist/chat_models/index.d.cts +42 -4
  34. package/dist/chat_models/index.d.cts.map +1 -1
  35. package/dist/chat_models/index.d.ts +42 -4
  36. package/dist/chat_models/index.d.ts.map +1 -1
  37. package/dist/chat_models/responses.d.cts +2 -2
  38. package/dist/chat_models/responses.d.cts.map +1 -1
  39. package/dist/chat_models/responses.d.ts +2 -2
  40. package/dist/chat_models/responses.d.ts.map +1 -1
  41. package/dist/converters/completions.cjs +22 -12
  42. package/dist/converters/completions.cjs.map +1 -1
  43. package/dist/converters/completions.d.cts +0 -1
  44. package/dist/converters/completions.d.cts.map +1 -1
  45. package/dist/converters/completions.d.ts +0 -1
  46. package/dist/converters/completions.d.ts.map +1 -1
  47. package/dist/converters/completions.js +23 -13
  48. package/dist/converters/completions.js.map +1 -1
  49. package/dist/converters/index.d.ts +2 -0
  50. package/dist/converters/responses.cjs +37 -4
  51. package/dist/converters/responses.cjs.map +1 -1
  52. package/dist/converters/responses.d.cts.map +1 -1
  53. package/dist/converters/responses.d.ts.map +1 -1
  54. package/dist/converters/responses.js +39 -6
  55. package/dist/converters/responses.js.map +1 -1
  56. package/dist/embeddings.d.cts +0 -1
  57. package/dist/embeddings.d.cts.map +1 -1
  58. package/dist/embeddings.d.ts +0 -1
  59. package/dist/embeddings.d.ts.map +1 -1
  60. package/dist/index.cjs +2 -1
  61. package/dist/index.d.cts +12 -2
  62. package/dist/index.d.ts +13 -2
  63. package/dist/index.js +2 -2
  64. package/dist/llms.d.cts +0 -1
  65. package/dist/llms.d.cts.map +1 -1
  66. package/dist/llms.d.ts +0 -1
  67. package/dist/llms.d.ts.map +1 -1
  68. package/dist/tools/applyPatch.cjs +116 -0
  69. package/dist/tools/applyPatch.cjs.map +1 -0
  70. package/dist/tools/applyPatch.d.cts +148 -0
  71. package/dist/tools/applyPatch.d.cts.map +1 -0
  72. package/dist/tools/applyPatch.d.ts +148 -0
  73. package/dist/tools/applyPatch.d.ts.map +1 -0
  74. package/dist/tools/applyPatch.js +115 -0
  75. package/dist/tools/applyPatch.js.map +1 -0
  76. package/dist/tools/codeInterpreter.cjs +95 -0
  77. package/dist/tools/codeInterpreter.cjs.map +1 -0
  78. package/dist/tools/codeInterpreter.d.cts +125 -0
  79. package/dist/tools/codeInterpreter.d.cts.map +1 -0
  80. package/dist/tools/codeInterpreter.d.ts +125 -0
  81. package/dist/tools/codeInterpreter.d.ts.map +1 -0
  82. package/dist/tools/codeInterpreter.js +94 -0
  83. package/dist/tools/codeInterpreter.js.map +1 -0
  84. package/dist/tools/computerUse.cjs +240 -0
  85. package/dist/tools/computerUse.cjs.map +1 -0
  86. package/dist/tools/computerUse.d.cts +234 -0
  87. package/dist/tools/computerUse.d.cts.map +1 -0
  88. package/dist/tools/computerUse.d.ts +234 -0
  89. package/dist/tools/computerUse.d.ts.map +1 -0
  90. package/dist/tools/computerUse.js +239 -0
  91. package/dist/tools/computerUse.js.map +1 -0
  92. package/dist/tools/custom.d.cts +1 -1
  93. package/dist/tools/custom.d.cts.map +1 -1
  94. package/dist/tools/custom.d.ts.map +1 -1
  95. package/dist/tools/dalle.d.cts +1 -2
  96. package/dist/tools/dalle.d.cts.map +1 -1
  97. package/dist/tools/dalle.d.ts +1 -2
  98. package/dist/tools/dalle.d.ts.map +1 -1
  99. package/dist/tools/fileSearch.cjs +137 -0
  100. package/dist/tools/fileSearch.cjs.map +1 -0
  101. package/dist/tools/fileSearch.d.cts +224 -0
  102. package/dist/tools/fileSearch.d.cts.map +1 -0
  103. package/dist/tools/fileSearch.d.ts +224 -0
  104. package/dist/tools/fileSearch.d.ts.map +1 -0
  105. package/dist/tools/fileSearch.js +136 -0
  106. package/dist/tools/fileSearch.js.map +1 -0
  107. package/dist/tools/imageGeneration.cjs +128 -0
  108. package/dist/tools/imageGeneration.cjs.map +1 -0
  109. package/dist/tools/imageGeneration.d.cts +199 -0
  110. package/dist/tools/imageGeneration.d.cts.map +1 -0
  111. package/dist/tools/imageGeneration.d.ts +199 -0
  112. package/dist/tools/imageGeneration.d.ts.map +1 -0
  113. package/dist/tools/imageGeneration.js +127 -0
  114. package/dist/tools/imageGeneration.js.map +1 -0
  115. package/dist/tools/index.cjs +26 -0
  116. package/dist/tools/index.cjs.map +1 -0
  117. package/dist/tools/index.d.cts +27 -0
  118. package/dist/tools/index.d.cts.map +1 -0
  119. package/dist/tools/index.d.ts +27 -0
  120. package/dist/tools/index.d.ts.map +1 -0
  121. package/dist/tools/index.js +26 -0
  122. package/dist/tools/index.js.map +1 -0
  123. package/dist/tools/localShell.cjs +145 -0
  124. package/dist/tools/localShell.cjs.map +1 -0
  125. package/dist/tools/localShell.d.cts +167 -0
  126. package/dist/tools/localShell.d.cts.map +1 -0
  127. package/dist/tools/localShell.d.ts +167 -0
  128. package/dist/tools/localShell.d.ts.map +1 -0
  129. package/dist/tools/localShell.js +144 -0
  130. package/dist/tools/localShell.js.map +1 -0
  131. package/dist/tools/mcp.cjs +53 -0
  132. package/dist/tools/mcp.cjs.map +1 -0
  133. package/dist/tools/mcp.d.cts +177 -0
  134. package/dist/tools/mcp.d.cts.map +1 -0
  135. package/dist/tools/mcp.d.ts +177 -0
  136. package/dist/tools/mcp.d.ts.map +1 -0
  137. package/dist/tools/mcp.js +52 -0
  138. package/dist/tools/mcp.js.map +1 -0
  139. package/dist/tools/shell.cjs +163 -0
  140. package/dist/tools/shell.cjs.map +1 -0
  141. package/dist/tools/shell.d.cts +221 -0
  142. package/dist/tools/shell.d.cts.map +1 -0
  143. package/dist/tools/shell.d.ts +221 -0
  144. package/dist/tools/shell.d.ts.map +1 -0
  145. package/dist/tools/shell.js +162 -0
  146. package/dist/tools/shell.js.map +1 -0
  147. package/dist/tools/webSearch.cjs +73 -0
  148. package/dist/tools/webSearch.cjs.map +1 -0
  149. package/dist/tools/webSearch.d.cts +130 -0
  150. package/dist/tools/webSearch.d.cts.map +1 -0
  151. package/dist/tools/webSearch.d.ts +130 -0
  152. package/dist/tools/webSearch.d.ts.map +1 -0
  153. package/dist/tools/webSearch.js +72 -0
  154. package/dist/tools/webSearch.js.map +1 -0
  155. package/dist/types.d.cts +2 -4
  156. package/dist/types.d.cts.map +1 -1
  157. package/dist/types.d.ts +1 -3
  158. package/dist/types.d.ts.map +1 -1
  159. package/dist/utils/azure.d.cts +1 -5
  160. package/dist/utils/azure.d.cts.map +1 -1
  161. package/dist/utils/azure.d.ts +1 -5
  162. package/dist/utils/azure.d.ts.map +1 -1
  163. package/dist/utils/client.d.cts.map +1 -1
  164. package/dist/utils/client.d.ts.map +1 -1
  165. package/dist/utils/misc.cjs +6 -0
  166. package/dist/utils/misc.cjs.map +1 -1
  167. package/dist/utils/misc.d.cts +1 -1
  168. package/dist/utils/misc.d.cts.map +1 -1
  169. package/dist/utils/misc.d.ts +1 -1
  170. package/dist/utils/misc.d.ts.map +1 -1
  171. package/dist/utils/misc.js +6 -1
  172. package/dist/utils/misc.js.map +1 -1
  173. package/dist/utils/prompts.d.cts +0 -1
  174. package/dist/utils/prompts.d.cts.map +1 -1
  175. package/dist/utils/prompts.d.ts +0 -1
  176. package/dist/utils/prompts.d.ts.map +1 -1
  177. package/dist/utils/tools.cjs +39 -1
  178. package/dist/utils/tools.cjs.map +1 -1
  179. package/dist/utils/tools.d.cts.map +1 -1
  180. package/dist/utils/tools.d.ts.map +1 -1
  181. package/dist/utils/tools.js +37 -2
  182. package/dist/utils/tools.js.map +1 -1
  183. package/package.json +18 -15
  184. package/dist/langchain-core/dist/callbacks/base.d.ts +0 -1
  185. package/dist/langchain-core/dist/callbacks/manager.d.ts +0 -2
  186. package/dist/langchain-core/dist/language_models/base.d.ts +0 -5
  187. package/dist/langchain-core/dist/language_models/chat_models.d.cts +0 -13
  188. package/dist/langchain-core/dist/language_models/chat_models.d.cts.map +0 -1
  189. package/dist/langchain-core/dist/language_models/chat_models.d.ts +0 -20
  190. package/dist/langchain-core/dist/language_models/chat_models.d.ts.map +0 -1
  191. package/dist/langchain-core/dist/runnables/base.d.ts +0 -7
  192. package/dist/langchain-core/dist/runnables/graph.d.ts +0 -1
  193. package/dist/langchain-core/dist/runnables/types.d.ts +0 -2
  194. package/dist/langchain-core/dist/tools/types.d.ts +0 -5
  195. package/dist/langchain-core/dist/tracers/base.d.ts +0 -2
  196. package/dist/langchain-core/dist/tracers/event_stream.d.ts +0 -1
  197. package/dist/langchain-core/dist/tracers/log_stream.d.ts +0 -3
  198. package/dist/langchain-core/dist/types/_internal.d.cts +0 -11
  199. package/dist/langchain-core/dist/types/_internal.d.cts.map +0 -1
  200. package/dist/langchain-core/dist/types/_internal.d.ts +0 -11
  201. package/dist/langchain-core/dist/types/_internal.d.ts.map +0 -1
  202. package/dist/langchain-core/dist/utils/stream.d.cts +0 -26
  203. package/dist/langchain-core/dist/utils/stream.d.cts.map +0 -1
  204. package/dist/langchain-core/dist/utils/stream.d.ts +0 -26
  205. package/dist/langchain-core/dist/utils/stream.d.ts.map +0 -1
  206. package/dist/langchain-core/dist/utils/types/index.d.ts +0 -1
  207. package/dist/langchain-core/dist/utils/types/zod.d.ts +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localShell.js","names":["options: LocalShellOptions"],"sources":["../../src/tools/localShell.ts"],"sourcesContent":["import { z } from \"zod/v4\";\nimport { OpenAI as OpenAIClient } from \"openai\";\nimport { tool, type DynamicStructuredTool } from \"@langchain/core/tools\";\n\n/**\n * Re-export action type from OpenAI SDK for convenience.\n * The action contains command details like argv tokens, environment variables,\n * working directory, timeout, and user.\n */\nexport type LocalShellAction =\n OpenAIClient.Responses.ResponseOutputItem.LocalShellCall.Action;\n\n// Zod schema for local shell exec action\nexport const LocalShellExecActionSchema = z.object({\n type: z.literal(\"exec\"),\n command: z.array(z.string()),\n env: z.record(z.string(), z.string()).optional(),\n working_directory: z.string().optional(),\n timeout_ms: z.number().optional(),\n user: z.string().optional(),\n});\n\n// Schema for all local shell actions (currently only exec)\nexport const LocalShellActionSchema = z.discriminatedUnion(\"type\", [\n LocalShellExecActionSchema,\n]);\n\n/**\n * Options for the Local Shell tool.\n */\nexport interface LocalShellOptions {\n /**\n * Optional execute function that handles shell command execution.\n * This function receives the action input and should return the command output\n * (stdout + stderr combined).\n *\n * If not provided, you'll need to handle action execution manually by\n * checking `local_shell_call` outputs in the response.\n *\n * @example\n * ```typescript\n * execute: async (action) => {\n * const result = await exec(action.command.join(' '), {\n * cwd: action.working_directory,\n * env: { ...process.env, ...action.env },\n * timeout: action.timeout_ms,\n * });\n * return result.stdout + result.stderr;\n * }\n * ```\n */\n execute: (action: LocalShellAction) => string | Promise<string>;\n}\n\n/**\n * OpenAI Local Shell tool type for the Responses API.\n */\nexport type LocalShellTool = OpenAIClient.Responses.Tool.LocalShell;\n\nconst TOOL_NAME = \"local_shell\";\n\n/**\n * Creates a Local Shell tool that allows models to run shell commands locally\n * on a machine you provide. Commands are executed inside your own runtime—\n * the API only returns the instructions, but does not execute them on OpenAI infrastructure.\n *\n * **Important**: The local shell tool is designed to work with\n * [Codex CLI](https://github.com/openai/codex) and the `codex-mini-latest` model.\n *\n * **How it works**:\n * The tool operates in a continuous loop:\n * 1. Model sends shell commands (`local_shell_call` with `exec` action)\n * 2. Your code executes the command locally\n * 3. You return the output back to the model\n * 4. Repeat until the task is complete\n *\n * **Security Warning**: Running arbitrary shell commands can be dangerous.\n * Always sandbox execution or add strict allow/deny-lists before forwarding\n * a command to the system shell.\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-local-shell | OpenAI Local Shell Documentation}\n *\n * @param options - Optional configuration for the Local Shell tool\n * @returns A Local Shell tool that can be passed to `bindTools`\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n * import { exec } from \"child_process\";\n * import { promisify } from \"util\";\n *\n * const execAsync = promisify(exec);\n * const model = new ChatOpenAI({ model: \"codex-mini-latest\" });\n *\n * // With execute callback for automatic command handling\n * const shell = tools.localShell({\n * execute: async (action) => {\n * const { command, env, working_directory, timeout_ms } = action;\n * const result = await execAsync(command.join(' '), {\n * cwd: working_directory ?? process.cwd(),\n * env: { ...process.env, ...env },\n * timeout: timeout_ms ?? undefined,\n * });\n * return result.stdout + result.stderr;\n * },\n * });\n *\n * const llmWithShell = model.bindTools([shell]);\n * const response = await llmWithShell.invoke(\n * \"List files in the current directory\"\n * );\n * ```\n *\n * @example\n * ```typescript\n * // Without execute callback (manual handling)\n * const shell = tools.localShell();\n *\n * const response = await model.invoke(\"List files\", {\n * tools: [shell],\n * });\n *\n * // Access the shell call from the response\n * const shellCall = response.additional_kwargs.tool_outputs?.find(\n * (output) => output.type === \"local_shell_call\"\n * );\n * if (shellCall) {\n * console.log(\"Command to execute:\", shellCall.action.command);\n * // Execute the command manually, then send back the output\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Full shell loop example\n * async function shellLoop(model, task) {\n * let response = await model.invoke(task, {\n * tools: [tools.localShell()],\n * });\n *\n * while (true) {\n * const shellCall = response.additional_kwargs.tool_outputs?.find(\n * (output) => output.type === \"local_shell_call\"\n * );\n *\n * if (!shellCall) break;\n *\n * // Execute command (with proper sandboxing!)\n * const output = await executeCommand(shellCall.action);\n *\n * // Send output back to model\n * response = await model.invoke([\n * response,\n * {\n * type: \"local_shell_call_output\",\n * id: shellCall.call_id,\n * output: output,\n * },\n * ], {\n * tools: [tools.localShell()],\n * });\n * }\n *\n * return response;\n * }\n * ```\n *\n * @remarks\n * - Only available through the Responses API (not Chat Completions)\n * - Designed for use with `codex-mini-latest` model\n * - Commands are provided as argv tokens in `action.command`\n * - Action includes: `command`, `env`, `working_directory`, `timeout_ms`, `user`\n * - Always sandbox or validate commands before execution\n * - The `timeout_ms` from the model is only a hint—enforce your own limits\n */\nexport function localShell(options: LocalShellOptions) {\n const shellTool = tool(options.execute, {\n name: TOOL_NAME,\n description:\n \"Execute shell commands locally on the machine. Commands are provided as argv tokens.\",\n schema: LocalShellActionSchema,\n });\n\n shellTool.extras = {\n ...(shellTool.extras ?? {}),\n providerToolDefinition: {\n type: \"local_shell\",\n } satisfies LocalShellTool,\n };\n\n return shellTool as DynamicStructuredTool<\n typeof LocalShellActionSchema,\n LocalShellAction,\n unknown,\n string\n >;\n}\n"],"mappings":";;;;AAaA,MAAa,6BAA6B,EAAE,OAAO;CACjD,MAAM,EAAE,QAAQ,OAAO;CACvB,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC;CAC5B,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,QAAQ,CAAC,CAAC,UAAU;CAChD,mBAAmB,EAAE,QAAQ,CAAC,UAAU;CACxC,YAAY,EAAE,QAAQ,CAAC,UAAU;CACjC,MAAM,EAAE,QAAQ,CAAC,UAAU;AAC5B,EAAC;AAGF,MAAa,yBAAyB,EAAE,mBAAmB,QAAQ,CACjE,0BACD,EAAC;AAkCF,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoHlB,SAAgB,WAAWA,SAA4B;CACrD,MAAM,YAAY,KAAK,QAAQ,SAAS;EACtC,MAAM;EACN,aACE;EACF,QAAQ;CACT,EAAC;CAEF,UAAU,SAAS;EACjB,GAAI,UAAU,UAAU,CAAE;EAC1B,wBAAwB,EACtB,MAAM,cACP;CACF;AAED,QAAO;AAMR"}
@@ -0,0 +1,53 @@
1
+
2
+ //#region src/tools/mcp.ts
3
+ /**
4
+ * Converts a McpToolFilter to the API format.
5
+ */
6
+ function convertToolFilter(filter) {
7
+ return {
8
+ tool_names: filter.toolNames,
9
+ read_only: filter.readOnly
10
+ };
11
+ }
12
+ /**
13
+ * Converts allowed_tools option to API format.
14
+ */
15
+ function convertAllowedTools(allowedTools) {
16
+ if (!allowedTools) return void 0;
17
+ if (Array.isArray(allowedTools)) return allowedTools;
18
+ return convertToolFilter(allowedTools);
19
+ }
20
+ /**
21
+ * Converts require_approval option to API format.
22
+ */
23
+ function convertRequireApproval(requireApproval) {
24
+ if (!requireApproval) return void 0;
25
+ if (typeof requireApproval === "string") return requireApproval;
26
+ return {
27
+ always: requireApproval.always ? convertToolFilter(requireApproval.always) : void 0,
28
+ never: requireApproval.never ? convertToolFilter(requireApproval.never) : void 0
29
+ };
30
+ }
31
+ function mcp(options) {
32
+ const baseConfig = {
33
+ type: "mcp",
34
+ server_label: options.serverLabel,
35
+ allowed_tools: convertAllowedTools(options.allowedTools),
36
+ authorization: options.authorization,
37
+ headers: options.headers,
38
+ require_approval: convertRequireApproval(options.requireApproval),
39
+ server_description: options.serverDescription
40
+ };
41
+ if ("serverUrl" in options) return {
42
+ ...baseConfig,
43
+ server_url: options.serverUrl
44
+ };
45
+ return {
46
+ ...baseConfig,
47
+ connector_id: options.connectorId
48
+ };
49
+ }
50
+
51
+ //#endregion
52
+ exports.mcp = mcp;
53
+ //# sourceMappingURL=mcp.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp.cjs","names":["filter: McpToolFilter","allowedTools: string[] | McpToolFilter | undefined","requireApproval: \"always\" | \"never\" | McpApprovalFilter | undefined","options: McpRemoteServerOptions | McpConnectorOptions","baseConfig: McpTool"],"sources":["../../src/tools/mcp.ts"],"sourcesContent":["import { OpenAI as OpenAIClient } from \"openai\";\nimport type { ServerTool } from \"@langchain/core/tools\";\n\n/**\n * Available connector IDs for OpenAI's built-in service connectors.\n * These are OpenAI-maintained MCP wrappers for popular services.\n */\nexport type McpConnectorId =\n | \"connector_dropbox\"\n | \"connector_gmail\"\n | \"connector_googlecalendar\"\n | \"connector_googledrive\"\n | \"connector_microsoftteams\"\n | \"connector_outlookcalendar\"\n | \"connector_outlookemail\"\n | \"connector_sharepoint\";\n\n/**\n * Filter object to specify which tools are allowed.\n */\nexport interface McpToolFilter {\n /**\n * List of allowed tool names.\n */\n toolNames?: string[];\n /**\n * Indicates whether or not a tool modifies data or is read-only.\n * If an MCP server is annotated with `readOnlyHint`, it will match this filter.\n */\n readOnly?: boolean;\n}\n\n/**\n * Filter object for approval requirements.\n */\nexport interface McpApprovalFilter {\n /**\n * Tools that always require approval before execution.\n */\n always?: McpToolFilter;\n /**\n * Tools that never require approval.\n */\n never?: McpToolFilter;\n}\n\n/**\n * Base options shared between remote MCP servers and connectors.\n */\ninterface McpBaseOptions {\n /**\n * A label for this MCP server, used to identify it in tool calls.\n */\n serverLabel: string;\n /**\n * List of allowed tool names or a filter object.\n * Use this to limit which tools from the MCP server are available to the model.\n */\n allowedTools?: string[] | McpToolFilter;\n /**\n * An OAuth access token for authentication with the MCP server.\n * Your application must handle the OAuth authorization flow and provide the token here.\n */\n authorization?: string;\n /**\n * Optional HTTP headers to send to the MCP server.\n * Use for authentication or other purposes.\n */\n headers?: Record<string, string>;\n /**\n * Specify which of the MCP server's tools require approval before execution.\n * - `\"always\"`: All tools require approval\n * - `\"never\"`: No tools require approval\n * - `McpApprovalFilter`: Fine-grained control over which tools require approval\n *\n * @default \"always\" (approval required for all tools)\n */\n requireApproval?: \"always\" | \"never\" | McpApprovalFilter;\n /**\n * Optional description of the MCP server, used to provide more context to the model.\n */\n serverDescription?: string;\n}\n\n/**\n * Options for connecting to a remote MCP server via URL.\n */\nexport interface McpRemoteServerOptions extends McpBaseOptions {\n /**\n * The URL for the MCP server.\n * The server must implement the Streamable HTTP or HTTP/SSE transport protocol.\n */\n serverUrl: string;\n}\n\n/**\n * Options for connecting to an OpenAI-maintained service connector.\n */\nexport interface McpConnectorOptions extends McpBaseOptions {\n /**\n * Identifier for the service connector.\n * These are OpenAI-maintained MCP wrappers for popular services.\n *\n * Available connectors:\n * - `connector_dropbox`: Dropbox file access\n * - `connector_gmail`: Gmail email access\n * - `connector_googlecalendar`: Google Calendar access\n * - `connector_googledrive`: Google Drive file access\n * - `connector_microsoftteams`: Microsoft Teams access\n * - `connector_outlookcalendar`: Outlook Calendar access\n * - `connector_outlookemail`: Outlook Email access\n * - `connector_sharepoint`: SharePoint file access\n */\n connectorId: McpConnectorId;\n}\n\n/**\n * OpenAI MCP tool type for the Responses API.\n */\nexport type McpTool = OpenAIClient.Responses.Tool.Mcp;\n\n/**\n * Converts a McpToolFilter to the API format.\n */\nfunction convertToolFilter(\n filter: McpToolFilter\n): OpenAIClient.Responses.Tool.Mcp.McpToolFilter {\n return {\n tool_names: filter.toolNames,\n read_only: filter.readOnly,\n };\n}\n\n/**\n * Converts allowed_tools option to API format.\n */\nfunction convertAllowedTools(\n allowedTools: string[] | McpToolFilter | undefined\n): Array<string> | OpenAIClient.Responses.Tool.Mcp.McpToolFilter | undefined {\n if (!allowedTools) return undefined;\n if (Array.isArray(allowedTools)) return allowedTools;\n return convertToolFilter(allowedTools);\n}\n\n/**\n * Converts require_approval option to API format.\n */\nfunction convertRequireApproval(\n requireApproval: \"always\" | \"never\" | McpApprovalFilter | undefined\n):\n | OpenAIClient.Responses.Tool.Mcp.McpToolApprovalFilter\n | \"always\"\n | \"never\"\n | undefined {\n if (!requireApproval) return undefined;\n if (typeof requireApproval === \"string\") return requireApproval;\n return {\n always: requireApproval.always\n ? convertToolFilter(requireApproval.always)\n : undefined,\n never: requireApproval.never\n ? convertToolFilter(requireApproval.never)\n : undefined,\n };\n}\n\n/**\n * Creates an MCP tool that connects to a remote MCP server or OpenAI service connector.\n * This allows OpenAI models to access external tools and services via the Model Context Protocol.\n *\n * There are two ways to use MCP tools:\n * 1. **Remote MCP servers**: Connect to any server on the public Internet that implements\n * the MCP protocol using `serverUrl`.\n * 2. **Connectors**: Use OpenAI-maintained MCP wrappers for popular services like\n * Google Workspace or Dropbox using `connectorId`.\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-remote-mcp | OpenAI MCP Documentation}\n *\n * @param options - Configuration options for the MCP tool\n * @returns An MCP tool definition to be passed to the OpenAI Responses API\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n *\n * const model = new ChatOpenAI({ model: \"gpt-4o\" });\n *\n * // Using a remote MCP server\n * const response = await model.invoke(\"Roll 2d4+1\", {\n * tools: [tools.mcp({\n * serverLabel: \"dmcp\",\n * serverDescription: \"A D&D MCP server for dice rolling\",\n * serverUrl: \"https://dmcp-server.deno.dev/sse\",\n * requireApproval: \"never\",\n * })],\n * });\n *\n * // Using a connector (e.g., Google Calendar)\n * const calendarResponse = await model.invoke(\"What's on my calendar today?\", {\n * tools: [tools.mcp({\n * serverLabel: \"google_calendar\",\n * connectorId: \"connector_googlecalendar\",\n * authorization: \"<oauth-access-token>\",\n * requireApproval: \"never\",\n * })],\n * });\n *\n * // With tool filtering - only allow specific tools\n * const filteredResponse = await model.invoke(\"Roll some dice\", {\n * tools: [tools.mcp({\n * serverLabel: \"dmcp\",\n * serverUrl: \"https://dmcp-server.deno.dev/sse\",\n * allowedTools: [\"roll\"], // Only allow the \"roll\" tool\n * requireApproval: \"never\",\n * })],\n * });\n *\n * // With fine-grained approval control\n * const controlledResponse = await model.invoke(\"Search and modify files\", {\n * tools: [tools.mcp({\n * serverLabel: \"deepwiki\",\n * serverUrl: \"https://mcp.deepwiki.com/mcp\",\n * requireApproval: {\n * never: { toolNames: [\"ask_question\", \"read_wiki_structure\"] },\n * // All other tools will require approval\n * },\n * })],\n * });\n * ```\n */\nexport function mcp(options: McpRemoteServerOptions): ServerTool;\nexport function mcp(options: McpConnectorOptions): ServerTool;\nexport function mcp(\n options: McpRemoteServerOptions | McpConnectorOptions\n): ServerTool {\n const baseConfig: McpTool = {\n type: \"mcp\",\n server_label: options.serverLabel,\n allowed_tools: convertAllowedTools(options.allowedTools),\n authorization: options.authorization,\n headers: options.headers,\n require_approval: convertRequireApproval(options.requireApproval),\n server_description: options.serverDescription,\n };\n\n if (\"serverUrl\" in options) {\n return {\n ...baseConfig,\n server_url: options.serverUrl,\n } satisfies McpTool;\n }\n\n return {\n ...baseConfig,\n connector_id: options.connectorId,\n } satisfies McpTool;\n}\n"],"mappings":";;;;;AA4HA,SAAS,kBACPA,QAC+C;AAC/C,QAAO;EACL,YAAY,OAAO;EACnB,WAAW,OAAO;CACnB;AACF;;;;AAKD,SAAS,oBACPC,cAC2E;AAC3E,KAAI,CAAC,aAAc,QAAO;AAC1B,KAAI,MAAM,QAAQ,aAAa,CAAE,QAAO;AACxC,QAAO,kBAAkB,aAAa;AACvC;;;;AAKD,SAAS,uBACPC,iBAKY;AACZ,KAAI,CAAC,gBAAiB,QAAO;AAC7B,KAAI,OAAO,oBAAoB,SAAU,QAAO;AAChD,QAAO;EACL,QAAQ,gBAAgB,SACpB,kBAAkB,gBAAgB,OAAO,GACzC;EACJ,OAAO,gBAAgB,QACnB,kBAAkB,gBAAgB,MAAM,GACxC;CACL;AACF;AAoED,SAAgB,IACdC,SACY;CACZ,MAAMC,aAAsB;EAC1B,MAAM;EACN,cAAc,QAAQ;EACtB,eAAe,oBAAoB,QAAQ,aAAa;EACxD,eAAe,QAAQ;EACvB,SAAS,QAAQ;EACjB,kBAAkB,uBAAuB,QAAQ,gBAAgB;EACjE,oBAAoB,QAAQ;CAC7B;AAED,KAAI,eAAe,QACjB,QAAO;EACL,GAAG;EACH,YAAY,QAAQ;CACrB;AAGH,QAAO;EACL,GAAG;EACH,cAAc,QAAQ;CACvB;AACF"}
@@ -0,0 +1,177 @@
1
+ import { OpenAI as OpenAI$1 } from "openai";
2
+ import { ServerTool } from "@langchain/core/tools";
3
+
4
+ //#region src/tools/mcp.d.ts
5
+
6
+ /**
7
+ * Available connector IDs for OpenAI's built-in service connectors.
8
+ * These are OpenAI-maintained MCP wrappers for popular services.
9
+ */
10
+ type McpConnectorId = "connector_dropbox" | "connector_gmail" | "connector_googlecalendar" | "connector_googledrive" | "connector_microsoftteams" | "connector_outlookcalendar" | "connector_outlookemail" | "connector_sharepoint";
11
+ /**
12
+ * Filter object to specify which tools are allowed.
13
+ */
14
+ interface McpToolFilter {
15
+ /**
16
+ * List of allowed tool names.
17
+ */
18
+ toolNames?: string[];
19
+ /**
20
+ * Indicates whether or not a tool modifies data or is read-only.
21
+ * If an MCP server is annotated with `readOnlyHint`, it will match this filter.
22
+ */
23
+ readOnly?: boolean;
24
+ }
25
+ /**
26
+ * Filter object for approval requirements.
27
+ */
28
+ interface McpApprovalFilter {
29
+ /**
30
+ * Tools that always require approval before execution.
31
+ */
32
+ always?: McpToolFilter;
33
+ /**
34
+ * Tools that never require approval.
35
+ */
36
+ never?: McpToolFilter;
37
+ }
38
+ /**
39
+ * Base options shared between remote MCP servers and connectors.
40
+ */
41
+ interface McpBaseOptions {
42
+ /**
43
+ * A label for this MCP server, used to identify it in tool calls.
44
+ */
45
+ serverLabel: string;
46
+ /**
47
+ * List of allowed tool names or a filter object.
48
+ * Use this to limit which tools from the MCP server are available to the model.
49
+ */
50
+ allowedTools?: string[] | McpToolFilter;
51
+ /**
52
+ * An OAuth access token for authentication with the MCP server.
53
+ * Your application must handle the OAuth authorization flow and provide the token here.
54
+ */
55
+ authorization?: string;
56
+ /**
57
+ * Optional HTTP headers to send to the MCP server.
58
+ * Use for authentication or other purposes.
59
+ */
60
+ headers?: Record<string, string>;
61
+ /**
62
+ * Specify which of the MCP server's tools require approval before execution.
63
+ * - `"always"`: All tools require approval
64
+ * - `"never"`: No tools require approval
65
+ * - `McpApprovalFilter`: Fine-grained control over which tools require approval
66
+ *
67
+ * @default "always" (approval required for all tools)
68
+ */
69
+ requireApproval?: "always" | "never" | McpApprovalFilter;
70
+ /**
71
+ * Optional description of the MCP server, used to provide more context to the model.
72
+ */
73
+ serverDescription?: string;
74
+ }
75
+ /**
76
+ * Options for connecting to a remote MCP server via URL.
77
+ */
78
+ interface McpRemoteServerOptions extends McpBaseOptions {
79
+ /**
80
+ * The URL for the MCP server.
81
+ * The server must implement the Streamable HTTP or HTTP/SSE transport protocol.
82
+ */
83
+ serverUrl: string;
84
+ }
85
+ /**
86
+ * Options for connecting to an OpenAI-maintained service connector.
87
+ */
88
+ interface McpConnectorOptions extends McpBaseOptions {
89
+ /**
90
+ * Identifier for the service connector.
91
+ * These are OpenAI-maintained MCP wrappers for popular services.
92
+ *
93
+ * Available connectors:
94
+ * - `connector_dropbox`: Dropbox file access
95
+ * - `connector_gmail`: Gmail email access
96
+ * - `connector_googlecalendar`: Google Calendar access
97
+ * - `connector_googledrive`: Google Drive file access
98
+ * - `connector_microsoftteams`: Microsoft Teams access
99
+ * - `connector_outlookcalendar`: Outlook Calendar access
100
+ * - `connector_outlookemail`: Outlook Email access
101
+ * - `connector_sharepoint`: SharePoint file access
102
+ */
103
+ connectorId: McpConnectorId;
104
+ }
105
+ /**
106
+ * OpenAI MCP tool type for the Responses API.
107
+ */
108
+ type McpTool = OpenAI$1.Responses.Tool.Mcp;
109
+ /**
110
+ * Creates an MCP tool that connects to a remote MCP server or OpenAI service connector.
111
+ * This allows OpenAI models to access external tools and services via the Model Context Protocol.
112
+ *
113
+ * There are two ways to use MCP tools:
114
+ * 1. **Remote MCP servers**: Connect to any server on the public Internet that implements
115
+ * the MCP protocol using `serverUrl`.
116
+ * 2. **Connectors**: Use OpenAI-maintained MCP wrappers for popular services like
117
+ * Google Workspace or Dropbox using `connectorId`.
118
+ *
119
+ * @see {@link https://platform.openai.com/docs/guides/tools-remote-mcp | OpenAI MCP Documentation}
120
+ *
121
+ * @param options - Configuration options for the MCP tool
122
+ * @returns An MCP tool definition to be passed to the OpenAI Responses API
123
+ *
124
+ * @example
125
+ * ```typescript
126
+ * import { ChatOpenAI, tools } from "@langchain/openai";
127
+ *
128
+ * const model = new ChatOpenAI({ model: "gpt-4o" });
129
+ *
130
+ * // Using a remote MCP server
131
+ * const response = await model.invoke("Roll 2d4+1", {
132
+ * tools: [tools.mcp({
133
+ * serverLabel: "dmcp",
134
+ * serverDescription: "A D&D MCP server for dice rolling",
135
+ * serverUrl: "https://dmcp-server.deno.dev/sse",
136
+ * requireApproval: "never",
137
+ * })],
138
+ * });
139
+ *
140
+ * // Using a connector (e.g., Google Calendar)
141
+ * const calendarResponse = await model.invoke("What's on my calendar today?", {
142
+ * tools: [tools.mcp({
143
+ * serverLabel: "google_calendar",
144
+ * connectorId: "connector_googlecalendar",
145
+ * authorization: "<oauth-access-token>",
146
+ * requireApproval: "never",
147
+ * })],
148
+ * });
149
+ *
150
+ * // With tool filtering - only allow specific tools
151
+ * const filteredResponse = await model.invoke("Roll some dice", {
152
+ * tools: [tools.mcp({
153
+ * serverLabel: "dmcp",
154
+ * serverUrl: "https://dmcp-server.deno.dev/sse",
155
+ * allowedTools: ["roll"], // Only allow the "roll" tool
156
+ * requireApproval: "never",
157
+ * })],
158
+ * });
159
+ *
160
+ * // With fine-grained approval control
161
+ * const controlledResponse = await model.invoke("Search and modify files", {
162
+ * tools: [tools.mcp({
163
+ * serverLabel: "deepwiki",
164
+ * serverUrl: "https://mcp.deepwiki.com/mcp",
165
+ * requireApproval: {
166
+ * never: { toolNames: ["ask_question", "read_wiki_structure"] },
167
+ * // All other tools will require approval
168
+ * },
169
+ * })],
170
+ * });
171
+ * ```
172
+ */
173
+ declare function mcp(options: McpRemoteServerOptions): ServerTool;
174
+ declare function mcp(options: McpConnectorOptions): ServerTool;
175
+ //#endregion
176
+ export { McpApprovalFilter, McpConnectorId, McpConnectorOptions, McpRemoteServerOptions, McpTool, McpToolFilter, mcp };
177
+ //# sourceMappingURL=mcp.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp.d.cts","names":["OpenAI","OpenAIClient","ServerTool","McpConnectorId","McpToolFilter","McpApprovalFilter","McpBaseOptions","Record","McpRemoteServerOptions","McpConnectorOptions","McpTool","Responses","Tool","Mcp","mcp"],"sources":["../../src/tools/mcp.d.ts"],"sourcesContent":["import { OpenAI as OpenAIClient } from \"openai\";\nimport type { ServerTool } from \"@langchain/core/tools\";\n/**\n * Available connector IDs for OpenAI's built-in service connectors.\n * These are OpenAI-maintained MCP wrappers for popular services.\n */\nexport type McpConnectorId = \"connector_dropbox\" | \"connector_gmail\" | \"connector_googlecalendar\" | \"connector_googledrive\" | \"connector_microsoftteams\" | \"connector_outlookcalendar\" | \"connector_outlookemail\" | \"connector_sharepoint\";\n/**\n * Filter object to specify which tools are allowed.\n */\nexport interface McpToolFilter {\n /**\n * List of allowed tool names.\n */\n toolNames?: string[];\n /**\n * Indicates whether or not a tool modifies data or is read-only.\n * If an MCP server is annotated with `readOnlyHint`, it will match this filter.\n */\n readOnly?: boolean;\n}\n/**\n * Filter object for approval requirements.\n */\nexport interface McpApprovalFilter {\n /**\n * Tools that always require approval before execution.\n */\n always?: McpToolFilter;\n /**\n * Tools that never require approval.\n */\n never?: McpToolFilter;\n}\n/**\n * Base options shared between remote MCP servers and connectors.\n */\ninterface McpBaseOptions {\n /**\n * A label for this MCP server, used to identify it in tool calls.\n */\n serverLabel: string;\n /**\n * List of allowed tool names or a filter object.\n * Use this to limit which tools from the MCP server are available to the model.\n */\n allowedTools?: string[] | McpToolFilter;\n /**\n * An OAuth access token for authentication with the MCP server.\n * Your application must handle the OAuth authorization flow and provide the token here.\n */\n authorization?: string;\n /**\n * Optional HTTP headers to send to the MCP server.\n * Use for authentication or other purposes.\n */\n headers?: Record<string, string>;\n /**\n * Specify which of the MCP server's tools require approval before execution.\n * - `\"always\"`: All tools require approval\n * - `\"never\"`: No tools require approval\n * - `McpApprovalFilter`: Fine-grained control over which tools require approval\n *\n * @default \"always\" (approval required for all tools)\n */\n requireApproval?: \"always\" | \"never\" | McpApprovalFilter;\n /**\n * Optional description of the MCP server, used to provide more context to the model.\n */\n serverDescription?: string;\n}\n/**\n * Options for connecting to a remote MCP server via URL.\n */\nexport interface McpRemoteServerOptions extends McpBaseOptions {\n /**\n * The URL for the MCP server.\n * The server must implement the Streamable HTTP or HTTP/SSE transport protocol.\n */\n serverUrl: string;\n}\n/**\n * Options for connecting to an OpenAI-maintained service connector.\n */\nexport interface McpConnectorOptions extends McpBaseOptions {\n /**\n * Identifier for the service connector.\n * These are OpenAI-maintained MCP wrappers for popular services.\n *\n * Available connectors:\n * - `connector_dropbox`: Dropbox file access\n * - `connector_gmail`: Gmail email access\n * - `connector_googlecalendar`: Google Calendar access\n * - `connector_googledrive`: Google Drive file access\n * - `connector_microsoftteams`: Microsoft Teams access\n * - `connector_outlookcalendar`: Outlook Calendar access\n * - `connector_outlookemail`: Outlook Email access\n * - `connector_sharepoint`: SharePoint file access\n */\n connectorId: McpConnectorId;\n}\n/**\n * OpenAI MCP tool type for the Responses API.\n */\nexport type McpTool = OpenAIClient.Responses.Tool.Mcp;\n/**\n * Creates an MCP tool that connects to a remote MCP server or OpenAI service connector.\n * This allows OpenAI models to access external tools and services via the Model Context Protocol.\n *\n * There are two ways to use MCP tools:\n * 1. **Remote MCP servers**: Connect to any server on the public Internet that implements\n * the MCP protocol using `serverUrl`.\n * 2. **Connectors**: Use OpenAI-maintained MCP wrappers for popular services like\n * Google Workspace or Dropbox using `connectorId`.\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-remote-mcp | OpenAI MCP Documentation}\n *\n * @param options - Configuration options for the MCP tool\n * @returns An MCP tool definition to be passed to the OpenAI Responses API\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n *\n * const model = new ChatOpenAI({ model: \"gpt-4o\" });\n *\n * // Using a remote MCP server\n * const response = await model.invoke(\"Roll 2d4+1\", {\n * tools: [tools.mcp({\n * serverLabel: \"dmcp\",\n * serverDescription: \"A D&D MCP server for dice rolling\",\n * serverUrl: \"https://dmcp-server.deno.dev/sse\",\n * requireApproval: \"never\",\n * })],\n * });\n *\n * // Using a connector (e.g., Google Calendar)\n * const calendarResponse = await model.invoke(\"What's on my calendar today?\", {\n * tools: [tools.mcp({\n * serverLabel: \"google_calendar\",\n * connectorId: \"connector_googlecalendar\",\n * authorization: \"<oauth-access-token>\",\n * requireApproval: \"never\",\n * })],\n * });\n *\n * // With tool filtering - only allow specific tools\n * const filteredResponse = await model.invoke(\"Roll some dice\", {\n * tools: [tools.mcp({\n * serverLabel: \"dmcp\",\n * serverUrl: \"https://dmcp-server.deno.dev/sse\",\n * allowedTools: [\"roll\"], // Only allow the \"roll\" tool\n * requireApproval: \"never\",\n * })],\n * });\n *\n * // With fine-grained approval control\n * const controlledResponse = await model.invoke(\"Search and modify files\", {\n * tools: [tools.mcp({\n * serverLabel: \"deepwiki\",\n * serverUrl: \"https://mcp.deepwiki.com/mcp\",\n * requireApproval: {\n * never: { toolNames: [\"ask_question\", \"read_wiki_structure\"] },\n * // All other tools will require approval\n * },\n * })],\n * });\n * ```\n */\nexport declare function mcp(options: McpRemoteServerOptions): ServerTool;\nexport declare function mcp(options: McpConnectorOptions): ServerTool;\nexport {};\n//# sourceMappingURL=mcp.d.ts.map"],"mappings":";;;;;;;AAMA;AAIA;AAciBK,KAlBLF,cAAAA,GAkBsB,mBAIrBC,GAAAA,iBAIY,GAAA,0BAAA,GAAA,uBAAA,GAAA,0BAAA,GAAA,2BAAA,GAAA,wBAAA,GAAA,sBAAA;AACxB;;;AAgC0CC,UAvD1BD,aAAAA,CAuD0BC;EAAiB;AAS5D;AAUA;EAoBYK,SAAAA,CAAO,EAAA,MAAA,EAAA;EAiEKI;AACxB;;;;;;;;UAlJiBT,iBAAAA;;;;WAIJD;;;;UAIDA;;;;;UAKFE,cAAAA;;;;;;;;;4BASoBF;;;;;;;;;;YAUhBG;;;;;;;;;yCAS6BF;;;;;;;;;UAS1BG,sBAAAA,SAA+BF;;;;;;;;;;UAU/BG,mBAAAA,SAA4BH;;;;;;;;;;;;;;;eAe5BH;;;;;KAKLO,OAAAA,GAAUT,QAAAA,CAAaU,SAAAA,CAAUC,IAAAA,CAAKC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiE1BC,GAAAA,UAAaN,yBAAyBN;iBACtCY,GAAAA,UAAaL,sBAAsBP"}
@@ -0,0 +1,177 @@
1
+ import { OpenAI as OpenAI$1 } from "openai";
2
+ import { ServerTool } from "@langchain/core/tools";
3
+
4
+ //#region src/tools/mcp.d.ts
5
+
6
+ /**
7
+ * Available connector IDs for OpenAI's built-in service connectors.
8
+ * These are OpenAI-maintained MCP wrappers for popular services.
9
+ */
10
+ type McpConnectorId = "connector_dropbox" | "connector_gmail" | "connector_googlecalendar" | "connector_googledrive" | "connector_microsoftteams" | "connector_outlookcalendar" | "connector_outlookemail" | "connector_sharepoint";
11
+ /**
12
+ * Filter object to specify which tools are allowed.
13
+ */
14
+ interface McpToolFilter {
15
+ /**
16
+ * List of allowed tool names.
17
+ */
18
+ toolNames?: string[];
19
+ /**
20
+ * Indicates whether or not a tool modifies data or is read-only.
21
+ * If an MCP server is annotated with `readOnlyHint`, it will match this filter.
22
+ */
23
+ readOnly?: boolean;
24
+ }
25
+ /**
26
+ * Filter object for approval requirements.
27
+ */
28
+ interface McpApprovalFilter {
29
+ /**
30
+ * Tools that always require approval before execution.
31
+ */
32
+ always?: McpToolFilter;
33
+ /**
34
+ * Tools that never require approval.
35
+ */
36
+ never?: McpToolFilter;
37
+ }
38
+ /**
39
+ * Base options shared between remote MCP servers and connectors.
40
+ */
41
+ interface McpBaseOptions {
42
+ /**
43
+ * A label for this MCP server, used to identify it in tool calls.
44
+ */
45
+ serverLabel: string;
46
+ /**
47
+ * List of allowed tool names or a filter object.
48
+ * Use this to limit which tools from the MCP server are available to the model.
49
+ */
50
+ allowedTools?: string[] | McpToolFilter;
51
+ /**
52
+ * An OAuth access token for authentication with the MCP server.
53
+ * Your application must handle the OAuth authorization flow and provide the token here.
54
+ */
55
+ authorization?: string;
56
+ /**
57
+ * Optional HTTP headers to send to the MCP server.
58
+ * Use for authentication or other purposes.
59
+ */
60
+ headers?: Record<string, string>;
61
+ /**
62
+ * Specify which of the MCP server's tools require approval before execution.
63
+ * - `"always"`: All tools require approval
64
+ * - `"never"`: No tools require approval
65
+ * - `McpApprovalFilter`: Fine-grained control over which tools require approval
66
+ *
67
+ * @default "always" (approval required for all tools)
68
+ */
69
+ requireApproval?: "always" | "never" | McpApprovalFilter;
70
+ /**
71
+ * Optional description of the MCP server, used to provide more context to the model.
72
+ */
73
+ serverDescription?: string;
74
+ }
75
+ /**
76
+ * Options for connecting to a remote MCP server via URL.
77
+ */
78
+ interface McpRemoteServerOptions extends McpBaseOptions {
79
+ /**
80
+ * The URL for the MCP server.
81
+ * The server must implement the Streamable HTTP or HTTP/SSE transport protocol.
82
+ */
83
+ serverUrl: string;
84
+ }
85
+ /**
86
+ * Options for connecting to an OpenAI-maintained service connector.
87
+ */
88
+ interface McpConnectorOptions extends McpBaseOptions {
89
+ /**
90
+ * Identifier for the service connector.
91
+ * These are OpenAI-maintained MCP wrappers for popular services.
92
+ *
93
+ * Available connectors:
94
+ * - `connector_dropbox`: Dropbox file access
95
+ * - `connector_gmail`: Gmail email access
96
+ * - `connector_googlecalendar`: Google Calendar access
97
+ * - `connector_googledrive`: Google Drive file access
98
+ * - `connector_microsoftteams`: Microsoft Teams access
99
+ * - `connector_outlookcalendar`: Outlook Calendar access
100
+ * - `connector_outlookemail`: Outlook Email access
101
+ * - `connector_sharepoint`: SharePoint file access
102
+ */
103
+ connectorId: McpConnectorId;
104
+ }
105
+ /**
106
+ * OpenAI MCP tool type for the Responses API.
107
+ */
108
+ type McpTool = OpenAI$1.Responses.Tool.Mcp;
109
+ /**
110
+ * Creates an MCP tool that connects to a remote MCP server or OpenAI service connector.
111
+ * This allows OpenAI models to access external tools and services via the Model Context Protocol.
112
+ *
113
+ * There are two ways to use MCP tools:
114
+ * 1. **Remote MCP servers**: Connect to any server on the public Internet that implements
115
+ * the MCP protocol using `serverUrl`.
116
+ * 2. **Connectors**: Use OpenAI-maintained MCP wrappers for popular services like
117
+ * Google Workspace or Dropbox using `connectorId`.
118
+ *
119
+ * @see {@link https://platform.openai.com/docs/guides/tools-remote-mcp | OpenAI MCP Documentation}
120
+ *
121
+ * @param options - Configuration options for the MCP tool
122
+ * @returns An MCP tool definition to be passed to the OpenAI Responses API
123
+ *
124
+ * @example
125
+ * ```typescript
126
+ * import { ChatOpenAI, tools } from "@langchain/openai";
127
+ *
128
+ * const model = new ChatOpenAI({ model: "gpt-4o" });
129
+ *
130
+ * // Using a remote MCP server
131
+ * const response = await model.invoke("Roll 2d4+1", {
132
+ * tools: [tools.mcp({
133
+ * serverLabel: "dmcp",
134
+ * serverDescription: "A D&D MCP server for dice rolling",
135
+ * serverUrl: "https://dmcp-server.deno.dev/sse",
136
+ * requireApproval: "never",
137
+ * })],
138
+ * });
139
+ *
140
+ * // Using a connector (e.g., Google Calendar)
141
+ * const calendarResponse = await model.invoke("What's on my calendar today?", {
142
+ * tools: [tools.mcp({
143
+ * serverLabel: "google_calendar",
144
+ * connectorId: "connector_googlecalendar",
145
+ * authorization: "<oauth-access-token>",
146
+ * requireApproval: "never",
147
+ * })],
148
+ * });
149
+ *
150
+ * // With tool filtering - only allow specific tools
151
+ * const filteredResponse = await model.invoke("Roll some dice", {
152
+ * tools: [tools.mcp({
153
+ * serverLabel: "dmcp",
154
+ * serverUrl: "https://dmcp-server.deno.dev/sse",
155
+ * allowedTools: ["roll"], // Only allow the "roll" tool
156
+ * requireApproval: "never",
157
+ * })],
158
+ * });
159
+ *
160
+ * // With fine-grained approval control
161
+ * const controlledResponse = await model.invoke("Search and modify files", {
162
+ * tools: [tools.mcp({
163
+ * serverLabel: "deepwiki",
164
+ * serverUrl: "https://mcp.deepwiki.com/mcp",
165
+ * requireApproval: {
166
+ * never: { toolNames: ["ask_question", "read_wiki_structure"] },
167
+ * // All other tools will require approval
168
+ * },
169
+ * })],
170
+ * });
171
+ * ```
172
+ */
173
+ declare function mcp(options: McpRemoteServerOptions): ServerTool;
174
+ declare function mcp(options: McpConnectorOptions): ServerTool;
175
+ //#endregion
176
+ export { McpApprovalFilter, McpConnectorId, McpConnectorOptions, McpRemoteServerOptions, McpTool, McpToolFilter, mcp };
177
+ //# sourceMappingURL=mcp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp.d.ts","names":["OpenAI","OpenAIClient","ServerTool","McpConnectorId","McpToolFilter","McpApprovalFilter","McpBaseOptions","Record","McpRemoteServerOptions","McpConnectorOptions","McpTool","Responses","Tool","Mcp","mcp"],"sources":["../../src/tools/mcp.d.ts"],"sourcesContent":["import { OpenAI as OpenAIClient } from \"openai\";\nimport type { ServerTool } from \"@langchain/core/tools\";\n/**\n * Available connector IDs for OpenAI's built-in service connectors.\n * These are OpenAI-maintained MCP wrappers for popular services.\n */\nexport type McpConnectorId = \"connector_dropbox\" | \"connector_gmail\" | \"connector_googlecalendar\" | \"connector_googledrive\" | \"connector_microsoftteams\" | \"connector_outlookcalendar\" | \"connector_outlookemail\" | \"connector_sharepoint\";\n/**\n * Filter object to specify which tools are allowed.\n */\nexport interface McpToolFilter {\n /**\n * List of allowed tool names.\n */\n toolNames?: string[];\n /**\n * Indicates whether or not a tool modifies data or is read-only.\n * If an MCP server is annotated with `readOnlyHint`, it will match this filter.\n */\n readOnly?: boolean;\n}\n/**\n * Filter object for approval requirements.\n */\nexport interface McpApprovalFilter {\n /**\n * Tools that always require approval before execution.\n */\n always?: McpToolFilter;\n /**\n * Tools that never require approval.\n */\n never?: McpToolFilter;\n}\n/**\n * Base options shared between remote MCP servers and connectors.\n */\ninterface McpBaseOptions {\n /**\n * A label for this MCP server, used to identify it in tool calls.\n */\n serverLabel: string;\n /**\n * List of allowed tool names or a filter object.\n * Use this to limit which tools from the MCP server are available to the model.\n */\n allowedTools?: string[] | McpToolFilter;\n /**\n * An OAuth access token for authentication with the MCP server.\n * Your application must handle the OAuth authorization flow and provide the token here.\n */\n authorization?: string;\n /**\n * Optional HTTP headers to send to the MCP server.\n * Use for authentication or other purposes.\n */\n headers?: Record<string, string>;\n /**\n * Specify which of the MCP server's tools require approval before execution.\n * - `\"always\"`: All tools require approval\n * - `\"never\"`: No tools require approval\n * - `McpApprovalFilter`: Fine-grained control over which tools require approval\n *\n * @default \"always\" (approval required for all tools)\n */\n requireApproval?: \"always\" | \"never\" | McpApprovalFilter;\n /**\n * Optional description of the MCP server, used to provide more context to the model.\n */\n serverDescription?: string;\n}\n/**\n * Options for connecting to a remote MCP server via URL.\n */\nexport interface McpRemoteServerOptions extends McpBaseOptions {\n /**\n * The URL for the MCP server.\n * The server must implement the Streamable HTTP or HTTP/SSE transport protocol.\n */\n serverUrl: string;\n}\n/**\n * Options for connecting to an OpenAI-maintained service connector.\n */\nexport interface McpConnectorOptions extends McpBaseOptions {\n /**\n * Identifier for the service connector.\n * These are OpenAI-maintained MCP wrappers for popular services.\n *\n * Available connectors:\n * - `connector_dropbox`: Dropbox file access\n * - `connector_gmail`: Gmail email access\n * - `connector_googlecalendar`: Google Calendar access\n * - `connector_googledrive`: Google Drive file access\n * - `connector_microsoftteams`: Microsoft Teams access\n * - `connector_outlookcalendar`: Outlook Calendar access\n * - `connector_outlookemail`: Outlook Email access\n * - `connector_sharepoint`: SharePoint file access\n */\n connectorId: McpConnectorId;\n}\n/**\n * OpenAI MCP tool type for the Responses API.\n */\nexport type McpTool = OpenAIClient.Responses.Tool.Mcp;\n/**\n * Creates an MCP tool that connects to a remote MCP server or OpenAI service connector.\n * This allows OpenAI models to access external tools and services via the Model Context Protocol.\n *\n * There are two ways to use MCP tools:\n * 1. **Remote MCP servers**: Connect to any server on the public Internet that implements\n * the MCP protocol using `serverUrl`.\n * 2. **Connectors**: Use OpenAI-maintained MCP wrappers for popular services like\n * Google Workspace or Dropbox using `connectorId`.\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-remote-mcp | OpenAI MCP Documentation}\n *\n * @param options - Configuration options for the MCP tool\n * @returns An MCP tool definition to be passed to the OpenAI Responses API\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n *\n * const model = new ChatOpenAI({ model: \"gpt-4o\" });\n *\n * // Using a remote MCP server\n * const response = await model.invoke(\"Roll 2d4+1\", {\n * tools: [tools.mcp({\n * serverLabel: \"dmcp\",\n * serverDescription: \"A D&D MCP server for dice rolling\",\n * serverUrl: \"https://dmcp-server.deno.dev/sse\",\n * requireApproval: \"never\",\n * })],\n * });\n *\n * // Using a connector (e.g., Google Calendar)\n * const calendarResponse = await model.invoke(\"What's on my calendar today?\", {\n * tools: [tools.mcp({\n * serverLabel: \"google_calendar\",\n * connectorId: \"connector_googlecalendar\",\n * authorization: \"<oauth-access-token>\",\n * requireApproval: \"never\",\n * })],\n * });\n *\n * // With tool filtering - only allow specific tools\n * const filteredResponse = await model.invoke(\"Roll some dice\", {\n * tools: [tools.mcp({\n * serverLabel: \"dmcp\",\n * serverUrl: \"https://dmcp-server.deno.dev/sse\",\n * allowedTools: [\"roll\"], // Only allow the \"roll\" tool\n * requireApproval: \"never\",\n * })],\n * });\n *\n * // With fine-grained approval control\n * const controlledResponse = await model.invoke(\"Search and modify files\", {\n * tools: [tools.mcp({\n * serverLabel: \"deepwiki\",\n * serverUrl: \"https://mcp.deepwiki.com/mcp\",\n * requireApproval: {\n * never: { toolNames: [\"ask_question\", \"read_wiki_structure\"] },\n * // All other tools will require approval\n * },\n * })],\n * });\n * ```\n */\nexport declare function mcp(options: McpRemoteServerOptions): ServerTool;\nexport declare function mcp(options: McpConnectorOptions): ServerTool;\nexport {};\n//# sourceMappingURL=mcp.d.ts.map"],"mappings":";;;;;;;AAMA;AAIA;AAciBK,KAlBLF,cAAAA,GAkBsB,mBAIrBC,GAAAA,iBAIY,GAAA,0BAAA,GAAA,uBAAA,GAAA,0BAAA,GAAA,2BAAA,GAAA,wBAAA,GAAA,sBAAA;AACxB;;;AAgC0CC,UAvD1BD,aAAAA,CAuD0BC;EAAiB;AAS5D;AAUA;EAoBYK,SAAAA,CAAO,EAAA,MAAA,EAAA;EAiEKI;AACxB;;;;;;;;UAlJiBT,iBAAAA;;;;WAIJD;;;;UAIDA;;;;;UAKFE,cAAAA;;;;;;;;;4BASoBF;;;;;;;;;;YAUhBG;;;;;;;;;yCAS6BF;;;;;;;;;UAS1BG,sBAAAA,SAA+BF;;;;;;;;;;UAU/BG,mBAAAA,SAA4BH;;;;;;;;;;;;;;;eAe5BH;;;;;KAKLO,OAAAA,GAAUT,QAAAA,CAAaU,SAAAA,CAAUC,IAAAA,CAAKC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiE1BC,GAAAA,UAAaN,yBAAyBN;iBACtCY,GAAAA,UAAaL,sBAAsBP"}
@@ -0,0 +1,52 @@
1
+ //#region src/tools/mcp.ts
2
+ /**
3
+ * Converts a McpToolFilter to the API format.
4
+ */
5
+ function convertToolFilter(filter) {
6
+ return {
7
+ tool_names: filter.toolNames,
8
+ read_only: filter.readOnly
9
+ };
10
+ }
11
+ /**
12
+ * Converts allowed_tools option to API format.
13
+ */
14
+ function convertAllowedTools(allowedTools) {
15
+ if (!allowedTools) return void 0;
16
+ if (Array.isArray(allowedTools)) return allowedTools;
17
+ return convertToolFilter(allowedTools);
18
+ }
19
+ /**
20
+ * Converts require_approval option to API format.
21
+ */
22
+ function convertRequireApproval(requireApproval) {
23
+ if (!requireApproval) return void 0;
24
+ if (typeof requireApproval === "string") return requireApproval;
25
+ return {
26
+ always: requireApproval.always ? convertToolFilter(requireApproval.always) : void 0,
27
+ never: requireApproval.never ? convertToolFilter(requireApproval.never) : void 0
28
+ };
29
+ }
30
+ function mcp(options) {
31
+ const baseConfig = {
32
+ type: "mcp",
33
+ server_label: options.serverLabel,
34
+ allowed_tools: convertAllowedTools(options.allowedTools),
35
+ authorization: options.authorization,
36
+ headers: options.headers,
37
+ require_approval: convertRequireApproval(options.requireApproval),
38
+ server_description: options.serverDescription
39
+ };
40
+ if ("serverUrl" in options) return {
41
+ ...baseConfig,
42
+ server_url: options.serverUrl
43
+ };
44
+ return {
45
+ ...baseConfig,
46
+ connector_id: options.connectorId
47
+ };
48
+ }
49
+
50
+ //#endregion
51
+ export { mcp };
52
+ //# sourceMappingURL=mcp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp.js","names":["filter: McpToolFilter","allowedTools: string[] | McpToolFilter | undefined","requireApproval: \"always\" | \"never\" | McpApprovalFilter | undefined","options: McpRemoteServerOptions | McpConnectorOptions","baseConfig: McpTool"],"sources":["../../src/tools/mcp.ts"],"sourcesContent":["import { OpenAI as OpenAIClient } from \"openai\";\nimport type { ServerTool } from \"@langchain/core/tools\";\n\n/**\n * Available connector IDs for OpenAI's built-in service connectors.\n * These are OpenAI-maintained MCP wrappers for popular services.\n */\nexport type McpConnectorId =\n | \"connector_dropbox\"\n | \"connector_gmail\"\n | \"connector_googlecalendar\"\n | \"connector_googledrive\"\n | \"connector_microsoftteams\"\n | \"connector_outlookcalendar\"\n | \"connector_outlookemail\"\n | \"connector_sharepoint\";\n\n/**\n * Filter object to specify which tools are allowed.\n */\nexport interface McpToolFilter {\n /**\n * List of allowed tool names.\n */\n toolNames?: string[];\n /**\n * Indicates whether or not a tool modifies data or is read-only.\n * If an MCP server is annotated with `readOnlyHint`, it will match this filter.\n */\n readOnly?: boolean;\n}\n\n/**\n * Filter object for approval requirements.\n */\nexport interface McpApprovalFilter {\n /**\n * Tools that always require approval before execution.\n */\n always?: McpToolFilter;\n /**\n * Tools that never require approval.\n */\n never?: McpToolFilter;\n}\n\n/**\n * Base options shared between remote MCP servers and connectors.\n */\ninterface McpBaseOptions {\n /**\n * A label for this MCP server, used to identify it in tool calls.\n */\n serverLabel: string;\n /**\n * List of allowed tool names or a filter object.\n * Use this to limit which tools from the MCP server are available to the model.\n */\n allowedTools?: string[] | McpToolFilter;\n /**\n * An OAuth access token for authentication with the MCP server.\n * Your application must handle the OAuth authorization flow and provide the token here.\n */\n authorization?: string;\n /**\n * Optional HTTP headers to send to the MCP server.\n * Use for authentication or other purposes.\n */\n headers?: Record<string, string>;\n /**\n * Specify which of the MCP server's tools require approval before execution.\n * - `\"always\"`: All tools require approval\n * - `\"never\"`: No tools require approval\n * - `McpApprovalFilter`: Fine-grained control over which tools require approval\n *\n * @default \"always\" (approval required for all tools)\n */\n requireApproval?: \"always\" | \"never\" | McpApprovalFilter;\n /**\n * Optional description of the MCP server, used to provide more context to the model.\n */\n serverDescription?: string;\n}\n\n/**\n * Options for connecting to a remote MCP server via URL.\n */\nexport interface McpRemoteServerOptions extends McpBaseOptions {\n /**\n * The URL for the MCP server.\n * The server must implement the Streamable HTTP or HTTP/SSE transport protocol.\n */\n serverUrl: string;\n}\n\n/**\n * Options for connecting to an OpenAI-maintained service connector.\n */\nexport interface McpConnectorOptions extends McpBaseOptions {\n /**\n * Identifier for the service connector.\n * These are OpenAI-maintained MCP wrappers for popular services.\n *\n * Available connectors:\n * - `connector_dropbox`: Dropbox file access\n * - `connector_gmail`: Gmail email access\n * - `connector_googlecalendar`: Google Calendar access\n * - `connector_googledrive`: Google Drive file access\n * - `connector_microsoftteams`: Microsoft Teams access\n * - `connector_outlookcalendar`: Outlook Calendar access\n * - `connector_outlookemail`: Outlook Email access\n * - `connector_sharepoint`: SharePoint file access\n */\n connectorId: McpConnectorId;\n}\n\n/**\n * OpenAI MCP tool type for the Responses API.\n */\nexport type McpTool = OpenAIClient.Responses.Tool.Mcp;\n\n/**\n * Converts a McpToolFilter to the API format.\n */\nfunction convertToolFilter(\n filter: McpToolFilter\n): OpenAIClient.Responses.Tool.Mcp.McpToolFilter {\n return {\n tool_names: filter.toolNames,\n read_only: filter.readOnly,\n };\n}\n\n/**\n * Converts allowed_tools option to API format.\n */\nfunction convertAllowedTools(\n allowedTools: string[] | McpToolFilter | undefined\n): Array<string> | OpenAIClient.Responses.Tool.Mcp.McpToolFilter | undefined {\n if (!allowedTools) return undefined;\n if (Array.isArray(allowedTools)) return allowedTools;\n return convertToolFilter(allowedTools);\n}\n\n/**\n * Converts require_approval option to API format.\n */\nfunction convertRequireApproval(\n requireApproval: \"always\" | \"never\" | McpApprovalFilter | undefined\n):\n | OpenAIClient.Responses.Tool.Mcp.McpToolApprovalFilter\n | \"always\"\n | \"never\"\n | undefined {\n if (!requireApproval) return undefined;\n if (typeof requireApproval === \"string\") return requireApproval;\n return {\n always: requireApproval.always\n ? convertToolFilter(requireApproval.always)\n : undefined,\n never: requireApproval.never\n ? convertToolFilter(requireApproval.never)\n : undefined,\n };\n}\n\n/**\n * Creates an MCP tool that connects to a remote MCP server or OpenAI service connector.\n * This allows OpenAI models to access external tools and services via the Model Context Protocol.\n *\n * There are two ways to use MCP tools:\n * 1. **Remote MCP servers**: Connect to any server on the public Internet that implements\n * the MCP protocol using `serverUrl`.\n * 2. **Connectors**: Use OpenAI-maintained MCP wrappers for popular services like\n * Google Workspace or Dropbox using `connectorId`.\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-remote-mcp | OpenAI MCP Documentation}\n *\n * @param options - Configuration options for the MCP tool\n * @returns An MCP tool definition to be passed to the OpenAI Responses API\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n *\n * const model = new ChatOpenAI({ model: \"gpt-4o\" });\n *\n * // Using a remote MCP server\n * const response = await model.invoke(\"Roll 2d4+1\", {\n * tools: [tools.mcp({\n * serverLabel: \"dmcp\",\n * serverDescription: \"A D&D MCP server for dice rolling\",\n * serverUrl: \"https://dmcp-server.deno.dev/sse\",\n * requireApproval: \"never\",\n * })],\n * });\n *\n * // Using a connector (e.g., Google Calendar)\n * const calendarResponse = await model.invoke(\"What's on my calendar today?\", {\n * tools: [tools.mcp({\n * serverLabel: \"google_calendar\",\n * connectorId: \"connector_googlecalendar\",\n * authorization: \"<oauth-access-token>\",\n * requireApproval: \"never\",\n * })],\n * });\n *\n * // With tool filtering - only allow specific tools\n * const filteredResponse = await model.invoke(\"Roll some dice\", {\n * tools: [tools.mcp({\n * serverLabel: \"dmcp\",\n * serverUrl: \"https://dmcp-server.deno.dev/sse\",\n * allowedTools: [\"roll\"], // Only allow the \"roll\" tool\n * requireApproval: \"never\",\n * })],\n * });\n *\n * // With fine-grained approval control\n * const controlledResponse = await model.invoke(\"Search and modify files\", {\n * tools: [tools.mcp({\n * serverLabel: \"deepwiki\",\n * serverUrl: \"https://mcp.deepwiki.com/mcp\",\n * requireApproval: {\n * never: { toolNames: [\"ask_question\", \"read_wiki_structure\"] },\n * // All other tools will require approval\n * },\n * })],\n * });\n * ```\n */\nexport function mcp(options: McpRemoteServerOptions): ServerTool;\nexport function mcp(options: McpConnectorOptions): ServerTool;\nexport function mcp(\n options: McpRemoteServerOptions | McpConnectorOptions\n): ServerTool {\n const baseConfig: McpTool = {\n type: \"mcp\",\n server_label: options.serverLabel,\n allowed_tools: convertAllowedTools(options.allowedTools),\n authorization: options.authorization,\n headers: options.headers,\n require_approval: convertRequireApproval(options.requireApproval),\n server_description: options.serverDescription,\n };\n\n if (\"serverUrl\" in options) {\n return {\n ...baseConfig,\n server_url: options.serverUrl,\n } satisfies McpTool;\n }\n\n return {\n ...baseConfig,\n connector_id: options.connectorId,\n } satisfies McpTool;\n}\n"],"mappings":";;;;AA4HA,SAAS,kBACPA,QAC+C;AAC/C,QAAO;EACL,YAAY,OAAO;EACnB,WAAW,OAAO;CACnB;AACF;;;;AAKD,SAAS,oBACPC,cAC2E;AAC3E,KAAI,CAAC,aAAc,QAAO;AAC1B,KAAI,MAAM,QAAQ,aAAa,CAAE,QAAO;AACxC,QAAO,kBAAkB,aAAa;AACvC;;;;AAKD,SAAS,uBACPC,iBAKY;AACZ,KAAI,CAAC,gBAAiB,QAAO;AAC7B,KAAI,OAAO,oBAAoB,SAAU,QAAO;AAChD,QAAO;EACL,QAAQ,gBAAgB,SACpB,kBAAkB,gBAAgB,OAAO,GACzC;EACJ,OAAO,gBAAgB,QACnB,kBAAkB,gBAAgB,MAAM,GACxC;CACL;AACF;AAoED,SAAgB,IACdC,SACY;CACZ,MAAMC,aAAsB;EAC1B,MAAM;EACN,cAAc,QAAQ;EACtB,eAAe,oBAAoB,QAAQ,aAAa;EACxD,eAAe,QAAQ;EACvB,SAAS,QAAQ;EACjB,kBAAkB,uBAAuB,QAAQ,gBAAgB;EACjE,oBAAoB,QAAQ;CAC7B;AAED,KAAI,eAAe,QACjB,QAAO;EACL,GAAG;EACH,YAAY,QAAQ;CACrB;AAGH,QAAO;EACL,GAAG;EACH,cAAc,QAAQ;CACvB;AACF"}