@openrouter/mcp 1.0.0 → 1.1.1
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 +40 -159
- 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 -93
- 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 -150
- package/esm/types.d.ts.map +1 -1
- package/package.json +9 -12
- 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 -33
- 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 -29
- package/esm/build-tools.d.ts.map +0 -1
- package/esm/build-tools.js +0 -80
- 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 -71
- package/esm/cache/cache-types.d.ts.map +0 -1
- package/esm/cache/cache-types.js +0 -49
- 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 -96
- package/esm/cache/serialize.js.map +0 -1
- package/esm/close-quietly.d.ts +0 -24
- package/esm/close-quietly.d.ts.map +0 -1
- package/esm/close-quietly.js +0 -30
- package/esm/close-quietly.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 -82
- package/esm/errors.d.ts.map +0 -1
- package/esm/errors.js +0 -80
- package/esm/errors.js.map +0 -1
- package/esm/handle.d.ts +0 -66
- package/esm/handle.d.ts.map +0 -1
- package/esm/handle.js +0 -323
- package/esm/handle.js.map +0 -1
- package/esm/mcp-connection.d.ts +0 -142
- package/esm/mcp-connection.d.ts.map +0 -1
- package/esm/mcp-connection.js +0 -477
- package/esm/mcp-connection.js.map +0 -1
- package/esm/rehydrate.d.ts +0 -76
- package/esm/rehydrate.d.ts.map +0 -1
- package/esm/rehydrate.js +0 -499
- 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 -155
- 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 -41
- package/esm/tool-wrapper.d.ts.map +0 -1
- package/esm/tool-wrapper.js +0 -131
- package/esm/tool-wrapper.js.map +0 -1
- package/esm/transport-types.d.ts +0 -45
- 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/version.d.ts +0 -3
- package/esm/version.d.ts.map +0 -1
- package/esm/version.js +0 -5
- package/esm/version.js.map +0 -1
package/esm/handle.js
DELETED
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
import { buildTools } from './build-tools.js';
|
|
2
|
-
import { serializeServer } from './cache/serialize.js';
|
|
3
|
-
import { closeQuietly } from './close-quietly.js';
|
|
4
|
-
import { MCPCacheWriteError } from './errors.js';
|
|
5
|
-
import { connect } from './mcp-connection.js';
|
|
6
|
-
export function normalizeUrl(url) {
|
|
7
|
-
return url instanceof URL ? url : new URL(url);
|
|
8
|
-
}
|
|
9
|
-
// Hard cap on pagination pages. A well-behaved server terminates the cursor
|
|
10
|
-
// chain by omitting `nextCursor`; this bounds a misbehaving one that never does.
|
|
11
|
-
const MAX_LIST_PAGES = 1000;
|
|
12
|
-
/**
|
|
13
|
-
* Normalize a paginated `nextCursor` field: treat anything that is not a
|
|
14
|
-
* non-empty string as "no more pages" so a malformed cursor terminates the loop.
|
|
15
|
-
*/
|
|
16
|
-
function nextCursorOrUndefined(value) {
|
|
17
|
-
return typeof value === 'string' && value.length > 0 ? value : undefined;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Parse a server-advertised doom-loop identity from a tool definition's
|
|
21
|
-
* `_meta['openrouter/loopKey']`: a field-name array (the declarative subset
|
|
22
|
-
* of arguments identifying a call) or `false` (tool exempt). Data-only by
|
|
23
|
-
* design — functions can't cross the wire; any other shape is ignored.
|
|
24
|
-
*/
|
|
25
|
-
function advertisedLoopKey(meta) {
|
|
26
|
-
const advertised = meta?.['openrouter/loopKey'];
|
|
27
|
-
if (advertised === false) {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
if (Array.isArray(advertised) && advertised.every((f) => typeof f === 'string')) {
|
|
31
|
-
return advertised;
|
|
32
|
-
}
|
|
33
|
-
return undefined;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Read the discovered tools off the live connection into our internal shape.
|
|
37
|
-
*
|
|
38
|
-
* `tools/list` is paginated: each response may carry a `nextCursor` that must be
|
|
39
|
-
* passed back as `{ cursor }` to fetch the next page. We accumulate every page so
|
|
40
|
-
* servers that paginate their tool list aren't silently truncated.
|
|
41
|
-
*
|
|
42
|
-
* Always `cacheMode: 'refresh'`. SDK v2 keeps a per-client response cache
|
|
43
|
-
* honouring the server's `ttlMs` on `tools/list` (up to 24h), so the default
|
|
44
|
-
* `'use'` would serve a still-fresh cached list without a round trip. That is
|
|
45
|
-
* fine for an opportunistic read but wrong for every caller here: `refresh()`
|
|
46
|
-
* documents a forced re-read, `freshConnect` is establishing the tool set for the
|
|
47
|
-
* first time, and the stale-replay path exists precisely because the age of the
|
|
48
|
-
* cached list is no longer acceptable. `'refresh'` fetches and re-stores, so the
|
|
49
|
-
* cache stays warm for the SDK's own readers.
|
|
50
|
-
*
|
|
51
|
-
* `'refresh'` rather than `'bypass'` deliberately — bypass would skip the write
|
|
52
|
-
* too, leaving a stale entry behind for anything that later reads with `'use'`.
|
|
53
|
-
*/
|
|
54
|
-
export async function listToolDefs(connection, signal) {
|
|
55
|
-
const requestOptions = {
|
|
56
|
-
cacheMode: 'refresh',
|
|
57
|
-
...(signal !== undefined && {
|
|
58
|
-
signal,
|
|
59
|
-
}),
|
|
60
|
-
};
|
|
61
|
-
const collected = [];
|
|
62
|
-
let cursor;
|
|
63
|
-
for (let page = 0; page < MAX_LIST_PAGES; page += 1) {
|
|
64
|
-
const params = cursor !== undefined
|
|
65
|
-
? {
|
|
66
|
-
cursor,
|
|
67
|
-
}
|
|
68
|
-
: undefined;
|
|
69
|
-
const { tools, nextCursor } = await connection.client.listTools(params, requestOptions);
|
|
70
|
-
for (const t of tools) {
|
|
71
|
-
const loopKey = advertisedLoopKey(t._meta);
|
|
72
|
-
collected.push({
|
|
73
|
-
name: t.name,
|
|
74
|
-
...(t.description !== undefined && {
|
|
75
|
-
description: t.description,
|
|
76
|
-
}),
|
|
77
|
-
inputSchema: t.inputSchema,
|
|
78
|
-
...(t.outputSchema !== undefined && {
|
|
79
|
-
outputSchema: t.outputSchema,
|
|
80
|
-
}),
|
|
81
|
-
...(loopKey !== undefined && {
|
|
82
|
-
loopKey,
|
|
83
|
-
}),
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
const next = nextCursorOrUndefined(nextCursor);
|
|
87
|
-
// Stop at the end of the chain, or if the server echoes the same cursor
|
|
88
|
-
// (which would otherwise spin forever).
|
|
89
|
-
if (next === undefined || next === cursor) {
|
|
90
|
-
break;
|
|
91
|
-
}
|
|
92
|
-
cursor = next;
|
|
93
|
-
}
|
|
94
|
-
return collected;
|
|
95
|
-
}
|
|
96
|
-
function serverHasResources(connection) {
|
|
97
|
-
const caps = connection.client.getServerCapabilities();
|
|
98
|
-
return caps?.resources !== undefined;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Connect, discover tools via `listTools()`, and build a handle WITHOUT
|
|
102
|
-
* consulting the cache for a hit. The cache (when present on `options`) is still
|
|
103
|
-
* written through `makeHandle`, so refreshes persist. This is the cold cache-miss
|
|
104
|
-
* path, and is also called directly by `rehydrateMCPTools`'s fallback: routing
|
|
105
|
-
* the fallback here instead of back through `createMCPTools` is what prevents the
|
|
106
|
-
* cache-fallback loop — re-reading the same snapshot would re-enter rehydrate and
|
|
107
|
-
* recurse without bound.
|
|
108
|
-
*/
|
|
109
|
-
export async function freshConnect(options, url, cacheKey) {
|
|
110
|
-
const connection = await connect({
|
|
111
|
-
url,
|
|
112
|
-
...(options.transport !== undefined && {
|
|
113
|
-
transport: options.transport,
|
|
114
|
-
}),
|
|
115
|
-
...(options.auth !== undefined && {
|
|
116
|
-
auth: options.auth,
|
|
117
|
-
}),
|
|
118
|
-
...(options.fetch !== undefined && {
|
|
119
|
-
fetch: options.fetch,
|
|
120
|
-
}),
|
|
121
|
-
...(options.clientInfo !== undefined && {
|
|
122
|
-
clientInfo: options.clientInfo,
|
|
123
|
-
}),
|
|
124
|
-
...(options.onElicitation !== undefined && {
|
|
125
|
-
onElicitation: options.onElicitation,
|
|
126
|
-
}),
|
|
127
|
-
...(options.protocolNegotiation !== undefined && {
|
|
128
|
-
protocolNegotiation: options.protocolNegotiation,
|
|
129
|
-
}),
|
|
130
|
-
...(options.probeTimeoutMs !== undefined && {
|
|
131
|
-
probeTimeoutMs: options.probeTimeoutMs,
|
|
132
|
-
}),
|
|
133
|
-
...(options.signal !== undefined && {
|
|
134
|
-
signal: options.signal,
|
|
135
|
-
}),
|
|
136
|
-
});
|
|
137
|
-
// Tear the connection down if discovery or the initial cache write throws —
|
|
138
|
-
// otherwise the open transport (HTTP keep-alive / SSE stream) leaks.
|
|
139
|
-
try {
|
|
140
|
-
const initialToolDefs = await listToolDefs(connection, options.signal);
|
|
141
|
-
return await makeHandle({
|
|
142
|
-
connection,
|
|
143
|
-
options,
|
|
144
|
-
context: {
|
|
145
|
-
url,
|
|
146
|
-
transport: connection.transport,
|
|
147
|
-
cacheKey,
|
|
148
|
-
},
|
|
149
|
-
initialToolDefs,
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
catch (err) {
|
|
153
|
-
await closeQuietly(connection);
|
|
154
|
-
throw err;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Construct an {@link MCPToolsHandle} around a live connection, wiring refresh,
|
|
159
|
-
* serialize, list_changed listeners, and cache writes.
|
|
160
|
-
*/
|
|
161
|
-
export async function makeHandle(args) {
|
|
162
|
-
const { connection, options, context, initialToolDefs } = args;
|
|
163
|
-
const listeners = new Set();
|
|
164
|
-
let toolDefs = initialToolDefs;
|
|
165
|
-
// Cleared by refresh(): once we have re-listed, age is measured from now.
|
|
166
|
-
let replayedCachedAt = args.replayedCachedAt;
|
|
167
|
-
const serverInfo = connection.client.getServerVersion();
|
|
168
|
-
const rebuild = () => buildTools(buildToolsArgs(connection, toolDefs, options));
|
|
169
|
-
let tools = rebuild();
|
|
170
|
-
const snapshot = () => serializeServer(serializeArgs({
|
|
171
|
-
connection,
|
|
172
|
-
context,
|
|
173
|
-
toolDefs,
|
|
174
|
-
serverInfo,
|
|
175
|
-
options,
|
|
176
|
-
...(replayedCachedAt !== undefined && {
|
|
177
|
-
cachedAt: replayedCachedAt,
|
|
178
|
-
}),
|
|
179
|
-
}));
|
|
180
|
-
const writeCache = async () => {
|
|
181
|
-
const store = options.cache?.store;
|
|
182
|
-
if (store === undefined) {
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
// Built OUTSIDE the try: `snapshot()` can reject from the caller's own
|
|
186
|
-
// OAuth provider (`provider.tokens()`), and relabelling that as a cache
|
|
187
|
-
// write failure would send it down every "store outages are harmless"
|
|
188
|
-
// path — swallowed by the list_changed handler, ignored by
|
|
189
|
-
// `refreshStaleReplay`, and dismissed by callers following the documented
|
|
190
|
-
// `MCPCacheWriteError` pattern. Only the store op earns the tag.
|
|
191
|
-
const payload = await snapshot();
|
|
192
|
-
try {
|
|
193
|
-
await store.set(context.cacheKey, payload);
|
|
194
|
-
}
|
|
195
|
-
catch (writeErr) {
|
|
196
|
-
// Tagged so callers can tell a store outage from a failed read. The two
|
|
197
|
-
// look identical coming out of `refresh()` but mean opposite things: a
|
|
198
|
-
// failed read leaves the tool set unknown, while a failed write leaves a
|
|
199
|
-
// live connection with current tools and only a stale cache entry.
|
|
200
|
-
throw new MCPCacheWriteError('Failed to write the MCP snapshot to the cache store', {
|
|
201
|
-
cause: writeErr,
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
// INVARIANT internal callers rely on: `refresh()` swaps `tools` to a fresh
|
|
206
|
-
// array (rebuild() always allocates) exactly when the re-list succeeded, and
|
|
207
|
-
// it does so BEFORE attempting to persist. A caller that captured the old
|
|
208
|
-
// reference can therefore tell "the re-list failed" (reference unchanged)
|
|
209
|
-
// from "only something after the re-list failed" (reference changed) without
|
|
210
|
-
// inspecting the error — which no error-class check can do reliably, since
|
|
211
|
-
// persistence can fail outside the store op too (the caller's own OAuth
|
|
212
|
-
// provider rejecting inside `snapshot()`).
|
|
213
|
-
const refresh = async () => {
|
|
214
|
-
toolDefs = await listToolDefs(connection, options.signal);
|
|
215
|
-
// Re-listed, so the snapshot is genuinely current from here on.
|
|
216
|
-
replayedCachedAt = undefined;
|
|
217
|
-
tools = rebuild();
|
|
218
|
-
await writeCache();
|
|
219
|
-
return tools;
|
|
220
|
-
};
|
|
221
|
-
if (options.autoRefreshOnListChanged ?? true) {
|
|
222
|
-
connection.setToolListChangedHandler(() => {
|
|
223
|
-
// Fire-and-forget, but never let a failed refresh escape as an unhandled
|
|
224
|
-
// rejection. Whether to announce is keyed on ADOPTION (the reference
|
|
225
|
-
// swap above), not on error class: once `refresh()` has swapped `tools`,
|
|
226
|
-
// skipping the announcement would leave subscribers permanently out of
|
|
227
|
-
// sync with `handle.tools`, no matter what broke afterwards — a store
|
|
228
|
-
// outage and an OAuth provider failing during serialize gate it equally
|
|
229
|
-
// little. On a failed re-list the reference is untouched and subscribers
|
|
230
|
-
// correctly keep the last good set.
|
|
231
|
-
const before = tools;
|
|
232
|
-
void refresh()
|
|
233
|
-
.catch(() => undefined)
|
|
234
|
-
.then(() => {
|
|
235
|
-
if (tools === before) {
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
for (const listener of listeners) {
|
|
239
|
-
listener(tools);
|
|
240
|
-
}
|
|
241
|
-
})
|
|
242
|
-
.catch(() => { });
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
// Skipped entirely on a replay: with `replayedCachedAt` carried forward the
|
|
246
|
-
// snapshot we would write is the one just read — same tool defs, same
|
|
247
|
-
// `cachedAt` — so the write is an external store round-trip per rehydrate
|
|
248
|
-
// buying nothing. (It also cannot *refresh* anything: preserving the age is
|
|
249
|
-
// the point.) A cold connect writes; `refresh()` clears `replayedCachedAt`
|
|
250
|
-
// and writes. Skipping here additionally narrows DEV-766's surface — one
|
|
251
|
-
// fewer path that can rewrite a credentialed entry under different options.
|
|
252
|
-
//
|
|
253
|
-
// Best-effort when it does run: the handle is fully usable without its cache
|
|
254
|
-
// entry, so a store outage should not stop a connection that already
|
|
255
|
-
// succeeded. `refresh()` reports write failures as `MCPCacheWriteError` for
|
|
256
|
-
// callers that do care.
|
|
257
|
-
if (args.replayedCachedAt === undefined) {
|
|
258
|
-
await writeCache().catch(() => { });
|
|
259
|
-
}
|
|
260
|
-
return {
|
|
261
|
-
get tools() {
|
|
262
|
-
return tools;
|
|
263
|
-
},
|
|
264
|
-
...(serverInfo !== undefined && {
|
|
265
|
-
serverInfo,
|
|
266
|
-
}),
|
|
267
|
-
serialize: snapshot,
|
|
268
|
-
refresh,
|
|
269
|
-
onToolsChanged: (listener) => {
|
|
270
|
-
listeners.add(listener);
|
|
271
|
-
return () => listeners.delete(listener);
|
|
272
|
-
},
|
|
273
|
-
close: () => connection.close(),
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
/** Assemble the {@link buildTools} arguments, threading only the defined options. */
|
|
277
|
-
function buildToolsArgs(connection, toolDefs, options) {
|
|
278
|
-
return {
|
|
279
|
-
client: connection.client,
|
|
280
|
-
toolDefs,
|
|
281
|
-
emitProgress: options.emitProgress ?? true,
|
|
282
|
-
serverHasResources: serverHasResources(connection),
|
|
283
|
-
...(options.toolNamePrefix !== undefined && {
|
|
284
|
-
namePrefix: options.toolNamePrefix,
|
|
285
|
-
}),
|
|
286
|
-
...(options.includeTools !== undefined && {
|
|
287
|
-
includeTools: options.includeTools,
|
|
288
|
-
}),
|
|
289
|
-
...(options.excludeTools !== undefined && {
|
|
290
|
-
excludeTools: options.excludeTools,
|
|
291
|
-
}),
|
|
292
|
-
...(options.onUnconvertibleSchema !== undefined && {
|
|
293
|
-
schemaMode: options.onUnconvertibleSchema,
|
|
294
|
-
}),
|
|
295
|
-
...(options.signal !== undefined && {
|
|
296
|
-
signal: options.signal,
|
|
297
|
-
}),
|
|
298
|
-
...(options.loopKeys !== undefined && {
|
|
299
|
-
loopKeys: options.loopKeys,
|
|
300
|
-
}),
|
|
301
|
-
...(options.resources !== undefined && {
|
|
302
|
-
resources: options.resources,
|
|
303
|
-
}),
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
/** Assemble the {@link serializeServer} input, threading only the defined fields. */
|
|
307
|
-
function serializeArgs(args) {
|
|
308
|
-
const { connection, context, toolDefs, serverInfo, options } = args;
|
|
309
|
-
return {
|
|
310
|
-
url: context.url.href,
|
|
311
|
-
transport: connection.transport,
|
|
312
|
-
toolDefs,
|
|
313
|
-
cacheCredentials: options.cacheCredentials ?? false,
|
|
314
|
-
cachedAt: args.cachedAt ?? Date.now(),
|
|
315
|
-
...(serverInfo !== undefined && {
|
|
316
|
-
serverInfo,
|
|
317
|
-
}),
|
|
318
|
-
...(options.auth !== undefined && {
|
|
319
|
-
auth: options.auth,
|
|
320
|
-
}),
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
//# 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;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,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,CA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AAG,CAAC,OAAO,CAAC,MAAM,KAAK,SAAS,IAAI;YAClC,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC;QACF,GAAG,CAAC,OAAO,CAAC,QAAQ,KAAK,SAAS,IAAI;YACpC,QAAQ,EAAE,OAAO,CAAC,QAAQ;SAC3B,CAAC;QACF,GAAG,CAAC,OAAO,CAAC,SAAS,KAAK,SAAS,IAAI;YACrC,SAAS,EAAE,OAAO,CAAC,SAAS;SAC7B,CAAC;KACH,CAAC;AACJ,CAAC;AAiBD,qFAAqF;AACrF,SAAS,aAAa,CAAC,IAAwB;IAC7C,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACpE,OAAO;QACL,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI;QACrB,SAAS,EAAE,UAAU,CAAC,SAAS;QAC/B,QAAQ;QACR,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,IAAI,KAAK;QACnD,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,GAAG,EAAE;QACrC,GAAG,CAAC,UAAU,KAAK,SAAS,IAAI;YAC9B,UAAU;SACX,CAAC;QACF,GAAG,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS,IAAI;YAChC,IAAI,EAAE,OAAO,CAAC,IAAI;SACnB,CAAC;KACH,CAAC;AACJ,CAAC"}
|
package/esm/mcp-connection.d.ts
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { Client } from '@modelcontextprotocol/client';
|
|
2
|
-
import type { MCPAuth } from './auth/auth-types.js';
|
|
3
|
-
import type { MCPProtocolNegotiation, MCPTransportKind } from './transport-types.js';
|
|
4
|
-
import type { ElicitationHandler } from './types.js';
|
|
5
|
-
export interface ConnectOptions {
|
|
6
|
-
url: URL;
|
|
7
|
-
transport?: MCPTransportKind;
|
|
8
|
-
auth?: MCPAuth;
|
|
9
|
-
fetch?: typeof fetch;
|
|
10
|
-
clientInfo?: {
|
|
11
|
-
name: string;
|
|
12
|
-
version: string;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Streamable HTTP session id to resume.
|
|
16
|
-
*
|
|
17
|
-
* @deprecated Ignored by 2026-07-28 servers — protocol-level sessions are
|
|
18
|
-
* removed (SEP-2567). Still honoured on 2025-era connections.
|
|
19
|
-
*/
|
|
20
|
-
sessionId?: string;
|
|
21
|
-
onElicitation?: ElicitationHandler;
|
|
22
|
-
protocolNegotiation?: MCPProtocolNegotiation;
|
|
23
|
-
/**
|
|
24
|
-
* Aborts the connect — every transport attempt, the negotiation probe, and
|
|
25
|
-
* the implicit legacy retry. Without this a caller with its own deadline has
|
|
26
|
-
* no way to bound the ladder, whose worst case is minutes (see
|
|
27
|
-
* {@link DEFAULT_PROBE_TIMEOUT_MS}).
|
|
28
|
-
*/
|
|
29
|
-
signal?: AbortSignal;
|
|
30
|
-
/**
|
|
31
|
-
* Ceiling on the `server/discover` probe, in ms. Defaults to
|
|
32
|
-
* `DEFAULT_PROBE_TIMEOUT_MS` (30000).
|
|
33
|
-
*
|
|
34
|
-
* Raise it for a server that is slow to answer its first request; the SDK's own
|
|
35
|
-
* default is the full request timeout, which makes a hanging gateway far slower
|
|
36
|
-
* to fail than it needs to be.
|
|
37
|
-
*/
|
|
38
|
-
probeTimeoutMs?: number;
|
|
39
|
-
}
|
|
40
|
-
export interface MCPConnection {
|
|
41
|
-
client: Client;
|
|
42
|
-
transport: MCPTransportKind;
|
|
43
|
-
/**
|
|
44
|
-
* Session id reported by the transport, when there is one.
|
|
45
|
-
*
|
|
46
|
-
* @deprecated `undefined` on 2026-07-28 connections (SEP-2567) and on SSE,
|
|
47
|
-
* which never had a protocol-level session.
|
|
48
|
-
*/
|
|
49
|
-
sessionId?: string;
|
|
50
|
-
/**
|
|
51
|
-
* Register a callback for `tools/list_changed`. Settable after connect so the
|
|
52
|
-
* handle can wire it to its own `refresh()`. Replaces any prior handler.
|
|
53
|
-
*/
|
|
54
|
-
setToolListChangedHandler(handler: () => void): void;
|
|
55
|
-
close(): Promise<void>;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Build the configured `Client` — negotiation mode, elicitation handler, and the
|
|
59
|
-
* `tools/list_changed` subscription — without connecting it.
|
|
60
|
-
*
|
|
61
|
-
* Exported for tests only, and deliberately not re-exported from the package
|
|
62
|
-
* entrypoint. It is the seam that lets a test drive the real handler wiring over
|
|
63
|
-
* `InMemoryTransport`: the notification method name is compile-checked (it is a
|
|
64
|
-
* `NotificationMethod` literal union, so a typo fails `tsc`), but the *dispatch*
|
|
65
|
-
* — that an inbound notification actually reaches `setToolListChangedHandler`'s
|
|
66
|
-
* callback — is only observable end to end. Without this seam, default-on
|
|
67
|
-
* `autoRefreshOnListChanged` could be silently dead with every test green.
|
|
68
|
-
*
|
|
69
|
-
* @internal
|
|
70
|
-
*/
|
|
71
|
-
export declare function makeClientForTest(options: ConnectOptions, onListChanged: () => void): Client;
|
|
72
|
-
/**
|
|
73
|
-
* Did any attempt behind this failure end in the server rejecting our
|
|
74
|
-
* credentials?
|
|
75
|
-
*
|
|
76
|
-
* Searches the whole tree rather than the `cause` spine, because a single
|
|
77
|
-
* `connect()` can fail more than once: `connectWithNegotiation` wraps transport
|
|
78
|
-
* errors in `MCPConnectionError`, and on the two-transport path it records both
|
|
79
|
-
* attempts in `errors`. Checking only `cause` would miss an `UnauthorizedError`
|
|
80
|
-
* from the Streamable HTTP attempt whenever the SSE fallback then failed for an
|
|
81
|
-
* unrelated reason — a URL that isn't an SSE endpoint answering 404 never
|
|
82
|
-
* reaches the auth path — and the retry would re-drive the OAuth flow anyway.
|
|
83
|
-
*
|
|
84
|
-
* Depth-capped: a cyclic `cause` would otherwise hang, and real chains here are
|
|
85
|
-
* two or three links.
|
|
86
|
-
*
|
|
87
|
-
* Exported for `rehydrateMCPTools`, whose fallback-to-`freshConnect` is a third
|
|
88
|
-
* reconnect layer with the same duplicated-OAuth hazard; deliberately not
|
|
89
|
-
* re-exported from the package entrypoint.
|
|
90
|
-
*/
|
|
91
|
-
export declare function isAuthFailure(err: unknown, auth: MCPAuth | undefined, depth?: number): boolean;
|
|
92
|
-
/**
|
|
93
|
-
* Connect a `Client` to the MCP server, degrading to the 2025-era handshake if
|
|
94
|
-
* protocol negotiation gets in the way.
|
|
95
|
-
*
|
|
96
|
-
* We default `protocolNegotiation` to `'auto'` where the SDK defaults to
|
|
97
|
-
* `'legacy'`, so every connection's first request is a `server/discover` probe.
|
|
98
|
-
* On its own that would be a connectivity regression: a proxy, WAF, or strict
|
|
99
|
-
* gateway that hangs or 5xx's on an unknown method takes a server from working
|
|
100
|
-
* to failing, and the SSE fallback re-probes and fails identically — so the
|
|
101
|
-
* two-transport fallback, which looks like defense in depth, collapses to a
|
|
102
|
-
* single point of failure against exactly the infrastructure it should rescue.
|
|
103
|
-
*
|
|
104
|
-
* So when the caller left `protocolNegotiation` unset, a failed connect is
|
|
105
|
-
* retried once with `'legacy'`. That makes `'auto'` strictly additive: modern
|
|
106
|
-
* servers get the new revision, everything else lands exactly where it did
|
|
107
|
-
* before this package started probing. The cost is one extra attempt on a path
|
|
108
|
-
* that is already failing, which is where latency matters least.
|
|
109
|
-
*
|
|
110
|
-
* The retry fires on **any** failure rather than only on ones that look like
|
|
111
|
-
* probe timeouts. Inspecting the cause would avoid a wasted attempt against a
|
|
112
|
-
* genuinely dead server, but it would couple this to SDK error codes — and a
|
|
113
|
-
* reshaped error would silently disable the degradation, which is the failure
|
|
114
|
-
* mode this package keeps getting bitten by.
|
|
115
|
-
*
|
|
116
|
-
* Two bounds keep the retry from making a bad situation worse:
|
|
117
|
-
*
|
|
118
|
-
* 1. **It is skipped on an auth failure.** `UnauthorizedError` means the
|
|
119
|
-
* transport reached the server and the credentials were rejected — nothing a
|
|
120
|
-
* different protocol revision changes. Retrying would re-drive the OAuth
|
|
121
|
-
* provider's authorization flow: a second `redirectToAuthorization`, a second
|
|
122
|
-
* saved PKCE verifier overwriting the first. Replaying a failure that had
|
|
123
|
-
* side effects is worse than not retrying.
|
|
124
|
-
* 2. **It re-walks the same transport ladder the first pass did.** An earlier
|
|
125
|
-
* revision pinned Streamable HTTP to cap the attempt count, which broke the
|
|
126
|
-
* case this whole mechanism exists for: a legacy server reachable *only* over
|
|
127
|
-
* SSE, behind infrastructure that chokes on the probe, would fail under
|
|
128
|
-
* `'auto'` and then never be offered SSE again. Correctness wins over the
|
|
129
|
-
* attempt count here — a server that used to connect must still connect.
|
|
130
|
-
*
|
|
131
|
-
* So the worst case for a genuinely unreachable server is four `connect()`
|
|
132
|
-
* calls, two per negotiation mode. That is the honest cost of guaranteeing no
|
|
133
|
-
* working setup regresses, and it is paid only on a path that was already going
|
|
134
|
-
* to fail. The bound that matters is that it is a fixed multiple rather than a
|
|
135
|
-
* retry loop.
|
|
136
|
-
*
|
|
137
|
-
* An **explicit** `protocolNegotiation` is honoured exactly, including
|
|
138
|
-
* `'auto'`: asking for a mode means asking for its failures too, and silently
|
|
139
|
-
* ignoring a caller's `{ pin }` would defeat the point of pinning.
|
|
140
|
-
*/
|
|
141
|
-
export declare function connect(options: ConnectOptions): Promise<MCPConnection>;
|
|
142
|
-
//# 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":"AAEA,OAAO,EACL,MAAM,EAIP,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAKpD,OAAO,KAAK,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACrF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AA0CrD,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,GAAG,CAAC;IACT,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,IA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