@openrouter/mcp 1.0.0 → 1.1.0

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 (96) hide show
  1. package/README.md +40 -159
  2. package/esm/cache.d.ts +7 -0
  3. package/esm/cache.d.ts.map +1 -0
  4. package/esm/cache.js +2 -0
  5. package/esm/cache.js.map +1 -0
  6. package/esm/create-mcp-tools.d.ts +4 -10
  7. package/esm/create-mcp-tools.d.ts.map +1 -1
  8. package/esm/create-mcp-tools.js +3 -93
  9. package/esm/create-mcp-tools.js.map +1 -1
  10. package/esm/index.d.ts +8 -12
  11. package/esm/index.d.ts.map +1 -1
  12. package/esm/index.js +1 -10
  13. package/esm/index.js.map +1 -1
  14. package/esm/schema.d.ts +7 -0
  15. package/esm/schema.d.ts.map +1 -0
  16. package/esm/schema.js +2 -0
  17. package/esm/schema.js.map +1 -0
  18. package/esm/types.d.ts +3 -150
  19. package/esm/types.d.ts.map +1 -1
  20. package/package.json +9 -12
  21. package/esm/auth/auth-resolver.d.ts +0 -14
  22. package/esm/auth/auth-resolver.d.ts.map +0 -1
  23. package/esm/auth/auth-resolver.js +0 -27
  24. package/esm/auth/auth-resolver.js.map +0 -1
  25. package/esm/auth/auth-types.d.ts +0 -33
  26. package/esm/auth/auth-types.d.ts.map +0 -1
  27. package/esm/auth/auth-types.js +0 -4
  28. package/esm/auth/auth-types.js.map +0 -1
  29. package/esm/build-tools.d.ts +0 -29
  30. package/esm/build-tools.d.ts.map +0 -1
  31. package/esm/build-tools.js +0 -80
  32. package/esm/build-tools.js.map +0 -1
  33. package/esm/cache/cache-store.d.ts +0 -24
  34. package/esm/cache/cache-store.d.ts.map +0 -1
  35. package/esm/cache/cache-store.js +0 -20
  36. package/esm/cache/cache-store.js.map +0 -1
  37. package/esm/cache/cache-types.d.ts +0 -71
  38. package/esm/cache/cache-types.d.ts.map +0 -1
  39. package/esm/cache/cache-types.js +0 -49
  40. package/esm/cache/cache-types.js.map +0 -1
  41. package/esm/cache/serialize.d.ts +0 -25
  42. package/esm/cache/serialize.d.ts.map +0 -1
  43. package/esm/cache/serialize.js +0 -96
  44. package/esm/cache/serialize.js.map +0 -1
  45. package/esm/close-quietly.d.ts +0 -24
  46. package/esm/close-quietly.d.ts.map +0 -1
  47. package/esm/close-quietly.js +0 -30
  48. package/esm/close-quietly.js.map +0 -1
  49. package/esm/elicitation.d.ts +0 -11
  50. package/esm/elicitation.d.ts.map +0 -1
  51. package/esm/elicitation.js +0 -51
  52. package/esm/elicitation.js.map +0 -1
  53. package/esm/errors.d.ts +0 -82
  54. package/esm/errors.d.ts.map +0 -1
  55. package/esm/errors.js +0 -80
  56. package/esm/errors.js.map +0 -1
  57. package/esm/handle.d.ts +0 -66
  58. package/esm/handle.d.ts.map +0 -1
  59. package/esm/handle.js +0 -323
  60. package/esm/handle.js.map +0 -1
  61. package/esm/mcp-connection.d.ts +0 -142
  62. package/esm/mcp-connection.d.ts.map +0 -1
  63. package/esm/mcp-connection.js +0 -477
  64. package/esm/mcp-connection.js.map +0 -1
  65. package/esm/rehydrate.d.ts +0 -76
  66. package/esm/rehydrate.d.ts.map +0 -1
  67. package/esm/rehydrate.js +0 -499
  68. package/esm/rehydrate.js.map +0 -1
  69. package/esm/resource-tools.d.ts +0 -17
  70. package/esm/resource-tools.d.ts.map +0 -1
  71. package/esm/resource-tools.js +0 -155
  72. package/esm/resource-tools.js.map +0 -1
  73. package/esm/result-mapper.d.ts +0 -19
  74. package/esm/result-mapper.d.ts.map +0 -1
  75. package/esm/result-mapper.js +0 -40
  76. package/esm/result-mapper.js.map +0 -1
  77. package/esm/schema/json-schema-guards.d.ts +0 -14
  78. package/esm/schema/json-schema-guards.d.ts.map +0 -1
  79. package/esm/schema/json-schema-guards.js +0 -19
  80. package/esm/schema/json-schema-guards.js.map +0 -1
  81. package/esm/schema/json-schema-to-zod.d.ts +0 -20
  82. package/esm/schema/json-schema-to-zod.d.ts.map +0 -1
  83. package/esm/schema/json-schema-to-zod.js +0 -72
  84. package/esm/schema/json-schema-to-zod.js.map +0 -1
  85. package/esm/tool-wrapper.d.ts +0 -41
  86. package/esm/tool-wrapper.d.ts.map +0 -1
  87. package/esm/tool-wrapper.js +0 -131
  88. package/esm/tool-wrapper.js.map +0 -1
  89. package/esm/transport-types.d.ts +0 -45
  90. package/esm/transport-types.d.ts.map +0 -1
  91. package/esm/transport-types.js +0 -2
  92. package/esm/transport-types.js.map +0 -1
  93. package/esm/version.d.ts +0 -3
  94. package/esm/version.d.ts.map +0 -1
  95. package/esm/version.js +0 -5
  96. package/esm/version.js.map +0 -1
package/esm/types.d.ts CHANGED
@@ -1,153 +1,6 @@
1
- import type { Tool, ToolLoopKey } from '@openrouter/agent/tool-types';
2
- import type { MCPAuth } from './auth/auth-types.js';
3
- import type { MCPCacheStore } from './cache/cache-store.js';
4
- import type { UnconvertibleSchemaMode } from './schema/json-schema-to-zod.js';
5
- import type { MCPProtocolNegotiation, MCPProtocolRevision, MCPTransportKind } from './transport-types.js';
6
- export type { MCPProtocolNegotiation, MCPProtocolRevision, MCPTransportKind };
7
1
  /**
8
- * Response to a server-initiated elicitation request. `accept` must carry
9
- * `content` matching the server's `requestedSchema`.
2
+ * @deprecated Import from `@openrouter/agent/mcp/types` instead.
3
+ * This compatibility subpath remains available for migration.
10
4
  */
11
- export type ElicitationResponse = {
12
- action: 'accept';
13
- content: Record<string, unknown>;
14
- } | {
15
- action: 'decline';
16
- } | {
17
- action: 'cancel';
18
- };
19
- /**
20
- * Handler for server-initiated `elicitation/create` requests during a tool
21
- * call. If omitted from options, requests are auto-declined so a tool call
22
- * needing input fails gracefully rather than hanging.
23
- */
24
- export type ElicitationHandler = (request: {
25
- message: string;
26
- requestedSchema: Record<string, unknown>;
27
- }) => Promise<ElicitationResponse> | ElicitationResponse;
28
- /** How MCP resources are exposed to the model. */
29
- export type ResourcesOption = boolean | {
30
- mode?: 'synthetic-tools';
31
- };
32
- export interface CreateMCPToolsOptions {
33
- /** Remote MCP server endpoint. */
34
- url: string | URL;
35
- /** Transport to use; defaults to `streamableHttp` with SSE fallback. */
36
- transport?: MCPTransportKind;
37
- /**
38
- * Protocol-revision negotiation policy. Defaults to `'auto'`, which probes
39
- * the server and speaks either 2025-11-25 or 2026-07-28 as appropriate.
40
- */
41
- protocolNegotiation?: MCPProtocolNegotiation;
42
- /**
43
- * Ceiling on the `server/discover` probe, in ms. Defaults to 30000 —
44
- * `DEFAULT_PROBE_TIMEOUT_MS` in `mcp-connection.ts` is the source of truth.
45
- *
46
- * Raise it for a server slow to answer its first request. The SDK's own default
47
- * is the full request timeout, which makes a hanging gateway far slower to fail
48
- * than it needs to be.
49
- */
50
- probeTimeoutMs?: number;
51
- /** Authentication, supplied once and reused for discovery + every call. */
52
- auth?: MCPAuth;
53
- /** Custom fetch implementation for all network requests. */
54
- fetch?: typeof fetch;
55
- /**
56
- * Client identity self-reported to the server while connecting — via the
57
- * `initialize` handshake on revision 2025-11-25, or the per-request `_meta`
58
- * envelope on 2026-07-28 (which has no `initialize`). Honoured on both.
59
- */
60
- clientInfo?: {
61
- name: string;
62
- version: string;
63
- };
64
- /** Prefix applied to every wrapped tool name (e.g. `"github_"`). */
65
- toolNamePrefix?: string;
66
- /**
67
- * Allow-list of MCP tool names to expose. Applies to discovered MCP tools
68
- * only; synthetic `list_resources`/`read_resource` tools are controlled
69
- * exclusively by `resources`.
70
- */
71
- includeTools?: readonly string[];
72
- /**
73
- * Deny-list of MCP tool names to skip. Applies to discovered MCP tools only;
74
- * synthetic `list_resources`/`read_resource` tools are controlled
75
- * exclusively by `resources`.
76
- */
77
- excludeTools?: readonly string[];
78
- /** Behavior when a tool's JSON Schema can't be fully represented in Zod. */
79
- onUnconvertibleSchema?: UnconvertibleSchemaMode;
80
- /** Cache store + key for automatic rehydrate-on-hit / write-on-miss. */
81
- cache?: {
82
- store: MCPCacheStore;
83
- key?: string;
84
- };
85
- /**
86
- * Persist resolved credentials (bearer/header values, or the OAuth provider's
87
- * current tokens) into the snapshot. Off by default. Session ids are never
88
- * serialized — protocol sessions are removed in revision 2026-07-28
89
- * (SEP-2567), and a rehydrate always performs a fresh handshake.
90
- */
91
- cacheCredentials?: boolean;
92
- /** Re-list tools when a cached snapshot is older than this. */
93
- staleness?: {
94
- maxAgeMs?: number;
95
- };
96
- /** Expose resources as synthetic `list_resources`/`read_resource` tools. */
97
- resources?: ResourcesOption;
98
- /** Map MCP progress notifications to generator-tool events. Default true. */
99
- emitProgress?: boolean;
100
- /**
101
- * Doom-loop identities for wrapped tools (see the `doomLoop` option on
102
- * `callModel`), keyed by the tool's UNPREFIXED MCP name. Any `ToolLoopKey`
103
- * form: a function computing key material, a declarative field-name array
104
- * (e.g. `{ run_command: ['command', 'cwd'] }`), or `false` to exempt a
105
- * tool. Takes precedence over a server-advertised
106
- * `_meta['openrouter/loopKey']` declaration. Function forms are
107
- * client-side only (they cannot be cached or transported); prefer field
108
- * lists where possible.
109
- */
110
- loopKeys?: Readonly<Record<string, ToolLoopKey<Record<string, unknown>>>>;
111
- /** Auto-refresh tools on `tools/list_changed`. Default true when connected. */
112
- autoRefreshOnListChanged?: boolean;
113
- /**
114
- * Handler for elicitation requests; auto-declines when omitted.
115
- *
116
- * Works against both protocol revisions. On 2025-11-25 the server sends
117
- * `elicitation/create` directly. On 2026-07-28 that request no longer
118
- * exists — the server answers with an `input_required` result instead
119
- * (SEP-2322) — but the SDK's multi-round-trip driver dispatches it through
120
- * this same handler and then retries the original call, so callers see
121
- * identical behavior either way.
122
- */
123
- onElicitation?: ElicitationHandler;
124
- /**
125
- * Abort signal threaded into every underlying `callTool` — and, new in this
126
- * release, into the connection itself: connecting, the negotiation probe, the
127
- * implicit legacy retry, and any reconnect all abort with it. An early
128
- * cancellation can therefore surface as a connection failure, not only as a
129
- * cancelled tool call.
130
- */
131
- signal?: AbortSignal;
132
- }
133
- /**
134
- * Handle returned by {@link createMCPTools}/`rehydrateMCPTools`. Holds a live
135
- * connection (unless rehydrated offline) and the wrapped tools.
136
- */
137
- export interface MCPToolsHandle {
138
- /** Tools ready to pass into `callModel({ tools })`. */
139
- readonly tools: readonly Tool[];
140
- readonly serverInfo?: {
141
- name?: string;
142
- version?: string;
143
- };
144
- /** Snapshot for persistence; omits credentials unless `cacheCredentials`. */
145
- serialize(): Promise<import('./cache/cache-types.js').SerializedMCPServer>;
146
- /** Force a fresh `listTools()` and rebuild the tool set. */
147
- refresh(): Promise<readonly Tool[]>;
148
- /** Subscribe to auto-refreshes triggered by `tools/list_changed`. */
149
- onToolsChanged(listener: (tools: readonly Tool[]) => void): () => void;
150
- /** Close the transport and underlying client. */
151
- close(): Promise<void>;
152
- }
5
+ export type { CreateMCPToolsOptions, ElicitationHandler, ElicitationResponse, MCPProtocolNegotiation, MCPProtocolRevision, MCPToolsHandle, MCPTransportKind, ResourcesOption, } from '@openrouter/agent/mcp/types';
153
6
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,KAAK,EACV,sBAAsB,EACtB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,CAAC;AAE9E;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAC3B;IACE,MAAM,EAAE,QAAQ,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,GACD;IACE,MAAM,EAAE,SAAS,CAAC;CACnB,GACD;IACE,MAAM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B,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,eAAe,GAChB,MAAM,6BAA6B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openrouter/mcp",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "engines": {
5
5
  "node": ">=20"
6
6
  },
@@ -33,12 +33,12 @@
33
33
  "default": "./esm/types.js"
34
34
  },
35
35
  "./schema": {
36
- "types": "./esm/schema/json-schema-to-zod.d.ts",
37
- "default": "./esm/schema/json-schema-to-zod.js"
36
+ "types": "./esm/schema.d.ts",
37
+ "default": "./esm/schema.js"
38
38
  },
39
39
  "./cache": {
40
- "types": "./esm/cache/cache-store.d.ts",
41
- "default": "./esm/cache/cache-store.js"
40
+ "types": "./esm/cache.d.ts",
41
+ "default": "./esm/cache.js"
42
42
  },
43
43
  "./package.json": "./package.json"
44
44
  },
@@ -59,18 +59,15 @@
59
59
  ],
60
60
  "dependencies": {
61
61
  "@modelcontextprotocol/client": "^2.0.0",
62
- "zod": "^4.0.0",
63
- "@openrouter/agent": "0.9.0"
62
+ "@openrouter/agent": "0.10.0"
64
63
  },
65
64
  "scripts": {
66
65
  "lint": "biome check src tests",
67
66
  "lint:fix": "biome check --write src tests",
68
- "gen:version": "node scripts/gen-version.mjs",
69
- "build": "node scripts/gen-version.mjs && tsc",
67
+ "build": "tsc",
70
68
  "test": "vitest --run --project unit",
71
- "test:e2e": "vitest --run --project e2e",
72
69
  "test:watch": "vitest --watch --project unit",
73
- "typecheck": "tsc --noEmit",
74
- "compile": "node scripts/gen-version.mjs && tsc"
70
+ "typecheck": "pnpm run build && tsc --noEmit -p tsconfig.typecheck.json",
71
+ "compile": "tsc"
75
72
  }
76
73
  }
@@ -1,14 +0,0 @@
1
- import type { OAuthClientProvider } from '@modelcontextprotocol/client';
2
- import type { MCPAuth } from './auth-types.js';
3
- /**
4
- * The transport-level pieces derived from an {@link MCPAuth}: static headers to
5
- * merge into `requestInit`, and/or an OAuth provider to hand to the transport.
6
- * Both flow into the same connected client, so discovery and tool calls share
7
- * one authenticated session.
8
- */
9
- export interface ResolvedAuth {
10
- headers: Record<string, string>;
11
- authProvider?: OAuthClientProvider;
12
- }
13
- export declare function resolveAuth(auth: MCPAuth | undefined): ResolvedAuth;
14
- //# sourceMappingURL=auth-resolver.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth-resolver.d.ts","sourceRoot":"","sources":["../../src/auth/auth-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,YAAY,CAAC,EAAE,mBAAmB,CAAC;CACpC;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,GAAG,YAAY,CAyBnE"}
@@ -1,27 +0,0 @@
1
- export function resolveAuth(auth) {
2
- if (auth === undefined) {
3
- return {
4
- headers: {},
5
- };
6
- }
7
- switch (auth.kind) {
8
- case 'bearer':
9
- return {
10
- headers: {
11
- Authorization: `Bearer ${auth.token}`,
12
- },
13
- };
14
- case 'headers':
15
- return {
16
- headers: {
17
- ...auth.headers,
18
- },
19
- };
20
- case 'oauth':
21
- return {
22
- headers: {},
23
- authProvider: auth.provider,
24
- };
25
- }
26
- }
27
- //# sourceMappingURL=auth-resolver.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth-resolver.js","sourceRoot":"","sources":["../../src/auth/auth-resolver.ts"],"names":[],"mappings":"AAcA,MAAM,UAAU,WAAW,CAAC,IAAyB;IACnD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO;YACL,OAAO,EAAE,EAAE;SACZ,CAAC;IACJ,CAAC;IACD,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,QAAQ;YACX,OAAO;gBACL,OAAO,EAAE;oBACP,aAAa,EAAE,UAAU,IAAI,CAAC,KAAK,EAAE;iBACtC;aACF,CAAC;QACJ,KAAK,SAAS;YACZ,OAAO;gBACL,OAAO,EAAE;oBACP,GAAG,IAAI,CAAC,OAAO;iBAChB;aACF,CAAC;QACJ,KAAK,OAAO;YACV,OAAO;gBACL,OAAO,EAAE,EAAE;gBACX,YAAY,EAAE,IAAI,CAAC,QAAQ;aAC5B,CAAC;IACN,CAAC;AACH,CAAC"}
@@ -1,33 +0,0 @@
1
- import type { OAuthClientProvider } from '@modelcontextprotocol/client';
2
- /**
3
- * The OAuth provider contract expected by {@link MCPAuth}'s `oauth` variant.
4
- *
5
- * Re-exported under our own name so consumers can type their provider without
6
- * importing from `@modelcontextprotocol/client` directly — that import path is
7
- * an implementation detail of this package and has changed once already.
8
- */
9
- export type MCPOAuthClientProvider = OAuthClientProvider;
10
- /**
11
- * Authentication for a remote MCP server. Supplied once and reused by the
12
- * connected client for tool discovery and every subsequent tool call.
13
- *
14
- * - `bearer`: a static bearer token sent as `Authorization: Bearer <token>`.
15
- * - `headers`: arbitrary static headers (e.g. API keys, custom auth schemes).
16
- * - `oauth`: a user-supplied {@link OAuthClientProvider} that owns token
17
- * acquisition/refresh. Preferred over caching static tokens.
18
- */
19
- export type MCPAuth = {
20
- kind: 'bearer';
21
- token: string;
22
- } | {
23
- kind: 'headers';
24
- headers: Readonly<Record<string, string>>;
25
- } | {
26
- kind: 'oauth';
27
- provider: OAuthClientProvider;
28
- };
29
- export declare function isOAuthAuth(auth: MCPAuth | undefined): auth is {
30
- kind: 'oauth';
31
- provider: OAuthClientProvider;
32
- };
33
- //# sourceMappingURL=auth-types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth-types.d.ts","sourceRoot":"","sources":["../../src/auth/auth-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAExE;;;;;;GAMG;AACH,MAAM,MAAM,sBAAsB,GAAG,mBAAmB,CAAC;AAEzD;;;;;;;;GAQG;AACH,MAAM,MAAM,OAAO,GACf;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf,GACD;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAC3C,GACD;IACE,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,mBAAmB,CAAC;CAC/B,CAAC;AAEN,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,IAAI;IAC9D,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,mBAAmB,CAAC;CAC/B,CAEA"}
@@ -1,4 +0,0 @@
1
- export function isOAuthAuth(auth) {
2
- return auth?.kind === 'oauth';
3
- }
4
- //# sourceMappingURL=auth-types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth-types.js","sourceRoot":"","sources":["../../src/auth/auth-types.ts"],"names":[],"mappings":"AAkCA,MAAM,UAAU,WAAW,CAAC,IAAyB;IAInD,OAAO,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC;AAChC,CAAC"}
@@ -1,29 +0,0 @@
1
- import type { Client } from '@modelcontextprotocol/client';
2
- import type { Tool, ToolLoopKey } from '@openrouter/agent/tool-types';
3
- import type { UnconvertibleSchemaMode } from './schema/json-schema-to-zod.js';
4
- import type { McpToolDef } from './tool-wrapper.js';
5
- import type { ResourcesOption } from './types.js';
6
- export interface BuildToolsOptions {
7
- client: Client;
8
- toolDefs: readonly McpToolDef[];
9
- namePrefix?: string;
10
- includeTools?: readonly string[];
11
- excludeTools?: readonly string[];
12
- schemaMode?: UnconvertibleSchemaMode;
13
- emitProgress?: boolean;
14
- /** Per-tool doom-loop identities, keyed by unprefixed MCP tool name. */
15
- loopKeys?: Readonly<Record<string, ToolLoopKey<Record<string, unknown>>>>;
16
- signal?: AbortSignal;
17
- resources?: ResourcesOption;
18
- /** Whether the server advertised the resources capability. */
19
- serverHasResources: boolean;
20
- }
21
- /** Apply allow/deny filters to discovered MCP tool definitions. */
22
- export declare function filterToolDefs(defs: readonly McpToolDef[], includeTools?: readonly string[], excludeTools?: readonly string[]): McpToolDef[];
23
- /**
24
- * Build the full ordered tool list for a handle: filtered + wrapped MCP tools,
25
- * plus synthetic resource tools when enabled. Throws on a name collision so two
26
- * tools never silently shadow each other in `callModel`.
27
- */
28
- export declare function buildTools(options: BuildToolsOptions): Tool[];
29
- //# sourceMappingURL=build-tools.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build-tools.d.ts","sourceRoot":"","sources":["../src/build-tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAGtE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,SAAS,UAAU,EAAE,CAAC;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,UAAU,CAAC,EAAE,uBAAuB,CAAC;IACrC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,wEAAwE;IACxE,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1E,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,8DAA8D;IAC9D,kBAAkB,EAAE,OAAO,CAAC;CAC7B;AASD,mEAAmE;AACnE,wBAAgB,cAAc,CAC5B,IAAI,EAAE,SAAS,UAAU,EAAE,EAC3B,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,EAChC,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,GAC/B,UAAU,EAAE,CASd;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,EAAE,CAwC7D"}
@@ -1,80 +0,0 @@
1
- import { MCPError } from './errors.js';
2
- import { buildResourceTools } from './resource-tools.js';
3
- import { wrapMcpTool } from './tool-wrapper.js';
4
- function resourcesEnabled(option) {
5
- if (option === undefined) {
6
- return true;
7
- }
8
- return option === true || (typeof option === 'object' && option !== null);
9
- }
10
- /** Apply allow/deny filters to discovered MCP tool definitions. */
11
- export function filterToolDefs(defs, includeTools, excludeTools) {
12
- const include = includeTools !== undefined ? new Set(includeTools) : undefined;
13
- const exclude = new Set(excludeTools ?? []);
14
- return defs.filter((def) => {
15
- if (include !== undefined && !include.has(def.name)) {
16
- return false;
17
- }
18
- return !exclude.has(def.name);
19
- });
20
- }
21
- /**
22
- * Build the full ordered tool list for a handle: filtered + wrapped MCP tools,
23
- * plus synthetic resource tools when enabled. Throws on a name collision so two
24
- * tools never silently shadow each other in `callModel`.
25
- */
26
- export function buildTools(options) {
27
- const filtered = filterToolDefs(options.toolDefs, options.includeTools, options.excludeTools);
28
- const wrapOptions = {
29
- client: options.client,
30
- ...(options.namePrefix !== undefined && {
31
- namePrefix: options.namePrefix,
32
- }),
33
- ...(options.schemaMode !== undefined && {
34
- schemaMode: options.schemaMode,
35
- }),
36
- ...(options.emitProgress !== undefined && {
37
- emitProgress: options.emitProgress,
38
- }),
39
- ...(options.loopKeys !== undefined && {
40
- loopKeys: options.loopKeys,
41
- }),
42
- ...(options.signal !== undefined && {
43
- signal: options.signal,
44
- }),
45
- };
46
- const tools = filtered.map((def) => wrapMcpTool(def, wrapOptions));
47
- if (options.serverHasResources && resourcesEnabled(options.resources)) {
48
- tools.push(...buildResourceTools({
49
- client: options.client,
50
- ...(options.namePrefix !== undefined && {
51
- namePrefix: options.namePrefix,
52
- }),
53
- ...(options.signal !== undefined && {
54
- signal: options.signal,
55
- }),
56
- }));
57
- }
58
- assertNoDuplicateNames(tools);
59
- return tools;
60
- }
61
- function toolName(tool) {
62
- if ('function' in tool && typeof tool.function.name === 'string') {
63
- return tool.function.name;
64
- }
65
- return undefined;
66
- }
67
- function assertNoDuplicateNames(tools) {
68
- const seen = new Set();
69
- for (const tool of tools) {
70
- const name = toolName(tool);
71
- if (name === undefined) {
72
- continue;
73
- }
74
- if (seen.has(name)) {
75
- throw new MCPError(`Duplicate tool name "${name}". Use toolNamePrefix or excludeTools to disambiguate.`);
76
- }
77
- seen.add(name);
78
- }
79
- }
80
- //# sourceMappingURL=build-tools.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build-tools.js","sourceRoot":"","sources":["../src/build-tools.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAGzD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAmBhD,SAAS,gBAAgB,CAAC,MAAmC;IAC3D,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,MAAM,KAAK,IAAI,IAAI,CAAC,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,CAAC,CAAC;AAC5E,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,cAAc,CAC5B,IAA2B,EAC3B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AwB,IAAI,wDAAwD,CACrF,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACjB,CAAC;AACH,CAAC"}
@@ -1,24 +0,0 @@
1
- import type { SerializedMCPServer } from './cache-types.js';
2
- /**
3
- * Pluggable cache for MCP server snapshots. Implement this to back the cache
4
- * with Redis, a database, or the filesystem. All methods may be async.
5
- *
6
- * SECURITY: when `cacheCredentials` is enabled, stored snapshots contain bearer
7
- * tokens/headers — treat the store as a secret store (encrypt at rest, scope
8
- * access) and namespace keys by principal in multi-tenant setups.
9
- */
10
- export interface MCPCacheStore {
11
- get(key: string): Promise<SerializedMCPServer | null> | SerializedMCPServer | null;
12
- set(key: string, value: SerializedMCPServer): Promise<void> | void;
13
- delete?(key: string): Promise<void> | void;
14
- }
15
- /** Default in-process cache backed by a `Map`. Not shared across processes. */
16
- export declare class InMemoryMCPCacheStore implements MCPCacheStore {
17
- private readonly entries;
18
- get(key: string): SerializedMCPServer | null;
19
- set(key: string, value: SerializedMCPServer): void;
20
- delete(key: string): void;
21
- }
22
- /** Default cache key for a server URL. Override via `cache.key` for multi-tenant. */
23
- export declare function defaultCacheKey(url: string): string;
24
- //# sourceMappingURL=cache-store.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cache-store.d.ts","sourceRoot":"","sources":["../../src/cache/cache-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE5D;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,GAAG,mBAAmB,GAAG,IAAI,CAAC;IACnF,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACnE,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAC5C;AAED,+EAA+E;AAC/E,qBAAa,qBAAsB,YAAW,aAAa;IACzD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA0C;IAElE,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,mBAAmB,GAAG,IAAI;IAI5C,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,mBAAmB,GAAG,IAAI;IAIlD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;CAG1B;AAED,qFAAqF;AACrF,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEnD"}
@@ -1,20 +0,0 @@
1
- /** Default in-process cache backed by a `Map`. Not shared across processes. */
2
- export class InMemoryMCPCacheStore {
3
- constructor() {
4
- this.entries = new Map();
5
- }
6
- get(key) {
7
- return this.entries.get(key) ?? null;
8
- }
9
- set(key, value) {
10
- this.entries.set(key, value);
11
- }
12
- delete(key) {
13
- this.entries.delete(key);
14
- }
15
- }
16
- /** Default cache key for a server URL. Override via `cache.key` for multi-tenant. */
17
- export function defaultCacheKey(url) {
18
- return `openrouter-mcp:${url}`;
19
- }
20
- //# sourceMappingURL=cache-store.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cache-store.js","sourceRoot":"","sources":["../../src/cache/cache-store.ts"],"names":[],"mappings":"AAgBA,+EAA+E;AAC/E,MAAM,OAAO,qBAAqB;IAAlC;QACmB,YAAO,GAAG,IAAI,GAAG,EAA+B,CAAC;IAapE,CAAC;IAXC,GAAG,CAAC,GAAW;QACb,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC;IACvC,CAAC;IAED,GAAG,CAAC,GAAW,EAAE,KAA0B;QACzC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED,MAAM,CAAC,GAAW;QAChB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;CACF;AAED,qFAAqF;AACrF,MAAM,UAAU,eAAe,CAAC,GAAW;IACzC,OAAO,kBAAkB,GAAG,EAAE,CAAC;AACjC,CAAC"}
@@ -1,71 +0,0 @@
1
- import type { MCPTransportKind } from '../transport-types.js';
2
- /** A discovered tool definition as stored in a cache snapshot. */
3
- export interface SerializedMCPToolDef {
4
- name: string;
5
- description?: string;
6
- inputSchema: Readonly<Record<string, unknown>>;
7
- outputSchema?: Readonly<Record<string, unknown>>;
8
- /** Server-advertised doom-loop identity (field list or `false`), if any. */
9
- loopKey?: readonly string[] | false;
10
- }
11
- /** OAuth/bearer token material, persisted only when `cacheCredentials` is on. */
12
- export interface SerializedTokenSet {
13
- accessToken: string;
14
- tokenType?: string;
15
- refreshToken?: string;
16
- /** Epoch ms; absence means unknown/no declared expiry. */
17
- expiresAt?: number;
18
- scope?: string;
19
- }
20
- /**
21
- * Serializable snapshot of a connected MCP server: enough to rebuild the tool
22
- * set (and, opt-in, reconnect with cached credentials) without re-listing or
23
- * re-authenticating.
24
- */
25
- export interface SerializedMCPServer {
26
- version: 1;
27
- url: string;
28
- transport: MCPTransportKind;
29
- serverInfo?: {
30
- name?: string;
31
- version?: string;
32
- };
33
- capabilities?: Readonly<Record<string, unknown>>;
34
- /**
35
- * Streamable HTTP session id, replayed on reconnect.
36
- *
37
- * @deprecated No longer written, and never read back. Protocol-level sessions
38
- * and the `Mcp-Session-Id` header are removed in revision 2026-07-28
39
- * (SEP-2567), where cross-call state moves to server-minted handles passed as
40
- * ordinary tool arguments.
41
- *
42
- * The field remains only so snapshots written by older versions keep
43
- * deserializing — a validator that rejected it would turn every existing cache
44
- * entry into a hard failure. Nothing populates it now: it is bearer-equivalent
45
- * to an authenticated server session, so persisting it to an external store was
46
- * attack surface for no functionality once the replay path stopped forwarding
47
- * it. Treat any value found here as untrusted legacy data. See the README.
48
- */
49
- sessionId?: string;
50
- tools: SerializedMCPToolDef[];
51
- auth?: {
52
- headers?: Readonly<Record<string, string>>;
53
- tokens?: SerializedTokenSet;
54
- };
55
- cachedAt: number;
56
- }
57
- /**
58
- * The shared "valid `cachedAt`" rule: a finite, non-negative epoch (ms).
59
- * Consumed by both the read-side snapshot validator and the write-side
60
- * serializer so the two can't drift. Rejecting negatives keeps the invariant
61
- * honest at the boundary rather than relying on downstream maxAge arithmetic to
62
- * fail-safe on a clock-skewed or garbage value.
63
- */
64
- export declare function isFiniteEpoch(value: unknown): value is number;
65
- /**
66
- * Validate an untrusted value as a {@link SerializedMCPServer}. Cache stores may
67
- * be backed by a DB or another org member's data, so snapshots are checked
68
- * structurally before use — never trusted by shape alone.
69
- */
70
- export declare function isSerializedMCPServer(value: unknown): value is SerializedMCPServer;
71
- //# sourceMappingURL=cache-types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cache-types.d.ts","sourceRoot":"","sources":["../../src/cache/cache-types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,kEAAkE;AAClE,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC/C,YAAY,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACjD,4EAA4E;IAC5E,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,KAAK,CAAC;CACrC;AAED,iFAAiF;AACjF,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,0DAA0D;IAC1D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,CAAC,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,gBAAgB,CAAC;IAC5B,UAAU,CAAC,EAAE;QACX,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,YAAY,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACjD;;;;;;;;;;;;;;OAcG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,oBAAoB,EAAE,CAAC;IAC9B,IAAI,CAAC,EAAE;QACL,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;QAC3C,MAAM,CAAC,EAAE,kBAAkB,CAAC;KAC7B,CAAC;IACF,QAAQ,EAAE,MAAM,CAAC;CAClB;AAMD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAE7D;AAmBD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,mBAAmB,CAelF"}
@@ -1,49 +0,0 @@
1
- import { isJsonSchemaObject } from '../schema/json-schema-guards.js';
2
- function isTransportKind(value) {
3
- return value === 'streamableHttp' || value === 'sse';
4
- }
5
- /**
6
- * The shared "valid `cachedAt`" rule: a finite, non-negative epoch (ms).
7
- * Consumed by both the read-side snapshot validator and the write-side
8
- * serializer so the two can't drift. Rejecting negatives keeps the invariant
9
- * honest at the boundary rather than relying on downstream maxAge arithmetic to
10
- * fail-safe on a clock-skewed or garbage value.
11
- */
12
- export function isFiniteEpoch(value) {
13
- return typeof value === 'number' && Number.isFinite(value) && value >= 0;
14
- }
15
- function isSerializedToolDef(value) {
16
- if (!isJsonSchemaObject(value)) {
17
- return false;
18
- }
19
- const loopKey = value['loopKey'];
20
- // Absent is valid (the field is optional); present must be `false` or a
21
- // string array. Anything else — a truthy scalar, a mixed array, a nested
22
- // object — is a poisoned or stale snapshot and rejects the whole entry.
23
- const hasValidLoopKey = loopKey === undefined ||
24
- loopKey === false ||
25
- (Array.isArray(loopKey) && loopKey.every((field) => typeof field === 'string'));
26
- return (typeof value['name'] === 'string' && isJsonSchemaObject(value['inputSchema']) && hasValidLoopKey);
27
- }
28
- /**
29
- * Validate an untrusted value as a {@link SerializedMCPServer}. Cache stores may
30
- * be backed by a DB or another org member's data, so snapshots are checked
31
- * structurally before use — never trusted by shape alone.
32
- */
33
- export function isSerializedMCPServer(value) {
34
- if (!isJsonSchemaObject(value)) {
35
- return false;
36
- }
37
- if (value['version'] !== 1) {
38
- return false;
39
- }
40
- if (typeof value['url'] !== 'string' || !isTransportKind(value['transport'])) {
41
- return false;
42
- }
43
- if (!isFiniteEpoch(value['cachedAt'])) {
44
- return false;
45
- }
46
- const { tools } = value;
47
- return Array.isArray(tools) && tools.every(isSerializedToolDef);
48
- }
49
- //# sourceMappingURL=cache-types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cache-types.js","sourceRoot":"","sources":["../../src/cache/cache-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AA6DrE,SAAS,eAAe,CAAC,KAAc;IACrC,OAAO,KAAK,KAAK,gBAAgB,IAAI,KAAK,KAAK,KAAK,CAAC;AACvD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AAC3E,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAc;IACzC,IAAI,CAAC,kBAAkB,CAAC,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';
2
- import type { McpToolDef } from '../tool-wrapper.js';
3
- import type { MCPTransportKind } from '../types.js';
4
- import type { SerializedMCPServer } from './cache-types.js';
5
- export interface SerializeInput {
6
- url: string;
7
- transport: MCPTransportKind;
8
- toolDefs: readonly McpToolDef[];
9
- serverInfo?: {
10
- name?: string;
11
- version?: string;
12
- };
13
- capabilities?: Readonly<Record<string, unknown>>;
14
- auth?: MCPAuth;
15
- cacheCredentials: boolean;
16
- cachedAt: number;
17
- }
18
- /**
19
- * Build a serializable snapshot. Credentials (tokens/headers) are included only
20
- * when `cacheCredentials` is true; otherwise the snapshot holds just the
21
- * structural data needed to rebuild the tool set after a fresh auth. Session ids
22
- * are never included — see the note in the `cacheCredentials` branch.
23
- */
24
- export declare function serializeServer(input: SerializeInput): Promise<SerializedMCPServer>;
25
- //# sourceMappingURL=serialize.d.ts.map