@questpie/mcp 3.3.0 → 3.15.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/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { a as requiredScopesForOperation, i as normalizeRequiredScopes, n as mcpTool, o as scopeGateAllows, r as defaultOperationScope, s as scopesFromContext, t as createMcpServer } from "./create-server-DIvtVlma.mjs";
2
- import { n as mcp_default, t as mcpModule } from "./mcp-DapXh3Mk.mjs";
2
+ import { n as mcp_default, t as mcpModule } from "./mcp-snyVygDQ.mjs";
3
3
  import { t as mcpPlugin } from "./plugin-BJ6gELRj.mjs";
4
4
  import { t as startStdioServer } from "./stdio-qyQFVEyU.mjs";
5
5
 
@@ -47,18 +47,23 @@ function withCors(response, request) {
47
47
  /**
48
48
  * Build the `WWW-Authenticate` challenge value for an unauthenticated HTTP MCP
49
49
  * request. `resource_metadata` points at this app's Protected Resource metadata
50
- * document (RFC 9728), served at the server root by the core `oauth-protected-
51
- * resource` route (MO4). An MCP client reads it to discover the authorization
52
- * server and start the OAuth 2.1 flow.
50
+ * document (RFC 9728), served beside the MCP route by the core
51
+ * `oauth-protected-resource` route (MO4). An MCP client reads it to discover
52
+ * the authorization server and start the OAuth 2.1 flow.
53
53
  *
54
- * The origin is derived from `app.config.app.url` — the same base MO2/MO6 use to
55
- * bind and verify token audience — so the advertised metadata URL always matches
56
- * where discovery actually lives. `new URL(...).origin` strips any path/query and
57
- * yields a bare `scheme://host[:port]`, so an app URL with a subpath still
58
- * produces a root-mounted metadata URL.
54
+ * The public origin comes from `app.config.app.url`, while the mount path comes
55
+ * from the actual MCP request. This keeps the canonical external host used for
56
+ * token audience binding, and also preserves adapter base paths such as `/api`.
59
57
  */
60
- function protectedResourceChallenge(appUrl) {
61
- return `Bearer resource_metadata="${new URL(appUrl).origin}/.well-known/oauth-protected-resource"`;
58
+ function protectedResourceChallenge(appUrl, requestUrl) {
59
+ const request = new URL(requestUrl);
60
+ request.pathname = request.pathname.replace(/\/+$/, "");
61
+ const metadataPath = new URL(".well-known/oauth-protected-resource", request).pathname;
62
+ const metadataUrl = new URL(appUrl);
63
+ metadataUrl.pathname = metadataPath;
64
+ metadataUrl.search = "";
65
+ metadataUrl.hash = "";
66
+ return `Bearer resource_metadata="${metadataUrl.href}"`;
62
67
  }
63
68
  /**
64
69
  * A verified principal is required to reach MCP tool execution over HTTP. The
@@ -75,7 +80,7 @@ async function mcpHandler(ctx) {
75
80
  if (request.method === "OPTIONS") return withCors(new Response(null, { status: 204 }), request);
76
81
  if (!hasVerifiedPrincipal(ctx)) return withCors(new Response(null, {
77
82
  status: 401,
78
- headers: { "WWW-Authenticate": protectedResourceChallenge(app.config.app.url) }
83
+ headers: { "WWW-Authenticate": protectedResourceChallenge(app.config.app.url, request.url) }
79
84
  }), request);
80
85
  const config = app.state?.config?.mcp ?? {};
81
86
  const server = await createMcpServer(app, {
@@ -1,3 +1,3 @@
1
- import { t as mcpModule } from "../mcp-DapXh3Mk.mjs";
1
+ import { t as mcpModule } from "../mcp-snyVygDQ.mjs";
2
2
 
3
3
  export { mcpModule };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@questpie/mcp",
3
- "version": "3.3.0",
3
+ "version": "3.15.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/questpie/questpie.git",
@@ -16,20 +16,20 @@
16
16
  "types": "./dist/index.d.mts",
17
17
  "exports": {
18
18
  ".": {
19
- "types": "./src/exports/index.ts",
20
- "default": "./src/exports/index.ts"
19
+ "types": "./dist/index.d.mts",
20
+ "default": "./dist/index.mjs"
21
21
  },
22
22
  "./modules/mcp": {
23
- "types": "./src/exports/modules/mcp.ts",
24
- "default": "./src/exports/modules/mcp.ts"
23
+ "types": "./dist/modules/mcp.d.mts",
24
+ "default": "./dist/modules/mcp.mjs"
25
25
  },
26
26
  "./plugin": {
27
- "types": "./src/exports/plugin.ts",
28
- "default": "./src/exports/plugin.ts"
27
+ "types": "./dist/plugin.d.mts",
28
+ "default": "./dist/plugin.mjs"
29
29
  },
30
30
  "./stdio": {
31
- "types": "./src/exports/stdio.ts",
32
- "default": "./src/exports/stdio.ts"
31
+ "types": "./dist/stdio.d.mts",
32
+ "default": "./dist/stdio.mjs"
33
33
  },
34
34
  "./package.json": {
35
35
  "types": "./package.json",
@@ -68,7 +68,7 @@
68
68
  },
69
69
  "dependencies": {
70
70
  "@modelcontextprotocol/sdk": "^1.29.0",
71
- "questpie": "workspace:*",
71
+ "questpie": "^3.15.1",
72
72
  "zod": "^4.2.1"
73
73
  },
74
74
  "devDependencies": {