managed-deepagents 0.6.2-dev.4 → 0.6.2-dev.41

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 (90) hide show
  1. package/README.md +18 -3
  2. package/dist/agent-auth.d.ts +141 -0
  3. package/dist/agent-auth.d.ts.map +1 -0
  4. package/dist/agent-auth.js +426 -0
  5. package/dist/agent-auth.js.map +1 -0
  6. package/dist/channels/manifest.d.ts +4 -0
  7. package/dist/channels/manifest.d.ts.map +1 -1
  8. package/dist/channels/schedule-delivery.d.ts +2 -0
  9. package/dist/channels/schedule-delivery.d.ts.map +1 -1
  10. package/dist/channels/schedule-delivery.js +40 -4
  11. package/dist/channels/schedule-delivery.js.map +1 -1
  12. package/dist/channels/trigger/client.d.ts +1 -0
  13. package/dist/channels/trigger/client.d.ts.map +1 -1
  14. package/dist/channels/trigger/client.js +19 -8
  15. package/dist/channels/trigger/client.js.map +1 -1
  16. package/dist/channels/trigger/http.d.ts +8 -0
  17. package/dist/channels/trigger/http.d.ts.map +1 -1
  18. package/dist/channels/trigger/http.js +42 -1
  19. package/dist/channels/trigger/http.js.map +1 -1
  20. package/dist/channels/trigger/identity-context.d.ts +47 -0
  21. package/dist/channels/trigger/identity-context.d.ts.map +1 -0
  22. package/dist/channels/trigger/identity-context.js +171 -0
  23. package/dist/channels/trigger/identity-context.js.map +1 -0
  24. package/dist/channels/trigger/types.d.ts +5 -1
  25. package/dist/channels/trigger/types.d.ts.map +1 -1
  26. package/dist/channels/trigger/types.js +5 -0
  27. package/dist/channels/trigger/types.js.map +1 -1
  28. package/dist/connections.d.ts +74 -0
  29. package/dist/connections.d.ts.map +1 -0
  30. package/dist/connections.js +277 -0
  31. package/dist/connections.js.map +1 -0
  32. package/dist/connectors/mcp/index.d.ts +29 -89
  33. package/dist/connectors/mcp/index.d.ts.map +1 -1
  34. package/dist/connectors/mcp/index.js +258 -50
  35. package/dist/connectors/mcp/index.js.map +1 -1
  36. package/dist/connectors/mcp/schema.d.ts +12 -0
  37. package/dist/connectors/mcp/schema.d.ts.map +1 -0
  38. package/dist/connectors/mcp/schema.js +57 -0
  39. package/dist/connectors/mcp/schema.js.map +1 -0
  40. package/dist/connectors/mcp/types.d.ts +62 -0
  41. package/dist/connectors/mcp/types.d.ts.map +1 -0
  42. package/dist/connectors/mcp/types.js +2 -0
  43. package/dist/connectors/mcp/types.js.map +1 -0
  44. package/dist/connectors/tool-selection.d.ts +9 -18
  45. package/dist/connectors/tool-selection.d.ts.map +1 -1
  46. package/dist/connectors/tool-selection.js +32 -58
  47. package/dist/connectors/tool-selection.js.map +1 -1
  48. package/dist/credential-gate.d.ts +40 -0
  49. package/dist/credential-gate.d.ts.map +1 -0
  50. package/dist/credential-gate.js +227 -0
  51. package/dist/credential-gate.js.map +1 -0
  52. package/dist/identity/index.d.ts +1 -1
  53. package/dist/identity/index.d.ts.map +1 -1
  54. package/dist/identity/index.js.map +1 -1
  55. package/dist/identity/types.d.ts +79 -5
  56. package/dist/identity/types.d.ts.map +1 -1
  57. package/dist/index.d.ts +11 -6
  58. package/dist/index.d.ts.map +1 -1
  59. package/dist/index.js +1 -0
  60. package/dist/index.js.map +1 -1
  61. package/dist/ingress/index.d.ts +10 -2
  62. package/dist/ingress/index.d.ts.map +1 -1
  63. package/dist/ingress/index.js +17 -9
  64. package/dist/ingress/index.js.map +1 -1
  65. package/dist/runtime/auth.d.ts +49 -5
  66. package/dist/runtime/auth.d.ts.map +1 -1
  67. package/dist/runtime/auth.js +100 -5
  68. package/dist/runtime/auth.js.map +1 -1
  69. package/dist/runtime/http.d.ts +1 -1
  70. package/dist/runtime/http.d.ts.map +1 -1
  71. package/dist/runtime/http.js.map +1 -1
  72. package/dist/runtime/identity-runtime.d.ts +65 -5
  73. package/dist/runtime/identity-runtime.d.ts.map +1 -1
  74. package/dist/runtime/identity-runtime.js +148 -0
  75. package/dist/runtime/identity-runtime.js.map +1 -1
  76. package/dist/runtime/index.d.ts.map +1 -1
  77. package/dist/runtime/index.js +12 -7
  78. package/dist/runtime/index.js.map +1 -1
  79. package/dist/runtime/managed-middleware.d.ts +2 -2
  80. package/dist/runtime/managed-middleware.js +6 -6
  81. package/dist/runtime/managed-tools.d.ts +19 -15
  82. package/dist/runtime/managed-tools.d.ts.map +1 -1
  83. package/dist/runtime/managed-tools.js +14 -13
  84. package/dist/runtime/managed-tools.js.map +1 -1
  85. package/dist/runtime/types.d.ts +2 -2
  86. package/package.json +8 -8
  87. package/dist/connectors/mcp/load.d.ts +0 -12
  88. package/dist/connectors/mcp/load.d.ts.map +0 -1
  89. package/dist/connectors/mcp/load.js +0 -122
  90. package/dist/connectors/mcp/load.js.map +0 -1
@@ -18,7 +18,7 @@
18
18
  * @example
19
19
  * ```ts
20
20
  * // connectors/mcp.ts
21
- * import { connectors } from "managed-deepagents";
21
+ * import { connectors, connections } from "managed-deepagents";
22
22
  *
23
23
  * export const connector = connectors.mcp({
24
24
  * mcpServers: {
@@ -26,69 +26,277 @@
26
26
  * transport: "http",
27
27
  * url: "https://docs.example.com/mcp",
28
28
  * },
29
+ * notion: {
30
+ * transport: "http",
31
+ * url: "https://mcp.notion.com/mcp",
32
+ * connection: connections.get("notion", { type: "user" }),
33
+ * },
29
34
  * },
30
35
  * });
31
36
  * ```
32
37
  */
33
- import { z } from "zod";
34
- import { checkToolSelectionOverlap, toolSelectionConnectorFields, } from "../tool-selection.js";
38
+ import { MultiServerMCPClient } from "@langchain/mcp-adapters";
35
39
  import { defineExtension } from "../../extension.js";
36
- /** Stdio servers are out of scope; the message points at the alternatives. */
37
- const STDIO_REJECTION = "uses a stdio transport, which is not supported. Managed Deep Agents " +
38
- "support remote MCP servers over HTTP/SSE only; expose the server over HTTP " +
39
- "or write a normal authored tool instead.";
40
- const remoteMcpServer = z
41
- .looseObject({
42
- // Present only to reject it: a `command` is how a stdio server is spelled.
43
- command: z.never({ error: STDIO_REJECTION }).optional(),
44
- transport: z.enum(["http", "sse"], {
45
- error: (issue) => issue.input === "stdio"
46
- ? STDIO_REJECTION
47
- : 'must declare a remote transport ("http" or "sse")',
48
- }),
49
- url: z
50
- .string("must be a non-empty URL")
51
- .refine((url) => url.trim().length > 0, "must be a non-empty URL"),
52
- headers: z.record(z.string(), z.string()).optional(),
53
- ...toolSelectionConnectorFields,
54
- })
55
- .check((ctx) => {
56
- checkToolSelectionOverlap(ctx, ctx.value);
57
- });
40
+ import { connections, isConnectionReference, } from "../../connections.js";
41
+ import { mcpServersConfig } from "./schema.js";
42
+ import { selectTools } from "../tool-selection.js";
58
43
  /**
59
- * The MCP connector's arguments.
44
+ * MCP tools loaded per declared connector, cached for the process lifetime.
60
45
  *
61
- * Shape, types, and tool-name lists are the schema's job; the rules that need
62
- * more than one field — a stdio server, a tool selected and deselected at once
63
- * — are checks with hand-written messages. Server configs stay loose because
64
- * `@langchain/mcp-adapters` accepts more per-transport options than MDA models.
46
+ * The compiled entry's graph factory runs `compileManagedAgent` on every
47
+ * invocation, but each connector's MCP connection and tool surface are stable
48
+ * for the life of the deployment — so the client is created and its tools
49
+ * loaded once per declaration, and every subsequent run reuses them. Storing
50
+ * the in-flight promise also dedupes concurrent first runs for the same
51
+ * connector. Multiple `connectors.mcp(...)` modules each get their own entry.
52
+ *
53
+ * An agent-owned connection is read into this cache once, so rotating that
54
+ * secret takes a redeploy. Servers with a user-owned connection are omitted
55
+ * entirely; the credential gate loads those per caller.
65
56
  */
66
- const mcpServersConfig = z.object({
67
- mcpServers: z
68
- .record(z.string(), remoteMcpServer, {
69
- error: "must be an object mapping server names to remote MCP server configs",
70
- })
71
- .refine((servers) => Object.keys(servers).length > 0, "requires at least one entry"),
72
- prefixToolNameWithServerName: z.boolean().optional(),
73
- throwOnLoadError: z.boolean().optional(),
74
- useStandardContentBlocks: z.boolean().optional(),
75
- onConnectionError: z.literal("throw").optional(),
76
- });
57
+ const cachedTools = new Map();
58
+ /**
59
+ * Load (and cache) the MCP tools for one connector declaration.
60
+ *
61
+ * A failed load is never cached, so a transient connection error on the first
62
+ * run can be retried on the next, but a misconfigured deployment surfaces the
63
+ * error rather than silently starting with no tools.
64
+ */
65
+ export function loadManagedMcpTools(connectors) {
66
+ const cached = cachedTools.get(connectors);
67
+ if (cached) {
68
+ return cached;
69
+ }
70
+ const loading = createClientAndLoadTools(connectors).catch((error) => {
71
+ cachedTools.delete(connectors);
72
+ throw error;
73
+ });
74
+ cachedTools.set(connectors, loading);
75
+ return loading;
76
+ }
77
+ /** Clear the process-level MCP tool cache. Test-only. */
78
+ export function clearManagedMcpToolsCacheForTests(connectors) {
79
+ if (connectors) {
80
+ cachedTools.delete(connectors);
81
+ return;
82
+ }
83
+ cachedTools.clear();
84
+ }
85
+ /**
86
+ * The credential gate's view of the declared MCP connectors.
87
+ *
88
+ * One consumer per declaration that names a user-owned connection; a
89
+ * declaration that needs no grant never reaches the gate.
90
+ */
91
+ export function mcpCredentialConsumers(connectors) {
92
+ const out = [];
93
+ for (const connector of connectors ?? []) {
94
+ if (!connector ||
95
+ typeof connector !== "object" ||
96
+ connector.kind !== "mcp_servers") {
97
+ continue;
98
+ }
99
+ const definition = connector;
100
+ const userConnections = userConnectionReferences(definition);
101
+ if (userConnections.length === 0) {
102
+ continue;
103
+ }
104
+ out.push({
105
+ declaration: definition,
106
+ credentials: userConnections,
107
+ load: (accessTokens) => loadUserConnectionMcpTools(definition, accessTokens),
108
+ });
109
+ }
110
+ return out;
111
+ }
112
+ /** The declared references themselves: the gate checks their owner. */
113
+ function userConnectionReferences(connectors) {
114
+ const bySlug = new Map();
115
+ for (const server of Object.values(connectors.mcpServers)) {
116
+ if (usesUserConnection(server)) {
117
+ const connection = server.connection;
118
+ bySlug.set(connection.slug, connection);
119
+ }
120
+ }
121
+ return [...bySlug.values()];
122
+ }
123
+ function agentConnectionReferences(connectors) {
124
+ const bySlug = new Map();
125
+ for (const server of Object.values(connectors.mcpServers)) {
126
+ const connection = server.connection;
127
+ if (isConnectionReference(connection) &&
128
+ connection.owner.type === "agent") {
129
+ bySlug.set(connection.slug, connection);
130
+ }
131
+ }
132
+ return [...bySlug.values()];
133
+ }
134
+ function mcpRequirements(name, connectors) {
135
+ const userSlugs = userConnectionReferences(connectors)
136
+ .map((connection) => connection.slug)
137
+ .sort();
138
+ const agentSlugs = agentConnectionReferences(connectors)
139
+ .map((connection) => connection.slug)
140
+ .sort();
141
+ return {
142
+ name,
143
+ provider: "mcp",
144
+ autoReply: false,
145
+ requiredPermissions: [],
146
+ requiredEnv: [],
147
+ userConnections: userSlugs,
148
+ agentConnections: agentSlugs,
149
+ providerConfig: {},
150
+ };
151
+ }
152
+ async function createClientAndLoadTools(connectors) {
153
+ const { eager, userConnection } = partitionMcpServers(connectors.mcpServers);
154
+ if (userConnection.length > 0) {
155
+ warnDeferredUserConnectionServers(userConnection);
156
+ }
157
+ if (Object.keys(eager).length === 0) {
158
+ return [];
159
+ }
160
+ const { tools } = await loadToolsFromServers(connectors, await withAgentConnections(eager));
161
+ return tools;
162
+ }
77
163
  /**
78
- * Declare the MCP servers whose tools should be loaded and added to the managed
79
- * Deep Agent at runtime.
164
+ * Load tools for user-connection servers, once the gate has confirmed the
165
+ * caller's grants.
80
166
  *
81
- * The tools hook runs at agent-graph construction time (inside the managed
82
- * runtime), so the MCP client loader is imported lazily — authoring-only
83
- * installs never pull in `@langchain/mcp-adapters`.
167
+ * Not process-cached here: the Authorization header is per caller, so the gate
168
+ * owns both the cache and closing the returned transport.
84
169
  */
170
+ export async function loadUserConnectionMcpTools(connectors, accessTokens) {
171
+ const { userConnection } = partitionMcpServers(connectors.mcpServers);
172
+ const connectable = {};
173
+ for (const name of userConnection) {
174
+ const server = connectors.mcpServers[name];
175
+ const connection = server?.connection;
176
+ if (!server || !isConnectionReference(connection)) {
177
+ continue;
178
+ }
179
+ const accessToken = accessTokens.get(connection.slug);
180
+ if (!accessToken) {
181
+ throw new Error(`MCP user connection "${connection.slug}" has no access token`);
182
+ }
183
+ connectable[name] = withBearer(server, accessToken);
184
+ }
185
+ if (Object.keys(connectable).length === 0) {
186
+ return { tools: [], close: async () => { } };
187
+ }
188
+ const { tools, client } = await loadToolsFromServers(connectors, connectable);
189
+ return { tools, close: () => client.close() };
190
+ }
191
+ /** Resolve each agent-owned connection into a static bearer header. */
192
+ async function withAgentConnections(servers) {
193
+ const out = {};
194
+ for (const [name, server] of Object.entries(servers)) {
195
+ const connection = server.connection;
196
+ out[name] = isConnectionReference(connection)
197
+ ? withBearer(server, await connections.resolveDeploymentSecret(connection.slug))
198
+ : server;
199
+ }
200
+ return out;
201
+ }
202
+ function withBearer(server, token) {
203
+ const headers = Object.fromEntries(Object.entries(server.headers ?? {}).filter(([name]) => name.toLowerCase() !== "authorization"));
204
+ return {
205
+ ...server,
206
+ headers: { ...headers, Authorization: `Bearer ${token}` },
207
+ };
208
+ }
209
+ function usesUserConnection(server) {
210
+ return (isConnectionReference(server.connection) &&
211
+ server.connection.owner.type === "user");
212
+ }
213
+ function partitionMcpServers(servers) {
214
+ const eager = {};
215
+ const userConnection = [];
216
+ for (const [name, server] of Object.entries(servers)) {
217
+ if (usesUserConnection(server)) {
218
+ userConnection.push(name);
219
+ }
220
+ else {
221
+ eager[name] = server;
222
+ }
223
+ }
224
+ return { eager, userConnection };
225
+ }
226
+ function warnDeferredUserConnectionServers(serverNames) {
227
+ console.warn(`[managed-deepagents] MCP server(s) ${serverNames.join(", ")} declare ` +
228
+ `a user connection; tools load after the pre-run credential gate ` +
229
+ `confirms grants for the caller.`);
230
+ }
231
+ function stripManagedToolSelection(servers) {
232
+ return Object.fromEntries(Object.entries(servers).map(([name, server]) => {
233
+ const { includeTools: _includeTools, excludeTools: _excludeTools, connection: _connection, ...clientConfig } = server;
234
+ return [name, clientConfig];
235
+ }));
236
+ }
237
+ async function loadToolsFromServers(connectors, connectable) {
238
+ const prefixToolNameWithServerName = connectors.prefixToolNameWithServerName ?? true;
239
+ const client = new MultiServerMCPClient({
240
+ mcpServers: stripManagedToolSelection(connectable),
241
+ prefixToolNameWithServerName,
242
+ throwOnLoadError: connectors.throwOnLoadError ?? true,
243
+ useStandardContentBlocks: connectors.useStandardContentBlocks ?? true,
244
+ onConnectionError: connectors.onConnectionError ?? "throw",
245
+ });
246
+ try {
247
+ const tools = await loadToolsByServer(client, connectable, prefixToolNameWithServerName);
248
+ if (!prefixToolNameWithServerName) {
249
+ assertNoToolNameCollisions(tools);
250
+ }
251
+ return { tools, client };
252
+ }
253
+ catch (error) {
254
+ await client.close().catch(() => undefined);
255
+ throw error;
256
+ }
257
+ }
258
+ async function loadToolsByServer(client, servers, prefixToolNameWithServerName) {
259
+ const tools = [];
260
+ for (const [serverName, server] of Object.entries(servers)) {
261
+ const serverTools = await client.getTools(serverName);
262
+ tools.push(...filterToolsForServer(serverName, server, serverTools, prefixToolNameWithServerName));
263
+ }
264
+ return tools;
265
+ }
266
+ function filterToolsForServer(serverName, selection, tools, prefixToolNameWithServerName) {
267
+ return selectTools(`MCP server "${serverName}"`, selection, tools, (tool) => {
268
+ const name = tool.name;
269
+ if (typeof name !== "string") {
270
+ return undefined;
271
+ }
272
+ const prefix = `${serverName}__`;
273
+ return prefixToolNameWithServerName && name.startsWith(prefix)
274
+ ? name.slice(prefix.length)
275
+ : name;
276
+ });
277
+ }
278
+ function assertNoToolNameCollisions(tools) {
279
+ const seen = new Set();
280
+ const collisions = new Set();
281
+ for (const tool of tools) {
282
+ const name = tool.name;
283
+ if (typeof name !== "string")
284
+ continue;
285
+ if (seen.has(name))
286
+ collisions.add(name);
287
+ seen.add(name);
288
+ }
289
+ if (collisions.size > 0) {
290
+ throw new Error(`MCP tool name collision: ${[...collisions].sort().join(", ")}. ` +
291
+ "Set `prefixToolNameWithServerName: true` (the default) so each tool is " +
292
+ "namespaced by its server, or rename the conflicting tools.");
293
+ }
294
+ }
85
295
  export const mcpConnector = defineExtension("connector", {
86
296
  kind: "mcp_servers",
87
297
  label: "connectors.mcp",
88
298
  args: mcpServersConfig,
89
- async tools(_ctx, self) {
90
- const { loadManagedMcpTools } = await import("./load.js");
91
- return loadManagedMcpTools(self);
92
- },
299
+ tools: (_ctx, self) => loadManagedMcpTools(self),
300
+ requirements: (name, self) => mcpRequirements(name, self),
93
301
  });
94
302
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connectors/mcp/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EACL,yBAAyB,EACzB,4BAA4B,GAC7B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AA8FrD,8EAA8E;AAC9E,MAAM,eAAe,GACnB,sEAAsE;IACtE,6EAA6E;IAC7E,0CAA0C,CAAC;AAE7C,MAAM,eAAe,GAAG,CAAC;KACtB,WAAW,CAAC;IACX,2EAA2E;IAC3E,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,eAAe,EAAE,CAAC,CAAC,QAAQ,EAAE;IACvD,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE;QACjC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CACf,KAAK,CAAC,KAAK,KAAK,OAAO;YACrB,CAAC,CAAC,eAAe;YACjB,CAAC,CAAC,mDAAmD;KAC1D,CAAC;IACF,GAAG,EAAE,CAAC;SACH,MAAM,CAAC,yBAAyB,CAAC;SACjC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,yBAAyB,CAAC;IACpE,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IACpD,GAAG,4BAA4B;CAChC,CAAC;KACD,KAAK,CAAC,C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AC,MAAM,CAAC;YAC3B,CAAC,CAAC,IAAI,CAAC;IACX,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,0BAA0B,CAAC,KAAgB;IAClD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;IACrC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,IAAI,GAAI,IAA2B,CAAC,IAAI,CAAC;QAC/C,IAAI,OAAO,IAAI,KAAK,QAAQ;YAAE,SAAS;QACvC,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACjB,CAAC;IACD,IAAI,UAAU,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CACb,4BAA4B,CAAC,GAAG,UAAU,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;YAC/D,yEAAyE;YACzE,4DAA4D,CAC/D,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GACvB,eAAe,CAAC,WAAW,EAAE;IAC3B,IAAI,EAAE,aAAa;IACnB,KAAK,EAAE,gBAAgB;IACvB,IAAI,EAAE,gBAAgB;IACtB,KAAK,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC;IAChD,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC;CAC1D,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { z } from "zod";
2
+ import type { McpServersConfig } from "./types.js";
3
+ /**
4
+ * The MCP connector's arguments.
5
+ *
6
+ * Shape, types, and tool-name lists are the schema's job; the rules that need
7
+ * more than one field — a stdio server, a tool selected and deselected at once
8
+ * — are checks with hand-written messages. Server configs stay loose because
9
+ * `@langchain/mcp-adapters` accepts more per-transport options than MDA models.
10
+ */
11
+ export declare const mcpServersConfig: z.ZodType<McpServersConfig, McpServersConfig>;
12
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/connectors/mcp/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAiDnD;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,EAAE,CAAC,CAAC,OAAO,CAAC,gBAAgB,EAAE,gBAAgB,CAevE,CAAC"}
@@ -0,0 +1,57 @@
1
+ import { z } from "zod";
2
+ import { appendToolSelectionOverlapIssue, optionalToolNameListSchema, } from "../tool-selection.js";
3
+ import { isConnectionReference, } from "../../connections.js";
4
+ /** Stdio servers are out of scope; the message points at the alternatives. */
5
+ const STDIO_REJECTION = "uses a stdio transport, which is not supported. Managed Deep Agents " +
6
+ "support remote MCP servers over HTTP/SSE only; expose the server over HTTP " +
7
+ "or write a normal authored tool instead.";
8
+ const CREDENTIAL_FIELD_REJECTION = 'the "credential" field was removed; use connection: connections.get(slug, owner) instead';
9
+ /** Raw MCP tool names, before the managed `{server}__` prefix is applied. */
10
+ const remoteMcpServer = z
11
+ .looseObject({
12
+ /**
13
+ * Present only to reject it: a `command` is how a stdio server is defined,
14
+ * which we don't support.
15
+ */
16
+ command: z.never({ error: STDIO_REJECTION }).optional(),
17
+ transport: z.enum(["http", "sse"], {
18
+ error: (issue) => issue.input === "stdio"
19
+ ? STDIO_REJECTION
20
+ : 'must declare a remote transport ("http" or "sse")',
21
+ }),
22
+ url: z
23
+ .string("must be a non-empty URL")
24
+ .refine((url) => url.trim().length > 0, "must be a non-empty URL"),
25
+ headers: z.record(z.string(), z.string()).optional(),
26
+ defaultToolTimeout: z
27
+ .number("defaultToolTimeout must be a positive number")
28
+ .positive("defaultToolTimeout must be a positive number")
29
+ .optional(),
30
+ includeTools: optionalToolNameListSchema,
31
+ excludeTools: optionalToolNameListSchema,
32
+ credential: z.never({ error: CREDENTIAL_FIELD_REJECTION }).optional(),
33
+ connection: z
34
+ .custom(isConnectionReference, "must be a connections.get(slug, owner) reference")
35
+ .optional(),
36
+ })
37
+ .check(appendToolSelectionOverlapIssue);
38
+ /**
39
+ * The MCP connector's arguments.
40
+ *
41
+ * Shape, types, and tool-name lists are the schema's job; the rules that need
42
+ * more than one field — a stdio server, a tool selected and deselected at once
43
+ * — are checks with hand-written messages. Server configs stay loose because
44
+ * `@langchain/mcp-adapters` accepts more per-transport options than MDA models.
45
+ */
46
+ export const mcpServersConfig = z.object({
47
+ mcpServers: z
48
+ .record(z.string(), remoteMcpServer, {
49
+ error: "must be an object mapping server names to remote MCP server configs",
50
+ })
51
+ .refine((servers) => Object.keys(servers).length > 0, "requires at least one entry"),
52
+ prefixToolNameWithServerName: z.boolean().optional(),
53
+ throwOnLoadError: z.boolean().optional(),
54
+ useStandardContentBlocks: z.boolean().optional(),
55
+ onConnectionError: z.literal("throw").optional(),
56
+ });
57
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/connectors/mcp/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,+BAA+B,EAC/B,0BAA0B,GAC3B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,qBAAqB,GAEtB,MAAM,sBAAsB,CAAC;AAE9B,8EAA8E;AAC9E,MAAM,eAAe,GACnB,sEAAsE;IACtE,6EAA6E;IAC7E,0CAA0C,CAAC;AAE7C,MAAM,0BAA0B,GAC9B,0FAA0F,CAAC;AAE7F,6EAA6E;AAC7E,MAAM,eAAe,G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AAqE;KACxE,CAAC;SACD,MAAM,CACL,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,EAC5C,6BAA6B,CAC9B;IACH,4BAA4B,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACpD,gBAAgB,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACxC,wBAAwB,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAChD,iBAAiB,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE;CACjD,CAAC,CAAC"}
@@ -0,0 +1,62 @@
1
+ import type { ClientConfig, StreamableHTTPConnection } from "@langchain/mcp-adapters";
2
+ import type { Connector } from "../../runtime/connector.js";
3
+ import type { ConnectionReference } from "../../connections.js";
4
+ /** Per-server MCP tool selection. Names are raw, unprefixed MCP tool names. */
5
+ export interface McpToolSelectionConfig {
6
+ /**
7
+ * Raw MCP tool names to expose from this server. Names are matched before any
8
+ * managed `{server}__` prefix is applied.
9
+ */
10
+ includeTools?: string[];
11
+ /**
12
+ * Raw MCP tool names to hide from this server. Names are matched before any
13
+ * managed `{server}__` prefix is applied.
14
+ */
15
+ excludeTools?: string[];
16
+ }
17
+ /** A connection reference resolved through Agent Auth at run time. */
18
+ export type McpServerConnection = ConnectionReference;
19
+ /** Adapter connection fields MDA forwards, excluding stdio/auth the runtime owns. */
20
+ type AdapterRemoteConnection = Omit<StreamableHTTPConnection, "transport" | "type" | "authProvider">;
21
+ /** Shared remote server options plus MDA-only tool selection and connection mode. */
22
+ export type RemoteMcpServerBaseConfig = AdapterRemoteConnection & McpToolSelectionConfig & {
23
+ /**
24
+ * Bearer connection for this server, declared with `connections.get(...)`.
25
+ * An agent owner is a workspace-shared secret read once at load; a user
26
+ * owner is the caller's grant, loaded per caller after the gate.
27
+ */
28
+ connection?: McpServerConnection;
29
+ };
30
+ /** Streamable HTTP MCP server connection. */
31
+ export type HttpMcpServerConfig = RemoteMcpServerBaseConfig & {
32
+ /** Remote transport. `"http"` selects Streamable HTTP. */
33
+ transport: "http";
34
+ };
35
+ /** Legacy SSE MCP server connection. */
36
+ export type SseMcpServerConfig = RemoteMcpServerBaseConfig & {
37
+ /** Remote transport. `"sse"` selects legacy SSE. */
38
+ transport: "sse";
39
+ };
40
+ /** A remote MCP server connection. Stdio servers are intentionally excluded. */
41
+ export type RemoteMcpServerConfig = HttpMcpServerConfig | SseMcpServerConfig;
42
+ /** {@link MultiServerMCPClient} options MDA exposes on `connectors.mcp`. */
43
+ type McpClientOptions = Pick<ClientConfig, "prefixToolNameWithServerName" | "throwOnLoadError" | "useStandardContentBlocks" | "onConnectionError">;
44
+ /** Configuration accepted by `connectors.mcp`. */
45
+ export interface McpServersConfig extends McpClientOptions {
46
+ /**
47
+ * MCP servers to connect to. Each key is the logical server name MDA uses
48
+ * for validation, tracing metadata, and tool-name prefixing.
49
+ */
50
+ mcpServers: Record<string, RemoteMcpServerConfig>;
51
+ }
52
+ /**
53
+ * The connector exported from a `connectors/` module for MCP. It is a branded
54
+ * managed {@link Connector} whose `tools` hook loads the declared MCP tools at
55
+ * runtime, plus the raw config the loader reads.
56
+ */
57
+ export interface McpServersDefinition extends McpServersConfig, Connector {
58
+ /** Internal discriminator used by the MDA loader. */
59
+ readonly kind: "mcp_servers";
60
+ }
61
+ export {};
62
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/connectors/mcp/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,wBAAwB,EACzB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,+EAA+E;AAC/E,MAA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0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/connectors/mcp/types.ts"],"names":[],"mappings":""}
@@ -20,27 +20,18 @@ export interface ToolSelection<TTool extends string = string> {
20
20
  /** Tool names to hide. Applied after {@link ToolSelection.includeTools}. */
21
21
  excludeTools?: TTool[];
22
22
  }
23
- /**
24
- * Shared authoring options for connectors that load remote tools.
25
- */
26
- export interface ToolSelectionConnectorConfig<TTool extends string = string> extends ToolSelection<TTool> {
27
- /** Timeout for each tool call (milliseconds on the TypeScript runtime). */
28
- defaultToolTimeout?: number;
29
- }
30
23
  /** Tool names: non-empty, no duplicates within one list. */
31
- export declare const toolSelectionConnectorFields: {
32
- includeTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
33
- excludeTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
34
- defaultToolTimeout: z.ZodOptional<z.ZodNumber>;
35
- };
36
- /** Shared include/exclude overlap check for connector arg schemas. */
37
- export declare function checkToolSelectionOverlap(ctx: {
24
+ export declare const optionalToolNameListSchema: z.ZodOptional<z.ZodArray<z.ZodString>>;
25
+ export declare function appendToolSelectionOverlapIssue(ctx: {
26
+ value: unknown;
38
27
  issues: {
39
- push(issue: unknown): void;
28
+ push: (issue: {
29
+ code: "custom";
30
+ input: unknown;
31
+ message: string;
32
+ }) => void;
40
33
  };
41
- value: unknown;
42
- }, value: ToolSelection): void;
43
- export declare function toolSelectionConnectorSchema<TArgs, TInput>(extra?: z.ZodRawShape): z.ZodType<TArgs, TInput>;
34
+ }): void;
44
35
  /** Read the name a selection matches a loaded tool by. */
45
36
  export type ToolNameReader = (tool: unknown) => string | undefined;
46
37
  /** Read a loaded tool's own `name`. The default for connectors that don't rename. */
@@ -1 +1 @@
1
- {"version":3,"file":"tool-selection.d.ts","sourceRoot":"","sources":["../../src/connectors/tool-selection.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;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