@happyvertical/smrt-app-mcp 0.62.4 → 0.62.6
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 +27 -2
- package/README.md +85 -9
- package/dist/approval-gate.d.ts +103 -0
- package/dist/approval-gate.d.ts.map +1 -0
- package/dist/audit-store.js +1 -1
- package/dist/audit-store.js.map +1 -1
- package/dist/auth.d.ts +41 -2
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +17 -8
- package/dist/auth.js.map +1 -1
- package/dist/chunks/{defaults-i3kpRFpB.js → defaults-DF29ycmk.js} +167 -9
- package/dist/chunks/defaults-DF29ycmk.js.map +1 -0
- package/dist/chunks/{errors-C704k8Mv.js → errors-BuM1XuuV.js} +4 -2
- package/dist/chunks/errors-BuM1XuuV.js.map +1 -0
- package/dist/chunks/{protocol-D_O2WaCO.js → protocol-DhngxmZq.js} +3 -3
- package/dist/chunks/{protocol-D_O2WaCO.js.map → protocol-DhngxmZq.js.map} +1 -1
- package/dist/errors.d.ts +13 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/host-operations.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/manifest.json +1 -1
- package/dist/server.d.ts +18 -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 +26 -2
- package/dist/sveltekit.d.ts.map +1 -1
- package/dist/sveltekit.js +48 -42
- package/dist/sveltekit.js.map +1 -1
- package/package.json +5 -5
- package/dist/chunks/defaults-i3kpRFpB.js.map +0 -1
- package/dist/chunks/errors-C704k8Mv.js.map +0 -1
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
var MCP_TOOL_ACCESS_DENIED_CODE = "mcp_tool_access_denied";
|
|
3
3
|
var MCP_ORIGIN_DENIED_CODE = "mcp_origin_denied";
|
|
4
4
|
var McpAccessError = class extends Error {
|
|
5
|
-
constructor(status, message, metadata = {}) {
|
|
5
|
+
constructor(status, message, metadata = {}, auditCode) {
|
|
6
6
|
super(message);
|
|
7
7
|
this.status = status;
|
|
8
8
|
this.metadata = metadata;
|
|
9
|
+
this.auditCode = auditCode;
|
|
9
10
|
this.name = "McpAccessError";
|
|
10
11
|
}
|
|
11
12
|
status;
|
|
12
13
|
metadata;
|
|
14
|
+
auditCode;
|
|
13
15
|
};
|
|
14
16
|
var MCP_TOOL_NOT_FOUND_CODE = "mcp_tool_not_found";
|
|
15
17
|
var MCP_CONFIRM_REQUIRED_CODE = "confirm_required";
|
|
@@ -71,4 +73,4 @@ function authoredMcpToolError(error, mapError) {
|
|
|
71
73
|
//#endregion
|
|
72
74
|
export { MCP_TOOL_EXECUTION_FAILED_CODE as a, McpToolError as c, MCP_TOOL_ACCESS_DENIED_CODE as i, authoredMcpToolError as l, MCP_CONFIRM_REQUIRED_CODE as n, MCP_TOOL_NOT_FOUND_CODE as o, MCP_ORIGIN_DENIED_CODE as r, McpAccessError as s, MCP_AUTHENTICATION_REQUIRED_CODE as t, safeMcpToolError as u };
|
|
73
75
|
|
|
74
|
-
//# sourceMappingURL=errors-
|
|
76
|
+
//# sourceMappingURL=errors-BuM1XuuV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-BuM1XuuV.js","names":[],"sources":["../../src/errors.ts"],"sourcesContent":["/** Machine-readable code for a principal policy denial. */\nexport const MCP_TOOL_ACCESS_DENIED_CODE = 'mcp_tool_access_denied';\n\n/** Machine-readable code for a request refused by the endpoint's origin check. */\nexport const MCP_ORIGIN_DENIED_CODE = 'mcp_origin_denied';\n\n/**\n * Metadata that is safe to expose for an app-MCP access failure. Policy\n * implementations must not place principal, scope, tool, or internal-error\n * details here.\n */\nexport interface McpAccessErrorMetadata {\n code?: string;\n retryable?: boolean;\n}\n\n/**\n * Error returned by the MCP app server when a caller tries to use a tool\n * they are not allowed to access. The HTTP layer should map `status` onto\n * the response status code.\n */\nexport class McpAccessError extends Error {\n constructor(\n readonly status: number,\n message: string,\n readonly metadata: McpAccessErrorMetadata = {},\n /**\n * Audit-only code. Never serialized to the wire: lets a denial that must\n * look exactly like an unknown tool (no existence oracle) still be\n * recorded as a policy denial.\n */\n readonly auditCode?: string,\n ) {\n super(message);\n this.name = 'McpAccessError';\n }\n}\n\n/** Stable code for a request naming a tool this server does not publish. */\nexport const MCP_TOOL_NOT_FOUND_CODE = 'mcp_tool_not_found';\n\n/** Stable code for a gated tool called without `arguments.confirm === true`. */\nexport const MCP_CONFIRM_REQUIRED_CODE = 'confirm_required';\n\n/** Stable code for a tool call that needs an authenticated principal. */\nexport const MCP_AUTHENTICATION_REQUIRED_CODE = 'mcp_authentication_required';\n\n/** Stable code for an unmapped handler failure; carries no internals. */\nexport const MCP_TOOL_EXECUTION_FAILED_CODE = 'mcp_tool_execution_failed';\n\n/** The generic message an unmapped handler failure returns. */\nexport const MCP_TOOL_EXECUTION_FAILED_MESSAGE = 'Workflow execution failed.';\n\n/** The agent-safe projection of a tool failure: a stable code and a message. */\nexport interface McpToolErrorInfo {\n code: string;\n message: string;\n /** Optional JSON-safe, non-sensitive structured detail. */\n details?: Record<string, unknown>;\n}\n\n/**\n * Throw from a workflow tool handler to hand the calling agent a typed,\n * authored failure. The `code` and `message` (and optional `details`) reach\n * the agent verbatim, so they must be safe to disclose: never put records,\n * credentials, stack traces, or other tenants' data in them. Any other\n * thrown value stays behind the generic failure message.\n */\nexport class McpToolError extends Error {\n readonly code: string;\n readonly details?: Record<string, unknown>;\n constructor(\n code: string,\n message: string,\n details?: Record<string, unknown>,\n ) {\n super(message);\n this.name = 'McpToolError';\n this.code = code;\n if (details !== undefined) this.details = details;\n }\n}\n\n/** Per-tool mapping of a handler failure to a safe code and message. */\nexport type McpToolErrorMapper = (\n error: unknown,\n) => McpToolErrorInfo | null | undefined;\n\nconst SAFE_CODE = /^[A-Za-z][A-Za-z0-9_.:-]{0,63}$/;\nconst MAX_SAFE_MESSAGE_LENGTH = 500;\nconst MAX_SAFE_DETAILS_BYTES = 4096;\n\nconst GENERIC_TOOL_ERROR: Readonly<McpToolErrorInfo> = Object.freeze({\n code: MCP_TOOL_EXECUTION_FAILED_CODE,\n message: MCP_TOOL_EXECUTION_FAILED_MESSAGE,\n});\n\nfunction validInfo(value: unknown): McpToolErrorInfo | undefined {\n if (!value || typeof value !== 'object') return undefined;\n const { code, message, details } = value as Record<string, unknown>;\n if (typeof code !== 'string' || !SAFE_CODE.test(code)) return undefined;\n if (\n typeof message !== 'string' ||\n !message.trim() ||\n message.length > MAX_SAFE_MESSAGE_LENGTH\n ) {\n return undefined;\n }\n const info: McpToolErrorInfo = { code, message };\n if (details !== undefined) {\n try {\n if (\n !details ||\n typeof details !== 'object' ||\n Array.isArray(details) ||\n typeof JSON.stringify(details) !== 'string' ||\n JSON.stringify(details).length > MAX_SAFE_DETAILS_BYTES\n ) {\n return undefined;\n }\n info.details = JSON.parse(JSON.stringify(details));\n } catch {\n return undefined;\n }\n }\n return info;\n}\n\n/**\n * Resolve a thrown value to the information that may reach an agent. Never\n * throws: a thrown {@link McpToolError} or a valid `mapError` result yields its\n * safe code and message; anything else (including a throwing or malformed\n * mapper) yields the generic failure.\n */\nexport function safeMcpToolError(\n error: unknown,\n mapError?: McpToolErrorMapper,\n): McpToolErrorInfo {\n return authoredMcpToolError(error, mapError) ?? { ...GENERIC_TOOL_ERROR };\n}\n\n/**\n * The authored (opt-in) safe error for a thrown value: a valid\n * {@link McpToolError} or `mapError` result, else `undefined`. Only this form\n * is typed on the MCP wire; an unmapped failure keeps the generic result.\n */\nexport function authoredMcpToolError(\n error: unknown,\n mapError?: McpToolErrorMapper,\n): McpToolErrorInfo | undefined {\n try {\n if (error instanceof McpToolError) {\n const info = validInfo({\n code: error.code,\n message: error.message,\n details: error.details,\n });\n if (info) return info;\n } else if (mapError) {\n const info = validInfo(mapError(error));\n if (info) return info;\n }\n } catch {\n // A m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nD,QAAQ;EACN;CACF;CAEF,OAAO;AACT;AAQO,SAAS,iBACd,OACA,UACkB;CAClB,OAAO,qBAAqB,OAAO,QAAQ,KAAK,EAAE,GAAG,mBAAmB;AAC1E;AAOO,SAAS,qBACd,OACA,UAC8B;CAC9B,IAAI;EACF,IAAI,iBAAiB,cAAc;GACjC,MAAM,OAAO,UAAU;IACrB,MAAM,MAAM;IACZ,SAAS,MAAM;IACf,SAAS,MAAM;GACjB,CAAC;GACD,IAAI,MAAM,OAAO;EACnB,OAAA,IAAW,UAAU;GACnB,MAAM,OAAO,UAAU,SAAS,KAAK,CAAC;GACtC,IAAI,MAAM,OAAO;EACnB;CACF,QAAQ,CAER;AAEF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as compareMcpToolNames } from "./defaults-
|
|
2
|
-
import { s as McpAccessError } from "./errors-
|
|
1
|
+
import { c as compareMcpToolNames } from "./defaults-DF29ycmk.js";
|
|
2
|
+
import { s as McpAccessError } from "./errors-BuM1XuuV.js";
|
|
3
3
|
import { ProtocolError, ProtocolErrorCode, Server } from "@modelcontextprotocol/server";
|
|
4
4
|
//#region \0rolldown/runtime.js
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
@@ -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-DhngxmZq.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol-D_O2WaCO.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,eAAe,WAAW,SAAS,CAAC,CAAC;AAC9C;AAEA,SAAS,eACP,WACA,SACA,YACQ;CAGR,MAAM,eACJ,UAAU,gBACV,OAAO,QAAQ,cAAc,cAC7B,QAAQ,QAAQ,WAAW,EAAE;CAC/B,MAAM,SAAS,IAAI,OAAO,UAAU,YAAY;EAC9C,cAAc;GACZ,OAAO,CAAC;GACR,GAAI,UAAU,iB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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-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,YAC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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/errors.d.ts
CHANGED
|
@@ -19,7 +19,19 @@ export interface McpAccessErrorMetadata {
|
|
|
19
19
|
export declare class McpAccessError extends Error {
|
|
20
20
|
readonly status: number;
|
|
21
21
|
readonly metadata: McpAccessErrorMetadata;
|
|
22
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Audit-only code. Never serialized to the wire: lets a denial that must
|
|
24
|
+
* look exactly like an unknown tool (no existence oracle) still be
|
|
25
|
+
* recorded as a policy denial.
|
|
26
|
+
*/
|
|
27
|
+
readonly auditCode?: string | undefined;
|
|
28
|
+
constructor(status: number, message: string, metadata?: McpAccessErrorMetadata,
|
|
29
|
+
/**
|
|
30
|
+
* Audit-only code. Never serialized to the wire: lets a denial that must
|
|
31
|
+
* look exactly like an unknown tool (no existence oracle) still be
|
|
32
|
+
* recorded as a policy denial.
|
|
33
|
+
*/
|
|
34
|
+
auditCode?: string | undefined);
|
|
23
35
|
}
|
|
24
36
|
/** Stable code for a request naming a tool this server does not publish. */
|
|
25
37
|
export declare const MCP_TOOL_NOT_FOUND_CODE = "mcp_tool_not_found";
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,eAAO,MAAM,2BAA2B,2BAA2B,CAAC;AAEpE,kFAAkF;AAClF,eAAO,MAAM,sBAAsB,sBAAsB,CAAC;AAE1D;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;GAIG;AACH,qBAAa,c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AAQ,KAAK;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAEzC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAOpC;AAED,wEAAwE;AACxE,MAAM,MAAM,kBAAkB,GAAG,CAC/B,KAAK,EAAE,OAAO,KACX,gBAAgB,GAAG,IAAI,GAAG,SAAS,CAAC;AA0CzC;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,OAAO,EACd,QAAQ,CAAC,EAAE,kBAAkB,GAC5B,gBAAgB,CAElB;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,EACd,QAAQ,CAAC,EAAE,kBAAkB,GAC5B,gBAAgB,GAAG,SAAS,CAiB9B"}
|
package/dist/host-operations.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as McpToolError, u as safeMcpToolError } from "./chunks/errors-
|
|
1
|
+
import { c as McpToolError, u as safeMcpToolError } from "./chunks/errors-BuM1XuuV.js";
|
|
2
2
|
//#region src/host-operations.ts
|
|
3
3
|
function defineHostOperationTool(definition) {
|
|
4
4
|
if (typeof definition.handler !== "function") throw new TypeError("Host operation handler must be a function.");
|
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
*
|
|
22
22
|
* @packageDocumentation
|
|
23
23
|
*/
|
|
24
|
+
export { buildMcpApprovalSummary, MCP_APPROVAL_CONSUMED_CODE, MCP_APPROVAL_PENDING_CODE, MCP_APPROVAL_REDACTED, MCP_APPROVAL_REFUSED_CODE, MCP_APPROVAL_REQUESTED_CODE, MCP_APPROVAL_UNAVAILABLE_CODE, type McpApprovalGate, type McpApprovalGateRequest, type McpApprovalGateResult, mcpApprovalBindingHash, redactMcpApprovalArguments, } from './approval-gate.js';
|
|
24
25
|
export { createInMemoryMcpAuditSink, type McpAuditOutcome, type McpAuditQuery, type McpAuditRecord, type McpAuditSink, mcpArgumentKeyNames, mcpAuditRecordFromEvent, } from './audit.js';
|
|
25
26
|
export { continueMcpWorkflow, createMcpContinuationTool, type McpWorkflowContinuation, } from './continuation.js';
|
|
26
27
|
export { type CreateDefaultMcpAppServerOptions, createDefaultMcpAppServer, DEFAULT_MCP_APP_SERVER_INFO, type McpAppModel, type McpPrincipalScopePolicyOptions, mcpAllowedClassNames, mcpPrincipalScopePolicy, } from './defaults.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EACL,0BAA0B,EAC1B,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,KAAK,uBAAuB,GAC7B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,KAAK,gCAAgC,EACrC,yBAAyB,EACzB,2BAA2B,EAC3B,KAAK,WAAW,EAChB,KAAK,8BAA8B,EACnC,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,gCAAgC,EAChC,yBAAyB,EACzB,sBAAsB,EACtB,2BAA2B,EAC3B,8BAA8B,EAC9B,uBAAuB,EACvB,cAAc,EACd,KAAK,sBAAsB,EAC3B,YAAY,EACZ,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,6BAA6B,EAC7B,uBAAuB,EACvB,oBAAoB,EACpB,KAAK,mBAAm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,GAC9B,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,0BAA0B,EAC1B,qBAAqB,EACrB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,yBAAyB,EAC9B,kBAAkB,EAClB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,GAC1B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,KAAK,aAAa,EAClB,kBAAkB,EAClB,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,qBAAqB,EACrB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,GAC/B,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as createMcpProtocolServerForRequest, t as createMcpProtocolServer } from "./chunks/protocol-
|
|
2
|
-
import { _ 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, 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, x as mcpAuditRecordFromEvent, y as createInMemoryMcpAuditSink } from "./chunks/defaults-
|
|
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-
|
|
1
|
+
import { n as createMcpProtocolServerForRequest, t as createMcpProtocolServer } from "./chunks/protocol-DhngxmZq.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-DF29ycmk.js";
|
|
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";
|
|
6
6
|
//#region src/continuation.ts
|
|
@@ -72,6 +72,6 @@ function createMcpContinuationTool(options) {
|
|
|
72
72
|
return definition;
|
|
73
73
|
}
|
|
74
74
|
//#endregion
|
|
75
|
-
export { DEFAULT_MCP_APP_SERVER_INFO, HostOperationError, MCP_APP_RESOURCE_MAX_BYTES, MCP_APP_RESOURCE_MIME, MCP_AUTHENTICATION_REQUIRED_CODE, MCP_CONFIRM_REQUIRED_CODE, MCP_ORIGIN_DENIED_CODE, MCP_TOOL_ACCESS_DENIED_CODE, MCP_TOOL_EFFECTS, MCP_TOOL_EXECUTION_FAILED_CODE, MCP_TOOL_NOT_FOUND_CODE, McpAccessError, McpToolError, classNamePrefixes, continueMcpWorkflow, createDefaultMcpAppServer, createInMemoryMcpAuditSink, createMcpAppServer, createMcpContinuationTool, createMcpProtocolServer, createMcpProtocolServerForRequest, createMcpWorkflowTool, createSameOriginSessionCaller, defineHostOperationTool, executeHostOperation, isAllowedCoreTool, isPublicMcpTool, isPublicToolName, isReadOnlyToolName, matchesToolPattern, mcpAllowedClassNames, mcpArgumentKeyNames, mcpAuditRecordFromEvent, mcpPrincipalScopePolicy, mcpToolEffect, prepareMcpAppResource, safeMcpToolError, toMcpWorkflowTool, toWebMcpSpec };
|
|
75
|
+
export { DEFAULT_MCP_APP_SERVER_INFO, HostOperationError, MCP_APPROVAL_CONSUMED_CODE, MCP_APPROVAL_PENDING_CODE, MCP_APPROVAL_REDACTED, MCP_APPROVAL_REFUSED_CODE, MCP_APPROVAL_REQUESTED_CODE, MCP_APPROVAL_UNAVAILABLE_CODE, MCP_APP_RESOURCE_MAX_BYTES, MCP_APP_RESOURCE_MIME, MCP_AUTHENTICATION_REQUIRED_CODE, MCP_CONFIRM_REQUIRED_CODE, MCP_ORIGIN_DENIED_CODE, MCP_TOOL_ACCESS_DENIED_CODE, MCP_TOOL_EFFECTS, MCP_TOOL_EXECUTION_FAILED_CODE, MCP_TOOL_NOT_FOUND_CODE, McpAccessError, McpToolError, buildMcpApprovalSummary, classNamePrefixes, continueMcpWorkflow, createDefaultMcpAppServer, createInMemoryMcpAuditSink, createMcpAppServer, createMcpContinuationTool, createMcpProtocolServer, createMcpProtocolServerForRequest, createMcpWorkflowTool, createSameOriginSessionCaller, defineHostOperationTool, executeHostOperation, isAllowedCoreTool, isPublicMcpTool, isPublicToolName, isReadOnlyToolName, matchesToolPattern, mcpAllowedClassNames, mcpApprovalBindingHash, mcpArgumentKeyNames, mcpAuditRecordFromEvent, mcpPrincipalScopePolicy, mcpToolEffect, prepareMcpAppResource, redactMcpApprovalArguments, safeMcpToolError, toMcpWorkflowTool, toWebMcpSpec };
|
|
76
76
|
|
|
77
77
|
//# sourceMappingURL=index.js.map
|
package/dist/manifest.json
CHANGED
package/dist/server.d.ts
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import type { MCPConfig, MCPResponse, MCPTool } from '@happyvertical/smrt-core/generators/mcp';
|
|
19
19
|
import { type McpTask } from '@happyvertical/smrt-jobs';
|
|
20
|
+
import { type McpApprovalGate } from './approval-gate.js';
|
|
20
21
|
import { type McpAuditSink } from './audit.js';
|
|
21
22
|
import { type McpToolErrorInfo } from './errors.js';
|
|
22
23
|
import { type McpAppResource, type McpAppResourceContent, type McpAppResourceDefinition, type McpResourcePolicy } from './resources.js';
|
|
@@ -234,6 +235,23 @@ export interface CreateMcpAppServerOptions {
|
|
|
234
235
|
* `requiresConfirm`.
|
|
235
236
|
*/
|
|
236
237
|
confirmTools?: readonly string[];
|
|
238
|
+
/**
|
|
239
|
+
* Approval adapter for gated tools (`confirmTools` and `requiresConfirm`).
|
|
240
|
+
* When set, `confirm: true` no longer authorizes a gated call: the first call
|
|
241
|
+
* opens an approval request and answers `approval_pending`; a person decides
|
|
242
|
+
* out of band (never through this server); the identical retried call
|
|
243
|
+
* consumes the approval and runs once. Fails closed: an adapter error,
|
|
244
|
+
* a principal without id and tenant, or non-JSON arguments refuse the call.
|
|
245
|
+
* Host assertions run first so an invalid call never opens or burns an
|
|
246
|
+
* approval. Omitted: the legacy `confirm: true` gate.
|
|
247
|
+
*/
|
|
248
|
+
approvals?: McpApprovalGate;
|
|
249
|
+
/**
|
|
250
|
+
* Narrow or mask the arguments shown to the approver (applied before the
|
|
251
|
+
* default secret-key redaction, which always runs). The binding hash still
|
|
252
|
+
* covers the real arguments.
|
|
253
|
+
*/
|
|
254
|
+
approvalRedact?: (tool: string, args: Record<string, unknown>) => unknown;
|
|
237
255
|
/** Receives (never rethrown) failures of {@link onToolCall}. */
|
|
238
256
|
onToolCallHookError?: (error: unknown) => void;
|
|
239
257
|
/**
|
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,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;AACx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;GASG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,yBAAyB,GACjC,YAAY,CA0/Bd"}
|
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.62.
|
|
6
|
+
"packageVersion": "0.62.6",
|
|
7
7
|
"sourceManifestPath": "dist/manifest.json",
|
|
8
8
|
"agentDocPath": "AGENTS.md",
|
|
9
9
|
"sourceHashes": {
|
|
10
|
-
"manifest": "
|
|
11
|
-
"packageJson": "
|
|
12
|
-
"agents": "
|
|
10
|
+
"manifest": "5bc15a90555c100c90de60690c94d2d4d0467c523ec28801bcea6b5e56b6b8cb",
|
|
11
|
+
"packageJson": "144dc0c513c0da870bc8197a1f28fd0f1bf2b6b962fbc32b5acc7a0975818384",
|
|
12
|
+
"agents": "d01bdc60d67fd53faaea38d54f2c0fc6b4f1fa225240150d55425faaafe2ac3f",
|
|
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- 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 does not
|
|
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",
|
|
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-17T23:02:13Z"
|
|
9
9
|
audience: "internal"
|
|
10
10
|
evidence_level: "source-inspected"
|
|
11
|
-
source_revision: "sha256:
|
|
11
|
+
source_revision: "sha256:70b3fb213285d6816ada71015710bdf1fff42cc24f28560c1957dcab4d90fe3a"
|
|
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
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
30
|
import type { SmrtClassOptions } from '@happyvertical/smrt-core';
|
|
31
|
-
import type { McpDeploymentProfile, McpLocalTokenPrincipal, McpPrincipalMapping, McpResourceAuth, McpVerifiedIdentity } from './auth.js';
|
|
31
|
+
import type { McpAuthRuntime, McpDeploymentProfile, McpLocalTokenPrincipal, McpPrincipalMapping, McpResourceAuth, McpVerifiedIdentity } from './auth.js';
|
|
32
32
|
import { type CreateDefaultMcpAppServerOptions } from './defaults.js';
|
|
33
33
|
import type { McpProtocolRequestOptions } from './protocol.js';
|
|
34
34
|
import type { McpAppPrincipal, McpAppServer, McpSmrtOptionsThunk } from './server.js';
|
|
@@ -77,6 +77,11 @@ export interface McpRouteAuthRuntime {
|
|
|
77
77
|
* tenant; `null` denies. Consulted only in hosted profiles.
|
|
78
78
|
*/
|
|
79
79
|
resolveMcpPrincipal(identity: McpVerifiedIdentity): Promise<McpPrincipalMapping | null>;
|
|
80
|
+
/**
|
|
81
|
+
* Present when the app is its own MCP issuer (smrt#5080): hosted bearer
|
|
82
|
+
* auth then verifies in process with per-call grant liveness.
|
|
83
|
+
*/
|
|
84
|
+
readonly mcpSelfIssuer?: McpAuthRuntime['mcpSelfIssuer'];
|
|
80
85
|
}
|
|
81
86
|
/**
|
|
82
87
|
* The runtime calls {@link mountMcpAppRoute} uses; the runtime from
|
|
@@ -103,9 +108,19 @@ export interface McpAppRouteRuntime extends McpRouteAuthRuntime {
|
|
|
103
108
|
* (`locals.selectedTenantId`), request bodies and route arguments are never
|
|
104
109
|
* identity inputs. Any missing or malformed field yields `null`
|
|
105
110
|
* (unauthenticated), which fails closed for every non-public tool.
|
|
111
|
+
*
|
|
112
|
+
* The principal kind comes from `locals.principalKind`, published by the SMRT
|
|
113
|
+
* app runtime. A session hook that does not classify the user (for example
|
|
114
|
+
* `createSessionHandler` from `@happyvertical/smrt-users` without the app
|
|
115
|
+
* runtime) leaves it absent, and an absent kind is unauthenticated: a bot
|
|
116
|
+
* profile with a session cookie must not pass as a person. A host that
|
|
117
|
+
* knowingly asserts one kind for every session user opts in with
|
|
118
|
+
* `options.defaultPrincipalKind`; it is unset by default.
|
|
106
119
|
*/
|
|
107
120
|
export declare function principalFromSessionLocals(event: {
|
|
108
121
|
locals?: Record<string, unknown>;
|
|
122
|
+
}, options?: {
|
|
123
|
+
defaultPrincipalKind?: string;
|
|
109
124
|
}): McpAppPrincipal | null;
|
|
110
125
|
/**
|
|
111
126
|
* Run MCP dispatch for a bearer-authenticated principal inside an
|
|
@@ -178,7 +193,9 @@ export interface MountMcpRouteOptions {
|
|
|
178
193
|
* `sessionFallback` adapter (the local owner-token adapter) challenges only
|
|
179
194
|
* requests that carry an `Authorization` header; others keep the session
|
|
180
195
|
* principal. Set `allowAnonymous` to permit a headerless request with a
|
|
181
|
-
* non-fallback adapter.
|
|
196
|
+
* non-fallback adapter. The deprecated REST-shaped mounts
|
|
197
|
+
* (`mountMcpToolsRoute`, `mountMcpCallRoute`) honor `auth` and
|
|
198
|
+
* `bindPrincipal` the same way, so list and call authorize identically.
|
|
182
199
|
*/
|
|
183
200
|
auth?: McpRouteResourceAuthSource;
|
|
184
201
|
/**
|
|
@@ -220,6 +237,13 @@ export interface MountMcpAppRouteOptions extends CreateDefaultMcpAppServerOption
|
|
|
220
237
|
* to {@link principalFromSessionLocals}.
|
|
221
238
|
*/
|
|
222
239
|
resolvePrincipal?: McpPrincipalResolver;
|
|
240
|
+
/**
|
|
241
|
+
* Kind assumed for session users whose `locals.principalKind` is absent.
|
|
242
|
+
* Unset by default: an unclassified session is unauthenticated. Set it only
|
|
243
|
+
* when the host knowingly asserts one kind for every session user. Ignored
|
|
244
|
+
* when `resolvePrincipal` is given.
|
|
245
|
+
*/
|
|
246
|
+
defaultPrincipalKind?: string;
|
|
223
247
|
/**
|
|
224
248
|
* The application runtime (`runtime` from
|
|
225
249
|
* `@happyvertical/smrt-app-runtime/sveltekit`). It supplies the three
|
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,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;AAwCnD;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG,IAAI,CACrC,eAAe,EACf,aAAa,GA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6E;IAC7E,IAAI,CAAC,EAAE,0BAA0B,CAAC;CACnC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,sCAAsC,CACpD,MAAM,EACF,0BAA0B,GAC1B,6CAA6C,GAChD,mBAAmB,CA2CrB;AAoPD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,EACpB,OAAO,GAAE,oBAAyB,GACjC,mBAAmB,CAkBrB;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,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,5 +1,5 @@
|
|
|
1
|
-
import { n as createDefaultMcpAppServer } from "./chunks/defaults-
|
|
2
|
-
import { i as MCP_TOOL_ACCESS_DENIED_CODE, r as MCP_ORIGIN_DENIED_CODE, s as McpAccessError } from "./chunks/errors-
|
|
1
|
+
import { n as createDefaultMcpAppServer } from "./chunks/defaults-DF29ycmk.js";
|
|
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
|
|
5
5
|
var defaultResolvePrincipal = (event) => event.locals?.user ?? null;
|
|
@@ -123,7 +123,7 @@ function originDeniedResponse() {
|
|
|
123
123
|
}
|
|
124
124
|
});
|
|
125
125
|
}
|
|
126
|
-
function principalFromSessionLocals(event) {
|
|
126
|
+
function principalFromSessionLocals(event, options = {}) {
|
|
127
127
|
const locals = event.locals;
|
|
128
128
|
if (!locals || typeof locals !== "object") return null;
|
|
129
129
|
const user = locals.user;
|
|
@@ -133,10 +133,13 @@ function principalFromSessionLocals(event) {
|
|
|
133
133
|
if (typeof user.id !== "string" || user.id.length === 0) return null;
|
|
134
134
|
if (typeof tenantId !== "string" || tenantId.length === 0) return null;
|
|
135
135
|
if (!Array.isArray(permissions) || !permissions.every((value) => typeof value === "string")) return null;
|
|
136
|
+
if (locals.principalKind === null) return null;
|
|
137
|
+
const classified = locals.principalKind ?? options.defaultPrincipalKind;
|
|
138
|
+
if (typeof classified !== "string" || classified.length === 0) return null;
|
|
136
139
|
return {
|
|
137
140
|
id: user.id,
|
|
138
141
|
tenantId,
|
|
139
|
-
kind:
|
|
142
|
+
kind: classified,
|
|
140
143
|
scopes: [...permissions].sort()
|
|
141
144
|
};
|
|
142
145
|
}
|
|
@@ -158,6 +161,36 @@ function protocolServerForRequest(server, resolved) {
|
|
|
158
161
|
callTool: (input) => server.callTool(input)
|
|
159
162
|
};
|
|
160
163
|
}
|
|
164
|
+
async function authenticateAndDispatch(event, options, resolveAuth, dispatch) {
|
|
165
|
+
const auth = await resolveAuth();
|
|
166
|
+
if (!auth) return dispatch(event, resolveRequestPrincipal(event, options));
|
|
167
|
+
if (!event.request.headers.has("authorization")) {
|
|
168
|
+
if (auth.sessionFallback === true) return dispatch(event, resolveRequestPrincipal(event, options));
|
|
169
|
+
if (options.allowAnonymous === true) return dispatch(event, { principal: null });
|
|
170
|
+
}
|
|
171
|
+
const checked = await auth.authenticate(event.request);
|
|
172
|
+
if (!checked.ok) return checked.response;
|
|
173
|
+
if (!options.bindPrincipal) return dispatch(event, { principal: checked.principal });
|
|
174
|
+
let entered = false;
|
|
175
|
+
let response;
|
|
176
|
+
try {
|
|
177
|
+
response = await options.bindPrincipal(checked.principal, async (bound) => {
|
|
178
|
+
entered = true;
|
|
179
|
+
const principal = effectiveBoundPrincipal(checked.principal, bound);
|
|
180
|
+
if (!principal) return principalUnboundResponse();
|
|
181
|
+
const dispatched = await dispatch(event, { principal });
|
|
182
|
+
return new Response(await dispatched.arrayBuffer(), {
|
|
183
|
+
status: dispatched.status,
|
|
184
|
+
statusText: dispatched.statusText,
|
|
185
|
+
headers: dispatched.headers
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
} catch (error) {
|
|
189
|
+
if (entered) throw error;
|
|
190
|
+
return principalUnboundResponse();
|
|
191
|
+
}
|
|
192
|
+
return entered ? response : principalUnboundResponse();
|
|
193
|
+
}
|
|
161
194
|
function mountMcpRoute(server, options = {}) {
|
|
162
195
|
return mountMcpRouteWith(server, options, () => currentResourceAuth(options.auth));
|
|
163
196
|
}
|
|
@@ -165,39 +198,12 @@ function mountMcpRouteWith(server, options, resolveAuth) {
|
|
|
165
198
|
const trustedOrigins = options.checkOrigin ? normalizeTrustedOrigins(options.trustedOrigins ?? []) : void 0;
|
|
166
199
|
return async (event) => {
|
|
167
200
|
if (trustedOrigins && !originPermitted(event, trustedOrigins)) return originDeniedResponse();
|
|
168
|
-
|
|
169
|
-
if (!auth) return dispatch(event, resolveRequestPrincipal(event, options));
|
|
170
|
-
if (!event.request.headers.has("authorization")) {
|
|
171
|
-
if (auth.sessionFallback === true) return dispatch(event, resolveRequestPrincipal(event, options));
|
|
172
|
-
if (options.allowAnonymous === true) return dispatch(event, { principal: null });
|
|
173
|
-
}
|
|
174
|
-
const checked = await auth.authenticate(event.request);
|
|
175
|
-
if (!checked.ok) return checked.response;
|
|
176
|
-
if (!options.bindPrincipal) return dispatch(event, { principal: checked.principal });
|
|
177
|
-
let entered = false;
|
|
178
|
-
let response;
|
|
179
|
-
try {
|
|
180
|
-
response = await options.bindPrincipal(checked.principal, async (bound) => {
|
|
181
|
-
entered = true;
|
|
182
|
-
const principal = effectiveBoundPrincipal(checked.principal, bound);
|
|
183
|
-
if (!principal) return principalUnboundResponse();
|
|
184
|
-
const dispatched = await dispatch(event, { principal });
|
|
185
|
-
return new Response(await dispatched.arrayBuffer(), {
|
|
186
|
-
status: dispatched.status,
|
|
187
|
-
statusText: dispatched.statusText,
|
|
188
|
-
headers: dispatched.headers
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
} catch (error) {
|
|
192
|
-
if (entered) throw error;
|
|
193
|
-
return principalUnboundResponse();
|
|
194
|
-
}
|
|
195
|
-
return entered ? response : principalUnboundResponse();
|
|
201
|
+
return authenticateAndDispatch(event, options, resolveAuth, dispatch);
|
|
196
202
|
};
|
|
197
203
|
async function dispatch(event, resolved) {
|
|
198
204
|
const taskResponse = await maybeHandleTaskRequest(server, resolved.principal, event.request);
|
|
199
205
|
if (taskResponse) return taskResponse;
|
|
200
|
-
const [{ createMcpHandler }, { createMcpProtocolServerForRequest }] = await Promise.all([import("@modelcontextprotocol/server"), import("./chunks/protocol-
|
|
206
|
+
const [{ createMcpHandler }, { createMcpProtocolServerForRequest }] = await Promise.all([import("@modelcontextprotocol/server"), import("./chunks/protocol-DhngxmZq.js").then((n) => n.r)]);
|
|
201
207
|
return createMcpHandler(() => createMcpProtocolServerForRequest(protocolServerForRequest(server, resolved), {
|
|
202
208
|
principal: resolved.principal,
|
|
203
209
|
extensions: options.extensions
|
|
@@ -228,7 +234,7 @@ function principalUnboundResponse() {
|
|
|
228
234
|
});
|
|
229
235
|
}
|
|
230
236
|
function mountMcpAppRoute(options) {
|
|
231
|
-
const { auth, allowAnonymous, bindPrincipal, extensions, resolvePrincipal, checkOrigin, trustedOrigins, runtime, ...serverOptions } = options;
|
|
237
|
+
const { auth, allowAnonymous, bindPrincipal, extensions, resolvePrincipal, defaultPrincipalKind, checkOrigin, trustedOrigins, runtime, ...serverOptions } = options;
|
|
232
238
|
if (runtime !== void 0) assertRuntime(runtime, APP_ROUTE_RUNTIME_METHODS, "mountMcpAppRoute");
|
|
233
239
|
const server = createDefaultMcpAppServer({
|
|
234
240
|
...serverOptions,
|
|
@@ -241,7 +247,7 @@ function mountMcpAppRoute(options) {
|
|
|
241
247
|
extensions,
|
|
242
248
|
checkOrigin: checkOrigin ?? true,
|
|
243
249
|
trustedOrigins,
|
|
244
|
-
resolvePrincipal: resolvePrincipal ?? principalFromSessionLocals
|
|
250
|
+
resolvePrincipal: resolvePrincipal ?? ((event) => principalFromSessionLocals(event, { defaultPrincipalKind }))
|
|
245
251
|
}, auth !== void 0 || !runtime ? () => currentResourceAuth(auth) : () => runtimeResourceAuth(runtime));
|
|
246
252
|
return Object.defineProperty(handler, "server", {
|
|
247
253
|
value: server,
|
|
@@ -280,7 +286,7 @@ async function maybeHandleTaskRequest(server, principal, request) {
|
|
|
280
286
|
"tasks/cancel"
|
|
281
287
|
].includes(body.method ?? "");
|
|
282
288
|
if (!taskTool && !taskMethod) return null;
|
|
283
|
-
const [{ isJsonContentType, classifyInboundRequest }, { MCP_TASKS_EXTENSION }] = await Promise.all([import("@modelcontextprotocol/server"), import("./chunks/protocol-
|
|
289
|
+
const [{ isJsonContentType, classifyInboundRequest }, { MCP_TASKS_EXTENSION }] = await Promise.all([import("@modelcontextprotocol/server"), import("./chunks/protocol-DhngxmZq.js").then((n) => n.r)]);
|
|
284
290
|
if (!isJsonContentType(request.headers.get("content-type"))) return null;
|
|
285
291
|
const classification = classifyInboundRequest({
|
|
286
292
|
httpMethod: request.method,
|
|
@@ -400,23 +406,23 @@ function asRecord(value) {
|
|
|
400
406
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
401
407
|
}
|
|
402
408
|
function mountMcpToolsRoute(server, options = {}) {
|
|
403
|
-
return
|
|
409
|
+
return (event) => authenticateAndDispatch(event, options, () => currentResourceAuth(options.auth), async (_event, resolved) => {
|
|
404
410
|
try {
|
|
405
|
-
return jsonResponse({ tools: await server.listTools(listToolsInput(
|
|
411
|
+
return jsonResponse({ tools: await server.listTools(listToolsInput(resolved)) });
|
|
406
412
|
} catch (error) {
|
|
407
413
|
if (error instanceof McpAccessError) return jsonResponse(mcpAccessErrorBody(error), error.status);
|
|
408
414
|
throw error;
|
|
409
415
|
}
|
|
410
|
-
};
|
|
416
|
+
});
|
|
411
417
|
}
|
|
412
418
|
function mountMcpCallRoute(server, options = {}) {
|
|
413
|
-
return
|
|
419
|
+
return (event) => authenticateAndDispatch(event, options, () => currentResourceAuth(options.auth), async (_event, resolved) => {
|
|
414
420
|
const body = await event.request.json().catch(() => null);
|
|
415
421
|
if (!body?.name) return jsonResponse({ error: "name is required." }, 400);
|
|
416
422
|
const input = {
|
|
417
423
|
arguments: body.arguments ?? {},
|
|
418
424
|
name: body.name,
|
|
419
|
-
principal:
|
|
425
|
+
principal: resolved.principal
|
|
420
426
|
};
|
|
421
427
|
try {
|
|
422
428
|
return jsonResponse(await server.callTool(input));
|
|
@@ -424,7 +430,7 @@ function mountMcpCallRoute(server, options = {}) {
|
|
|
424
430
|
if (error instanceof McpAccessError) return jsonResponse(mcpAccessErrorBody(error), error.status);
|
|
425
431
|
throw error;
|
|
426
432
|
}
|
|
427
|
-
};
|
|
433
|
+
});
|
|
428
434
|
}
|
|
429
435
|
function mcpAccessErrorBody(error) {
|
|
430
436
|
const { code, retryable } = error.metadata;
|