@openrouter/mcp 0.0.1 → 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.
- package/README.md +35 -4
- package/esm/cache.d.ts +7 -0
- package/esm/cache.d.ts.map +1 -0
- package/esm/cache.js +2 -0
- package/esm/cache.js.map +1 -0
- package/esm/create-mcp-tools.d.ts +4 -10
- package/esm/create-mcp-tools.d.ts.map +1 -1
- package/esm/create-mcp-tools.js +3 -72
- package/esm/create-mcp-tools.js.map +1 -1
- package/esm/index.d.ts +8 -12
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -10
- package/esm/index.js.map +1 -1
- package/esm/schema.d.ts +7 -0
- package/esm/schema.d.ts.map +1 -0
- package/esm/schema.js +2 -0
- package/esm/schema.js.map +1 -0
- package/esm/types.d.ts +3 -101
- package/esm/types.d.ts.map +1 -1
- package/package.json +14 -13
- package/esm/auth/auth-resolver.d.ts +0 -14
- package/esm/auth/auth-resolver.d.ts.map +0 -1
- package/esm/auth/auth-resolver.js +0 -27
- package/esm/auth/auth-resolver.js.map +0 -1
- package/esm/auth/auth-types.d.ts +0 -25
- package/esm/auth/auth-types.d.ts.map +0 -1
- package/esm/auth/auth-types.js +0 -4
- package/esm/auth/auth-types.js.map +0 -1
- package/esm/build-tools.d.ts +0 -27
- package/esm/build-tools.d.ts.map +0 -1
- package/esm/build-tools.js +0 -77
- package/esm/build-tools.js.map +0 -1
- package/esm/cache/cache-store.d.ts +0 -24
- package/esm/cache/cache-store.d.ts.map +0 -1
- package/esm/cache/cache-store.js +0 -20
- package/esm/cache/cache-store.js.map +0 -1
- package/esm/cache/cache-types.d.ts +0 -54
- package/esm/cache/cache-types.d.ts.map +0 -1
- package/esm/cache/cache-types.js +0 -41
- package/esm/cache/cache-types.js.map +0 -1
- package/esm/cache/serialize.d.ts +0 -25
- package/esm/cache/serialize.d.ts.map +0 -1
- package/esm/cache/serialize.js +0 -85
- package/esm/cache/serialize.js.map +0 -1
- package/esm/elicitation.d.ts +0 -11
- package/esm/elicitation.d.ts.map +0 -1
- package/esm/elicitation.js +0 -51
- package/esm/elicitation.js.map +0 -1
- package/esm/errors.d.ts +0 -35
- package/esm/errors.d.ts.map +0 -1
- package/esm/errors.js +0 -39
- package/esm/errors.js.map +0 -1
- package/esm/handle.d.ts +0 -41
- package/esm/handle.d.ts.map +0 -1
- package/esm/handle.js +0 -221
- package/esm/handle.js.map +0 -1
- package/esm/mcp-connection.d.ts +0 -35
- package/esm/mcp-connection.d.ts.map +0 -1
- package/esm/mcp-connection.js +0 -147
- package/esm/mcp-connection.js.map +0 -1
- package/esm/rehydrate.d.ts +0 -41
- package/esm/rehydrate.d.ts.map +0 -1
- package/esm/rehydrate.js +0 -173
- package/esm/rehydrate.js.map +0 -1
- package/esm/resource-tools.d.ts +0 -17
- package/esm/resource-tools.d.ts.map +0 -1
- package/esm/resource-tools.js +0 -133
- package/esm/resource-tools.js.map +0 -1
- package/esm/result-mapper.d.ts +0 -19
- package/esm/result-mapper.d.ts.map +0 -1
- package/esm/result-mapper.js +0 -40
- package/esm/result-mapper.js.map +0 -1
- package/esm/schema/json-schema-guards.d.ts +0 -14
- package/esm/schema/json-schema-guards.d.ts.map +0 -1
- package/esm/schema/json-schema-guards.js +0 -19
- package/esm/schema/json-schema-guards.js.map +0 -1
- package/esm/schema/json-schema-to-zod.d.ts +0 -20
- package/esm/schema/json-schema-to-zod.d.ts.map +0 -1
- package/esm/schema/json-schema-to-zod.js +0 -72
- package/esm/schema/json-schema-to-zod.js.map +0 -1
- package/esm/tool-wrapper.d.ts +0 -26
- package/esm/tool-wrapper.d.ts.map +0 -1
- package/esm/tool-wrapper.js +0 -118
- package/esm/tool-wrapper.js.map +0 -1
- package/esm/transport-types.d.ts +0 -3
- package/esm/transport-types.d.ts.map +0 -1
- package/esm/transport-types.js +0 -2
- package/esm/transport-types.js.map +0 -1
package/esm/handle.js
DELETED
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
import { buildTools } from './build-tools.js';
|
|
2
|
-
import { serializeServer } from './cache/serialize.js';
|
|
3
|
-
import { connect } from './mcp-connection.js';
|
|
4
|
-
export function normalizeUrl(url) {
|
|
5
|
-
return url instanceof URL ? url : new URL(url);
|
|
6
|
-
}
|
|
7
|
-
// Hard cap on pagination pages. A well-behaved server terminates the cursor
|
|
8
|
-
// chain by omitting `nextCursor`; this bounds a misbehaving one that never does.
|
|
9
|
-
const MAX_LIST_PAGES = 1000;
|
|
10
|
-
/**
|
|
11
|
-
* Normalize a paginated `nextCursor` field: treat anything that is not a
|
|
12
|
-
* non-empty string as "no more pages" so a malformed cursor terminates the loop.
|
|
13
|
-
*/
|
|
14
|
-
function nextCursorOrUndefined(value) {
|
|
15
|
-
return typeof value === 'string' && value.length > 0 ? value : undefined;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Read the discovered tools off the live connection into our internal shape.
|
|
19
|
-
*
|
|
20
|
-
* `tools/list` is paginated: each response may carry a `nextCursor` that must be
|
|
21
|
-
* passed back as `{ cursor }` to fetch the next page. We accumulate every page so
|
|
22
|
-
* servers that paginate their tool list aren't silently truncated.
|
|
23
|
-
*/
|
|
24
|
-
export async function listToolDefs(connection, signal) {
|
|
25
|
-
const requestOptions = signal !== undefined
|
|
26
|
-
? {
|
|
27
|
-
signal,
|
|
28
|
-
}
|
|
29
|
-
: undefined;
|
|
30
|
-
const collected = [];
|
|
31
|
-
let cursor;
|
|
32
|
-
for (let page = 0; page < MAX_LIST_PAGES; page += 1) {
|
|
33
|
-
const params = cursor !== undefined
|
|
34
|
-
? {
|
|
35
|
-
cursor,
|
|
36
|
-
}
|
|
37
|
-
: undefined;
|
|
38
|
-
const { tools, nextCursor } = await connection.client.listTools(params, requestOptions);
|
|
39
|
-
for (const t of tools) {
|
|
40
|
-
collected.push({
|
|
41
|
-
name: t.name,
|
|
42
|
-
...(t.description !== undefined && {
|
|
43
|
-
description: t.description,
|
|
44
|
-
}),
|
|
45
|
-
inputSchema: t.inputSchema,
|
|
46
|
-
...(t.outputSchema !== undefined && {
|
|
47
|
-
outputSchema: t.outputSchema,
|
|
48
|
-
}),
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
const next = nextCursorOrUndefined(nextCursor);
|
|
52
|
-
// Stop at the end of the chain, or if the server echoes the same cursor
|
|
53
|
-
// (which would otherwise spin forever).
|
|
54
|
-
if (next === undefined || next === cursor) {
|
|
55
|
-
break;
|
|
56
|
-
}
|
|
57
|
-
cursor = next;
|
|
58
|
-
}
|
|
59
|
-
return collected;
|
|
60
|
-
}
|
|
61
|
-
function serverHasResources(connection) {
|
|
62
|
-
const caps = connection.client.getServerCapabilities();
|
|
63
|
-
return caps?.resources !== undefined;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Connect, discover tools via `listTools()`, and build a handle WITHOUT
|
|
67
|
-
* consulting the cache for a hit. The cache (when present on `options`) is still
|
|
68
|
-
* written through `makeHandle`, so refreshes persist. This is the cold cache-miss
|
|
69
|
-
* path, and is also called directly by `rehydrateMCPTools`'s fallback: routing
|
|
70
|
-
* the fallback here instead of back through `createMCPTools` is what prevents the
|
|
71
|
-
* cache-fallback loop — re-reading the same snapshot would re-enter rehydrate and
|
|
72
|
-
* recurse without bound.
|
|
73
|
-
*/
|
|
74
|
-
export async function freshConnect(options, url, cacheKey) {
|
|
75
|
-
const connection = await connect({
|
|
76
|
-
url,
|
|
77
|
-
...(options.transport !== undefined && {
|
|
78
|
-
transport: options.transport,
|
|
79
|
-
}),
|
|
80
|
-
...(options.auth !== undefined && {
|
|
81
|
-
auth: options.auth,
|
|
82
|
-
}),
|
|
83
|
-
...(options.fetch !== undefined && {
|
|
84
|
-
fetch: options.fetch,
|
|
85
|
-
}),
|
|
86
|
-
...(options.clientInfo !== undefined && {
|
|
87
|
-
clientInfo: options.clientInfo,
|
|
88
|
-
}),
|
|
89
|
-
...(options.onElicitation !== undefined && {
|
|
90
|
-
onElicitation: options.onElicitation,
|
|
91
|
-
}),
|
|
92
|
-
});
|
|
93
|
-
// Tear the connection down if discovery or the initial cache write throws —
|
|
94
|
-
// otherwise the open transport (HTTP keep-alive / SSE stream) leaks.
|
|
95
|
-
try {
|
|
96
|
-
const initialToolDefs = await listToolDefs(connection, options.signal);
|
|
97
|
-
return await makeHandle({
|
|
98
|
-
connection,
|
|
99
|
-
options,
|
|
100
|
-
context: {
|
|
101
|
-
url,
|
|
102
|
-
transport: connection.transport,
|
|
103
|
-
cacheKey,
|
|
104
|
-
},
|
|
105
|
-
initialToolDefs,
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
catch (err) {
|
|
109
|
-
await connection.close().catch(() => { });
|
|
110
|
-
throw err;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Construct an {@link MCPToolsHandle} around a live connection, wiring refresh,
|
|
115
|
-
* serialize, list_changed listeners, and cache writes.
|
|
116
|
-
*/
|
|
117
|
-
export async function makeHandle(args) {
|
|
118
|
-
const { connection, options, context, initialToolDefs } = args;
|
|
119
|
-
const listeners = new Set();
|
|
120
|
-
let toolDefs = initialToolDefs;
|
|
121
|
-
const serverInfo = connection.client.getServerVersion();
|
|
122
|
-
const rebuild = () => buildTools(buildToolsArgs(connection, toolDefs, options));
|
|
123
|
-
let tools = rebuild();
|
|
124
|
-
const snapshot = () => serializeServer(serializeArgs({
|
|
125
|
-
connection,
|
|
126
|
-
context,
|
|
127
|
-
toolDefs,
|
|
128
|
-
serverInfo,
|
|
129
|
-
options,
|
|
130
|
-
}));
|
|
131
|
-
const writeCache = async () => {
|
|
132
|
-
const store = options.cache?.store;
|
|
133
|
-
if (store === undefined) {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
await store.set(context.cacheKey, await snapshot());
|
|
137
|
-
};
|
|
138
|
-
const refresh = async () => {
|
|
139
|
-
toolDefs = await listToolDefs(connection, options.signal);
|
|
140
|
-
tools = rebuild();
|
|
141
|
-
await writeCache();
|
|
142
|
-
return tools;
|
|
143
|
-
};
|
|
144
|
-
if (options.autoRefreshOnListChanged ?? true) {
|
|
145
|
-
connection.setToolListChangedHandler(() => {
|
|
146
|
-
// Fire-and-forget, but never let a failed refresh escape as an unhandled
|
|
147
|
-
// rejection. On failure listeners keep the last good tool set.
|
|
148
|
-
void refresh()
|
|
149
|
-
.then((next) => {
|
|
150
|
-
for (const listener of listeners) {
|
|
151
|
-
listener(next);
|
|
152
|
-
}
|
|
153
|
-
})
|
|
154
|
-
.catch(() => { });
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
await writeCache();
|
|
158
|
-
return {
|
|
159
|
-
get tools() {
|
|
160
|
-
return tools;
|
|
161
|
-
},
|
|
162
|
-
...(serverInfo !== undefined && {
|
|
163
|
-
serverInfo,
|
|
164
|
-
}),
|
|
165
|
-
serialize: snapshot,
|
|
166
|
-
refresh,
|
|
167
|
-
onToolsChanged: (listener) => {
|
|
168
|
-
listeners.add(listener);
|
|
169
|
-
return () => listeners.delete(listener);
|
|
170
|
-
},
|
|
171
|
-
close: () => connection.close(),
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
/** Assemble the {@link buildTools} arguments, threading only the defined options. */
|
|
175
|
-
function buildToolsArgs(connection, toolDefs, options) {
|
|
176
|
-
return {
|
|
177
|
-
client: connection.client,
|
|
178
|
-
toolDefs,
|
|
179
|
-
emitProgress: options.emitProgress ?? true,
|
|
180
|
-
serverHasResources: serverHasResources(connection),
|
|
181
|
-
...(options.toolNamePrefix !== undefined && {
|
|
182
|
-
namePrefix: options.toolNamePrefix,
|
|
183
|
-
}),
|
|
184
|
-
...(options.includeTools !== undefined && {
|
|
185
|
-
includeTools: options.includeTools,
|
|
186
|
-
}),
|
|
187
|
-
...(options.excludeTools !== undefined && {
|
|
188
|
-
excludeTools: options.excludeTools,
|
|
189
|
-
}),
|
|
190
|
-
...(options.onUnconvertibleSchema !== undefined && {
|
|
191
|
-
schemaMode: options.onUnconvertibleSchema,
|
|
192
|
-
}),
|
|
193
|
-
...(options.signal !== undefined && {
|
|
194
|
-
signal: options.signal,
|
|
195
|
-
}),
|
|
196
|
-
...(options.resources !== undefined && {
|
|
197
|
-
resources: options.resources,
|
|
198
|
-
}),
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
/** Assemble the {@link serializeServer} input, threading only the defined fields. */
|
|
202
|
-
function serializeArgs(args) {
|
|
203
|
-
const { connection, context, toolDefs, serverInfo, options } = args;
|
|
204
|
-
return {
|
|
205
|
-
url: context.url.href,
|
|
206
|
-
transport: connection.transport,
|
|
207
|
-
toolDefs,
|
|
208
|
-
cacheCredentials: options.cacheCredentials ?? false,
|
|
209
|
-
cachedAt: Date.now(),
|
|
210
|
-
...(serverInfo !== undefined && {
|
|
211
|
-
serverInfo,
|
|
212
|
-
}),
|
|
213
|
-
...(connection.sessionId !== undefined && {
|
|
214
|
-
sessionId: connection.sessionId,
|
|
215
|
-
}),
|
|
216
|
-
...(options.auth !== undefined && {
|
|
217
|
-
auth: options.auth,
|
|
218
|
-
}),
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
//# sourceMappingURL=handle.js.map
|
package/esm/handle.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handle.js","sourceRoot":"","sources":["../src/handle.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAK9C,MAAM,UAAU,YAAY,CAAC,GAAiB;IAC5C,OAAO,GAAG,YAAY,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;AACjD,CAAC;AAED,4EAA4E;AAC5E,iFAAiF;AACjF,MAAM,cAAc,GAAG,IAAI,CAAC;AAE5B;;;GAGG;AACH,SAAS,qBAA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;AACJ,CAAC"}
|
package/esm/mcp-connection.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
2
|
-
import type { MCPAuth } from './auth/auth-types.js';
|
|
3
|
-
import type { ElicitationHandler, MCPTransportKind } from './types.js';
|
|
4
|
-
export interface ConnectOptions {
|
|
5
|
-
url: URL;
|
|
6
|
-
transport?: MCPTransportKind;
|
|
7
|
-
auth?: MCPAuth;
|
|
8
|
-
fetch?: typeof fetch;
|
|
9
|
-
clientInfo?: {
|
|
10
|
-
name: string;
|
|
11
|
-
version: string;
|
|
12
|
-
};
|
|
13
|
-
sessionId?: string;
|
|
14
|
-
onElicitation?: ElicitationHandler;
|
|
15
|
-
}
|
|
16
|
-
export interface MCPConnection {
|
|
17
|
-
client: Client;
|
|
18
|
-
transport: MCPTransportKind;
|
|
19
|
-
sessionId?: string;
|
|
20
|
-
/**
|
|
21
|
-
* Register a callback for `tools/list_changed`. Settable after connect so the
|
|
22
|
-
* handle can wire it to its own `refresh()`. Replaces any prior handler.
|
|
23
|
-
*/
|
|
24
|
-
setToolListChangedHandler(handler: () => void): void;
|
|
25
|
-
close(): Promise<void>;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Connect a `Client` to the MCP server. Defaults to Streamable HTTP and falls
|
|
29
|
-
* back to SSE on connection failure (legacy servers), unless a transport is
|
|
30
|
-
* pinned explicitly. Auth, the elicitation handler, and the list_changed
|
|
31
|
-
* subscription are wired into the single connected client so they apply to
|
|
32
|
-
* discovery and every tool call.
|
|
33
|
-
*/
|
|
34
|
-
export declare function connect(options: ConnectOptions): Promise<MCPConnection>;
|
|
35
|
-
//# sourceMappingURL=mcp-connection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-connection.d.ts","sourceRoot":"","sources":["../src/mcp-connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAWnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAGpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAOvE,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,GAAG,CAAC;IACT,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,UAAU,CAAC,EAAE;QACX,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,kBAAkB,CAAC;CACpC;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,gBAAgB,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,yBAAyB,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IACrD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAmFD;;;;;;GAMG;AACH,wBAAsB,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CAkD7E"}
|
package/esm/mcp-connection.js
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
2
|
-
// SSEClientTransport is deprecated upstream but intentionally supported here for
|
|
3
|
-
// legacy MCP servers that haven't migrated to Streamable HTTP.
|
|
4
|
-
import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js';
|
|
5
|
-
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
6
|
-
import { ElicitRequestSchema, ToolListChangedNotificationSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
7
|
-
import { resolveAuth } from './auth/auth-resolver.js';
|
|
8
|
-
import { makeElicitationRequestHandler } from './elicitation.js';
|
|
9
|
-
import { MCPConnectionError } from './errors.js';
|
|
10
|
-
const DEFAULT_CLIENT_INFO = {
|
|
11
|
-
name: '@openrouter/mcp',
|
|
12
|
-
version: '0.1.0',
|
|
13
|
-
};
|
|
14
|
-
function buildStreamableHttp(options) {
|
|
15
|
-
const { headers, authProvider } = resolveAuth(options.auth);
|
|
16
|
-
return new StreamableHTTPClientTransport(options.url, {
|
|
17
|
-
requestInit: {
|
|
18
|
-
headers,
|
|
19
|
-
},
|
|
20
|
-
...(authProvider !== undefined && {
|
|
21
|
-
authProvider,
|
|
22
|
-
}),
|
|
23
|
-
...(options.fetch !== undefined && {
|
|
24
|
-
fetch: options.fetch,
|
|
25
|
-
}),
|
|
26
|
-
...(options.sessionId !== undefined && {
|
|
27
|
-
sessionId: options.sessionId,
|
|
28
|
-
}),
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
function buildSse(options) {
|
|
32
|
-
const { headers, authProvider } = resolveAuth(options.auth);
|
|
33
|
-
return new SSEClientTransport(options.url, {
|
|
34
|
-
requestInit: {
|
|
35
|
-
headers,
|
|
36
|
-
},
|
|
37
|
-
...(authProvider !== undefined && {
|
|
38
|
-
authProvider,
|
|
39
|
-
}),
|
|
40
|
-
...(options.fetch !== undefined && {
|
|
41
|
-
fetch: options.fetch,
|
|
42
|
-
}),
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Runtime narrowing to `Transport`. The SDK's transport classes implement the
|
|
47
|
-
* interface, but their `.d.ts` types `sessionId` as `string | undefined` rather
|
|
48
|
-
* than `sessionId?: string`, which `exactOptionalPropertyTypes` rejects at the
|
|
49
|
-
* `connect()` call site. We confirm the structural contract at runtime instead
|
|
50
|
-
* of asserting past the variance with `as`.
|
|
51
|
-
*/
|
|
52
|
-
function isTransport(value) {
|
|
53
|
-
return (typeof value.start === 'function' &&
|
|
54
|
-
typeof value.send === 'function' &&
|
|
55
|
-
typeof value.close === 'function');
|
|
56
|
-
}
|
|
57
|
-
function makeClient(options, listChanged) {
|
|
58
|
-
const client = new Client(options.clientInfo ?? DEFAULT_CLIENT_INFO, {
|
|
59
|
-
capabilities: {
|
|
60
|
-
elicitation: {},
|
|
61
|
-
},
|
|
62
|
-
});
|
|
63
|
-
client.setRequestHandler(ElicitRequestSchema, makeElicitationRequestHandler(options.onElicitation));
|
|
64
|
-
client.setNotificationHandler(ToolListChangedNotificationSchema, () => {
|
|
65
|
-
listChanged.handler?.();
|
|
66
|
-
});
|
|
67
|
-
return client;
|
|
68
|
-
}
|
|
69
|
-
async function connectWith(client, transport) {
|
|
70
|
-
if (!isTransport(transport)) {
|
|
71
|
-
throw new MCPConnectionError('MCP transport does not implement the Transport contract');
|
|
72
|
-
}
|
|
73
|
-
await client.connect(transport);
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Connect a `Client` to the MCP server. Defaults to Streamable HTTP and falls
|
|
77
|
-
* back to SSE on connection failure (legacy servers), unless a transport is
|
|
78
|
-
* pinned explicitly. Auth, the elicitation handler, and the list_changed
|
|
79
|
-
* subscription are wired into the single connected client so they apply to
|
|
80
|
-
* discovery and every tool call.
|
|
81
|
-
*/
|
|
82
|
-
export async function connect(options) {
|
|
83
|
-
const preferred = options.transport ?? 'streamableHttp';
|
|
84
|
-
const listChanged = {
|
|
85
|
-
handler: undefined,
|
|
86
|
-
};
|
|
87
|
-
if (preferred === 'sse') {
|
|
88
|
-
const client = makeClient(options, listChanged);
|
|
89
|
-
await connectWith(client, buildSse(options));
|
|
90
|
-
return wrap({
|
|
91
|
-
client,
|
|
92
|
-
transport: 'sse',
|
|
93
|
-
listChanged,
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
// Streamable HTTP, with SSE fallback when the transport wasn't pinned.
|
|
97
|
-
const client = makeClient(options, listChanged);
|
|
98
|
-
try {
|
|
99
|
-
const http = buildStreamableHttp(options);
|
|
100
|
-
await connectWith(client, http);
|
|
101
|
-
return wrap({
|
|
102
|
-
client,
|
|
103
|
-
transport: 'streamableHttp',
|
|
104
|
-
listChanged,
|
|
105
|
-
...(http.sessionId !== undefined && {
|
|
106
|
-
sessionId: http.sessionId,
|
|
107
|
-
}),
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
catch (httpErr) {
|
|
111
|
-
if (options.transport === 'streamableHttp') {
|
|
112
|
-
throw new MCPConnectionError('Failed to connect over Streamable HTTP', {
|
|
113
|
-
cause: httpErr,
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
// Fall back to SSE on a fresh client (the failed one may be half-initialized).
|
|
117
|
-
const sseClient = makeClient(options, listChanged);
|
|
118
|
-
try {
|
|
119
|
-
await connectWith(sseClient, buildSse(options));
|
|
120
|
-
return wrap({
|
|
121
|
-
client: sseClient,
|
|
122
|
-
transport: 'sse',
|
|
123
|
-
listChanged,
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
catch (sseErr) {
|
|
127
|
-
throw new MCPConnectionError('Failed to connect over Streamable HTTP and SSE', {
|
|
128
|
-
cause: sseErr,
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
function wrap(args) {
|
|
134
|
-
const { client, transport, listChanged, sessionId } = args;
|
|
135
|
-
return {
|
|
136
|
-
client,
|
|
137
|
-
transport,
|
|
138
|
-
...(sessionId !== undefined && {
|
|
139
|
-
sessionId,
|
|
140
|
-
}),
|
|
141
|
-
setToolListChangedHandler: (handler) => {
|
|
142
|
-
listChanged.handler = handler;
|
|
143
|
-
},
|
|
144
|
-
close: () => client.close(),
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
//# sourceMappingURL=mcp-connection.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-connection.js","sourceRoot":"","sources":["../src/mcp-connection.ts"],"names":[],"mappings":"AAAA,OA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ChB,MAAM,IAAI,kBAAkB,CAAC,gDAAgD,EAAE;gBAC7E,KAAK,EAAE,MAAM;aACd,CAAC,CAAC;QACL,CAAC;IACH,CAAC;AACH,CAAC;AASD,SAAS,IAAI,CAAC,IAAc;IAC1B,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IAC3D,OAAO;QACL,MAAM;QACN,SAAS;QACT,GAAG,CAAC,SAAS,KAAK,SAAS,IAAI;YAC7B,SAAS;SACV,CAAC;QACF,yBAAyB,EAAE,CAAC,OAAmB,EAAE,EAAE;YACjD,WAAW,CAAC,OAAO,GAAG,OAAO,CAAC;QAChC,CAAC;QACD,KAAK,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE;KAC5B,CAAC;AACJ,CAAC"}
|
package/esm/rehydrate.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { MCPAuth } from './auth/auth-types.js';
|
|
2
|
-
import type { MCPCacheStore } from './cache/cache-store.js';
|
|
3
|
-
import type { SerializedMCPServer } from './cache/cache-types.js';
|
|
4
|
-
import type { UnconvertibleSchemaMode } from './schema/json-schema-to-zod.js';
|
|
5
|
-
import type { ElicitationHandler, MCPToolsHandle, ResourcesOption } from './types.js';
|
|
6
|
-
export interface RehydrateMCPToolsOptions {
|
|
7
|
-
snapshot: SerializedMCPServer;
|
|
8
|
-
/** Required when the snapshot carries no cached credentials. */
|
|
9
|
-
auth?: MCPAuth;
|
|
10
|
-
fetch?: typeof fetch;
|
|
11
|
-
onUnconvertibleSchema?: UnconvertibleSchemaMode;
|
|
12
|
-
onElicitation?: ElicitationHandler;
|
|
13
|
-
signal?: AbortSignal;
|
|
14
|
-
/** Cache to refresh on reconnect/fallback. */
|
|
15
|
-
cache?: {
|
|
16
|
-
store: MCPCacheStore;
|
|
17
|
-
key?: string;
|
|
18
|
-
};
|
|
19
|
-
/** On expiry / missing creds / connection failure, do a full reconnect. Default true. */
|
|
20
|
-
reconnectOnExpiry?: boolean;
|
|
21
|
-
toolNamePrefix?: string;
|
|
22
|
-
includeTools?: readonly string[];
|
|
23
|
-
excludeTools?: readonly string[];
|
|
24
|
-
resources?: ResourcesOption;
|
|
25
|
-
emitProgress?: boolean;
|
|
26
|
-
autoRefreshOnListChanged?: boolean;
|
|
27
|
-
cacheCredentials?: boolean;
|
|
28
|
-
clientInfo?: {
|
|
29
|
-
name: string;
|
|
30
|
-
version: string;
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Rebuild an {@link MCPToolsHandle} from a cached snapshot. On the happy path we
|
|
35
|
-
* reconnect the transport and rebuild tools directly from the snapshot —
|
|
36
|
-
* skipping `listTools()`. If cached tokens are expired, credentials are missing,
|
|
37
|
-
* or the connection fails, we transparently fall back to a full
|
|
38
|
-
* {@link createMCPTools} (unless `reconnectOnExpiry` is false).
|
|
39
|
-
*/
|
|
40
|
-
export declare function rehydrateMCPTools(options: RehydrateMCPToolsOptions): Promise<MCPToolsHandle>;
|
|
41
|
-
//# sourceMappingURL=rehydrate.d.ts.map
|
package/esm/rehydrate.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rehydrate.d.ts","sourceRoot":"","sources":["../src/rehydrate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAKlE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAE9E,OAAO,KAAK,EAEV,kBAAkB,EAClB,cAAc,EACd,eAAe,EAChB,MAAM,YAAY,CAAC;AAKpB,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,gEAAgE;IAChE,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,qBAAqB,CAAC,EAAE,uBAAuB,CAAC;IAChD,aAAa,CAAC,EAAE,kBAAkB,CAAC;IACnC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,8CAA8C;IAC9C,KAAK,CAAC,EAAE;QACN,KAAK,EAAE,aAAa,CAAC;QACrB,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;IACF,yFAAyF;IACzF,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAG5B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,UAAU,CAAC,EAAE;QACX,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH;AA2GD;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,cAAc,CAAC,CA+DzB"}
|
package/esm/rehydrate.js
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import { defaultCacheKey } from './cache/cache-store.js';
|
|
2
|
-
import { isSerializedMCPServer } from './cache/cache-types.js';
|
|
3
|
-
import { MCPCacheError } from './errors.js';
|
|
4
|
-
import { freshConnect, makeHandle } from './handle.js';
|
|
5
|
-
import { connect } from './mcp-connection.js';
|
|
6
|
-
/** Clock skew (ms) treated as "already expired" when checking cached tokens. */
|
|
7
|
-
const EXPIRY_SKEW_MS = 30000;
|
|
8
|
-
function snapshotToToolDefs(snapshot) {
|
|
9
|
-
return snapshot.tools.map((t) => ({
|
|
10
|
-
name: t.name,
|
|
11
|
-
...(t.description !== undefined && {
|
|
12
|
-
description: t.description,
|
|
13
|
-
}),
|
|
14
|
-
inputSchema: {
|
|
15
|
-
...t.inputSchema,
|
|
16
|
-
},
|
|
17
|
-
...(t.outputSchema !== undefined && {
|
|
18
|
-
outputSchema: {
|
|
19
|
-
...t.outputSchema,
|
|
20
|
-
},
|
|
21
|
-
}),
|
|
22
|
-
}));
|
|
23
|
-
}
|
|
24
|
-
/** Cached tokens are unusable if they have a known expiry within the skew window. */
|
|
25
|
-
function tokensExpired(snapshot) {
|
|
26
|
-
const expiresAt = snapshot.auth?.tokens?.expiresAt;
|
|
27
|
-
if (expiresAt === undefined) {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
return expiresAt - Date.now() <= EXPIRY_SKEW_MS;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Reconstruct an {@link MCPAuth} from credentials persisted in a snapshot (only
|
|
34
|
-
* present when it was serialized with `cacheCredentials: true`). Prefer static
|
|
35
|
-
* headers when present; otherwise fall back to the OAuth/bearer access token.
|
|
36
|
-
* Returns undefined when the snapshot carries no usable credentials.
|
|
37
|
-
*/
|
|
38
|
-
function authFromSnapshot(snapshot) {
|
|
39
|
-
const auth = snapshot.auth;
|
|
40
|
-
if (auth === undefined) {
|
|
41
|
-
return undefined;
|
|
42
|
-
}
|
|
43
|
-
if (auth.headers !== undefined && Object.keys(auth.headers).length > 0) {
|
|
44
|
-
return {
|
|
45
|
-
kind: 'headers',
|
|
46
|
-
headers: auth.headers,
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
if (auth.tokens?.accessToken !== undefined) {
|
|
50
|
-
return {
|
|
51
|
-
kind: 'bearer',
|
|
52
|
-
token: auth.tokens.accessToken,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
return undefined;
|
|
56
|
-
}
|
|
57
|
-
function toCreateOptions(options, snapshot, effectiveAuth) {
|
|
58
|
-
return {
|
|
59
|
-
url: snapshot.url,
|
|
60
|
-
transport: snapshot.transport,
|
|
61
|
-
...(effectiveAuth !== undefined && {
|
|
62
|
-
auth: effectiveAuth,
|
|
63
|
-
}),
|
|
64
|
-
...(options.fetch !== undefined && {
|
|
65
|
-
fetch: options.fetch,
|
|
66
|
-
}),
|
|
67
|
-
...(options.onUnconvertibleSchema !== undefined && {
|
|
68
|
-
onUnconvertibleSchema: options.onUnconvertibleSchema,
|
|
69
|
-
}),
|
|
70
|
-
...(options.onElicitation !== undefined && {
|
|
71
|
-
onElicitation: options.onElicitation,
|
|
72
|
-
}),
|
|
73
|
-
...(options.signal !== undefined && {
|
|
74
|
-
signal: options.signal,
|
|
75
|
-
}),
|
|
76
|
-
...(options.clientInfo !== undefined && {
|
|
77
|
-
clientInfo: options.clientInfo,
|
|
78
|
-
}),
|
|
79
|
-
...(options.toolNamePrefix !== undefined && {
|
|
80
|
-
toolNamePrefix: options.toolNamePrefix,
|
|
81
|
-
}),
|
|
82
|
-
...(options.includeTools !== undefined && {
|
|
83
|
-
includeTools: options.includeTools,
|
|
84
|
-
}),
|
|
85
|
-
...(options.excludeTools !== undefined && {
|
|
86
|
-
excludeTools: options.excludeTools,
|
|
87
|
-
}),
|
|
88
|
-
...(options.resources !== undefined && {
|
|
89
|
-
resources: options.resources,
|
|
90
|
-
}),
|
|
91
|
-
...(options.emitProgress !== undefined && {
|
|
92
|
-
emitProgress: options.emitProgress,
|
|
93
|
-
}),
|
|
94
|
-
...(options.autoRefreshOnListChanged !== undefined && {
|
|
95
|
-
autoRefreshOnListChanged: options.autoRefreshOnListChanged,
|
|
96
|
-
}),
|
|
97
|
-
...(options.cacheCredentials !== undefined && {
|
|
98
|
-
cacheCredentials: options.cacheCredentials,
|
|
99
|
-
}),
|
|
100
|
-
...(options.cache !== undefined && {
|
|
101
|
-
cache: options.cache,
|
|
102
|
-
}),
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Rebuild an {@link MCPToolsHandle} from a cached snapshot. On the happy path we
|
|
107
|
-
* reconnect the transport and rebuild tools directly from the snapshot —
|
|
108
|
-
* skipping `listTools()`. If cached tokens are expired, credentials are missing,
|
|
109
|
-
* or the connection fails, we transparently fall back to a full
|
|
110
|
-
* {@link createMCPTools} (unless `reconnectOnExpiry` is false).
|
|
111
|
-
*/
|
|
112
|
-
export async function rehydrateMCPTools(options) {
|
|
113
|
-
const { snapshot } = options;
|
|
114
|
-
if (!isSerializedMCPServer(snapshot)) {
|
|
115
|
-
throw new MCPCacheError('Invalid MCP snapshot: failed structural validation');
|
|
116
|
-
}
|
|
117
|
-
const reconnectOnExpiry = options.reconnectOnExpiry ?? true;
|
|
118
|
-
const url = new URL(snapshot.url);
|
|
119
|
-
const cacheKey = options.cache?.key ?? defaultCacheKey(url.href);
|
|
120
|
-
// Fall back to credentials cached in the snapshot when the caller didn't pass
|
|
121
|
-
// any — otherwise a credential-bearing snapshot would reconnect unauthenticated.
|
|
122
|
-
const effectiveAuth = options.auth ?? authFromSnapshot(snapshot);
|
|
123
|
-
const hasCredentials = effectiveAuth !== undefined;
|
|
124
|
-
// Route the fallback through `freshConnect`, NOT `createMCPTools`: the latter
|
|
125
|
-
// would re-read this same snapshot and re-enter rehydrate, recursing without
|
|
126
|
-
// bound on any no-credential / expired-token snapshot. `freshConnect` still
|
|
127
|
-
// writes the refreshed result back to the cache via `makeHandle`.
|
|
128
|
-
const createOptions = toCreateOptions(options, snapshot, effectiveAuth);
|
|
129
|
-
if ((tokensExpired(snapshot) || !hasCredentials) && reconnectOnExpiry) {
|
|
130
|
-
return freshConnect(createOptions, url, cacheKey);
|
|
131
|
-
}
|
|
132
|
-
try {
|
|
133
|
-
const connection = await connect({
|
|
134
|
-
url,
|
|
135
|
-
transport: snapshot.transport,
|
|
136
|
-
...(effectiveAuth !== undefined && {
|
|
137
|
-
auth: effectiveAuth,
|
|
138
|
-
}),
|
|
139
|
-
...(options.fetch !== undefined && {
|
|
140
|
-
fetch: options.fetch,
|
|
141
|
-
}),
|
|
142
|
-
...(options.clientInfo !== undefined && {
|
|
143
|
-
clientInfo: options.clientInfo,
|
|
144
|
-
}),
|
|
145
|
-
...(snapshot.sessionId !== undefined && {
|
|
146
|
-
sessionId: snapshot.sessionId,
|
|
147
|
-
}),
|
|
148
|
-
...(options.onElicitation !== undefined && {
|
|
149
|
-
onElicitation: options.onElicitation,
|
|
150
|
-
}),
|
|
151
|
-
});
|
|
152
|
-
// Rebuild tools from the snapshot — no listTools() round-trip.
|
|
153
|
-
return makeHandle({
|
|
154
|
-
connection,
|
|
155
|
-
options: createOptions,
|
|
156
|
-
context: {
|
|
157
|
-
url,
|
|
158
|
-
transport: connection.transport,
|
|
159
|
-
cacheKey,
|
|
160
|
-
},
|
|
161
|
-
initialToolDefs: snapshotToToolDefs(snapshot),
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
catch (err) {
|
|
165
|
-
if (reconnectOnExpiry) {
|
|
166
|
-
return freshConnect(createOptions, url, cacheKey);
|
|
167
|
-
}
|
|
168
|
-
throw new MCPCacheError('Failed to rehydrate MCP connection from snapshot', {
|
|
169
|
-
cause: err,
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
//# sourceMappingURL=rehydrate.js.map
|
package/esm/rehydrate.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rehydrate.js","sourceRoot":"","sources":["../src/rehydrate.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAU9C,gFAAgF;AAChF,MAAM,cAAc,GAAG,KAAM,CA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