@lostgradient/mcp 0.1.0 → 0.2.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 +68 -8
- package/dist/chunk-3ek3knfm.js +73 -0
- package/dist/{chunk-v14p4gng.js → chunk-3rr24vhh.js} +4 -1
- package/dist/chunk-6ekjtvcq.js +273 -0
- package/dist/chunk-7dpts3r9.js +909 -0
- package/dist/chunk-88nhf6xt.js +449 -0
- package/dist/{chunk-psnez3q2.js → chunk-k6fm3cmk.js} +23 -2
- package/dist/chunk-rxnyn7tf.js +19 -0
- package/dist/{chunk-mf3t0afg.js → chunk-wfty87ws.js} +1 -1
- package/dist/{chunk-wmkqd45r.js → chunk-xcf742mf.js} +1 -1
- package/dist/chunk-yf4nw40e.js +1102 -0
- package/dist/conformance.d.ts +43 -0
- package/dist/env.d.ts +1 -1
- package/dist/env.js +2 -2
- package/dist/environment-schema.d.ts +1 -1
- package/dist/environment-schema.js +1 -1
- package/dist/http/authenticate.d.ts +35 -0
- package/dist/http/authorization-header.d.ts +5 -0
- package/dist/http/grant-revocation-channel.d.ts +24 -0
- package/dist/http/handler.d.ts +32 -0
- package/dist/http/index.d.ts +27 -0
- package/dist/http/index.js +813 -0
- package/dist/http/request-context.d.ts +17 -0
- package/dist/http/responses.d.ts +11 -0
- package/dist/http/serving-layer.d.ts +18 -0
- package/dist/http/user-handler-cache.d.ts +37 -0
- package/dist/http/user-server-event-bus.d.ts +35 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +230 -940
- package/dist/logger.d.ts +20 -0
- package/dist/logger.js +9 -5
- package/dist/oauth/authorize-endpoint.d.ts +5 -0
- package/dist/oauth/canonicalize-ip-address.d.ts +20 -0
- package/dist/oauth/client-authentication.d.ts +10 -0
- package/dist/oauth/client-metadata-documents.d.ts +52 -0
- package/dist/oauth/client-metadata-documents.js +19 -0
- package/dist/oauth/discovery-metadata.d.ts +19 -0
- package/dist/oauth/endpoint-rate-limits.d.ts +10 -0
- package/dist/oauth/endpoint-responses.d.ts +10 -0
- package/dist/oauth/index.d.ts +214 -0
- package/dist/oauth/index.js +69 -0
- package/dist/oauth/network-identity.d.ts +32 -0
- package/dist/oauth/pkce-validation.d.ts +2 -0
- package/dist/oauth/postgres/client-store.d.ts +12 -0
- package/dist/oauth/postgres/code-store.d.ts +14 -0
- package/dist/oauth/postgres/database.d.ts +18 -0
- package/dist/oauth/postgres/index.d.ts +11 -0
- package/dist/oauth/postgres/index.js +584 -0
- package/dist/oauth/postgres/schema.d.ts +1455 -0
- package/dist/oauth/postgres/token-store.d.ts +16 -0
- package/dist/oauth/postgres/transaction-store.d.ts +14 -0
- package/dist/oauth/redirect-uri-matching.d.ts +2 -0
- package/dist/oauth/registration-endpoint.d.ts +2 -0
- package/dist/oauth/request-body.d.ts +14 -0
- package/dist/oauth/revocation-endpoint.d.ts +2 -0
- package/dist/oauth/safe-public-https-fetch.d.ts +28 -0
- package/dist/oauth/scope-utilities.d.ts +15 -0
- package/dist/oauth/security-utilities.d.ts +8 -0
- package/dist/oauth/stores.d.ts +225 -0
- package/dist/oauth/stores.js +0 -0
- package/dist/oauth/testing/contract-fixtures.d.ts +134 -0
- package/dist/oauth/testing/index.d.ts +56 -0
- package/dist/oauth/testing/index.js +330 -0
- package/dist/oauth/token-endpoint.d.ts +2 -0
- package/dist/oauth-scope-configuration.d.ts +3 -0
- package/dist/rate-limit/in-memory-sliding-window-store.d.ts +3 -0
- package/dist/rate-limit/index.d.ts +23 -0
- package/dist/rate-limit/index.js +29 -0
- package/dist/rate-limit/mcp-concurrency-limiter.d.ts +26 -0
- package/dist/rate-limit/rate-limit-response.d.ts +1 -0
- package/dist/rate-limit/redis-sliding-window-store.d.ts +2 -0
- package/dist/rate-limit/request-rate-limiter.d.ts +10 -0
- package/dist/rate-limit/sliding-window-rate-limiter.d.ts +16 -0
- package/dist/scopes.d.ts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/sveltekit-mount-state.d.ts +4 -0
- package/dist/sveltekit-mount.d.ts +43 -0
- package/dist/sveltekit-mount.js +332 -0
- package/dist/tool-response.d.ts +6 -0
- package/dist/types/primitives.d.ts +1 -1
- package/dist/ui-extension-support.d.ts +2 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +56 -4
|
@@ -0,0 +1,813 @@
|
|
|
1
|
+
import {
|
|
2
|
+
attachConcurrencySlotToResponseLifetime
|
|
3
|
+
} from "../chunk-6ekjtvcq.js";
|
|
4
|
+
import {
|
|
5
|
+
areResourceSubscriptionsAuthorized,
|
|
6
|
+
createMcpServer,
|
|
7
|
+
hasValidLocalhostRebindingHeaders,
|
|
8
|
+
isLoopbackHostname
|
|
9
|
+
} from "../chunk-7dpts3r9.js";
|
|
10
|
+
import"../chunk-taxyscge.js";
|
|
11
|
+
import"../chunk-wfty87ws.js";
|
|
12
|
+
import {
|
|
13
|
+
resolveOauthNetworkIdentity
|
|
14
|
+
} from "../chunk-yf4nw40e.js";
|
|
15
|
+
import"../chunk-88nhf6xt.js";
|
|
16
|
+
import"../chunk-3ek3knfm.js";
|
|
17
|
+
import {
|
|
18
|
+
getSupportedScopes
|
|
19
|
+
} from "../chunk-rxnyn7tf.js";
|
|
20
|
+
import"../chunk-k6fm3cmk.js";
|
|
21
|
+
import"../chunk-3rr24vhh.js";
|
|
22
|
+
import"../chunk-xcf742mf.js";
|
|
23
|
+
|
|
24
|
+
// src/http/authorization-header.ts
|
|
25
|
+
function parseAuthorizationHeader(header) {
|
|
26
|
+
if (!header)
|
|
27
|
+
return { scheme: undefined, credential: undefined };
|
|
28
|
+
const match = /^(\S+)[ \t]+([\s\S]*)$/.exec(header);
|
|
29
|
+
if (!match)
|
|
30
|
+
return { scheme: undefined, credential: undefined };
|
|
31
|
+
return { scheme: match[1], credential: match[2] };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// src/http/grant-revocation-channel.ts
|
|
35
|
+
var grantRevocationChannel = "mcp:control:grant-revocations";
|
|
36
|
+
var initialRetryDelayMilliseconds = 1000;
|
|
37
|
+
var maximumRetryDelayMilliseconds = 30000;
|
|
38
|
+
function readUserId(message) {
|
|
39
|
+
try {
|
|
40
|
+
const parsed = JSON.parse(message);
|
|
41
|
+
if (typeof parsed !== "object" || parsed === null)
|
|
42
|
+
return;
|
|
43
|
+
const userId = parsed.userId;
|
|
44
|
+
return typeof userId === "string" && userId.length > 0 ? userId : undefined;
|
|
45
|
+
} catch {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
class GrantRevocationChannel {
|
|
51
|
+
closeLocalUser;
|
|
52
|
+
messaging;
|
|
53
|
+
onError;
|
|
54
|
+
retryConfiguration;
|
|
55
|
+
unsubscribe;
|
|
56
|
+
startup;
|
|
57
|
+
closeRequested = false;
|
|
58
|
+
finishRetryDelay;
|
|
59
|
+
retryDelayMilliseconds;
|
|
60
|
+
constructor(closeLocalUser, messaging, onError = () => {}, retryConfiguration = {
|
|
61
|
+
initialDelayMilliseconds: initialRetryDelayMilliseconds,
|
|
62
|
+
maximumDelayMilliseconds: maximumRetryDelayMilliseconds
|
|
63
|
+
}) {
|
|
64
|
+
this.closeLocalUser = closeLocalUser;
|
|
65
|
+
this.messaging = messaging;
|
|
66
|
+
this.onError = onError;
|
|
67
|
+
this.retryConfiguration = retryConfiguration;
|
|
68
|
+
this.retryDelayMilliseconds = retryConfiguration.initialDelayMilliseconds;
|
|
69
|
+
}
|
|
70
|
+
async start() {
|
|
71
|
+
if (!this.messaging || this.unsubscribe || this.closeRequested)
|
|
72
|
+
return;
|
|
73
|
+
if (!this.startup) {
|
|
74
|
+
const startup = this.subscribe();
|
|
75
|
+
this.startup = startup;
|
|
76
|
+
startup.finally(() => {
|
|
77
|
+
if (this.startup === startup)
|
|
78
|
+
this.startup = undefined;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
await this.startup;
|
|
82
|
+
}
|
|
83
|
+
async publish(userId) {
|
|
84
|
+
if (!this.messaging) {
|
|
85
|
+
this.runLocalCloser(userId);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
await this.messaging.publish(grantRevocationChannel, JSON.stringify({ userId }));
|
|
90
|
+
} catch (error) {
|
|
91
|
+
this.onError(error, userId);
|
|
92
|
+
}
|
|
93
|
+
this.runLocalCloser(userId);
|
|
94
|
+
}
|
|
95
|
+
async close() {
|
|
96
|
+
this.closeRequested = true;
|
|
97
|
+
this.finishRetryDelay?.();
|
|
98
|
+
await this.startup;
|
|
99
|
+
const unsubscribe = this.unsubscribe;
|
|
100
|
+
if (!unsubscribe)
|
|
101
|
+
return;
|
|
102
|
+
try {
|
|
103
|
+
await unsubscribe();
|
|
104
|
+
if (this.unsubscribe === unsubscribe)
|
|
105
|
+
this.unsubscribe = undefined;
|
|
106
|
+
} catch (error) {
|
|
107
|
+
this.onError(error);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
async subscribe() {
|
|
111
|
+
while (!this.closeRequested && !this.unsubscribe) {
|
|
112
|
+
try {
|
|
113
|
+
this.unsubscribe = await this.messaging?.subscribe(grantRevocationChannel, (message) => {
|
|
114
|
+
const userId = readUserId(message);
|
|
115
|
+
if (userId)
|
|
116
|
+
this.runLocalCloser(userId);
|
|
117
|
+
});
|
|
118
|
+
this.retryDelayMilliseconds = this.retryConfiguration.initialDelayMilliseconds;
|
|
119
|
+
} catch (error) {
|
|
120
|
+
this.onError(error);
|
|
121
|
+
if (!this.closeRequested)
|
|
122
|
+
await this.waitBeforeRetry();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
async waitBeforeRetry() {
|
|
127
|
+
const delayMilliseconds = this.retryDelayMilliseconds;
|
|
128
|
+
this.retryDelayMilliseconds = Math.min(delayMilliseconds * 2, this.retryConfiguration.maximumDelayMilliseconds);
|
|
129
|
+
await new Promise((resolve) => {
|
|
130
|
+
const finish = () => {
|
|
131
|
+
clearTimeout(timer);
|
|
132
|
+
if (this.finishRetryDelay === finish)
|
|
133
|
+
this.finishRetryDelay = undefined;
|
|
134
|
+
resolve();
|
|
135
|
+
};
|
|
136
|
+
this.finishRetryDelay = finish;
|
|
137
|
+
const timer = setTimeout(finish, delayMilliseconds);
|
|
138
|
+
timer.unref?.();
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
runLocalCloser(userId) {
|
|
142
|
+
Promise.resolve(this.closeLocalUser(userId)).catch((error) => {
|
|
143
|
+
this.onError(error, userId);
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// src/http/handler.ts
|
|
149
|
+
import { createMcpHandler } from "@modelcontextprotocol/server";
|
|
150
|
+
|
|
151
|
+
// src/http/request-context.ts
|
|
152
|
+
function buildMcpAuthInfo(input) {
|
|
153
|
+
return {
|
|
154
|
+
token: input.accessToken,
|
|
155
|
+
clientId: input.extra.oauthClientId,
|
|
156
|
+
scopes: input.extra.scopes,
|
|
157
|
+
expiresAt: Math.floor(input.expiresAt.getTime() / 1000),
|
|
158
|
+
resource: new URL(input.extra.resource),
|
|
159
|
+
extra: input.extra
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
function readMcpRequestAuthExtra(authInfo) {
|
|
163
|
+
const extra = authInfo?.extra;
|
|
164
|
+
if (!extra || typeof extra !== "object")
|
|
165
|
+
return;
|
|
166
|
+
const candidate = extra;
|
|
167
|
+
if (typeof candidate.userId !== "string")
|
|
168
|
+
return;
|
|
169
|
+
if (typeof candidate.userProfile?.id !== "string")
|
|
170
|
+
return;
|
|
171
|
+
return candidate;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// src/http/responses.ts
|
|
175
|
+
function createMcpProtocolErrorResponse(input) {
|
|
176
|
+
return new Response(JSON.stringify({
|
|
177
|
+
error: input.error,
|
|
178
|
+
error_description: input.errorDescription,
|
|
179
|
+
status: input.status,
|
|
180
|
+
...input.data ? { data: input.data } : {}
|
|
181
|
+
}), {
|
|
182
|
+
status: input.status,
|
|
183
|
+
headers: { "Content-Type": "application/json", ...input.headers ?? {} }
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
function createMcpCorsHeaders(request, allowedOrigins) {
|
|
187
|
+
const origin = request.headers.get("origin");
|
|
188
|
+
if (!origin || origin === "null" || !allowedOrigins.has(origin))
|
|
189
|
+
return {};
|
|
190
|
+
return {
|
|
191
|
+
"Access-Control-Allow-Origin": origin,
|
|
192
|
+
Vary: "Origin",
|
|
193
|
+
"Access-Control-Allow-Methods": "GET, POST, DELETE, OPTIONS",
|
|
194
|
+
"Access-Control-Allow-Headers": "Content-Type, Authorization, mcp-session-id, mcp-protocol-version, Last-Event-ID",
|
|
195
|
+
"Access-Control-Expose-Headers": "mcp-session-id, mcp-protocol-version"
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
function isMcpOriginAllowed(request, allowedOrigins) {
|
|
199
|
+
const origin = request.headers.get("origin");
|
|
200
|
+
return !origin || origin !== "null" && allowedOrigins.has(origin);
|
|
201
|
+
}
|
|
202
|
+
function createRateLimitedResponse(retryAfterSeconds, headers) {
|
|
203
|
+
return createMcpProtocolErrorResponse({
|
|
204
|
+
status: 429,
|
|
205
|
+
error: "rate_limited",
|
|
206
|
+
errorDescription: "Too many requests. Try again later.",
|
|
207
|
+
headers: { ...headers, "Retry-After": String(retryAfterSeconds) }
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// src/http/user-handler-cache.ts
|
|
212
|
+
class McpUserHandlerCache {
|
|
213
|
+
createEntry;
|
|
214
|
+
now;
|
|
215
|
+
onError;
|
|
216
|
+
entries = new Map;
|
|
217
|
+
sweepTimer;
|
|
218
|
+
constructor(createEntry, now = Date.now, onError = () => {}) {
|
|
219
|
+
this.createEntry = createEntry;
|
|
220
|
+
this.now = now;
|
|
221
|
+
this.onError = onError;
|
|
222
|
+
}
|
|
223
|
+
get size() {
|
|
224
|
+
return this.entries.size;
|
|
225
|
+
}
|
|
226
|
+
peek(userId) {
|
|
227
|
+
return this.entries.get(userId);
|
|
228
|
+
}
|
|
229
|
+
get(userId) {
|
|
230
|
+
let entry = this.entries.get(userId);
|
|
231
|
+
if (!entry) {
|
|
232
|
+
entry = {
|
|
233
|
+
...this.createEntry(userId),
|
|
234
|
+
lastAccessedAt: this.now(),
|
|
235
|
+
activeRequestCount: 0
|
|
236
|
+
};
|
|
237
|
+
this.entries.set(userId, entry);
|
|
238
|
+
return entry;
|
|
239
|
+
}
|
|
240
|
+
entry.lastAccessedAt = this.now();
|
|
241
|
+
return entry;
|
|
242
|
+
}
|
|
243
|
+
async dispatch(userId, operation) {
|
|
244
|
+
const entry = this.get(userId);
|
|
245
|
+
entry.activeRequestCount += 1;
|
|
246
|
+
try {
|
|
247
|
+
return await operation(entry.handler);
|
|
248
|
+
} finally {
|
|
249
|
+
entry.activeRequestCount -= 1;
|
|
250
|
+
entry.lastAccessedAt = this.now();
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
evictIdle(idleMilliseconds) {
|
|
254
|
+
const cutoff = this.now() - idleMilliseconds;
|
|
255
|
+
const evictedUserIds = [];
|
|
256
|
+
for (const [userId, entry] of this.entries) {
|
|
257
|
+
if (entry.bus.listenerCount === 0 && entry.activeRequestCount === 0 && entry.lastAccessedAt <= cutoff) {
|
|
258
|
+
evictedUserIds.push(userId);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
for (const userId of evictedUserIds) {
|
|
262
|
+
const entry = this.entries.get(userId);
|
|
263
|
+
this.entries.delete(userId);
|
|
264
|
+
if (entry) {
|
|
265
|
+
entry.handler.close().catch((error) => {
|
|
266
|
+
this.onError({ error, userId, operation: "evict" });
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return evictedUserIds;
|
|
271
|
+
}
|
|
272
|
+
async closeUser(userId) {
|
|
273
|
+
const entry = this.entries.get(userId);
|
|
274
|
+
if (!entry)
|
|
275
|
+
return false;
|
|
276
|
+
this.entries.delete(userId);
|
|
277
|
+
await entry.handler.close().catch((error) => {
|
|
278
|
+
this.onError({ error, userId, operation: "revoke" });
|
|
279
|
+
});
|
|
280
|
+
return true;
|
|
281
|
+
}
|
|
282
|
+
startSweep(intervalMilliseconds, idleMilliseconds) {
|
|
283
|
+
if (this.sweepTimer)
|
|
284
|
+
clearInterval(this.sweepTimer);
|
|
285
|
+
this.sweepTimer = setInterval(() => this.evictIdle(idleMilliseconds), intervalMilliseconds);
|
|
286
|
+
this.sweepTimer.unref?.();
|
|
287
|
+
}
|
|
288
|
+
async closeAll() {
|
|
289
|
+
if (this.sweepTimer) {
|
|
290
|
+
clearInterval(this.sweepTimer);
|
|
291
|
+
this.sweepTimer = undefined;
|
|
292
|
+
}
|
|
293
|
+
const closings = [...this.entries.entries()].map(([userId, entry]) => entry.handler.close().catch((error) => {
|
|
294
|
+
this.onError({ error, userId, operation: "shutdown" });
|
|
295
|
+
}));
|
|
296
|
+
this.entries.clear();
|
|
297
|
+
await Promise.all(closings);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// src/http/user-server-event-bus.ts
|
|
302
|
+
import { InMemoryServerEventBus } from "@modelcontextprotocol/server";
|
|
303
|
+
var initialRetryDelayMilliseconds2 = 1000;
|
|
304
|
+
var maximumRetryDelayMilliseconds2 = 30000;
|
|
305
|
+
function channelForUser(userId) {
|
|
306
|
+
return `mcp:events:user:${userId}`;
|
|
307
|
+
}
|
|
308
|
+
function readServerEvent(message) {
|
|
309
|
+
const parsed = JSON.parse(message);
|
|
310
|
+
if (typeof parsed !== "object" || parsed === null)
|
|
311
|
+
return;
|
|
312
|
+
const envelope = parsed;
|
|
313
|
+
if (typeof envelope.sourceId === "string" && envelope.event) {
|
|
314
|
+
const event2 = envelope.event;
|
|
315
|
+
return typeof event2.kind === "string" ? { event: envelope.event, sourceId: envelope.sourceId } : undefined;
|
|
316
|
+
}
|
|
317
|
+
if (typeof envelope.kind !== "string")
|
|
318
|
+
return;
|
|
319
|
+
const event = { ...parsed };
|
|
320
|
+
delete event.sourceId;
|
|
321
|
+
return {
|
|
322
|
+
event,
|
|
323
|
+
sourceId: typeof envelope.sourceId === "string" ? envelope.sourceId : undefined
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
class CrossInstanceUserServerEventBus {
|
|
328
|
+
userId;
|
|
329
|
+
messaging;
|
|
330
|
+
onError;
|
|
331
|
+
listeners = new Set;
|
|
332
|
+
unsubscribeFromMessaging;
|
|
333
|
+
transitionQueue = Promise.resolve();
|
|
334
|
+
retryTimer;
|
|
335
|
+
retryDelayMilliseconds = initialRetryDelayMilliseconds2;
|
|
336
|
+
sourceId = crypto.randomUUID();
|
|
337
|
+
constructor(userId, messaging, onError = () => {}) {
|
|
338
|
+
this.userId = userId;
|
|
339
|
+
this.messaging = messaging;
|
|
340
|
+
this.onError = onError;
|
|
341
|
+
}
|
|
342
|
+
get listenerCount() {
|
|
343
|
+
return this.listeners.size;
|
|
344
|
+
}
|
|
345
|
+
publish(event) {
|
|
346
|
+
let message;
|
|
347
|
+
try {
|
|
348
|
+
message = JSON.stringify({ ...event, sourceId: this.sourceId });
|
|
349
|
+
} catch (error) {
|
|
350
|
+
this.onError({ error, userId: this.userId, operation: "publish" });
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
for (const listener of this.listeners)
|
|
354
|
+
listener(event);
|
|
355
|
+
this.messaging.publish(channelForUser(this.userId), message).catch((error) => this.onError({ error, userId: this.userId, operation: "publish" }));
|
|
356
|
+
}
|
|
357
|
+
subscribe(listener) {
|
|
358
|
+
this.listeners.add(listener);
|
|
359
|
+
this.enqueueTransition();
|
|
360
|
+
let live = true;
|
|
361
|
+
return () => {
|
|
362
|
+
if (!live)
|
|
363
|
+
return;
|
|
364
|
+
live = false;
|
|
365
|
+
this.listeners.delete(listener);
|
|
366
|
+
this.enqueueTransition();
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
async whenSubscribed() {
|
|
370
|
+
await this.transitionQueue;
|
|
371
|
+
}
|
|
372
|
+
enqueueTransition() {
|
|
373
|
+
const transition = this.transitionQueue.then(() => this.reconcileSubscription(), () => this.reconcileSubscription());
|
|
374
|
+
this.transitionQueue = transition;
|
|
375
|
+
return transition;
|
|
376
|
+
}
|
|
377
|
+
scheduleRetry() {
|
|
378
|
+
if (this.retryTimer)
|
|
379
|
+
return;
|
|
380
|
+
const delay = this.retryDelayMilliseconds;
|
|
381
|
+
this.retryDelayMilliseconds = Math.min(delay * 2, maximumRetryDelayMilliseconds2);
|
|
382
|
+
this.retryTimer = setTimeout(() => {
|
|
383
|
+
this.retryTimer = undefined;
|
|
384
|
+
const subscriptionMatchesDemand = this.listeners.size === 0 && !this.unsubscribeFromMessaging || this.listeners.size > 0 && Boolean(this.unsubscribeFromMessaging);
|
|
385
|
+
if (subscriptionMatchesDemand) {
|
|
386
|
+
this.retryDelayMilliseconds = initialRetryDelayMilliseconds2;
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
this.enqueueTransition();
|
|
390
|
+
}, delay);
|
|
391
|
+
this.retryTimer.unref?.();
|
|
392
|
+
}
|
|
393
|
+
async reconcileSubscription() {
|
|
394
|
+
if (this.listeners.size > 0 && !this.unsubscribeFromMessaging) {
|
|
395
|
+
try {
|
|
396
|
+
this.unsubscribeFromMessaging = await this.messaging.subscribe(channelForUser(this.userId), (message) => {
|
|
397
|
+
try {
|
|
398
|
+
const received = readServerEvent(message);
|
|
399
|
+
if (received && received.sourceId !== this.sourceId) {
|
|
400
|
+
for (const listener of this.listeners)
|
|
401
|
+
listener(received.event);
|
|
402
|
+
}
|
|
403
|
+
} catch (error) {
|
|
404
|
+
this.onError({ error, userId: this.userId, operation: "deserialize" });
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
this.retryDelayMilliseconds = initialRetryDelayMilliseconds2;
|
|
408
|
+
} catch (error) {
|
|
409
|
+
this.onError({ error, userId: this.userId, operation: "subscribe" });
|
|
410
|
+
this.scheduleRetry();
|
|
411
|
+
}
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
if (this.listeners.size === 0 && this.unsubscribeFromMessaging) {
|
|
415
|
+
const unsubscribe = this.unsubscribeFromMessaging;
|
|
416
|
+
try {
|
|
417
|
+
await unsubscribe();
|
|
418
|
+
if (this.unsubscribeFromMessaging === unsubscribe) {
|
|
419
|
+
this.unsubscribeFromMessaging = undefined;
|
|
420
|
+
}
|
|
421
|
+
this.retryDelayMilliseconds = initialRetryDelayMilliseconds2;
|
|
422
|
+
} catch (error) {
|
|
423
|
+
this.onError({ error, userId: this.userId, operation: "unsubscribe" });
|
|
424
|
+
this.scheduleRetry();
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
function createUserServerEventBus(input) {
|
|
430
|
+
return input.messaging ? new CrossInstanceUserServerEventBus(input.userId, input.messaging, input.onError) : new InMemoryServerEventBus;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// src/http/handler.ts
|
|
434
|
+
class McpPayloadTooLargeError extends Error {
|
|
435
|
+
}
|
|
436
|
+
function boundRequestBody(request, maximumBytes) {
|
|
437
|
+
const declaredLength = request.headers.get("content-length");
|
|
438
|
+
if (declaredLength && (!/^\d+$/.test(declaredLength) || Number(declaredLength) > maximumBytes)) {
|
|
439
|
+
throw new McpPayloadTooLargeError(`Request body exceeds the ${maximumBytes}-byte limit.`);
|
|
440
|
+
}
|
|
441
|
+
if (!request.body)
|
|
442
|
+
return request;
|
|
443
|
+
const reader = request.body.getReader();
|
|
444
|
+
let receivedBytes = 0;
|
|
445
|
+
const body = new ReadableStream({
|
|
446
|
+
async start(controller) {
|
|
447
|
+
try {
|
|
448
|
+
while (true) {
|
|
449
|
+
const { done, value } = await reader.read();
|
|
450
|
+
if (done) {
|
|
451
|
+
controller.close();
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
receivedBytes += value.byteLength;
|
|
455
|
+
if (receivedBytes > maximumBytes) {
|
|
456
|
+
const error = new McpPayloadTooLargeError(`Request body exceeded the ${maximumBytes}-byte limit while streaming.`);
|
|
457
|
+
controller.error(error);
|
|
458
|
+
await reader.cancel(error).catch(() => {});
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
controller.enqueue(value);
|
|
462
|
+
}
|
|
463
|
+
} catch (error) {
|
|
464
|
+
controller.error(error);
|
|
465
|
+
}
|
|
466
|
+
},
|
|
467
|
+
cancel: (reason) => reader.cancel(reason)
|
|
468
|
+
});
|
|
469
|
+
return new Request(request.url, {
|
|
470
|
+
method: request.method,
|
|
471
|
+
headers: request.headers,
|
|
472
|
+
body,
|
|
473
|
+
duplex: "half",
|
|
474
|
+
signal: request.signal
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
function readRequestedResourceUris(message) {
|
|
478
|
+
const parameters = message.params;
|
|
479
|
+
if (typeof parameters !== "object" || parameters === null)
|
|
480
|
+
return [];
|
|
481
|
+
const notifications = parameters.notifications;
|
|
482
|
+
if (typeof notifications !== "object" || notifications === null)
|
|
483
|
+
return [];
|
|
484
|
+
const uris = notifications.resourceSubscriptions;
|
|
485
|
+
return Array.isArray(uris) ? uris.filter((uri) => typeof uri === "string") : [];
|
|
486
|
+
}
|
|
487
|
+
async function inspectListenRequest(request) {
|
|
488
|
+
const none = { isListenRequest: false, requestedResourceUris: [] };
|
|
489
|
+
if (!request.body)
|
|
490
|
+
return none;
|
|
491
|
+
try {
|
|
492
|
+
const parsed = await request.clone().json();
|
|
493
|
+
const messages = Array.isArray(parsed) ? parsed : [parsed];
|
|
494
|
+
const listens = messages.filter((message) => typeof message === "object" && message !== null && message.method === "subscriptions/listen");
|
|
495
|
+
return listens.length === 0 ? none : {
|
|
496
|
+
isListenRequest: true,
|
|
497
|
+
requestedResourceUris: listens.flatMap(readRequestedResourceUris)
|
|
498
|
+
};
|
|
499
|
+
} catch {
|
|
500
|
+
return none;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
function createMcpServingHandler(input) {
|
|
504
|
+
const { registry, configuration, seams } = input;
|
|
505
|
+
if (!seams.messaging)
|
|
506
|
+
seams.reportDegradation("single_instance_messaging_fallback");
|
|
507
|
+
function createEntry(userId) {
|
|
508
|
+
const bus = createUserServerEventBus({
|
|
509
|
+
userId,
|
|
510
|
+
messaging: seams.messaging,
|
|
511
|
+
onError: ({ error, operation }) => seams.onError(error, operation, userId)
|
|
512
|
+
});
|
|
513
|
+
const handler = createMcpHandler(async (context) => {
|
|
514
|
+
const extra = readMcpRequestAuthExtra(context.authInfo);
|
|
515
|
+
if (!extra || extra.userId !== userId) {
|
|
516
|
+
throw new Error("MCP request authenticated user does not match its routed handler.");
|
|
517
|
+
}
|
|
518
|
+
return createMcpServer({
|
|
519
|
+
userId,
|
|
520
|
+
user: extra.userProfile,
|
|
521
|
+
requestId: extra.requestId,
|
|
522
|
+
enableUiExtension: configuration.enableUiExtension,
|
|
523
|
+
enableConformanceMode: configuration.enableConformanceMode,
|
|
524
|
+
era: context.era,
|
|
525
|
+
publishResourceUpdate: async (uri) => handler.notify.resourceUpdated(uri),
|
|
526
|
+
scopes: extra.scopes
|
|
527
|
+
}, registry);
|
|
528
|
+
}, {
|
|
529
|
+
legacy: "stateless",
|
|
530
|
+
bus,
|
|
531
|
+
maxSubscriptions: configuration.maximumSubscriptionsPerUser,
|
|
532
|
+
onerror: (error) => {
|
|
533
|
+
seams.recordEvent("transport_failure");
|
|
534
|
+
seams.onError(error, "transport", userId);
|
|
535
|
+
}
|
|
536
|
+
});
|
|
537
|
+
return { handler, bus };
|
|
538
|
+
}
|
|
539
|
+
const cache = new McpUserHandlerCache(createEntry, Date.now, ({ error, operation, userId }) => seams.onError(error, operation, userId));
|
|
540
|
+
cache.startSweep(configuration.userHandlerSweepIntervalMilliseconds, configuration.userHandlerIdleMilliseconds);
|
|
541
|
+
const revocations = new GrantRevocationChannel((userId) => cache.closeUser(userId), seams.messaging, (error, userId) => seams.onError(error, "grant_revocation", userId));
|
|
542
|
+
return {
|
|
543
|
+
start: () => revocations.start(),
|
|
544
|
+
async handle(request, authInfo) {
|
|
545
|
+
const options = { authInfo };
|
|
546
|
+
let boundedRequest;
|
|
547
|
+
try {
|
|
548
|
+
boundedRequest = boundRequestBody(request, configuration.maximumRequestBodyBytes);
|
|
549
|
+
} catch (error) {
|
|
550
|
+
if (!(error instanceof McpPayloadTooLargeError))
|
|
551
|
+
throw error;
|
|
552
|
+
return createMcpProtocolErrorResponse({
|
|
553
|
+
status: 413,
|
|
554
|
+
error: "payload_too_large",
|
|
555
|
+
errorDescription: error.message,
|
|
556
|
+
headers: { "MCP-Protocol-Version": configuration.protocolVersion }
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
const extra = readMcpRequestAuthExtra(authInfo);
|
|
560
|
+
if (!extra)
|
|
561
|
+
throw new Error("MCP request reached the handler without verified auth context.");
|
|
562
|
+
const inspection = await inspectListenRequest(boundedRequest);
|
|
563
|
+
if (inspection.isListenRequest && !areResourceSubscriptionsAuthorized(inspection.requestedResourceUris, extra.scopes, registry)) {
|
|
564
|
+
seams.recordEvent("insufficient_scope");
|
|
565
|
+
return createMcpProtocolErrorResponse({
|
|
566
|
+
status: 403,
|
|
567
|
+
error: "forbidden",
|
|
568
|
+
errorDescription: "The access token does not carry the scopes required for the requested resource subscriptions.",
|
|
569
|
+
headers: {
|
|
570
|
+
"MCP-Protocol-Version": configuration.protocolVersion,
|
|
571
|
+
"WWW-Authenticate": `Bearer error="insufficient_scope", scope="${getSupportedScopes(registry).join(" ")}"`
|
|
572
|
+
}
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
const response = await cache.dispatch(extra.userId, (handler) => handler.fetch(boundedRequest, options));
|
|
576
|
+
return inspection.isListenRequest ? seams.markServerOnlyCloseableStream?.(response) ?? response : response;
|
|
577
|
+
},
|
|
578
|
+
publishUserResourceUpdate(userId, uri) {
|
|
579
|
+
const existing = cache.peek(userId);
|
|
580
|
+
if (existing) {
|
|
581
|
+
existing.handler.notify.resourceUpdated(uri);
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
584
|
+
if (seams.messaging) {
|
|
585
|
+
createUserServerEventBus({ userId, messaging: seams.messaging }).publish({
|
|
586
|
+
kind: "resource_updated",
|
|
587
|
+
uri
|
|
588
|
+
});
|
|
589
|
+
}
|
|
590
|
+
},
|
|
591
|
+
publishGrantRevocation: (userId) => revocations.publish(userId),
|
|
592
|
+
closeUser: (userId) => cache.closeUser(userId),
|
|
593
|
+
async shutdown() {
|
|
594
|
+
await revocations.close();
|
|
595
|
+
await cache.closeAll();
|
|
596
|
+
}
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
// src/http/authenticate.ts
|
|
601
|
+
function bearerChallenge(configuration, errorCode) {
|
|
602
|
+
const resourceMetadataUrl = new URL("/.well-known/oauth-protected-resource/mcp", configuration.resource).href;
|
|
603
|
+
const parts = [
|
|
604
|
+
...errorCode ? [`error="${errorCode}"`] : [],
|
|
605
|
+
`resource_metadata="${resourceMetadataUrl}"`,
|
|
606
|
+
`scope="${configuration.supportedScopes.join(" ")}"`
|
|
607
|
+
];
|
|
608
|
+
return `Bearer ${parts.join(", ")}`;
|
|
609
|
+
}
|
|
610
|
+
function invalidTokenResponse(configuration, corsHeaders) {
|
|
611
|
+
return createMcpProtocolErrorResponse({
|
|
612
|
+
status: 401,
|
|
613
|
+
error: "unauthorized",
|
|
614
|
+
errorDescription: "Invalid or expired token.",
|
|
615
|
+
headers: {
|
|
616
|
+
...corsHeaders,
|
|
617
|
+
"MCP-Protocol-Version": configuration.protocolVersion,
|
|
618
|
+
"WWW-Authenticate": bearerChallenge(configuration, "invalid_token")
|
|
619
|
+
}
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
async function authenticateMcpUser(input) {
|
|
623
|
+
const { context, configuration, seams } = input;
|
|
624
|
+
const corsHeaders = createMcpCorsHeaders(context.request, configuration.allowedOrigins);
|
|
625
|
+
const protocolHeaders = {
|
|
626
|
+
...corsHeaders,
|
|
627
|
+
"MCP-Protocol-Version": configuration.protocolVersion
|
|
628
|
+
};
|
|
629
|
+
if (configuration.dnsRebindingProtection && isLoopbackHostname(context.requestUrl.hostname) && !hasValidLocalhostRebindingHeaders(context.request.headers)) {
|
|
630
|
+
return createMcpProtocolErrorResponse({
|
|
631
|
+
status: 403,
|
|
632
|
+
error: "forbidden",
|
|
633
|
+
errorDescription: "Request rejected by localhost DNS rebinding protection.",
|
|
634
|
+
headers: protocolHeaders
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
if (!isMcpOriginAllowed(context.request, configuration.allowedOrigins)) {
|
|
638
|
+
return createMcpProtocolErrorResponse({
|
|
639
|
+
status: 403,
|
|
640
|
+
error: "forbidden",
|
|
641
|
+
errorDescription: "Origin is not allowed for MCP requests.",
|
|
642
|
+
headers: protocolHeaders
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
if (context.request.method === "OPTIONS") {
|
|
646
|
+
return new Response(null, { status: 204, headers: protocolHeaders });
|
|
647
|
+
}
|
|
648
|
+
const networkIdentity = context.socketAddress ?? "unknown";
|
|
649
|
+
const failedAuthenticationCount = await seams.rateLimiter.peek("failed_authentication", networkIdentity);
|
|
650
|
+
if (failedAuthenticationCount >= configuration.maximumFailedAuthenticationAttempts) {
|
|
651
|
+
return createMcpProtocolErrorResponse({
|
|
652
|
+
status: 429,
|
|
653
|
+
error: "rate_limited",
|
|
654
|
+
errorDescription: "Too many failed authentication attempts. Try again later.",
|
|
655
|
+
headers: protocolHeaders
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
const { scheme, credential } = parseAuthorizationHeader(context.request.headers.get("authorization"));
|
|
659
|
+
if (scheme?.toLowerCase() !== "bearer") {
|
|
660
|
+
return createMcpProtocolErrorResponse({
|
|
661
|
+
status: 401,
|
|
662
|
+
error: "unauthorized",
|
|
663
|
+
errorDescription: "Missing or invalid Authorization header.",
|
|
664
|
+
headers: {
|
|
665
|
+
...protocolHeaders,
|
|
666
|
+
"WWW-Authenticate": bearerChallenge(configuration)
|
|
667
|
+
}
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
const bearerToken = credential ?? "";
|
|
671
|
+
if (bearerToken.length === 0 || bearerToken.length > configuration.maximumBearerTokenLength) {
|
|
672
|
+
return createMcpProtocolErrorResponse({
|
|
673
|
+
status: 401,
|
|
674
|
+
error: "unauthorized",
|
|
675
|
+
errorDescription: "Malformed bearer token.",
|
|
676
|
+
headers: {
|
|
677
|
+
...protocolHeaders,
|
|
678
|
+
"WWW-Authenticate": bearerChallenge(configuration, "invalid_token")
|
|
679
|
+
}
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
const tokenHash = seams.hashCredential(bearerToken);
|
|
683
|
+
const combinedAuthentication = seams.findTokenAndUserProfileByHash ? await seams.findTokenAndUserProfileByHash(tokenHash) : undefined;
|
|
684
|
+
const token = seams.findTokenAndUserProfileByHash ? combinedAuthentication?.token ?? null : await seams.tokens.findByHash(tokenHash);
|
|
685
|
+
const now = new Date;
|
|
686
|
+
if (!token || token.revokedAt || token.expiresAt <= now) {
|
|
687
|
+
await seams.rateLimiter.consume("failed_authentication", networkIdentity);
|
|
688
|
+
seams.recordEvent("expired_or_invalid_token", context.requestId);
|
|
689
|
+
return invalidTokenResponse(configuration, corsHeaders);
|
|
690
|
+
}
|
|
691
|
+
if (token.resource !== configuration.resource.href) {
|
|
692
|
+
await seams.rateLimiter.consume("failed_authentication", networkIdentity);
|
|
693
|
+
seams.recordEvent("invalid_resource", context.requestId);
|
|
694
|
+
return invalidTokenResponse(configuration, corsHeaders);
|
|
695
|
+
}
|
|
696
|
+
const profile = seams.findTokenAndUserProfileByHash ? combinedAuthentication?.profile : await seams.resolveUserProfile(token.userId);
|
|
697
|
+
if (!profile) {
|
|
698
|
+
await seams.rateLimiter.consume("failed_authentication", networkIdentity);
|
|
699
|
+
seams.recordEvent("expired_or_invalid_token", context.requestId);
|
|
700
|
+
return invalidTokenResponse(configuration, corsHeaders);
|
|
701
|
+
}
|
|
702
|
+
seams.recordEvent("success", context.requestId);
|
|
703
|
+
return buildMcpAuthInfo({
|
|
704
|
+
accessToken: bearerToken,
|
|
705
|
+
expiresAt: token.expiresAt,
|
|
706
|
+
extra: {
|
|
707
|
+
userId: token.userId,
|
|
708
|
+
userProfile: profile,
|
|
709
|
+
oauthClientId: token.clientId,
|
|
710
|
+
scopes: (token.scope ?? "").split(" ").filter(Boolean),
|
|
711
|
+
resource: token.resource,
|
|
712
|
+
networkIdentity,
|
|
713
|
+
requestId: context.requestId
|
|
714
|
+
}
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
// src/http/serving-layer.ts
|
|
719
|
+
function createMcpHttpServingLayer(input) {
|
|
720
|
+
return {
|
|
721
|
+
async handle(context) {
|
|
722
|
+
const networkIdentity = resolveOauthNetworkIdentity({
|
|
723
|
+
socketAddress: context.socketAddress,
|
|
724
|
+
headers: context.request.headers,
|
|
725
|
+
configuration: input.authenticationConfiguration.trustedProxy
|
|
726
|
+
});
|
|
727
|
+
const resolvedContext = { ...context, socketAddress: networkIdentity };
|
|
728
|
+
const corsHeaders = createMcpCorsHeaders(context.request, input.authenticationConfiguration.allowedOrigins);
|
|
729
|
+
const protocolHeaders = {
|
|
730
|
+
...corsHeaders,
|
|
731
|
+
"MCP-Protocol-Version": input.authenticationConfiguration.protocolVersion
|
|
732
|
+
};
|
|
733
|
+
if (context.request.method !== "OPTIONS") {
|
|
734
|
+
const networkAdmission = await input.rateLimiter.consume("mcp_network", networkIdentity);
|
|
735
|
+
if (!networkAdmission.allowed) {
|
|
736
|
+
return createRateLimitedResponse(networkAdmission.retryAfterSeconds, protocolHeaders);
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
const authentication = await authenticateMcpUser({
|
|
740
|
+
context: resolvedContext,
|
|
741
|
+
configuration: input.authenticationConfiguration,
|
|
742
|
+
seams: input.authenticationSeams
|
|
743
|
+
});
|
|
744
|
+
if (authentication instanceof Response)
|
|
745
|
+
return authentication;
|
|
746
|
+
const extra = readMcpRequestAuthExtra(authentication);
|
|
747
|
+
if (!extra) {
|
|
748
|
+
return createMcpProtocolErrorResponse({
|
|
749
|
+
status: 401,
|
|
750
|
+
error: "unauthorized",
|
|
751
|
+
errorDescription: "Invalid or expired token.",
|
|
752
|
+
headers: protocolHeaders
|
|
753
|
+
});
|
|
754
|
+
}
|
|
755
|
+
const userAdmission = await input.rateLimiter.consume("mcp_user", extra.userId);
|
|
756
|
+
if (!userAdmission.allowed) {
|
|
757
|
+
return createRateLimitedResponse(userAdmission.retryAfterSeconds, protocolHeaders);
|
|
758
|
+
}
|
|
759
|
+
const concurrencySlot = await input.concurrencyLimiter.acquire(`rate_limit:mcp_concurrent:${extra.userId}`);
|
|
760
|
+
if (!concurrencySlot.allowed) {
|
|
761
|
+
return createMcpProtocolErrorResponse({
|
|
762
|
+
status: 429,
|
|
763
|
+
error: "rate_limited",
|
|
764
|
+
errorDescription: "Too many concurrent MCP requests for this user.",
|
|
765
|
+
headers: protocolHeaders
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
try {
|
|
769
|
+
const response = await input.handler.handle(context.request, authentication);
|
|
770
|
+
const headers = new Headers(response.headers);
|
|
771
|
+
for (const [name, value] of Object.entries(corsHeaders))
|
|
772
|
+
headers.set(name, value);
|
|
773
|
+
const responseWithCorsHeaders = new Response(response.body, {
|
|
774
|
+
status: response.status,
|
|
775
|
+
statusText: response.statusText,
|
|
776
|
+
headers
|
|
777
|
+
});
|
|
778
|
+
return attachConcurrencySlotToResponseLifetime(responseWithCorsHeaders, concurrencySlot);
|
|
779
|
+
} catch (error) {
|
|
780
|
+
await concurrencySlot.release();
|
|
781
|
+
throw error;
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
// src/http/index.ts
|
|
788
|
+
var parseAuthorizationHeader2 = parseAuthorizationHeader;
|
|
789
|
+
var GrantRevocationChannel2 = GrantRevocationChannel;
|
|
790
|
+
var createMcpServingHandler2 = createMcpServingHandler;
|
|
791
|
+
var buildMcpAuthInfo2 = buildMcpAuthInfo;
|
|
792
|
+
var readMcpRequestAuthExtra2 = readMcpRequestAuthExtra;
|
|
793
|
+
var createMcpCorsHeaders2 = createMcpCorsHeaders;
|
|
794
|
+
var createMcpProtocolErrorResponse2 = createMcpProtocolErrorResponse;
|
|
795
|
+
var isMcpOriginAllowed2 = isMcpOriginAllowed;
|
|
796
|
+
var createMcpHttpServingLayer2 = createMcpHttpServingLayer;
|
|
797
|
+
var McpUserHandlerCache2 = McpUserHandlerCache;
|
|
798
|
+
var createUserServerEventBus2 = createUserServerEventBus;
|
|
799
|
+
var CrossInstanceUserServerEventBus2 = CrossInstanceUserServerEventBus;
|
|
800
|
+
export {
|
|
801
|
+
CrossInstanceUserServerEventBus2 as CrossInstanceUserServerEventBus,
|
|
802
|
+
GrantRevocationChannel2 as GrantRevocationChannel,
|
|
803
|
+
McpUserHandlerCache2 as McpUserHandlerCache,
|
|
804
|
+
buildMcpAuthInfo2 as buildMcpAuthInfo,
|
|
805
|
+
createMcpCorsHeaders2 as createMcpCorsHeaders,
|
|
806
|
+
createMcpHttpServingLayer2 as createMcpHttpServingLayer,
|
|
807
|
+
createMcpProtocolErrorResponse2 as createMcpProtocolErrorResponse,
|
|
808
|
+
createMcpServingHandler2 as createMcpServingHandler,
|
|
809
|
+
createUserServerEventBus2 as createUserServerEventBus,
|
|
810
|
+
isMcpOriginAllowed2 as isMcpOriginAllowed,
|
|
811
|
+
parseAuthorizationHeader2 as parseAuthorizationHeader,
|
|
812
|
+
readMcpRequestAuthExtra2 as readMcpRequestAuthExtra
|
|
813
|
+
};
|