@happyvertical/smrt-app-mcp 0.69.0 → 0.70.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +13 -0
- package/README.md +25 -4
- package/dist/audit-store.js +1 -1
- package/dist/audit-store.js.map +1 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +2 -1
- package/dist/auth.js.map +1 -1
- package/dist/chunks/{defaults-DF29ycmk.js → defaults-B9-qW692.js} +10 -4
- package/dist/chunks/{defaults-DF29ycmk.js.map → defaults-B9-qW692.js.map} +1 -1
- package/dist/chunks/{protocol-DhngxmZq.js → protocol-Ck9LMfma.js} +2 -2
- package/dist/chunks/{protocol-DhngxmZq.js.map → protocol-Ck9LMfma.js.map} +1 -1
- package/dist/index.js +2 -2
- package/dist/manifest.json +1 -1
- package/dist/server.d.ts +7 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/smrt-knowledge.json +5 -5
- package/dist/smrt-knowledge.okf.md +2 -2
- package/dist/sveltekit.d.ts +21 -1
- package/dist/sveltekit.d.ts.map +1 -1
- package/dist/sveltekit.js +11 -5
- package/dist/sveltekit.js.map +1 -1
- package/package.json +5 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as compareMcpToolNames } from "./defaults-
|
|
1
|
+
import { c as compareMcpToolNames } from "./defaults-B9-qW692.js";
|
|
2
2
|
import { s as McpAccessError } from "./errors-BuM1XuuV.js";
|
|
3
3
|
import { ProtocolError, ProtocolErrorCode, Server } from "@modelcontextprotocol/server";
|
|
4
4
|
//#region \0rolldown/runtime.js
|
|
@@ -150,4 +150,4 @@ function assertExtensionMetadata(value) {
|
|
|
150
150
|
//#endregion
|
|
151
151
|
export { createMcpProtocolServerForRequest as n, protocol_exports as r, createMcpProtocolServer as t };
|
|
152
152
|
|
|
153
|
-
//# sourceMappingURL=protocol-
|
|
153
|
+
//# sourceMappingURL=protocol-Ck9LMfma.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol-DhngxmZq.js","names":[],"sources":["../../src/protocol.ts"],"sourcesContent":["/** MCP SDK v2 protocol adapter for the framework-neutral app server core. */\n\nimport type { MCPTool } from '@happyvertical/smrt-core/generators/mcp';\nimport {\n type CallToolResult,\n type JSONObject,\n ProtocolError,\n ProtocolErrorCode,\n Server,\n type ServerContext,\n type Tool,\n} from '@modelcontextprotocol/server';\nimport { McpAccessError } from './errors.js';\nimport type { McpAppPrincipal, McpAppServer } from './server.js';\nimport { compareMcpToolNames } from './tools.js';\n\nexport const MCP_TASKS_EXTENSION = 'io.modelcontextprotocol/tasks';\n\nconst DEFAULT_TOOL_LIST_CACHE_HINT = {\n ttlMs: 86_400_000,\n cacheScope: 'private' as const,\n};\n\nexport interface McpProtocolServerOptions {\n /** Resolve the authenticated application principal for each MCP request. */\n principal?:\n | McpAppPrincipal\n | null\n | ((\n context: ServerContext,\n ) => McpAppPrincipal | null | Promise<McpAppPrincipal | null>);\n}\n\n/** Request-bound options for asynchronous catalog extension projection. */\nexport interface McpProtocolRequestOptions {\n principal?: McpAppPrincipal | null;\n /** Optional inert extension metadata, recomputed from this request's authorized catalog. */\n extensions?: (context: {\n principal: McpAppPrincipal | null;\n tools: readonly MCPTool[];\n }) =>\n | Record<string, Record<string, unknown>>\n | Promise<Record<string, Record<string, unknown>>>;\n}\n\n/** Prepare native capabilities before the SDK HTTP factory installs discovery handlers. */\nexport async function createMcpProtocolServerForRequest(\n appServer: McpAppServer,\n options: McpProtocolRequestOptions = {},\n): Promise<Server> {\n const principal = options.principal ?? null;\n let extensions: Record<string, JSONObject> = {};\n if (options.extensions) {\n try {\n const tools = await appServer.listTools({ principal });\n const projected = await options.extensions({ principal, tools });\n assertExtensionMetadata(projected);\n if (Object.hasOwn(projected, MCP_TASKS_EXTENSION))\n throw new TypeError('Reserved extension.');\n extensions = structuredClone(projected);\n } catch {\n throw new ProtocolError(\n ProtocolErrorCode.InternalError,\n 'Extension discovery unavailable.',\n );\n }\n }\n return protocolServer(appServer, { principal }, extensions);\n}\n\nasync function resolvePrincipal(\n option: McpProtocolServerOptions['principal'],\n context: ServerContext,\n): Promise<McpAppPrincipal | null> {\n if (typeof option === 'function') return (await option(context)) ?? null;\n return option ?? null;\n}\n\n/**\n * Adapt an app MCP core to the SDK v2 low-level server protocol.\n *\n * Transport ownership remains with the caller. In particular, this does not\n * add a production HTTP endpoint; it is safe to compose with `serveStdio` or\n * `createMcpHandler` in a deployment that supplies its own authentication.\n */\nexport function createMcpProtocolServer(\n appServer: McpAppServer,\n options: McpProtocolServerOptions = {},\n): Server {\n if ('extensions' in options) {\n throw new TypeError(\n 'Extension discovery requires createMcpProtocolServerForRequest.',\n );\n }\n return protocolServer(appServer, options, {});\n}\n\nfunction protocolServer(\n appServer: McpAppServer,\n options: McpProtocolServerOptions,\n extensions: Record<string, JSONObject>,\n): Server {\n // Task lifecycle records are owner-scoped. Unlike ordinary public read-only\n // tools, they cannot be safely exposed without a stable principal id.\n const tasksEnabled =\n appServer.tasksEnabled &&\n typeof options.principal !== 'function' &&\n Boolean(options.principal?.id);\n const server = new Server(appServer.serverInfo, {\n capabilities: {\n tools: {},\n ...(appServer.listResources && appServer.readResource\n ? { resources: {} }\n : {}),\n ...(tasksEnabled || Object.keys(extensions).length\n ? {\n extensions: {\n ...extensions,\n ...(tasksEnabled ? { [MCP_TASKS_EXTENSION]: {} } : {}),\n },\n }\n : {}),\n } as never,\n cacheHints: { 'tools/list': DEFAULT_TOOL_LIST_CACHE_HINT },\n });\n\n server.setRequestHandler('tools/list', async (_request, context) => {\n const principal = await resolvePrincipal(options.principal, context);\n const cacheHint =\n (await appServer.getToolsListCacheHint?.()) ??\n DEFAULT_TOOL_LIST_CACHE_HINT;\n return {\n tools: [...(await appServer.listTools({ principal }))].sort(\n (left, right) => compareMcpToolNames(left.name, right.name),\n ) as Tool[],\n ...cacheHint,\n };\n });\n\n if (appServer.listResources && appServer.readResource) {\n server.setRequestHandler('resources/list', async (_request, context) => ({\n resources: await appServer.listResources!({\n principal: await resolvePrincipal(options.principal, context),\n }),\n ttlMs: 0,\n cacheScope: 'private',\n }));\n server.setRequestHandler('resources/read', async (request, context) => {\n try {\n return {\n contents: [\n await appServer.readResource!({\n uri: request.params.uri,\n principal: await resolvePrincipal(options.principal, context),\n }),\n ],\n ttlMs: 0,\n cacheScope: 'private',\n };\n } catch (error) {\n if (error instanceof McpAccessError)\n throw new ProtocolError(\n ProtocolErrorCode.InvalidParams,\n 'MCP resource is not available.',\n );\n throw error;\n }\n });\n }\n\n server.setRequestHandler('tools/call', async (request, context) => {\n try {\n return (await appServer.callTool({\n name: request.params.name,\n arguments: request.params.arguments,\n principal: await resolvePrincipal(options.principal, context),\n })) as CallToolResult;\n } catch (error) {\n if (error instanceof McpAccessError) {\n const { code, retryable } = error.metadata;\n throw new ProtocolError(\n error.status === 404\n ? ProtocolErrorCode.InvalidParams\n : ProtocolErrorCode.InvalidRequest,\n error.message,\n {\n ...(typeof code === 'string' ? { code } : {}),\n ...(typeof retryable === 'boolean' ? { retryable } : {}),\n },\n );\n }\n throw error;\n }\n });\n\n return server;\n}\n\n/** Bound plugin discovery metadata without allowing executable values or provider-specific types. */\nfunction assertExtensionMetadata(\n value: unknown,\n): asserts value is Record<string, JSONObject> {\n let budget = 65536;\n const visit = (v: unknown, depth: number): void => {\n if (--budget < 0 || depth > 16)\n throw new TypeError('Extension metadata exceeds limits.');\n if (v === null || typeof v === 'boolean') return;\n if (typeof v === 'number' && Number.isFinite(v)) return;\n if (typeof v === 'string') {\n budget -= new TextEncoder().encode(v).length;\n if (budget < 0) throw new TypeError('Extension metadata exceeds limits.');\n return;\n }\n if (Array.isArray(v)) {\n if (v.length > 1024)\n throw new TypeError('Extension array exceeds limits.');\n for (const item of v) visit(item, depth + 1);\n return;\n }\n if (\n !v ||\n typeof v !== 'object' ||\n ![Object.prototype, null].includes(Object.getPrototypeOf(v))\n )\n throw new TypeError('Expected plain extension object.');\n const names = Object.keys(v);\n if (names.length > 256)\n throw new TypeError('Extension object exceeds limits.');\n for (const name of names) {\n if (['__proto__', 'constructor', 'prototype'].includes(name))\n throw new TypeError('Unsafe extension key.');\n const descriptor = Object.getOwnPropertyDescriptor(v, name);\n if (!descriptor || !('value' in descriptor))\n throw new TypeError('Expected inert extension metadata.');\n visit(name, depth + 1);\n visit(descriptor.value, depth + 1);\n }\n };\n visit(value, 0);\n if (!value || typeof value !== 'object' || Array.isArray(value))\n throw new TypeError('Expected extension map.');\n for (const [name, entry] of Object.entries(value)) {\n if (\n !name.trim() ||\n !entry ||\n typeof entry !== 'object' ||\n Array.isArray(entry)\n )\n throw new TypeError('Expected named extension object.');\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAgBO,IAAM,sBAAsB;AAEnC,IAAM,+BAA+B;CACnC,OAAO;CACP,YAAY;AACd;AAyBA,eAAsB,kCACpB,WACA,UAAqC,CAAC,GACrB;CACjB,MAAM,YAAY,QAAQ,aAAa;CACvC,IAAI,aAAyC,CAAC;CAC9C,IAAI,QAAQ,YACV,IAAI;EACF,MAAM,QAAQ,MAAM,UAAU,UAAU,EAAE,UAAU,CAAC;EACrD,MAAM,YAAY,MAAM,QAAQ,WAAW;GAAE;GAAW;EAAM,CAAC;EAC/D,wBAAwB,SAAS;EACjC,IAAI,OAAO,OAAO,WAAA,+BAA8B,GAC9C,MAAM,IAAI,UAAU,qBAAqB;EAC3C,aAAa,gBAAgB,SAAS;CACxC,QAAQ;EACN,MAAM,IAAI,cACR,kBAAkB,eAClB,kCACF;CACF;CAEF,OAAO,eAAe,WAAW,EAAE,UAAU,GAAG,UAAU;AAC5D;AAEA,eAAe,iBACb,QACA,SACiC;CACjC,IAAI,OAAO,WAAW,YAAY,OAAQ,MAAM,OAAO,OAAO,KAAM;CACpE,OAAO,UAAU;AACnB;AASO,SAAS,wBACd,WACA,UAAoC,CAAC,GAC7B;CACR,IAAI,gBAAgB,SAClB,MAAM,IAAI,UACR,iEACF;CAEF,OAAO,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AM,YACb,CAAC,CAAC,OAAO,WAAW,IAAI,CAAA,CAAE,SAAS,OAAO,eAAe,CAAC,CAAC,GAE3D,MAAM,IAAI,UAAU,kCAAkC;EACxD,MAAM,QAAQ,OAAO,KAAK,CAAC;EAC3B,IAAI,MAAM,SAAS,KACjB,MAAM,IAAI,UAAU,kCAAkC;EACxD,KAAA,MAAW,QAAQ,OAAO;GACxB,IAAI;IAAC;IAAa;IAAe;GAAW,CAAA,CAAE,SAAS,IAAI,GACzD,MAAM,IAAI,UAAU,uBAAuB;GAC7C,MAAM,aAAa,OAAO,yBAAyB,GAAG,IAAI;GAC1D,IAAI,CAAC,cAAc,EAAE,WAAW,aAC9B,MAAM,IAAI,UAAU,oCAAoC;GAC1D,MAAM,MAAM,QAAQ,CAAC;GACrB,MAAM,WAAW,OAAO,QAAQ,CAAC;EACnC;CACF;CACA,MAAM,OAAO,CAAC;CACd,IAAI,CAAC,SAAS,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,GAC5D,MAAM,IAAI,UAAU,yBAAyB;CAC/C,KAAA,MAAW,CAAC,MAAM,UAAU,OAAO,QAAQ,KAAK,GAC9C,IACE,CAAC,KAAK,KAAK,KACX,CAAC,SACD,OAAO,UAAU,YACjB,MAAM,QAAQ,KAAK,GAEnB,MAAM,IAAI,UAAU,kCAAkC;AAE5D"}
|
|
1
|
+
{"version":3,"file":"protocol-Ck9LMfma.js","names":[],"sources":["../../src/protocol.ts"],"sourcesContent":["/** MCP SDK v2 protocol adapter for the framework-neutral app server core. */\n\nimport type { MCPTool } from '@happyvertical/smrt-core/generators/mcp';\nimport {\n type CallToolResult,\n type JSONObject,\n ProtocolError,\n ProtocolErrorCode,\n Server,\n type ServerContext,\n type Tool,\n} from '@modelcontextprotocol/server';\nimport { McpAccessError } from './errors.js';\nimport type { McpAppPrincipal, McpAppServer } from './server.js';\nimport { compareMcpToolNames } from './tools.js';\n\nexport const MCP_TASKS_EXTENSION = 'io.modelcontextprotocol/tasks';\n\nconst DEFAULT_TOOL_LIST_CACHE_HINT = {\n ttlMs: 86_400_000,\n cacheScope: 'private' as const,\n};\n\nexport interface McpProtocolServerOptions {\n /** Resolve the authenticated application principal for each MCP request. */\n principal?:\n | McpAppPrincipal\n | null\n | ((\n context: ServerContext,\n ) => McpAppPrincipal | null | Promise<McpAppPrincipal | null>);\n}\n\n/** Request-bound options for asynchronous catalog extension projection. */\nexport interface McpProtocolRequestOptions {\n principal?: McpAppPrincipal | null;\n /** Optional inert extension metadata, recomputed from this request's authorized catalog. */\n extensions?: (context: {\n principal: McpAppPrincipal | null;\n tools: readonly MCPTool[];\n }) =>\n | Record<string, Record<string, unknown>>\n | Promise<Record<string, Record<string, unknown>>>;\n}\n\n/** Prepare native capabilities before the SDK HTTP factory installs discovery handlers. */\nexport async function createMcpProtocolServerForRequest(\n appServer: McpAppServer,\n options: McpProtocolRequestOptions = {},\n): Promise<Server> {\n const principal = options.principal ?? null;\n let extensions: Record<string, JSONObject> = {};\n if (options.extensions) {\n try {\n const tools = await appServer.listTools({ principal });\n const projected = await options.extensions({ principal, tools });\n assertExtensionMetadata(projected);\n if (Object.hasOwn(projected, MCP_TASKS_EXTENSION))\n throw new TypeError('Reserved extension.');\n extensions = structuredClone(projected);\n } catch {\n throw new ProtocolError(\n ProtocolErrorCode.InternalError,\n 'Extension discovery unavailable.',\n );\n }\n }\n return protocolServer(appServer, { principal }, extensions);\n}\n\nasync function resolvePrincipal(\n option: McpProtocolServerOptions['principal'],\n context: ServerContext,\n): Promise<McpAppPrincipal | null> {\n if (typeof option === 'function') return (await option(context)) ?? null;\n return option ?? null;\n}\n\n/**\n * Adapt an app MCP core to the SDK v2 low-level server protocol.\n *\n * Transport ownership remains with the caller. In particular, this does not\n * add a production HTTP endpoint; it is safe to compose with `serveStdio` or\n * `createMcpHandler` in a deployment that supplies its own authentication.\n */\nexport function createMcpProtocolServer(\n appServer: McpAppServer,\n options: McpProtocolServerOptions = {},\n): Server {\n if ('extensions' in options) {\n throw new TypeError(\n 'Extension discovery requires createMcpProtocolServerForRequest.',\n );\n }\n return protocolServer(appServer, options, {});\n}\n\nfunction protocolServer(\n appServer: McpAppServer,\n options: McpProtocolServerOptions,\n extensions: Record<string, JSONObject>,\n): Server {\n // Task lifecycle records are owner-scoped. Unlike ordinary public read-only\n // tools, they cannot be safely exposed without a stable principal id.\n const tasksEnabled =\n appServer.tasksEnabled &&\n typeof options.principal !== 'function' &&\n Boolean(options.principal?.id);\n const server = new Server(appServer.serverInfo, {\n capabilities: {\n tools: {},\n ...(appServer.listResources && appServer.readResource\n ? { resources: {} }\n : {}),\n ...(tasksEnabled || Object.keys(extensions).length\n ? {\n extensions: {\n ...extensions,\n ...(tasksEnabled ? { [MCP_TASKS_EXTENSION]: {} } : {}),\n },\n }\n : {}),\n } as never,\n cacheHints: { 'tools/list': DEFAULT_TOOL_LIST_CACHE_HINT },\n });\n\n server.setRequestHandler('tools/list', async (_request, context) => {\n const principal = await resolvePrincipal(options.principal, context);\n const cacheHint =\n (await appServer.getToolsListCacheHint?.()) ??\n DEFAULT_TOOL_LIST_CACHE_HINT;\n return {\n tools: [...(await appServer.listTools({ principal }))].sort(\n (left, right) => compareMcpToolNames(left.name, right.name),\n ) as Tool[],\n ...cacheHint,\n };\n });\n\n if (appServer.listResources && appServer.readResource) {\n server.setRequestHandler('resources/list', async (_request, context) => ({\n resources: await appServer.listResources!({\n principal: await resolvePrincipal(options.principal, context),\n }),\n ttlMs: 0,\n cacheScope: 'private',\n }));\n server.setRequestHandler('resources/read', async (request, context) => {\n try {\n return {\n contents: [\n await appServer.readResource!({\n uri: request.params.uri,\n principal: await resolvePrincipal(options.principal, context),\n }),\n ],\n ttlMs: 0,\n cacheScope: 'private',\n };\n } catch (error) {\n if (error instanceof McpAccessError)\n throw new ProtocolError(\n ProtocolErrorCode.InvalidParams,\n 'MCP resource is not available.',\n );\n throw error;\n }\n });\n }\n\n server.setRequestHandler('tools/call', async (request, context) => {\n try {\n return (await appServer.callTool({\n name: request.params.name,\n arguments: request.params.arguments,\n principal: await resolvePrincipal(options.principal, context),\n })) as CallToolResult;\n } catch (error) {\n if (error instanceof McpAccessError) {\n const { code, retryable } = error.metadata;\n throw new ProtocolError(\n error.status === 404\n ? ProtocolErrorCode.InvalidParams\n : ProtocolErrorCode.InvalidRequest,\n error.message,\n {\n ...(typeof code === 'string' ? { code } : {}),\n ...(typeof retryable === 'boolean' ? { retryable } : {}),\n },\n );\n }\n throw error;\n }\n });\n\n return server;\n}\n\n/** Bound plugin discovery metadata without allowing executable values or provider-specific types. */\nfunction assertExtensionMetadata(\n value: unknown,\n): asserts value is Record<string, JSONObject> {\n let budget = 65536;\n const visit = (v: unknown, depth: number): void => {\n if (--budget < 0 || depth > 16)\n throw new TypeError('Extension metadata exceeds limits.');\n if (v === null || typeof v === 'boolean') return;\n if (typeof v === 'number' && Number.isFinite(v)) return;\n if (typeof v === 'string') {\n budget -= new TextEncoder().encode(v).length;\n if (budget < 0) throw new TypeError('Extension metadata exceeds limits.');\n return;\n }\n if (Array.isArray(v)) {\n if (v.length > 1024)\n throw new TypeError('Extension array exceeds limits.');\n for (const item of v) visit(item, depth + 1);\n return;\n }\n if (\n !v ||\n typeof v !== 'object' ||\n ![Object.prototype, null].includes(Object.getPrototypeOf(v))\n )\n throw new TypeError('Expected plain extension object.');\n const names = Object.keys(v);\n if (names.length > 256)\n throw new TypeError('Extension object exceeds limits.');\n for (const name of names) {\n if (['__proto__', 'constructor', 'prototype'].includes(name))\n throw new TypeError('Unsafe extension key.');\n const descriptor = Object.getOwnPropertyDescriptor(v, name);\n if (!descriptor || !('value' in descriptor))\n throw new TypeError('Expected inert extension metadata.');\n visit(name, depth + 1);\n visit(descriptor.value, depth + 1);\n }\n };\n visit(value, 0);\n if (!value || typeof value !== 'object' || Array.isArray(value))\n throw new TypeError('Expected extension map.');\n for (const [name, entry] of Object.entries(value)) {\n if (\n !name.trim() ||\n !entry ||\n typeof entry !== 'object' ||\n Array.isArray(entry)\n )\n throw new TypeError('Exp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AE,WAAW,aAC9B,MAAM,IAAI,UAAU,oCAAoC;GAC1D,MAAM,MAAM,QAAQ,CAAC;GACrB,MAAM,WAAW,OAAO,QAAQ,CAAC;EACnC;CACF;CACA,MAAM,OAAO,CAAC;CACd,IAAI,CAAC,SAAS,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,GAC5D,MAAM,IAAI,UAAU,yBAAyB;CAC/C,KAAA,MAAW,CAAC,MAAM,UAAU,OAAO,QAAQ,KAAK,GAC9C,IACE,CAAC,KAAK,KAAK,KACX,CAAC,SACD,OAAO,UAAU,YACjB,MAAM,QAAQ,KAAK,GAEnB,MAAM,IAAI,UAAU,kCAAkC;AAE5D"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as createMcpProtocolServerForRequest, t as createMcpProtocolServer } from "./chunks/protocol-
|
|
2
|
-
import { A as redactMcpApprovalArguments, C as MCP_APPROVAL_PENDING_CODE, D as MCP_APPROVAL_UNAVAILABLE_CODE, E as MCP_APPROVAL_REQUESTED_CODE, O as buildMcpApprovalSummary, S as MCP_APPROVAL_CONSUMED_CODE, T as MCP_APPROVAL_REFUSED_CODE, _ as prepareMcpAppResource, a as createMcpAppServer, b as mcpArgumentKeyNames, d as isPublicToolName, f as isReadOnlyToolName, g as MCP_APP_RESOURCE_MIME, h as MCP_APP_RESOURCE_MAX_BYTES, i as mcpPrincipalScopePolicy, k as mcpApprovalBindingHash, l as isAllowedCoreTool, m as mcpToolEffect, n as createDefaultMcpAppServer, o as MCP_TOOL_EFFECTS, p as matchesToolPattern, r as mcpAllowedClassNames, s as classNamePrefixes, t as DEFAULT_MCP_APP_SERVER_INFO, u as isPublicMcpTool, v as createMcpWorkflowTool, w as MCP_APPROVAL_REDACTED, x as mcpAuditRecordFromEvent, y as createInMemoryMcpAuditSink } from "./chunks/defaults-
|
|
1
|
+
import { n as createMcpProtocolServerForRequest, t as createMcpProtocolServer } from "./chunks/protocol-Ck9LMfma.js";
|
|
2
|
+
import { A as redactMcpApprovalArguments, C as MCP_APPROVAL_PENDING_CODE, D as MCP_APPROVAL_UNAVAILABLE_CODE, E as MCP_APPROVAL_REQUESTED_CODE, O as buildMcpApprovalSummary, S as MCP_APPROVAL_CONSUMED_CODE, T as MCP_APPROVAL_REFUSED_CODE, _ as prepareMcpAppResource, a as createMcpAppServer, b as mcpArgumentKeyNames, d as isPublicToolName, f as isReadOnlyToolName, g as MCP_APP_RESOURCE_MIME, h as MCP_APP_RESOURCE_MAX_BYTES, i as mcpPrincipalScopePolicy, k as mcpApprovalBindingHash, l as isAllowedCoreTool, m as mcpToolEffect, n as createDefaultMcpAppServer, o as MCP_TOOL_EFFECTS, p as matchesToolPattern, r as mcpAllowedClassNames, s as classNamePrefixes, t as DEFAULT_MCP_APP_SERVER_INFO, u as isPublicMcpTool, v as createMcpWorkflowTool, w as MCP_APPROVAL_REDACTED, x as mcpAuditRecordFromEvent, y as createInMemoryMcpAuditSink } from "./chunks/defaults-B9-qW692.js";
|
|
3
3
|
import { a as MCP_TOOL_EXECUTION_FAILED_CODE, c as McpToolError, i as MCP_TOOL_ACCESS_DENIED_CODE, n as MCP_CONFIRM_REQUIRED_CODE, o as MCP_TOOL_NOT_FOUND_CODE, r as MCP_ORIGIN_DENIED_CODE, s as McpAccessError, t as MCP_AUTHENTICATION_REQUIRED_CODE, u as safeMcpToolError } from "./chunks/errors-BuM1XuuV.js";
|
|
4
4
|
import { HostOperationError, createSameOriginSessionCaller, defineHostOperationTool, executeHostOperation, toMcpWorkflowTool, toWebMcpSpec } from "./host-operations.js";
|
|
5
5
|
import { getActiveJobExecutionContext, isRunnerExecutionContext } from "@happyvertical/smrt-jobs";
|
package/dist/manifest.json
CHANGED
package/dist/server.d.ts
CHANGED
|
@@ -60,6 +60,13 @@ export interface McpAppPrincipal {
|
|
|
60
60
|
kind?: string;
|
|
61
61
|
roles?: string[];
|
|
62
62
|
scopes?: string[];
|
|
63
|
+
/**
|
|
64
|
+
* Scopes a tool with no `toolScopes`/`requiredScopes` mapping requires of
|
|
65
|
+
* this principal. Stamped by the bearer adapter with every scope the
|
|
66
|
+
* resource advertises, so a token narrowed by consent (#5110) neither sees
|
|
67
|
+
* nor calls an unmapped tool. Absent: unmapped tools need no scope.
|
|
68
|
+
*/
|
|
69
|
+
unmappedToolScopes?: readonly string[];
|
|
63
70
|
/**
|
|
64
71
|
* Binding mode carried from the authentication adapter, never request
|
|
65
72
|
* input: local owner tokens are `direct`; hosted access tokens default to
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAMH,OAAO,KAAK,EACV,SAAS,EACT,WAAW,EACX,OAAO,EAER,MAAM,yCAAyC,CAAC;AAKjD,OAAO,EACL,KAAK,OAAO,EAIb,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAOL,KAAK,eAAe,EAErB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,KAAK,YAAY,EAGlB,MAAM,YAAY,CAAC;AACpB,OAAO,EAOL,KAAK,gBAAgB,EAEtB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EAEvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAIL,KAAK,aAAa,EAGnB,MAAM,YAAY,CAAC;AACpB,OAAO,EAGL,KAAK,yBAAyB,EAC/B,MAAM,qBAAqB,CAAC;AAE7B;;;;;;;GAOG;AACH;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,qBAAqB,CAAC;AAEhE;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED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gB,kBAAkB,CAChC,OAAO,EAAE,yBAAyB,GACjC,YAAY,CAmhCd"}
|
package/dist/smrt-knowledge.json
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
"sensitiveFieldsExcluded": true,
|
|
4
4
|
"generatedAt": "1970-01-01T00:00:00.000Z",
|
|
5
5
|
"packageName": "@happyvertical/smrt-app-mcp",
|
|
6
|
-
"packageVersion": "0.
|
|
6
|
+
"packageVersion": "0.70.0",
|
|
7
7
|
"sourceManifestPath": "dist/manifest.json",
|
|
8
8
|
"agentDocPath": "AGENTS.md",
|
|
9
9
|
"sourceHashes": {
|
|
10
|
-
"manifest": "
|
|
11
|
-
"packageJson": "
|
|
12
|
-
"agents": "
|
|
10
|
+
"manifest": "728c67adcf64f1bdbd695eeb00f88a4c5738607690b92bc917c151a939bcc002",
|
|
11
|
+
"packageJson": "ed7a8773f1dace83f37f7256bfeba5f008091141c11dc0f4ffae42efef918501",
|
|
12
|
+
"agents": "42f09fb9bac1c5f89febdab27f55b25e262e52b2f81a1f65735b5adc4a1859fe",
|
|
13
13
|
"moduleDoc:agents/runtime-loading.md": "4fe25501e5066a0b0f8c26409ce419029965ccad26f2c6e976070f85145900b4"
|
|
14
14
|
},
|
|
15
15
|
"exports": [
|
|
@@ -221,7 +221,7 @@
|
|
|
221
221
|
"polymorphicAssociations": 0,
|
|
222
222
|
"uuidColumns": 4
|
|
223
223
|
},
|
|
224
|
-
"agentDoc": "# @happyvertical/smrt-app-mcp\n\nApplication-scoped MCP server wrapper for SMRT apps. The core owns generated\ntool policy; `./sveltekit` owns the stateless Streamable HTTP transport.\n\n## Purpose\n\n- Wraps `@happyvertical/smrt-core` MCP generation with app-level tool allow-lists.\n- Filters unauthenticated tool visibility to public read-only tools.\n- Applies an optional principal-aware policy consistently to discovery and calls.\n- Provides workflow assertions so app servers can reject unsafe or incomplete tool calls before dispatch.\n- Exposes an opt-in durable Tasks extension through `@happyvertical/smrt-jobs`.\n\n## Patterns\n\n- Scopes, confirm and audit are server options (`toolScopes`, workflow\n `requiredScopes`/`requiresConfirm`, `confirmTools`, `auditSink`,\n `auditTenantId`). The scope check lives inside `passesToolPolicy` so tools and\n resources share it and an anonymous caller never passes a scoped tool; the\n confirm gate runs in `authorizeCall` before assertions and handlers and\n answers as an `isError` result (`confirm_required`, audited `denied`). Audit\n records hold argument KEY names only. `audit.ts` is model-free; the\n `@smrt()` `McpCallAudit` model lives only behind the `./audit-store` subpath\n (smrt#4957), never in the main entry.\n\n- `approvals` (`src/approval-gate.ts`, structural `McpApprovalGate`) replaces\n `confirm: true` for gated tools: assertions first, then the gate opens or\n consumes an approval keyed by `mcpApprovalBindingHash` (tool, canonical args\n without `confirm`, tenant, principal). Fail closed (`approval_unavailable`);\n no decide path exists here; the adapter lives in `@happyvertical/smrt-approvals`\n (`createApprovalMcpGate`). Never import approvals from this package.\n\n- Generate tools from core scoped to the allow-list (`MCPConfig.classNames`),\n then filter by allowed class names: a duplicate tool name among registered\n classes the app never publishes must not fail its catalog or calls (#3490).\n `mountMcpAppRoute`/`createDefaultMcpAppServer` resolve each model\n constructor to its registry-qualified name, so a same-named class elsewhere\n never collides; a raw simple name two classes share fails closed.\n- Treat list/get tools as read-only; mutating tools require authentication unless the app deliberately wraps them with stronger policy.\n- Keep app policy outside generated tool schemas. The wrapper owns auth, allow-list, and workflow assertion behavior.\n- Return 404 for tools outside the app allow-list so private generated tools are not enumerated by mistake.\n- Trust only a principal supplied by the application adapter. This package\n validates tokens and does not issue them; issuance lives in\n `@happyvertical/smrt-users` (see\n `docs/content/architecture/remote-mcp-authorization.md`). The opt-in `./auth` entry\n validates JWT access tokens and requires an application-owned principal mapper.\n- Mount `mountMcpRoute` as one modern `POST` endpoint. It creates a fresh\n protocol server per request, emits no session id, and refuses subscriptions.\n- `mountMcpAppRoute` (`src/defaults.ts` + `./sveltekit`) is the one-call app\n route: explicit `models` allow-list, required `requiredScopes`, principal from\n session locals (`principalFromSessionLocals`; absent `principalKind` denies\n unless `defaultPrincipalKind` is set). App policies compose with the\n default and may only narrow it. Its `Origin` check (default on; opt-in on\n `mountMcpRoute`) runs before auth and dispatch; no-`Origin` clients pass.\n `effects` filters the catalog by `mcpToolEffect` (excluded tools 404).\n `auth` swaps in bearer principals; `bindPrincipal` runs their dispatch in\n the app's principal context (RLS transaction), failing closed, and\n authorizes with the binder's narrowed (live) scopes; task lifecycle calls\n re-check the originating action against the allow-list and `effects`,\n after a principal-level `taskPrincipalPolicy` (defaults: scope policy);\n `mountMcpProtectedResourceMetadataRoute` serves only the advertised path.\n- `runtime` (structural `McpAppRouteRuntime`; no app-runtime dependency)\n derives `smrtOptions`, `bindPrincipal` and `auth` on both mounts, the\n profile resolved per request after the origin check (adapters memoized per\n runtime × profile). Fail closed: missing bindings throw at mount; an\n unresolvable profile or missing hosted config rejects (500), never serves\n without the bearer adapter. Explicit options override; keep both forms\n byte-identical (`runtime-route.test.ts`). `./auth` loads lazily from\n `./sveltekit`.\n- `createHostedMcpResourceAuth({ profile, runtime })`: locally, a runtime\n `verifyLocalMcpToken` yields the `sessionFallback` adapter\n (`createLocalMcpTokenAuth`): no `Authorization` header keeps the session\n principal; a presented bearer must verify (401, never cookie fallback); no\n metadata (404). Hosted, `runtime.resolveMcpPrincipal` is the default\n identity mapping; an explicit `resolvePrincipal` overrides it.\n `runtime.mcpSelfIssuer` (app is its own issuer, #5080): verify in process via\n `verifyAccessToken(token, resource)`, then `validateGrant(claims)` on every\n call (anything but `true` = 401); no JWKS/issuer env; metadata advertises\n its issuer. Override mappings never skip the liveness check.\n- Adapters stamp `principal.tenantBinding` for `bindPrincipal`: the local\n token adapter always `direct`; the JWT adapter the mapping's value or\n `direct-or-inherited`. Never derive it from request input. Both adapters\n read principals/mappings from own data only (`own-data.ts`): inherited\n values, accessors and poison keys deny.\n- A policy-denied call (scopes, `toolPolicy`, effects) answers exactly like an\n unknown tool (404 `Unknown MCP tool.`, no `data.code`) so the catalog cannot\n be probed; only the audit record carries `mcp_tool_access_denied` (the\n `McpAccessError.auditCode`). Anonymous callers still get 401 for a tool that\n needs authentication, which the OAuth challenge requires. Agent principals\n (`kind: 'agent'`, #5086) pass the default policy only when `principalKinds`\n lists them.\n- `mountMcpToolsRoute`/`mountMcpCallRoute` share the modern route's\n `auth`/`bindPrincipal` sequence (`authenticateAndDispatch`): a bearer agent\n lists and calls with the same live-capped scopes on every route. `mountMcpRoute`\n with `auth` but no `bindPrincipal` authorizes on token scopes only.\n- Keep tool catalogs private by default. Public caching requires an explicit\n attestation and a global, unauthenticated, read-only, non-tenant catalog with\n no principal-aware policy.\n\n- Host operations (`./host-operations`, browser-safe) are authored once and\n projected by `toMcpWorkflowTool`/`toWebMcpSpec`. `onToolCall` audits every\n call once; its principal/identity come from the adapter, and a failing hook\n never alters a result. Only `McpToolError`/`mapError` output reaches agents.\n Details: README \"Host operations, audit and typed errors\".\n\n## Gotchas\n\n- Public tool patterns are still constrained by read-only detection.\n- Policy errors fail closed and expose only the shared safe denial envelope.\n- Workflow assertions run before generated tool dispatch and should be deterministic.\n- Tasks require a stable authenticated principal id, preserve its tenant boundary,\n and require the deployment to run a `TaskRunner` for the `mcp-tasks` queue.\n- This package ships no stdio executable. Use `@happyvertical/smrt-app-cli` to\n bridge a deployed app endpoint to a local MCP client.\n- `mountMcpToolsRoute` and `mountMcpCallRoute` are deprecated REST-shaped\n compatibility aliases, not MCP transports.\n- This package is runtime app infrastructure, not the development MCP. Use `@happyvertical/smrt-dev-mcp` for agentic development knowledge, review, and architecture tooling.\n\nHTTP transport loading: [agents/runtime-loading.md](agents/runtime-loading.md).\n",
|
|
224
|
+
"agentDoc": "# @happyvertical/smrt-app-mcp\n\nApplication-scoped MCP server wrapper for SMRT apps. The core owns generated\ntool policy; `./sveltekit` owns the stateless Streamable HTTP transport.\n\n## Purpose\n\n- Wraps `@happyvertical/smrt-core` MCP generation with app-level tool allow-lists.\n- Filters unauthenticated tool visibility to public read-only tools.\n- Applies an optional principal-aware policy consistently to discovery and calls.\n- Provides workflow assertions so app servers can reject unsafe or incomplete tool calls before dispatch.\n- Exposes an opt-in durable Tasks extension through `@happyvertical/smrt-jobs`.\n\n## Patterns\n\n- Scopes, confirm and audit are server options (`toolScopes`, workflow\n `requiredScopes`/`requiresConfirm`, `confirmTools`, `auditSink`,\n `auditTenantId`). The scope check lives inside `passesToolPolicy` so tools and\n resources share it and an anonymous caller never passes a scoped tool; the\n confirm gate runs in `authorizeCall` before assertions and handlers and\n answers as an `isError` result (`confirm_required`, audited `denied`). Audit\n records hold argument KEY names only. `audit.ts` is model-free; the\n `@smrt()` `McpCallAudit` model lives only behind the `./audit-store` subpath\n (smrt#4957), never in the main entry.\n\n- `approvals` (`src/approval-gate.ts`, structural `McpApprovalGate`) replaces\n `confirm: true` for gated tools: assertions first, then the gate opens or\n consumes an approval keyed by `mcpApprovalBindingHash` (tool, canonical args\n without `confirm`, tenant, principal). Fail closed (`approval_unavailable`);\n no decide path exists here; the adapter lives in `@happyvertical/smrt-approvals`\n (`createApprovalMcpGate`). Never import approvals from this package.\n\n- Generate tools from core scoped to the allow-list (`MCPConfig.classNames`),\n then filter by allowed class names: a duplicate tool name among registered\n classes the app never publishes must not fail its catalog or calls (#3490).\n `mountMcpAppRoute`/`createDefaultMcpAppServer` resolve each model\n constructor to its registry-qualified name, so a same-named class elsewhere\n never collides; a raw simple name two classes share fails closed.\n- Treat list/get tools as read-only; mutating tools require authentication unless the app deliberately wraps them with stronger policy.\n- Keep app policy outside generated tool schemas. The wrapper owns auth, allow-list, and workflow assertion behavior.\n- Return 404 for tools outside the app allow-list so private generated tools are not enumerated by mistake.\n- Trust only a principal supplied by the application adapter. This package\n validates tokens and does not issue them; issuance lives in\n `@happyvertical/smrt-users` (see\n `docs/content/architecture/remote-mcp-authorization.md`). The opt-in `./auth` entry\n validates JWT access tokens and requires an application-owned principal mapper.\n- Mount `mountMcpRoute` as one modern `POST` endpoint. It creates a fresh\n protocol server per request, emits no session id, and refuses subscriptions.\n `legacy: 'reject' | 'stateless'` (both mounts, SDK vocabulary, default\n `'reject'` = `-32022`, mount-time only, #5109) opts 2025-era JSON-RPC clients\n in; the SDK serves them from the SAME per-request factory and bound\n principal, so every gate (auth, grant liveness, binder, scopes, policy,\n confirm/approvals, audit) applies. Never add a parallel legacy dispatch path;\n legacy gets stateless semantics (no sessions, `list_changed`, subscriptions).\n- `mountMcpAppRoute` (`src/defaults.ts` + `./sveltekit`) is the one-call app\n route: explicit `models` allow-list, required `requiredScopes`, principal from\n session locals (`principalFromSessionLocals`; absent `principalKind` denies\n unless `defaultPrincipalKind` is set). App policies compose with the\n default and may only narrow it. Its `Origin` check (default on; opt-in on\n `mountMcpRoute`) runs before auth and dispatch; no-`Origin` clients pass.\n `effects` filters the catalog by `mcpToolEffect` (excluded tools 404).\n `auth` swaps in bearer principals; `bindPrincipal` runs their dispatch in\n the app's principal context (RLS transaction), failing closed, and\n authorizes with the binder's narrowed (live) scopes; task lifecycle calls\n re-check the originating action against the allow-list and `effects`,\n after a principal-level `taskPrincipalPolicy` (defaults: scope policy);\n `mountMcpProtectedResourceMetadataRoute` serves only the advertised path.\n- `runtime` (structural `McpAppRouteRuntime`; no app-runtime dependency)\n derives `smrtOptions`, `bindPrincipal` and `auth` on both mounts, the\n profile resolved per request after the origin check (adapters memoized per\n runtime × profile). Fail closed: missing bindings throw at mount; an\n unresolvable profile or missing hosted config rejects (500), never serves\n without the bearer adapter. Explicit options override; keep both forms\n byte-identical (`runtime-route.test.ts`). `./auth` loads lazily from\n `./sveltekit`.\n- `createHostedMcpResourceAuth({ profile, runtime })`: locally, a runtime\n `verifyLocalMcpToken` yields the `sessionFallback` adapter\n (`createLocalMcpTokenAuth`): no `Authorization` header keeps the session\n principal; a presented bearer must verify (401, never cookie fallback); no\n metadata (404). Hosted, `runtime.resolveMcpPrincipal` is the default\n identity mapping; an explicit `resolvePrincipal` overrides it.\n `runtime.mcpSelfIssuer` (app is its own issuer, #5080): verify in process via\n `verifyAccessToken(token, resource)`, then `validateGrant(claims)` on every\n call (anything but `true` = 401); no JWKS/issuer env; metadata advertises\n its issuer. Override mappings never skip the liveness check.\n- Adapters stamp `principal.tenantBinding` for `bindPrincipal`: the local\n token adapter always `direct`; the JWT adapter the mapping's value or\n `direct-or-inherited`. Never derive it from request input. Both adapters\n read principals/mappings from own data only (`own-data.ts`): inherited\n values, accessors and poison keys deny.\n- A policy-denied call (scopes, `toolPolicy`, effects) answers exactly like an\n unknown tool (404 `Unknown MCP tool.`, no `data.code`) so the catalog cannot\n be probed; only the audit record carries `mcp_tool_access_denied` (the\n `McpAccessError.auditCode`). Anonymous callers still get 401 for a tool that\n needs authentication, which the OAuth challenge requires. Agent principals\n (`kind: 'agent'`, #5086) pass the default policy only when `principalKinds`\n lists them.\n- Scope narrowing (#5110): consent may grant fewer scopes than the resource\n advertises, so `createMcpResourceAuth` needs only one advertised scope (none:\n 403 `insufficient_scope`, `scope=` challenge; metadata unchanged). Per-tool\n needs come from `toolScopes`/workflow `requiredScopes`; an unmapped tool\n requires every advertised scope (fail closed, via the principal's\n `unmappedToolScopes` stamped by the adapter), so map every tool for narrowed\n tokens and keep `requiredScopes` `[]`. Tests: `narrowed-token.test.ts`.\n- `mountMcpToolsRoute`/`mountMcpCallRoute` share the modern route's\n `auth`/`bindPrincipal` sequence (`authenticateAndDispatch`): a bearer agent\n lists and calls with the same live-capped scopes on every route. `mountMcpRoute`\n with `auth` but no `bindPrincipal` authorizes on token scopes only.\n- Keep tool catalogs private by default. Public caching requires an explicit\n attestation and a global, unauthenticated, read-only, non-tenant catalog with\n no principal-aware policy.\n\n- Host operations (`./host-operations`, browser-safe) are authored once and\n projected by `toMcpWorkflowTool`/`toWebMcpSpec`. `onToolCall` audits every\n call once; its principal/identity come from the adapter, and a failing hook\n never alters a result. Only `McpToolError`/`mapError` output reaches agents.\n Details: README \"Host operations, audit and typed errors\".\n\n## Gotchas\n\n- Public tool patterns are still constrained by read-only detection.\n- Policy errors fail closed and expose only the shared safe denial envelope.\n- Workflow assertions run before generated tool dispatch and should be deterministic.\n- Tasks require a stable authenticated principal id, preserve its tenant boundary,\n and require the deployment to run a `TaskRunner` for the `mcp-tasks` queue.\n- This package ships no stdio executable. Use `@happyvertical/smrt-app-cli` to\n bridge a deployed app endpoint to a local MCP client.\n- `mountMcpToolsRoute` and `mountMcpCallRoute` are deprecated REST-shaped\n compatibility aliases, not MCP transports.\n- This package is runtime app infrastructure, not the development MCP. Use `@happyvertical/smrt-dev-mcp` for agentic development knowledge, review, and architecture tooling.\n\nHTTP transport loading: [agents/runtime-loading.md](agents/runtime-loading.md).\n",
|
|
225
225
|
"moduleDocs": [
|
|
226
226
|
{
|
|
227
227
|
"path": "agents/runtime-loading.md",
|
|
@@ -5,10 +5,10 @@ description: "App-runtime MCP server scaffolding for SMRT apps — `createMcpApp
|
|
|
5
5
|
status: "stable"
|
|
6
6
|
generated:
|
|
7
7
|
by: "smrt/scripts/generate-knowledge-okf.ts"
|
|
8
|
-
at: "2026-11-
|
|
8
|
+
at: "2026-11-22T16:44:08Z"
|
|
9
9
|
audience: "internal"
|
|
10
10
|
evidence_level: "source-inspected"
|
|
11
|
-
source_revision: "sha256:
|
|
11
|
+
source_revision: "sha256:111e82bae1347e4a3f0afaeb183ec775d9ef04691cd5bcc26619ec1aec01e597"
|
|
12
12
|
sources:
|
|
13
13
|
- id: "manifest"
|
|
14
14
|
resource: "https://github.com/happyvertical/smrt/blob/main/packages/smrt-app-mcp/package.json"
|
package/dist/sveltekit.d.ts
CHANGED
|
@@ -150,6 +150,8 @@ export type McpBoundPrincipal = Omit<McpAppPrincipal, 'scopes' | 'roles'> & {
|
|
|
150
150
|
scopes?: readonly string[];
|
|
151
151
|
roles?: readonly string[];
|
|
152
152
|
};
|
|
153
|
+
/** How a mounted MCP route serves 2025-era JSON-RPC traffic. */
|
|
154
|
+
export type McpLegacyProtocolPosture = 'reject' | 'stateless';
|
|
153
155
|
/** Options shared by both route mounts. */
|
|
154
156
|
export interface MountMcpRouteOptions {
|
|
155
157
|
/**
|
|
@@ -207,6 +209,24 @@ export interface MountMcpRouteOptions {
|
|
|
207
209
|
allowAnonymous?: boolean;
|
|
208
210
|
/** Optional extension discovery projected from the request-authorized tool catalog. */
|
|
209
211
|
extensions?: McpProtocolRequestOptions['extensions'];
|
|
212
|
+
/**
|
|
213
|
+
* How 2025-era JSON-RPC traffic (an `initialize` handshake, or a request
|
|
214
|
+
* naming no protocol version) is served, with the SDK's own vocabulary:
|
|
215
|
+
*
|
|
216
|
+
* - `'reject'` (default): modern-only. Legacy requests answer the SDK's
|
|
217
|
+
* `-32022` unsupported-protocol-version error.
|
|
218
|
+
* - `'stateless'`: explicit opt-in for clients that still speak the 2025
|
|
219
|
+
* protocol (for example Paperclip, #5109). Each legacy request is served
|
|
220
|
+
* by a fresh protocol server built by the same per-request factory, with
|
|
221
|
+
* the same authenticated, bound principal, so authentication, grant
|
|
222
|
+
* liveness, `bindPrincipal`, tool policy, scopes, confirm/approvals,
|
|
223
|
+
* audit and 404-for-unknown all apply unchanged. Legacy clients get
|
|
224
|
+
* stateless semantics: no sessions, no `list_changed`, no subscriptions.
|
|
225
|
+
*
|
|
226
|
+
* Mount-time only: it is never read from request data. A modern request is
|
|
227
|
+
* served identically under either value.
|
|
228
|
+
*/
|
|
229
|
+
legacy?: McpLegacyProtocolPosture;
|
|
210
230
|
/**
|
|
211
231
|
* Resolve the request principal once for both discovery and direct calls.
|
|
212
232
|
* Defaults to `event.locals.user`.
|
|
@@ -231,7 +251,7 @@ export interface MountMcpRouteOptions {
|
|
|
231
251
|
*/
|
|
232
252
|
export declare function mountMcpRoute(server: McpAppServer, options?: MountMcpRouteOptions): McpSvelteKitHandler;
|
|
233
253
|
/** Options for {@link mountMcpAppRoute}. */
|
|
234
|
-
export interface MountMcpAppRouteOptions extends CreateDefaultMcpAppServerOptions, Pick<MountMcpRouteOptions, 'auth' | 'bindPrincipal' | 'extensions' | 'checkOrigin' | 'trustedOrigins' | 'allowAnonymous'> {
|
|
254
|
+
export interface MountMcpAppRouteOptions extends CreateDefaultMcpAppServerOptions, Pick<MountMcpRouteOptions, 'auth' | 'bindPrincipal' | 'extensions' | 'checkOrigin' | 'trustedOrigins' | 'allowAnonymous' | 'legacy'> {
|
|
235
255
|
/**
|
|
236
256
|
* Resolve the request principal when no bearer adapter is active. Defaults
|
|
237
257
|
* to {@link principalFromSessionLocals}.
|
package/dist/sveltekit.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sveltekit.d.ts","sourceRoot":"","sources":["../src/sveltekit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EACV,cAAc,EACd,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,KAAK,gCAAgC,EAEtC,MAAM,eAAe,CAAC;AAOvB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,KAAK,EAEV,eAAe,EACf,YAAY,EACZ,mBAAmB,EACpB,MAAM,aAAa,CAAC;AAErB,oEAAoE;AACpE,KAAK,qBAAqB,GAAG;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,GAAG,CAAC;CACV,CAAC;AAEF,6EAA6E;AAC7E,MAAM,MAAM,mBAAmB,GAAG,CAChC,KAAK,EAAE,qBAAqB,KACzB,OAAO,CAAC,QAAQ,CAAC,CAAC;AAQvB,8EAA8E;AAC9E,MAAM,MAAM,oBAAoB,GAAG,CACjC,KAAK,EAAE,qBAAqB,KACzB,eAAe,GAAG,IAAI,GAAG,SAAS,CAAC;AAExC,6EAA6E;AAC7E,MAAM,MAAM,eAAe,GAAG,oBAAoB,CAAC;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AM,EAAE,YAAY,EACpB,OAAO,GAAE,oBAAyB,GACjC,mBAAmB,CAiCrB;AAyBD,YAAY,EACV,gCAAgC,EAChC,WAAW,GACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/sveltekit.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as createDefaultMcpAppServer } from "./chunks/defaults-
|
|
1
|
+
import { n as createDefaultMcpAppServer } from "./chunks/defaults-B9-qW692.js";
|
|
2
2
|
import { i as MCP_TOOL_ACCESS_DENIED_CODE, r as MCP_ORIGIN_DENIED_CODE, s as McpAccessError } from "./chunks/errors-BuM1XuuV.js";
|
|
3
3
|
import { t as stampVerifiedIdentity } from "./chunks/identity-BNzyRsWf.js";
|
|
4
4
|
//#region src/sveltekit.ts
|
|
@@ -152,6 +152,9 @@ function effectiveBoundPrincipal(authenticated, bound) {
|
|
|
152
152
|
scopes: (authenticated.scopes ?? []).filter((scope) => granted.has(scope))
|
|
153
153
|
}, authenticated.identity);
|
|
154
154
|
}
|
|
155
|
+
function assertLegacyPosture(legacy) {
|
|
156
|
+
if (legacy !== void 0 && legacy !== "reject" && legacy !== "stateless") throw new TypeError("MCP legacy must be 'reject' or 'stateless'.");
|
|
157
|
+
}
|
|
155
158
|
function protocolServerForRequest(server, resolved) {
|
|
156
159
|
if (!resolved.legacyAuthenticated || resolved.principal) return server;
|
|
157
160
|
return {
|
|
@@ -195,6 +198,8 @@ function mountMcpRoute(server, options = {}) {
|
|
|
195
198
|
return mountMcpRouteWith(server, options, () => currentResourceAuth(options.auth));
|
|
196
199
|
}
|
|
197
200
|
function mountMcpRouteWith(server, options, resolveAuth) {
|
|
201
|
+
assertLegacyPosture(options.legacy);
|
|
202
|
+
const legacy = options.legacy ?? "reject";
|
|
198
203
|
const trustedOrigins = options.checkOrigin ? normalizeTrustedOrigins(options.trustedOrigins ?? []) : void 0;
|
|
199
204
|
return async (event) => {
|
|
200
205
|
if (trustedOrigins && !originPermitted(event, trustedOrigins)) return originDeniedResponse();
|
|
@@ -203,12 +208,12 @@ function mountMcpRouteWith(server, options, resolveAuth) {
|
|
|
203
208
|
async function dispatch(event, resolved) {
|
|
204
209
|
const taskResponse = await maybeHandleTaskRequest(server, resolved.principal, event.request);
|
|
205
210
|
if (taskResponse) return taskResponse;
|
|
206
|
-
const [{ createMcpHandler }, { createMcpProtocolServerForRequest }] = await Promise.all([import("@modelcontextprotocol/server"), import("./chunks/protocol-
|
|
211
|
+
const [{ createMcpHandler }, { createMcpProtocolServerForRequest }] = await Promise.all([import("@modelcontextprotocol/server"), import("./chunks/protocol-Ck9LMfma.js").then((n) => n.r)]);
|
|
207
212
|
return createMcpHandler(() => createMcpProtocolServerForRequest(protocolServerForRequest(server, resolved), {
|
|
208
213
|
principal: resolved.principal,
|
|
209
214
|
extensions: options.extensions
|
|
210
215
|
}), {
|
|
211
|
-
legacy
|
|
216
|
+
legacy,
|
|
212
217
|
maxSubscriptions: 0
|
|
213
218
|
}).fetch(event.request);
|
|
214
219
|
}
|
|
@@ -234,7 +239,7 @@ function principalUnboundResponse() {
|
|
|
234
239
|
});
|
|
235
240
|
}
|
|
236
241
|
function mountMcpAppRoute(options) {
|
|
237
|
-
const { auth, allowAnonymous, bindPrincipal, extensions, resolvePrincipal, defaultPrincipalKind, checkOrigin, trustedOrigins, runtime, ...serverOptions } = options;
|
|
242
|
+
const { auth, allowAnonymous, bindPrincipal, extensions, resolvePrincipal, defaultPrincipalKind, checkOrigin, trustedOrigins, legacy, runtime, ...serverOptions } = options;
|
|
238
243
|
if (runtime !== void 0) assertRuntime(runtime, APP_ROUTE_RUNTIME_METHODS, "mountMcpAppRoute");
|
|
239
244
|
const server = createDefaultMcpAppServer({
|
|
240
245
|
...serverOptions,
|
|
@@ -247,6 +252,7 @@ function mountMcpAppRoute(options) {
|
|
|
247
252
|
extensions,
|
|
248
253
|
checkOrigin: checkOrigin ?? true,
|
|
249
254
|
trustedOrigins,
|
|
255
|
+
legacy,
|
|
250
256
|
resolvePrincipal: resolvePrincipal ?? ((event) => principalFromSessionLocals(event, { defaultPrincipalKind }))
|
|
251
257
|
}, auth !== void 0 || !runtime ? () => currentResourceAuth(auth) : () => runtimeResourceAuth(runtime));
|
|
252
258
|
return Object.defineProperty(handler, "server", {
|
|
@@ -286,7 +292,7 @@ async function maybeHandleTaskRequest(server, principal, request) {
|
|
|
286
292
|
"tasks/cancel"
|
|
287
293
|
].includes(body.method ?? "");
|
|
288
294
|
if (!taskTool && !taskMethod) return null;
|
|
289
|
-
const [{ isJsonContentType, classifyInboundRequest }, { MCP_TASKS_EXTENSION }] = await Promise.all([import("@modelcontextprotocol/server"), import("./chunks/protocol-
|
|
295
|
+
const [{ isJsonContentType, classifyInboundRequest }, { MCP_TASKS_EXTENSION }] = await Promise.all([import("@modelcontextprotocol/server"), import("./chunks/protocol-Ck9LMfma.js").then((n) => n.r)]);
|
|
290
296
|
if (!isJsonContentType(request.headers.get("content-type"))) return null;
|
|
291
297
|
const classification = classifyInboundRequest({
|
|
292
298
|
httpMethod: request.method,
|