@zuplo/cli 7.8.5 → 7.8.7
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/node_modules/@modelcontextprotocol/client/dist/{index-CHhhk6PQ.d.cts → index-BCtJi0p5.d.mts} +38 -6
- package/node_modules/@modelcontextprotocol/client/dist/index-BCtJi0p5.d.mts.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/{index-D4xIIEF6.d.mts → index-CEk3qkZM.d.cts} +41 -3
- package/node_modules/@modelcontextprotocol/client/dist/index-CEk3qkZM.d.cts.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/index.cjs +375 -60
- package/node_modules/@modelcontextprotocol/client/dist/index.cjs.map +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/index.d.cts +227 -11
- package/node_modules/@modelcontextprotocol/client/dist/index.d.cts.map +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/index.d.mts +227 -11
- package/node_modules/@modelcontextprotocol/client/dist/index.d.mts.map +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/index.mjs +369 -61
- package/node_modules/@modelcontextprotocol/client/dist/index.mjs.map +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.cjs +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.mjs +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/{src-NAgB4Mp8.cjs → src-D0qEN74R.cjs} +111 -38
- package/node_modules/@modelcontextprotocol/client/dist/src-D0qEN74R.cjs.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/{src-D_zzAWoS.mjs → src-DDAAhLnO.mjs} +106 -33
- package/node_modules/@modelcontextprotocol/client/dist/src-DDAAhLnO.mjs.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/stdio.cjs +8 -2
- package/node_modules/@modelcontextprotocol/client/dist/stdio.cjs.map +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/stdio.d.cts +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/stdio.d.cts.map +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/stdio.d.mts +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/stdio.d.mts.map +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/stdio.mjs +8 -2
- package/node_modules/@modelcontextprotocol/client/dist/stdio.mjs.map +1 -1
- package/node_modules/@modelcontextprotocol/client/package.json +4 -4
- package/node_modules/@modelcontextprotocol/core/dist/{auth-BWdKR39I.d.mts → auth--n_Yzytt.d.cts} +6 -1
- package/node_modules/@modelcontextprotocol/core/dist/{auth-BWdKR39I.d.mts.map → auth--n_Yzytt.d.cts.map} +1 -1
- package/node_modules/@modelcontextprotocol/core/dist/{auth-CfDMXiII.cjs → auth-4-zilcqg.cjs} +3 -2
- package/node_modules/@modelcontextprotocol/core/dist/{auth-CfDMXiII.cjs.map → auth-4-zilcqg.cjs.map} +1 -1
- package/node_modules/@modelcontextprotocol/core/dist/{auth-CUe6YdwF.mjs → auth-CGP0BDVq.mjs} +3 -2
- package/node_modules/@modelcontextprotocol/core/dist/{auth-CUe6YdwF.mjs.map → auth-CGP0BDVq.mjs.map} +1 -1
- package/node_modules/@modelcontextprotocol/core/dist/{auth-hYtaIUZm.d.cts → auth-YUQV3RRv.d.mts} +6 -1
- package/node_modules/@modelcontextprotocol/core/dist/{auth-hYtaIUZm.d.cts.map → auth-YUQV3RRv.d.mts.map} +1 -1
- package/node_modules/@modelcontextprotocol/core/dist/index.cjs +1 -1
- package/node_modules/@modelcontextprotocol/core/dist/index.d.cts +1 -1
- package/node_modules/@modelcontextprotocol/core/dist/index.d.mts +1 -1
- package/node_modules/@modelcontextprotocol/core/dist/index.mjs +1 -1
- package/node_modules/@modelcontextprotocol/core/dist/internal.cjs +1 -1
- package/node_modules/@modelcontextprotocol/core/dist/internal.d.cts +1 -1
- package/node_modules/@modelcontextprotocol/core/dist/internal.d.mts +1 -1
- package/node_modules/@modelcontextprotocol/core/dist/internal.mjs +1 -1
- package/node_modules/@modelcontextprotocol/core/package.json +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/auth.d.ts +15 -4
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/auth.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/auth.js +22 -3
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/auth.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/express.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/express.js +3 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/express.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/requestBody.d.ts +25 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/requestBody.d.ts.map +1 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/requestBody.js +64 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/requestBody.js.map +1 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/webStandardStreamableHttp.d.ts +10 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/webStandardStreamableHttp.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/webStandardStreamableHttp.js +13 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/webStandardStreamableHttp.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth.d.ts +15 -4
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth.js +22 -3
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/express.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/express.js +3 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/express.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/requestBody.d.ts +25 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/requestBody.d.ts.map +1 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/requestBody.js +58 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/requestBody.js.map +1 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.d.ts +10 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.js +13 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/package.json +1 -1
- package/node_modules/@modelcontextprotocol/server/dist/{createMcpHandler-dBHMsxwf.d.cts → createMcpHandler-BLVe3qmU.d.cts} +110 -7
- package/node_modules/@modelcontextprotocol/server/dist/createMcpHandler-BLVe3qmU.d.cts.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/{createMcpHandler-CLhGwQTn.d.mts → createMcpHandler-Bt6U_Fqb.d.mts} +110 -7
- package/node_modules/@modelcontextprotocol/server/dist/createMcpHandler-Bt6U_Fqb.d.mts.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/index.cjs +144 -248
- package/node_modules/@modelcontextprotocol/server/dist/index.cjs.map +1 -1
- package/node_modules/@modelcontextprotocol/server/dist/index.d.cts +38 -3
- package/node_modules/@modelcontextprotocol/server/dist/index.d.cts.map +1 -1
- package/node_modules/@modelcontextprotocol/server/dist/index.d.mts +38 -3
- package/node_modules/@modelcontextprotocol/server/dist/index.d.mts.map +1 -1
- package/node_modules/@modelcontextprotocol/server/dist/index.mjs +136 -243
- package/node_modules/@modelcontextprotocol/server/dist/index.mjs.map +1 -1
- package/node_modules/@modelcontextprotocol/server/dist/{mcp-D7GmuPnv.cjs → mcp-DUcCQSTW.cjs} +426 -21
- package/node_modules/@modelcontextprotocol/server/dist/mcp-DUcCQSTW.cjs.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/{mcp-DXXb3Vv3.mjs → mcp-Dw2OlZ1f.mjs} +367 -22
- package/node_modules/@modelcontextprotocol/server/dist/mcp-Dw2OlZ1f.mjs.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/shimsWorkerd.cjs +1 -1
- package/node_modules/@modelcontextprotocol/server/dist/shimsWorkerd.mjs +1 -1
- package/node_modules/@modelcontextprotocol/server/dist/{src-STyD_Vvf.cjs → src-CgFsfg3E.cjs} +114 -36
- package/node_modules/@modelcontextprotocol/server/dist/src-CgFsfg3E.cjs.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/{src-CX2iR2pK.mjs → src-D-y6h4N7.mjs} +114 -36
- package/node_modules/@modelcontextprotocol/server/dist/src-D-y6h4N7.mjs.map +1 -0
- package/node_modules/@modelcontextprotocol/server/dist/stdio.cjs +30 -3
- package/node_modules/@modelcontextprotocol/server/dist/stdio.cjs.map +1 -1
- package/node_modules/@modelcontextprotocol/server/dist/stdio.d.cts +9 -1
- package/node_modules/@modelcontextprotocol/server/dist/stdio.d.cts.map +1 -1
- package/node_modules/@modelcontextprotocol/server/dist/stdio.d.mts +9 -1
- package/node_modules/@modelcontextprotocol/server/dist/stdio.d.mts.map +1 -1
- package/node_modules/@modelcontextprotocol/server/dist/stdio.mjs +30 -3
- package/node_modules/@modelcontextprotocol/server/dist/stdio.mjs.map +1 -1
- package/node_modules/@modelcontextprotocol/server/package.json +3 -3
- package/node_modules/@posthog/core/dist/featureFlagLocalEvaluation.d.ts +12 -1
- package/node_modules/@posthog/core/dist/featureFlagLocalEvaluation.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/featureFlagLocalEvaluation.js +16 -2
- package/node_modules/@posthog/core/dist/featureFlagLocalEvaluation.mjs +14 -3
- package/node_modules/@posthog/core/dist/index.d.ts +1 -1
- package/node_modules/@posthog/core/dist/index.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/index.js +15 -6
- package/node_modules/@posthog/core/dist/index.mjs +1 -1
- package/node_modules/@posthog/core/package.json +2 -2
- package/node_modules/@posthog/core/src/featureFlagLocalEvaluation.ts +45 -2
- package/node_modules/@posthog/core/src/index.ts +1 -0
- package/node_modules/@zuplo/core/package.json +1 -1
- package/node_modules/@zuplo/graphql/package.json +1 -1
- package/node_modules/@zuplo/openapi-tools/package.json +1 -1
- package/node_modules/@zuplo/otel/package.json +1 -1
- package/node_modules/@zuplo/runtime/package.json +1 -1
- package/package.json +12 -12
- package/node_modules/@modelcontextprotocol/client/dist/index-CHhhk6PQ.d.cts.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/index-D4xIIEF6.d.mts.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/src-D_zzAWoS.mjs.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/src-NAgB4Mp8.cjs.map +0 -1
- package/node_modules/@modelcontextprotocol/server/dist/createMcpHandler-CLhGwQTn.d.mts.map +0 -1
- package/node_modules/@modelcontextprotocol/server/dist/createMcpHandler-dBHMsxwf.d.cts.map +0 -1
- package/node_modules/@modelcontextprotocol/server/dist/mcp-D7GmuPnv.cjs.map +0 -1
- package/node_modules/@modelcontextprotocol/server/dist/mcp-DXXb3Vv3.mjs.map +0 -1
- package/node_modules/@modelcontextprotocol/server/dist/src-CX2iR2pK.mjs.map +0 -1
- package/node_modules/@modelcontextprotocol/server/dist/src-STyD_Vvf.cjs.map +0 -1
package/node_modules/@modelcontextprotocol/server/dist/{mcp-D7GmuPnv.cjs → mcp-DUcCQSTW.cjs}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-Bnu9O96Y.cjs');
|
|
2
|
-
const require_src = require('./src-
|
|
2
|
+
const require_src = require('./src-CgFsfg3E.cjs');
|
|
3
3
|
let _modelcontextprotocol_server__shims = require("@modelcontextprotocol/server/_shims");
|
|
4
4
|
let _modelcontextprotocol_core_internal = require("@modelcontextprotocol/core/internal");
|
|
5
5
|
|
|
@@ -476,6 +476,310 @@ function notificationToServerEvent(method, uri) {
|
|
|
476
476
|
}
|
|
477
477
|
}
|
|
478
478
|
|
|
479
|
+
//#endregion
|
|
480
|
+
//#region src/server/middleware/bearerAuth.ts
|
|
481
|
+
function headerQuotedValue(value) {
|
|
482
|
+
return value.replaceAll(/[\\"]/g, String.raw`\$&`).replaceAll(/[^\u0020-\u007E]/g, " ");
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Build a `WWW-Authenticate: Bearer …` challenge header value (RFC 6750).
|
|
486
|
+
*
|
|
487
|
+
* The single formatter behind every challenge this package emits — the
|
|
488
|
+
* bearer-auth 401/403 answers and the per-operation scope-challenge 403 — so
|
|
489
|
+
* all challenges from one server agree on parameter order and quoting. Every
|
|
490
|
+
* parameter value is emitted as an HTTP quoted-string with `\` and `"`
|
|
491
|
+
* escaped and non-printable characters replaced.
|
|
492
|
+
*/
|
|
493
|
+
function buildWwwAuthenticateHeader(errorCode, description, requiredScopes, resourceMetadataUrl) {
|
|
494
|
+
let header = `Bearer error="${headerQuotedValue(errorCode)}", error_description="${headerQuotedValue(description)}"`;
|
|
495
|
+
if (requiredScopes.length > 0) header += `, scope="${headerQuotedValue(requiredScopes.join(" "))}"`;
|
|
496
|
+
if (resourceMetadataUrl) header += `, resource_metadata="${headerQuotedValue(resourceMetadataUrl)}"`;
|
|
497
|
+
return header;
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Validate a raw `Authorization` header value as a Bearer token and return
|
|
501
|
+
* the verified {@link AuthInfo}.
|
|
502
|
+
*
|
|
503
|
+
* The runtime-neutral core of Bearer authentication: it parses the header,
|
|
504
|
+
* runs the verifier, enforces `requiredScopes`, and rejects tokens without an
|
|
505
|
+
* expiration or past it. On any failure it throws an {@link OAuthError} —
|
|
506
|
+
* pass that to {@link bearerAuthChallengeResponse} for the matching HTTP
|
|
507
|
+
* answer, or use {@link requireBearerAuth} to get both steps as one call.
|
|
508
|
+
*
|
|
509
|
+
* Framework adapters build on this: `requireBearerAuth` from
|
|
510
|
+
* `@modelcontextprotocol/express` feeds it `req.headers.authorization`.
|
|
511
|
+
*/
|
|
512
|
+
async function verifyBearerToken(authorizationHeader, options) {
|
|
513
|
+
const { verifier, requiredScopes = [] } = options;
|
|
514
|
+
if (!authorizationHeader) throw new require_src.OAuthError(require_src.OAuthErrorCode.InvalidToken, "Missing Authorization header");
|
|
515
|
+
const [type, token] = authorizationHeader.split(" ");
|
|
516
|
+
if (type?.toLowerCase() !== "bearer" || !token) throw new require_src.OAuthError(require_src.OAuthErrorCode.InvalidToken, "Invalid Authorization header format, expected 'Bearer TOKEN'");
|
|
517
|
+
const authInfo = await verifier.verifyAccessToken(token);
|
|
518
|
+
if (requiredScopes.length > 0) {
|
|
519
|
+
if (!requiredScopes.every((scope) => authInfo.scopes.includes(scope))) throw new require_src.OAuthError(require_src.OAuthErrorCode.InsufficientScope, "Insufficient scope");
|
|
520
|
+
}
|
|
521
|
+
if (typeof authInfo.expiresAt !== "number" || Number.isNaN(authInfo.expiresAt)) throw new require_src.OAuthError(require_src.OAuthErrorCode.InvalidToken, "Token has no expiration time");
|
|
522
|
+
else if (authInfo.expiresAt < Date.now() / 1e3) throw new require_src.OAuthError(require_src.OAuthErrorCode.InvalidToken, "Token has expired");
|
|
523
|
+
if (options.resourceMetadataUrl !== void 0 && authInfo.resourceMetadataUrl === void 0) return {
|
|
524
|
+
...authInfo,
|
|
525
|
+
resourceMetadataUrl: options.resourceMetadataUrl
|
|
526
|
+
};
|
|
527
|
+
return authInfo;
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* Build the HTTP answer for a Bearer authentication failure.
|
|
531
|
+
*
|
|
532
|
+
* Maps an {@link OAuthError} to its status — `401` for `invalid_token` and
|
|
533
|
+
* `403` for `insufficient_scope` (both carrying the `WWW-Authenticate: Bearer …`
|
|
534
|
+
* challenge, with `resource_metadata` when configured so clients can discover
|
|
535
|
+
* the Authorization Server), `500` for `server_error`, `400` for anything
|
|
536
|
+
* else. A non-`OAuthError` value answers `500 server_error`. The body is the
|
|
537
|
+
* OAuth error JSON.
|
|
538
|
+
*/
|
|
539
|
+
function bearerAuthChallengeResponse(error, options) {
|
|
540
|
+
const { requiredScopes = [], resourceMetadataUrl } = options ?? {};
|
|
541
|
+
if (!(error instanceof require_src.OAuthError)) {
|
|
542
|
+
const serverError = new require_src.OAuthError(require_src.OAuthErrorCode.ServerError, "Internal Server Error");
|
|
543
|
+
return Response.json(serverError.toResponseObject(), { status: 500 });
|
|
544
|
+
}
|
|
545
|
+
switch (error.code) {
|
|
546
|
+
case require_src.OAuthErrorCode.InvalidToken: {
|
|
547
|
+
const challenge = buildWwwAuthenticateHeader(error.code, error.message, requiredScopes, resourceMetadataUrl);
|
|
548
|
+
return Response.json(error.toResponseObject(), {
|
|
549
|
+
status: 401,
|
|
550
|
+
headers: { "WWW-Authenticate": challenge }
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
case require_src.OAuthErrorCode.InsufficientScope: {
|
|
554
|
+
const challenge = buildWwwAuthenticateHeader(error.code, error.message, requiredScopes, resourceMetadataUrl);
|
|
555
|
+
return Response.json(error.toResponseObject(), {
|
|
556
|
+
status: 403,
|
|
557
|
+
headers: { "WWW-Authenticate": challenge }
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
case require_src.OAuthErrorCode.ServerError: return Response.json(error.toResponseObject(), { status: 500 });
|
|
561
|
+
default: return Response.json(error.toResponseObject(), { status: 400 });
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Require a valid Bearer token on web-standard requests.
|
|
566
|
+
*
|
|
567
|
+
* The framework-free counterpart of `requireBearerAuth` from
|
|
568
|
+
* `@modelcontextprotocol/express`, for hosts whose HTTP surface is a
|
|
569
|
+
* `fetch(request)` handler — Cloudflare Workers, Deno, Bun, Hono. The
|
|
570
|
+
* returned gate resolves to the verified {@link AuthInfo}, or to the
|
|
571
|
+
* ready-to-return challenge `Response` when the request must be refused.
|
|
572
|
+
*
|
|
573
|
+
* @example
|
|
574
|
+
* ```ts source="./bearerAuth.examples.ts#requireBearerAuth_fetchGate"
|
|
575
|
+
* const gate = requireBearerAuth({ verifier, requiredScopes: ['mcp'] });
|
|
576
|
+
*
|
|
577
|
+
* async function fetchHandler(request: Request): Promise<Response> {
|
|
578
|
+
* const auth: AuthInfo | Response = await gate(request);
|
|
579
|
+
* if (auth instanceof Response) return auth;
|
|
580
|
+
* return handler.fetch(request, { authInfo: auth });
|
|
581
|
+
* }
|
|
582
|
+
* ```
|
|
583
|
+
*/
|
|
584
|
+
function requireBearerAuth(options) {
|
|
585
|
+
const { verifier, requiredScopes = [], resourceMetadataUrl } = options;
|
|
586
|
+
const resolved = {
|
|
587
|
+
verifier,
|
|
588
|
+
requiredScopes,
|
|
589
|
+
resourceMetadataUrl
|
|
590
|
+
};
|
|
591
|
+
return async (request) => {
|
|
592
|
+
const [authorizationHeader] = (request.headers.get("authorization") ?? "").split(",");
|
|
593
|
+
try {
|
|
594
|
+
return await verifyBearerToken(authorizationHeader || void 0, resolved);
|
|
595
|
+
} catch (error) {
|
|
596
|
+
return bearerAuthChallengeResponse(error, resolved);
|
|
597
|
+
}
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
//#endregion
|
|
602
|
+
//#region src/server/middleware/oauthMetadata.ts
|
|
603
|
+
function checkIssuerUrl(issuer, allowInsecure) {
|
|
604
|
+
if (issuer.protocol !== "https:" && issuer.hostname !== "localhost" && issuer.hostname !== "127.0.0.1" && !allowInsecure) throw new Error("Issuer URL must be HTTPS");
|
|
605
|
+
if (issuer.hash) throw new Error(`Issuer URL must not have a fragment: ${issuer}`);
|
|
606
|
+
if (issuer.search) throw new Error(`Issuer URL must not have a query string: ${issuer}`);
|
|
607
|
+
}
|
|
608
|
+
/**
|
|
609
|
+
* Derive the RFC 9728 Protected Resource Metadata document from
|
|
610
|
+
* {@link AuthMetadataOptions}, validating the Authorization Server issuer URL
|
|
611
|
+
* (HTTPS required outside localhost) in the process.
|
|
612
|
+
*
|
|
613
|
+
* `oauthMetadataResponse` and the Express `mcpAuthMetadataRouter` both build
|
|
614
|
+
* on this; use it directly when serving the document through your own
|
|
615
|
+
* routing — or call it once at startup to fail fast on a misconfigured
|
|
616
|
+
* issuer before any request arrives.
|
|
617
|
+
*/
|
|
618
|
+
function buildOAuthProtectedResourceMetadata(options) {
|
|
619
|
+
checkIssuerUrl(new URL(options.oauthMetadata.issuer), options.dangerouslyAllowInsecureIssuerUrl);
|
|
620
|
+
return {
|
|
621
|
+
resource: options.resourceServerUrl.href,
|
|
622
|
+
authorization_servers: [options.oauthMetadata.issuer],
|
|
623
|
+
scopes_supported: options.scopesSupported,
|
|
624
|
+
resource_name: options.resourceName,
|
|
625
|
+
resource_documentation: options.serviceDocumentationUrl?.href
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Builds the RFC 9728 Protected Resource Metadata URL for a given MCP server
|
|
630
|
+
* URL by inserting `/.well-known/oauth-protected-resource` ahead of the path.
|
|
631
|
+
*
|
|
632
|
+
* @example
|
|
633
|
+
* ```ts
|
|
634
|
+
* getOAuthProtectedResourceMetadataUrl(new URL('https://api.example.com/mcp'))
|
|
635
|
+
* // → 'https://api.example.com/.well-known/oauth-protected-resource/mcp'
|
|
636
|
+
* ```
|
|
637
|
+
*/
|
|
638
|
+
function getOAuthProtectedResourceMetadataUrl(serverUrl) {
|
|
639
|
+
const metadataUrl = new URL(serverUrl);
|
|
640
|
+
metadataUrl.pathname = protectedResourceMetadataPath(serverUrl);
|
|
641
|
+
metadataUrl.hash = "";
|
|
642
|
+
return metadataUrl.href;
|
|
643
|
+
}
|
|
644
|
+
/** The RFC 9728 path-aware well-known path for a resource URL. */
|
|
645
|
+
function protectedResourceMetadataPath(resourceServerUrl) {
|
|
646
|
+
const rsPath = stripTrailingSlash(resourceServerUrl.pathname);
|
|
647
|
+
return `/.well-known/oauth-protected-resource${rsPath === "/" ? "" : rsPath}`;
|
|
648
|
+
}
|
|
649
|
+
function stripTrailingSlash(path) {
|
|
650
|
+
return path.length > 1 && path.endsWith("/") ? path.slice(0, -1) : path;
|
|
651
|
+
}
|
|
652
|
+
const ALLOWED_METHODS = "GET, HEAD, OPTIONS";
|
|
653
|
+
function metadataDocumentResponse(request, metadata) {
|
|
654
|
+
if (request.method === "OPTIONS") {
|
|
655
|
+
const requestedHeaders = request.headers.get("access-control-request-headers");
|
|
656
|
+
return new Response(null, {
|
|
657
|
+
status: 204,
|
|
658
|
+
headers: {
|
|
659
|
+
"Access-Control-Allow-Origin": "*",
|
|
660
|
+
"Access-Control-Allow-Methods": ALLOWED_METHODS,
|
|
661
|
+
...requestedHeaders === null ? {} : {
|
|
662
|
+
"Access-Control-Allow-Headers": requestedHeaders,
|
|
663
|
+
Vary: "Access-Control-Request-Headers"
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
if (request.method !== "GET" && request.method !== "HEAD") {
|
|
669
|
+
const error = new require_src.OAuthError(require_src.OAuthErrorCode.MethodNotAllowed, `The method ${request.method} is not allowed for this endpoint`);
|
|
670
|
+
return Response.json(error.toResponseObject(), {
|
|
671
|
+
status: 405,
|
|
672
|
+
headers: {
|
|
673
|
+
Allow: ALLOWED_METHODS,
|
|
674
|
+
"Access-Control-Allow-Origin": "*"
|
|
675
|
+
}
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
const response = Response.json(metadata, { headers: { "Access-Control-Allow-Origin": "*" } });
|
|
679
|
+
return request.method === "HEAD" ? new Response(null, {
|
|
680
|
+
status: response.status,
|
|
681
|
+
headers: response.headers
|
|
682
|
+
}) : response;
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* Serve the two OAuth discovery documents an MCP server acting as a Resource
|
|
686
|
+
* Server exposes, from a web-standard `fetch(request)` handler:
|
|
687
|
+
*
|
|
688
|
+
* - `/.well-known/oauth-protected-resource[/<path>]` — RFC 9728 Protected
|
|
689
|
+
* Resource Metadata, derived from the supplied options (path-aware: the
|
|
690
|
+
* resource URL's path is reflected in the route).
|
|
691
|
+
* - `/.well-known/oauth-authorization-server` — RFC 8414 Authorization
|
|
692
|
+
* Server Metadata, passed through verbatim.
|
|
693
|
+
*
|
|
694
|
+
* Returns the matched document `Response` (JSON with permissive CORS, `405`
|
|
695
|
+
* with an `Allow` header for non-GET methods, `204` for CORS preflight), or
|
|
696
|
+
* `undefined` when the request path is neither well-known route — fall
|
|
697
|
+
* through to your own routing. The framework-free counterpart of
|
|
698
|
+
* `mcpAuthMetadataRouter` from `@modelcontextprotocol/express`; pair it with
|
|
699
|
+
* `requireBearerAuth` and `getOAuthProtectedResourceMetadataUrl` so
|
|
700
|
+
* unauthenticated clients can discover the AS from the `401` challenge.
|
|
701
|
+
*
|
|
702
|
+
* @example
|
|
703
|
+
* ```ts source="./oauthMetadata.examples.ts#oauthMetadataResponse_fetchHandler"
|
|
704
|
+
* async function fetchHandler(request: Request): Promise<Response> {
|
|
705
|
+
* return oauthMetadataResponse(request, options) ?? serveMcp(request);
|
|
706
|
+
* }
|
|
707
|
+
* ```
|
|
708
|
+
*/
|
|
709
|
+
function oauthMetadataResponse(request, options) {
|
|
710
|
+
const requestPath = stripTrailingSlash(new URL(request.url).pathname);
|
|
711
|
+
if (requestPath === protectedResourceMetadataPath(options.resourceServerUrl)) return metadataDocumentResponse(request, buildOAuthProtectedResourceMetadata(options));
|
|
712
|
+
if (requestPath === "/.well-known/oauth-authorization-server") {
|
|
713
|
+
buildOAuthProtectedResourceMetadata(options);
|
|
714
|
+
return metadataDocumentResponse(request, options.oauthMetadata);
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
//#endregion
|
|
719
|
+
//#region src/server/scopeChallenge.ts
|
|
720
|
+
/** @internal */
|
|
721
|
+
function supportsScopeChallengeResolver(transport) {
|
|
722
|
+
return typeof transport === "object" && transport !== null && "setScopeChallengeResolver" in transport && typeof transport.setScopeChallengeResolver === "function";
|
|
723
|
+
}
|
|
724
|
+
function assertScope(scope, location) {
|
|
725
|
+
if (typeof scope !== "string" || !/^[\u0021\u0023-\u005B\u005D-\u007E]+$/.test(scope)) throw new TypeError(`${location} must satisfy the OAuth scope-token grammar`);
|
|
726
|
+
}
|
|
727
|
+
function validateScopeChallenge(challenge) {
|
|
728
|
+
if (challenge === null || typeof challenge !== "object" || !Array.isArray(challenge.scopes) || challenge.scopes.length === 0) throw new TypeError("scope challenge must contain at least one scope");
|
|
729
|
+
for (const [index, scope] of challenge.scopes.entries()) assertScope(scope, `scope challenge scopes[${index}]`);
|
|
730
|
+
if (challenge.errorDescription !== void 0 && typeof challenge.errorDescription !== "string") throw new TypeError("scope challenge errorDescription must be a string");
|
|
731
|
+
if (challenge.errorDescription !== void 0 && !/^[\u0020-\u0021\u0023-\u005B\u005D-\u007E]+$/.test(challenge.errorDescription)) throw new TypeError("scope challenge errorDescription must satisfy the RFC 6750 error-description grammar");
|
|
732
|
+
return challenge;
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* Creates a handler that requires every supplied scope exactly.
|
|
736
|
+
*
|
|
737
|
+
* Requests without authentication are left to the server's authentication gate.
|
|
738
|
+
*/
|
|
739
|
+
function requireScopes(...scopes) {
|
|
740
|
+
if (scopes.length === 0) throw new TypeError("requireScopes must contain at least one scope");
|
|
741
|
+
for (const [index, scope] of scopes.entries()) assertScope(scope, `requireScopes scope[${index}]`);
|
|
742
|
+
const requiredScopes = [...scopes];
|
|
743
|
+
return ({ authInfo }) => {
|
|
744
|
+
if (authInfo === void 0) return;
|
|
745
|
+
const activeScopes = new Set(authInfo.scopes);
|
|
746
|
+
if (requiredScopes.every((scope) => activeScopes.has(scope))) return;
|
|
747
|
+
return { scopes: requiredScopes };
|
|
748
|
+
};
|
|
749
|
+
}
|
|
750
|
+
/** @internal */
|
|
751
|
+
async function findScopeChallenge(requests, authInfo, resolve) {
|
|
752
|
+
for (const request of requests) {
|
|
753
|
+
const challenge = await resolve({
|
|
754
|
+
request,
|
|
755
|
+
...authInfo !== void 0 && { authInfo }
|
|
756
|
+
});
|
|
757
|
+
if (challenge !== void 0) return validateScopeChallenge(challenge);
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
/**
|
|
761
|
+
* The RFC 9728 Protected Resource Metadata URL to advertise on a scope
|
|
762
|
+
* challenge, derived from the verified {@link AuthInfo}: the URL the
|
|
763
|
+
* authentication gate stamped (`authInfo.resourceMetadataUrl`, set by the
|
|
764
|
+
* bearer-auth helpers from their `resourceMetadataUrl` option), falling back
|
|
765
|
+
* to the well-known location for an HTTP(S) RFC 8707 `resource` identifier, or
|
|
766
|
+
* `undefined` when neither is available (the `resource_metadata` parameter is
|
|
767
|
+
* then omitted, matching the bearer-auth challenges).
|
|
768
|
+
*
|
|
769
|
+
* @internal
|
|
770
|
+
*/
|
|
771
|
+
function scopeChallengeResourceMetadataUrl(authInfo) {
|
|
772
|
+
if (authInfo?.resourceMetadataUrl !== void 0) return authInfo.resourceMetadataUrl;
|
|
773
|
+
if (authInfo?.resource?.protocol === "https:" || authInfo?.resource?.protocol === "http:") return getOAuthProtectedResourceMetadataUrl(authInfo.resource);
|
|
774
|
+
}
|
|
775
|
+
/** @internal */
|
|
776
|
+
function createScopeChallengeResponse(challenge, resourceMetadataUrl) {
|
|
777
|
+
return bearerAuthChallengeResponse(new require_src.OAuthError(require_src.OAuthErrorCode.InsufficientScope, challenge.errorDescription ?? "Insufficient scope"), {
|
|
778
|
+
requiredScopes: [...challenge.scopes],
|
|
779
|
+
resourceMetadataUrl
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
|
|
479
783
|
//#endregion
|
|
480
784
|
//#region src/server/legacyInputRequiredShim.ts
|
|
481
785
|
/**
|
|
@@ -1365,6 +1669,7 @@ var McpServer = class {
|
|
|
1365
1669
|
* ```
|
|
1366
1670
|
*/
|
|
1367
1671
|
async connect(transport) {
|
|
1672
|
+
if (supportsScopeChallengeResolver(transport)) transport.setScopeChallengeResolver((context) => this.resolveScopeChallenge(context));
|
|
1368
1673
|
return await this.server.connect(transport);
|
|
1369
1674
|
}
|
|
1370
1675
|
/**
|
|
@@ -1373,6 +1678,40 @@ var McpServer = class {
|
|
|
1373
1678
|
async close() {
|
|
1374
1679
|
await this.server.close();
|
|
1375
1680
|
}
|
|
1681
|
+
/** @internal */
|
|
1682
|
+
resolveScopeChallenge = (context) => {
|
|
1683
|
+
switch (context.request.method) {
|
|
1684
|
+
case "tools/call": {
|
|
1685
|
+
const toolName = context.request.params?.name;
|
|
1686
|
+
if (typeof toolName !== "string") return;
|
|
1687
|
+
const tool = this._registeredTools[toolName];
|
|
1688
|
+
if (tool === void 0 || !tool.enabled) return;
|
|
1689
|
+
return tool.scopeChallenge?.(context);
|
|
1690
|
+
}
|
|
1691
|
+
case "resources/read": {
|
|
1692
|
+
const resourceUri = context.request.params?.uri;
|
|
1693
|
+
if (typeof resourceUri !== "string") return;
|
|
1694
|
+
let uri;
|
|
1695
|
+
try {
|
|
1696
|
+
uri = new URL(resourceUri);
|
|
1697
|
+
} catch {
|
|
1698
|
+
return;
|
|
1699
|
+
}
|
|
1700
|
+
const resource = this._registeredResources[uri.toString()];
|
|
1701
|
+
if (resource !== void 0) return resource.enabled ? resource.scopeChallenge?.(context) : void 0;
|
|
1702
|
+
for (const template of Object.values(this._registeredResourceTemplates)) if (template.resourceTemplate.uriTemplate.match(uri.toString())) return template.enabled ? template.scopeChallenge?.(context) : void 0;
|
|
1703
|
+
return;
|
|
1704
|
+
}
|
|
1705
|
+
case "prompts/get": {
|
|
1706
|
+
const promptName = context.request.params?.name;
|
|
1707
|
+
if (typeof promptName !== "string") return;
|
|
1708
|
+
const prompt = this._registeredPrompts[promptName];
|
|
1709
|
+
if (prompt === void 0 || !prompt.enabled) return;
|
|
1710
|
+
return prompt.scopeChallenge?.(context);
|
|
1711
|
+
}
|
|
1712
|
+
default: return;
|
|
1713
|
+
}
|
|
1714
|
+
};
|
|
1376
1715
|
_toolHandlersInitialized = false;
|
|
1377
1716
|
setToolRequestHandlers() {
|
|
1378
1717
|
if (this._toolHandlersInitialized) return;
|
|
@@ -1538,7 +1877,10 @@ var McpServer = class {
|
|
|
1538
1877
|
}
|
|
1539
1878
|
for (const template of Object.values(this._registeredResourceTemplates)) {
|
|
1540
1879
|
const variables = template.resourceTemplate.uriTemplate.match(uri.toString());
|
|
1541
|
-
if (variables)
|
|
1880
|
+
if (variables) {
|
|
1881
|
+
if (!template.enabled) throw new require_src.ProtocolError(require_src.ProtocolErrorCode.InvalidParams, `Resource template ${template.resourceTemplate.uriTemplate} disabled`);
|
|
1882
|
+
return require_src.attachCacheHintFallback(await template.readCallback(uri, variables, ctx), template.cacheHint);
|
|
1883
|
+
}
|
|
1542
1884
|
}
|
|
1543
1885
|
throw new require_src.ResourceNotFoundError(request.params.uri);
|
|
1544
1886
|
});
|
|
@@ -1569,36 +1911,32 @@ var McpServer = class {
|
|
|
1569
1911
|
this._promptHandlersInitialized = true;
|
|
1570
1912
|
}
|
|
1571
1913
|
registerResource(name, uriOrTemplate, config, readCallback) {
|
|
1572
|
-
const cacheHint = config
|
|
1573
|
-
|
|
1574
|
-
if (cacheHint !== void 0) {
|
|
1575
|
-
require_src.assertValidCacheHint(cacheHint, `resource ${name}`);
|
|
1576
|
-
const rest = { ...config };
|
|
1577
|
-
delete rest.cacheHint;
|
|
1578
|
-
metadata = rest;
|
|
1579
|
-
}
|
|
1914
|
+
const { cacheHint, scopeChallenge, ...resourceMetadata } = config;
|
|
1915
|
+
const metadata = resourceMetadata;
|
|
1916
|
+
if (cacheHint !== void 0) require_src.assertValidCacheHint(cacheHint, `resource ${name}`);
|
|
1580
1917
|
if (typeof uriOrTemplate === "string") {
|
|
1581
1918
|
if (this._registeredResources[uriOrTemplate]) throw new Error(`Resource ${uriOrTemplate} is already registered`);
|
|
1582
|
-
const registeredResource = this._createRegisteredResource(name, config.title, uriOrTemplate, metadata, readCallback);
|
|
1919
|
+
const registeredResource = this._createRegisteredResource(name, config.title, uriOrTemplate, metadata, scopeChallenge, readCallback);
|
|
1583
1920
|
if (cacheHint !== void 0) registeredResource.cacheHint = cacheHint;
|
|
1584
1921
|
this.setResourceRequestHandlers();
|
|
1585
1922
|
this.sendResourceListChanged();
|
|
1586
1923
|
return registeredResource;
|
|
1587
1924
|
} else {
|
|
1588
1925
|
if (this._registeredResourceTemplates[name]) throw new Error(`Resource template ${name} is already registered`);
|
|
1589
|
-
const registeredResourceTemplate = this._createRegisteredResourceTemplate(name, config.title, uriOrTemplate, metadata, readCallback);
|
|
1926
|
+
const registeredResourceTemplate = this._createRegisteredResourceTemplate(name, config.title, uriOrTemplate, metadata, scopeChallenge, readCallback);
|
|
1590
1927
|
if (cacheHint !== void 0) registeredResourceTemplate.cacheHint = cacheHint;
|
|
1591
1928
|
this.setResourceRequestHandlers();
|
|
1592
1929
|
this.sendResourceListChanged();
|
|
1593
1930
|
return registeredResourceTemplate;
|
|
1594
1931
|
}
|
|
1595
1932
|
}
|
|
1596
|
-
_createRegisteredResource(name, title, uri, metadata, readCallback) {
|
|
1933
|
+
_createRegisteredResource(name, title, uri, metadata, scopeChallenge, readCallback) {
|
|
1597
1934
|
const registeredResource = {
|
|
1598
1935
|
name,
|
|
1599
1936
|
title,
|
|
1600
1937
|
metadata,
|
|
1601
1938
|
readCallback,
|
|
1939
|
+
scopeChallenge,
|
|
1602
1940
|
enabled: true,
|
|
1603
1941
|
disable: () => registeredResource.update({ enabled: false }),
|
|
1604
1942
|
enable: () => registeredResource.update({ enabled: true }),
|
|
@@ -1612,6 +1950,7 @@ var McpServer = class {
|
|
|
1612
1950
|
if (updates.title !== void 0) registeredResource.title = updates.title;
|
|
1613
1951
|
if (updates.metadata !== void 0) registeredResource.metadata = updates.metadata;
|
|
1614
1952
|
if (updates.callback !== void 0) registeredResource.readCallback = updates.callback;
|
|
1953
|
+
if (updates.scopeChallenge !== void 0) registeredResource.scopeChallenge = updates.scopeChallenge === null ? void 0 : updates.scopeChallenge;
|
|
1615
1954
|
if (updates.enabled !== void 0) registeredResource.enabled = updates.enabled;
|
|
1616
1955
|
this.sendResourceListChanged();
|
|
1617
1956
|
}
|
|
@@ -1619,12 +1958,13 @@ var McpServer = class {
|
|
|
1619
1958
|
this._registeredResources[uri] = registeredResource;
|
|
1620
1959
|
return registeredResource;
|
|
1621
1960
|
}
|
|
1622
|
-
_createRegisteredResourceTemplate(name, title, template, metadata, readCallback) {
|
|
1961
|
+
_createRegisteredResourceTemplate(name, title, template, metadata, scopeChallenge, readCallback) {
|
|
1623
1962
|
const registeredResourceTemplate = {
|
|
1624
1963
|
resourceTemplate: template,
|
|
1625
1964
|
title,
|
|
1626
1965
|
metadata,
|
|
1627
1966
|
readCallback,
|
|
1967
|
+
scopeChallenge,
|
|
1628
1968
|
enabled: true,
|
|
1629
1969
|
disable: () => registeredResourceTemplate.update({ enabled: false }),
|
|
1630
1970
|
enable: () => registeredResourceTemplate.update({ enabled: true }),
|
|
@@ -1638,6 +1978,7 @@ var McpServer = class {
|
|
|
1638
1978
|
if (updates.template !== void 0) registeredResourceTemplate.resourceTemplate = updates.template;
|
|
1639
1979
|
if (updates.metadata !== void 0) registeredResourceTemplate.metadata = updates.metadata;
|
|
1640
1980
|
if (updates.callback !== void 0) registeredResourceTemplate.readCallback = updates.callback;
|
|
1981
|
+
if (updates.scopeChallenge !== void 0) registeredResourceTemplate.scopeChallenge = updates.scopeChallenge === null ? void 0 : updates.scopeChallenge;
|
|
1641
1982
|
if (updates.enabled !== void 0) registeredResourceTemplate.enabled = updates.enabled;
|
|
1642
1983
|
this.sendResourceListChanged();
|
|
1643
1984
|
}
|
|
@@ -1647,7 +1988,7 @@ var McpServer = class {
|
|
|
1647
1988
|
if (Array.isArray(variableNames) && variableNames.some((v) => !!template.completeCallback(v))) this.setCompletionRequestHandler();
|
|
1648
1989
|
return registeredResourceTemplate;
|
|
1649
1990
|
}
|
|
1650
|
-
_createRegisteredPrompt(name, title, description, argsSchema, callback, icons, _meta) {
|
|
1991
|
+
_createRegisteredPrompt(name, title, description, argsSchema, callback, icons, scopeChallenge, _meta) {
|
|
1651
1992
|
let currentArgsSchema = argsSchema;
|
|
1652
1993
|
let currentCallback = callback;
|
|
1653
1994
|
const registeredPrompt = {
|
|
@@ -1655,6 +1996,7 @@ var McpServer = class {
|
|
|
1655
1996
|
description,
|
|
1656
1997
|
argsSchema,
|
|
1657
1998
|
icons,
|
|
1999
|
+
scopeChallenge,
|
|
1658
2000
|
_meta,
|
|
1659
2001
|
handler: createPromptHandler(name, argsSchema, callback),
|
|
1660
2002
|
enabled: true,
|
|
@@ -1669,6 +2011,7 @@ var McpServer = class {
|
|
|
1669
2011
|
if (updates.title !== void 0) registeredPrompt.title = updates.title;
|
|
1670
2012
|
if (updates.description !== void 0) registeredPrompt.description = updates.description;
|
|
1671
2013
|
if (updates.icons !== void 0) registeredPrompt.icons = updates.icons;
|
|
2014
|
+
if (updates.scopeChallenge !== void 0) registeredPrompt.scopeChallenge = updates.scopeChallenge === null ? void 0 : updates.scopeChallenge;
|
|
1672
2015
|
if (updates._meta !== void 0) registeredPrompt._meta = updates._meta;
|
|
1673
2016
|
let needsHandlerRegen = false;
|
|
1674
2017
|
if (updates.argsSchema !== void 0) {
|
|
@@ -1696,7 +2039,7 @@ var McpServer = class {
|
|
|
1696
2039
|
}
|
|
1697
2040
|
return registeredPrompt;
|
|
1698
2041
|
}
|
|
1699
|
-
_createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, icons, execution, _meta, handler) {
|
|
2042
|
+
_createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, icons, execution, scopeChallenge, _meta, handler) {
|
|
1700
2043
|
require_src.validateAndWarnToolName(name);
|
|
1701
2044
|
if (inputSchema !== void 0) try {
|
|
1702
2045
|
const json = require_src.standardSchemaToJsonSchema(inputSchema, "input");
|
|
@@ -1714,6 +2057,7 @@ var McpServer = class {
|
|
|
1714
2057
|
annotations,
|
|
1715
2058
|
icons,
|
|
1716
2059
|
execution,
|
|
2060
|
+
scopeChallenge,
|
|
1717
2061
|
_meta,
|
|
1718
2062
|
handler,
|
|
1719
2063
|
executor: createToolExecutor(inputSchema, handler),
|
|
@@ -1752,6 +2096,7 @@ var McpServer = class {
|
|
|
1752
2096
|
}
|
|
1753
2097
|
if (updates.annotations !== void 0) registeredTool.annotations = updates.annotations;
|
|
1754
2098
|
if (updates.icons !== void 0) registeredTool.icons = updates.icons;
|
|
2099
|
+
if (updates.scopeChallenge !== void 0) registeredTool.scopeChallenge = updates.scopeChallenge === null ? void 0 : updates.scopeChallenge;
|
|
1755
2100
|
if (updates._meta !== void 0) registeredTool._meta = updates._meta;
|
|
1756
2101
|
if (updates.enabled !== void 0) registeredTool.enabled = updates.enabled;
|
|
1757
2102
|
this.sendToolListChanged();
|
|
@@ -1764,13 +2109,13 @@ var McpServer = class {
|
|
|
1764
2109
|
}
|
|
1765
2110
|
registerTool(name, config, cb) {
|
|
1766
2111
|
if (this._registeredTools[name]) throw new Error(`Tool ${name} is already registered`);
|
|
1767
|
-
const { title, description, inputSchema, outputSchema, annotations, icons, _meta } = config;
|
|
1768
|
-
return this._createRegisteredTool(name, title, description, require_src.normalizeRawShapeSchema(inputSchema), require_src.normalizeRawShapeSchema(outputSchema), annotations, icons, void 0, _meta, cb);
|
|
2112
|
+
const { title, description, inputSchema, outputSchema, annotations, icons, scopeChallenge, _meta } = config;
|
|
2113
|
+
return this._createRegisteredTool(name, title, description, require_src.normalizeRawShapeSchema(inputSchema), require_src.normalizeRawShapeSchema(outputSchema), annotations, icons, void 0, scopeChallenge, _meta, cb);
|
|
1769
2114
|
}
|
|
1770
2115
|
registerPrompt(name, config, cb) {
|
|
1771
2116
|
if (this._registeredPrompts[name]) throw new Error(`Prompt ${name} is already registered`);
|
|
1772
|
-
const { title, description, argsSchema, icons, _meta } = config;
|
|
1773
|
-
const registeredPrompt = this._createRegisteredPrompt(name, title, description, require_src.normalizeRawShapeSchema(argsSchema), cb, icons, _meta);
|
|
2117
|
+
const { title, description, argsSchema, icons, scopeChallenge, _meta } = config;
|
|
2118
|
+
const registeredPrompt = this._createRegisteredPrompt(name, title, description, require_src.normalizeRawShapeSchema(argsSchema), cb, icons, scopeChallenge, _meta);
|
|
1774
2119
|
this.setPromptRequestHandlers();
|
|
1775
2120
|
this.sendPromptListChanged();
|
|
1776
2121
|
return registeredPrompt;
|
|
@@ -1977,6 +2322,18 @@ Object.defineProperty(exports, 'armSseKeepAlive', {
|
|
|
1977
2322
|
return armSseKeepAlive;
|
|
1978
2323
|
}
|
|
1979
2324
|
});
|
|
2325
|
+
Object.defineProperty(exports, 'bearerAuthChallengeResponse', {
|
|
2326
|
+
enumerable: true,
|
|
2327
|
+
get: function () {
|
|
2328
|
+
return bearerAuthChallengeResponse;
|
|
2329
|
+
}
|
|
2330
|
+
});
|
|
2331
|
+
Object.defineProperty(exports, 'buildOAuthProtectedResourceMetadata', {
|
|
2332
|
+
enumerable: true,
|
|
2333
|
+
get: function () {
|
|
2334
|
+
return buildOAuthProtectedResourceMetadata;
|
|
2335
|
+
}
|
|
2336
|
+
});
|
|
1980
2337
|
Object.defineProperty(exports, 'completable', {
|
|
1981
2338
|
enumerable: true,
|
|
1982
2339
|
get: function () {
|
|
@@ -1989,12 +2346,30 @@ Object.defineProperty(exports, 'createListenRouter', {
|
|
|
1989
2346
|
return createListenRouter;
|
|
1990
2347
|
}
|
|
1991
2348
|
});
|
|
2349
|
+
Object.defineProperty(exports, 'createScopeChallengeResponse', {
|
|
2350
|
+
enumerable: true,
|
|
2351
|
+
get: function () {
|
|
2352
|
+
return createScopeChallengeResponse;
|
|
2353
|
+
}
|
|
2354
|
+
});
|
|
1992
2355
|
Object.defineProperty(exports, 'createServerNotifier', {
|
|
1993
2356
|
enumerable: true,
|
|
1994
2357
|
get: function () {
|
|
1995
2358
|
return createServerNotifier;
|
|
1996
2359
|
}
|
|
1997
2360
|
});
|
|
2361
|
+
Object.defineProperty(exports, 'findScopeChallenge', {
|
|
2362
|
+
enumerable: true,
|
|
2363
|
+
get: function () {
|
|
2364
|
+
return findScopeChallenge;
|
|
2365
|
+
}
|
|
2366
|
+
});
|
|
2367
|
+
Object.defineProperty(exports, 'getOAuthProtectedResourceMetadataUrl', {
|
|
2368
|
+
enumerable: true,
|
|
2369
|
+
get: function () {
|
|
2370
|
+
return getOAuthProtectedResourceMetadataUrl;
|
|
2371
|
+
}
|
|
2372
|
+
});
|
|
1998
2373
|
Object.defineProperty(exports, 'installModernOnlyHandlers', {
|
|
1999
2374
|
enumerable: true,
|
|
2000
2375
|
get: function () {
|
|
@@ -2007,6 +2382,30 @@ Object.defineProperty(exports, 'isCompletable', {
|
|
|
2007
2382
|
return isCompletable;
|
|
2008
2383
|
}
|
|
2009
2384
|
});
|
|
2385
|
+
Object.defineProperty(exports, 'oauthMetadataResponse', {
|
|
2386
|
+
enumerable: true,
|
|
2387
|
+
get: function () {
|
|
2388
|
+
return oauthMetadataResponse;
|
|
2389
|
+
}
|
|
2390
|
+
});
|
|
2391
|
+
Object.defineProperty(exports, 'requireBearerAuth', {
|
|
2392
|
+
enumerable: true,
|
|
2393
|
+
get: function () {
|
|
2394
|
+
return requireBearerAuth;
|
|
2395
|
+
}
|
|
2396
|
+
});
|
|
2397
|
+
Object.defineProperty(exports, 'requireScopes', {
|
|
2398
|
+
enumerable: true,
|
|
2399
|
+
get: function () {
|
|
2400
|
+
return requireScopes;
|
|
2401
|
+
}
|
|
2402
|
+
});
|
|
2403
|
+
Object.defineProperty(exports, 'scopeChallengeResourceMetadataUrl', {
|
|
2404
|
+
enumerable: true,
|
|
2405
|
+
get: function () {
|
|
2406
|
+
return scopeChallengeResourceMetadataUrl;
|
|
2407
|
+
}
|
|
2408
|
+
});
|
|
2010
2409
|
Object.defineProperty(exports, 'seedClientIdentityFromEnvelope', {
|
|
2011
2410
|
enumerable: true,
|
|
2012
2411
|
get: function () {
|
|
@@ -2019,4 +2418,10 @@ Object.defineProperty(exports, 'serverIdentityOf', {
|
|
|
2019
2418
|
return serverIdentityOf;
|
|
2020
2419
|
}
|
|
2021
2420
|
});
|
|
2022
|
-
|
|
2421
|
+
Object.defineProperty(exports, 'verifyBearerToken', {
|
|
2422
|
+
enumerable: true,
|
|
2423
|
+
get: function () {
|
|
2424
|
+
return verifyBearerToken;
|
|
2425
|
+
}
|
|
2426
|
+
});
|
|
2427
|
+
//# sourceMappingURL=mcp-DUcCQSTW.cjs.map
|