@frontmcp/sdk 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/package.json +13 -6
- package/src/auth/session/index.d.ts +1 -0
- package/src/auth/session/index.js +3 -1
- package/src/auth/session/index.js.map +1 -1
- package/src/auth/session/vercel-kv-session.store.d.ts +96 -0
- package/src/auth/session/vercel-kv-session.store.js +216 -0
- package/src/auth/session/vercel-kv-session.store.js.map +1 -0
- package/src/common/decorators/front-mcp.decorator.js +14 -17
- package/src/common/decorators/front-mcp.decorator.js.map +1 -1
- package/src/common/metadata/front-mcp.metadata.d.ts +705 -23
- package/src/common/metadata/front-mcp.metadata.js +1 -0
- package/src/common/metadata/front-mcp.metadata.js.map +1 -1
- package/src/common/metadata/prompt.metadata.d.ts +4 -0
- package/src/common/metadata/resource.metadata.d.ts +8 -0
- package/src/common/metadata/tool-ui.metadata.d.ts +2 -2
- package/src/common/metadata/tool-ui.metadata.js +1 -1
- package/src/common/metadata/tool-ui.metadata.js.map +1 -1
- package/src/common/metadata/tool.metadata.d.ts +4 -0
- package/src/common/schemas/http-output.schema.d.ts +24 -6
- package/src/common/tokens/front-mcp.tokens.js +1 -0
- package/src/common/tokens/front-mcp.tokens.js.map +1 -1
- package/src/common/types/options/redis.options.d.ts +173 -5
- package/src/common/types/options/redis.options.js +157 -11
- package/src/common/types/options/redis.options.js.map +1 -1
- package/src/common/types/options/server-info.options.d.ts +4 -0
- package/src/common/types/options/transport.options.d.ts +68 -4
- package/src/common/utils/global-config.utils.d.ts +36 -0
- package/src/common/utils/global-config.utils.js +44 -0
- package/src/common/utils/global-config.utils.js.map +1 -0
- package/src/common/utils/index.d.ts +1 -0
- package/src/common/utils/index.js +1 -0
- package/src/common/utils/index.js.map +1 -1
- package/src/completion/flows/complete.flow.d.ts +6 -8
- package/src/errors/index.d.ts +1 -1
- package/src/errors/index.js +2 -1
- package/src/errors/index.js.map +1 -1
- package/src/errors/mcp.error.d.ts +9 -0
- package/src/errors/mcp.error.js +19 -1
- package/src/errors/mcp.error.js.map +1 -1
- package/src/front-mcp/front-mcp.providers.d.ts +208 -0
- package/src/front-mcp/index.d.ts +1 -0
- package/src/front-mcp/index.js +3 -0
- package/src/front-mcp/index.js.map +1 -1
- package/src/index.d.ts +1 -1
- package/src/index.js +2 -1
- package/src/index.js.map +1 -1
- package/src/logging/flows/set-level.flow.d.ts +6 -8
- package/src/prompt/flows/get-prompt.flow.d.ts +14 -8
- package/src/prompt/flows/prompts-list.flow.d.ts +8 -7
- package/src/resource/flows/read-resource.flow.d.ts +8 -9
- package/src/resource/flows/resource-templates-list.flow.d.ts +8 -7
- package/src/resource/flows/resources-list.flow.d.ts +8 -7
- package/src/resource/flows/subscribe-resource.flow.d.ts +6 -8
- package/src/resource/flows/unsubscribe-resource.flow.d.ts +6 -8
- package/src/store/adapters/store.vercel-kv.adapter.d.ts +86 -0
- package/src/store/adapters/store.vercel-kv.adapter.js +155 -0
- package/src/store/adapters/store.vercel-kv.adapter.js.map +1 -0
- package/src/store/index.d.ts +2 -0
- package/src/store/index.js +2 -0
- package/src/store/index.js.map +1 -1
- package/src/store/store.factory.d.ts +86 -0
- package/src/store/store.factory.js +194 -0
- package/src/store/store.factory.js.map +1 -0
- package/src/tool/flows/call-tool.flow.d.ts +18 -9
- package/src/tool/flows/call-tool.flow.js +2 -2
- package/src/tool/flows/call-tool.flow.js.map +1 -1
- package/src/tool/flows/tools-list.flow.d.ts +9 -8
- package/src/tool/flows/tools-list.flow.js +2 -2
- package/src/tool/flows/tools-list.flow.js.map +1 -1
- package/src/tool/ui/index.d.ts +4 -4
- package/src/tool/ui/index.js +4 -4
- package/src/tool/ui/index.js.map +1 -1
- package/src/tool/ui/platform-adapters.d.ts +2 -2
- package/src/tool/ui/platform-adapters.js +3 -3
- package/src/tool/ui/platform-adapters.js.map +1 -1
- package/src/tool/ui/template-helpers.d.ts +5 -7
- package/src/tool/ui/template-helpers.js +9 -26
- package/src/tool/ui/template-helpers.js.map +1 -1
- package/src/tool/ui/ui-resource.handler.d.ts +1 -1
- package/src/tool/ui/ui-resource.handler.js +5 -5
- package/src/tool/ui/ui-resource.handler.js.map +1 -1
- package/src/transport/mcp-handlers/complete-request.handler.d.ts +4 -15
- package/src/transport/mcp-handlers/get-prompt-request.handler.d.ts +5 -15
- package/src/transport/mcp-handlers/index.d.ts +67 -195
- package/src/transport/mcp-handlers/list-prompts-request.handler.d.ts +5 -15
- package/src/transport/mcp-handlers/list-resource-templates-request.handler.d.ts +5 -15
- package/src/transport/mcp-handlers/list-resources-request.handler.d.ts +5 -15
- package/src/transport/mcp-handlers/list-tools-request.handler.d.ts +5 -15
- package/src/transport/mcp-handlers/logging-set-level-request.handler.d.ts +3 -14
- package/src/transport/mcp-handlers/read-resource-request.handler.d.ts +4 -15
- package/src/transport/mcp-handlers/subscribe-request.handler.d.ts +3 -14
- package/src/transport/mcp-handlers/unsubscribe-request.handler.d.ts +3 -14
- package/src/transport/transport.registry.d.ts +5 -1
- package/src/transport/transport.registry.js +52 -23
- package/src/transport/transport.registry.js.map +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.factory.js","sourceRoot":"","sources":["../../../src/store/store.factory.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAuCH,8CAWC;AA4DD,gDAWC;AA2DD,wDAsBC;AAkBD,8CAIC;AA3ND,yEAO+C;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,SAAgB,iBAAiB,CAAC,OAAqB;IACrD,IAAI,IAAA,kCAAkB,EAAC,OAAO,CAAC,EAAE,CAAC;QAChC,OAAO,yBAAyB,CAAC,OAAO,CAAC,CAAC;IAC5C,CAAC;IAED,IAAI,IAAA,+BAAe,EAAC,OAAO,CAAC,EAAE,CAAC;QAC7B,OAAO,sBAAsB,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAED,oDAAoD;IACpD,OAAO,sBAAsB,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IAAI,IAAA,kCAAkB,EAAC,OAAO,CAAC,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CAAC,0FAA0F,CAAC,CAAC;IAC9G,CAAC;IAED,oCAAoC;IACpC,iEAAiE;IACjE,MAAM,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC;IAC7E,MAAM,YAAY,GAAG,IAAA,+BAAe,EAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAE,OAAgC,CAAC;IAE5F,OAAO,IAAI,iBAAiB,CAC1B;QACE,IAAI,EAAE,YAAY,CAAC,IAAI;QACvB,IAAI,EAAE,YAAY,CAAC,IAAI;QACvB,QAAQ,EAAE,YAAY,CAAC,QAAQ;QAC/B,EAAE,EAAE,YAAY,CAAC,EAAE;QACnB,GAAG,EAAE,YAAY,CAAC,GAAG;QACrB,SAAS,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,cAAc;QACxF,YAAY,EAAE,YAAY,CAAC,YAAY;KACxC,EACD,MAAM,CACP,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,iBAAiB,CAAC,OAAsB;IACtD,kEAAkE;IAClE,MAAM,YAAY,GAAG,OAA+B,CAAC;IACrD,OAAO,sBAAsB,CAAC,YAAY,CAAC,CAAC;AAC9C,CAAC","sourcesContent":["/**\n * Storage Factory\n *\n * Factory functions for creating store drivers and session stores\n * based on configuration. Supports both Redis and Vercel KV providers.\n */\n\nimport type { StoreDriver } from './store.types';\nimport type { SessionStore } from '../auth/session/transport-session.types';\nimport type { FrontMcpLogger } from '../common/interfaces/logger.interface';\nimport {\n type RedisOptions,\n type RedisProviderOptions,\n type VercelKvProviderOptions,\n type PubsubOptions,\n isRedisProvider,\n isVercelKvProvider,\n} from '../common/types/options/redis.options';\n\n/**\n * Create a store driver based on configuration\n *\n * @param options - Storage configuration (Redis or Vercel KV)\n * @returns A store driver instance (not connected)\n *\n * @example Redis\n * ```typescript\n * const driver = createStoreDriver({\n * provider: 'redis',\n * host: 'localhost',\n * port: 6379,\n * });\n * await driver.connect();\n * ```\n *\n * @example Vercel KV\n * ```typescript\n * const driver = createStoreDriver({\n * provider: 'vercel-kv',\n * // Uses KV_REST_API_URL and KV_REST_API_TOKEN env vars\n * });\n * await driver.connect();\n * ```\n */\nexport function createStoreDriver(options: RedisOptions): StoreDriver {\n if (isVercelKvProvider(options)) {\n return createVercelKvStoreDriver(options);\n }\n\n if (isRedisProvider(options)) {\n return createRedisStoreDriver(options);\n }\n\n // Fallback for legacy format without provider field\n return createRedisStoreDriver(options as RedisProviderOptions);\n}\n\n/**\n * Create a Redis store driver\n */\nfunction createRedisStoreDriver(options: RedisProviderOptions): StoreDriver {\n // Lazy import to avoid bundling ioredis when not used\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const { ScopedRedisStore } = require('./adapters/store.redis.adapter');\n\n return new ScopedRedisStore({\n options: {\n host: options.host,\n port: options.port,\n password: options.password,\n db: options.db,\n tls: options.tls ? {} : undefined,\n keyPrefix: options.keyPrefix,\n },\n });\n}\n\n/**\n * Create a Vercel KV store driver\n */\nfunction createVercelKvStoreDriver(options: VercelKvProviderOptions): StoreDriver {\n // Lazy import to avoid bundling @vercel/kv when not used\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const { ScopedVercelKvStore } = require('./adapters/store.vercel-kv.adapter');\n\n return new ScopedVercelKvStore({\n url: options.url,\n token: options.token,\n keyPrefix: options.keyPrefix,\n });\n}\n\n/**\n * Create a session store based on configuration\n *\n * @param options - Storage configuration (Redis or Vercel KV)\n * @param logger - Optional logger instance\n * @returns A session store instance\n *\n * @example Redis\n * ```typescript\n * const store = await createSessionStore({\n * provider: 'redis',\n * host: 'localhost',\n * port: 6379,\n * });\n * ```\n *\n * @example Vercel KV\n * ```typescript\n * const store = await createSessionStore({\n * provider: 'vercel-kv',\n * });\n * ```\n */\nexport async function createSessionStore(options: RedisOptions, logger?: FrontMcpLogger): Promise<SessionStore> {\n if (isVercelKvProvider(options)) {\n return createVercelKvSessionStore(options, logger);\n }\n\n if (isRedisProvider(options)) {\n return createRedisSessionStore(options, logger);\n }\n\n // Fallback for legacy format without provider field\n return createRedisSessionStore(options as RedisProviderOptions, logger);\n}\n\n/**\n * Create a Redis session store\n */\nasync function createRedisSessionStore(options: RedisProviderOptions, logger?: FrontMcpLogger): Promise<SessionStore> {\n // Lazy require to avoid bundling ioredis when not used\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const { RedisSessionStore } = require('../auth/session/redis-session.store');\n\n return new RedisSessionStore(\n {\n host: options.host,\n port: options.port,\n password: options.password,\n db: options.db,\n tls: options.tls,\n keyPrefix: options.keyPrefix ? `${options.keyPrefix}session:` : 'mcp:session:',\n defaultTtlMs: options.defaultTtlMs,\n },\n logger,\n );\n}\n\n/**\n * Create a Vercel KV session store\n */\nasync function createVercelKvSessionStore(\n options: VercelKvProviderOptions,\n logger?: FrontMcpLogger,\n): Promise<SessionStore> {\n // Lazy require to avoid bundling @vercel/kv when not used\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const { VercelKvSessionStore } = require('../auth/session/vercel-kv-session.store');\n\n const store = new VercelKvSessionStore(\n {\n url: options.url,\n token: options.token,\n keyPrefix: options.keyPrefix ? `${options.keyPrefix}session:` : 'mcp:session:',\n defaultTtlMs: options.defaultTtlMs,\n },\n logger,\n );\n\n // Pre-connect for Vercel KV\n await store.connect();\n\n return store;\n}\n\n/**\n * Create a session store synchronously (for backwards compatibility)\n * Note: For Vercel KV, use createSessionStore() instead as it requires async connect\n *\n * @param options - Storage configuration (Redis only)\n * @param logger - Optional logger instance\n * @returns A session store instance\n */\nexport function createSessionStoreSync(options: RedisOptions, logger?: FrontMcpLogger): SessionStore {\n if (isVercelKvProvider(options)) {\n throw new Error('Vercel KV session store requires async initialization. Use createSessionStore() instead.');\n }\n\n // Redis only - synchronous creation\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const { RedisSessionStore } = require('../auth/session/redis-session.store');\n const redisOptions = isRedisProvider(options) ? options : (options as RedisProviderOptions);\n\n return new RedisSessionStore(\n {\n host: redisOptions.host,\n port: redisOptions.port,\n password: redisOptions.password,\n db: redisOptions.db,\n tls: redisOptions.tls,\n keyPrefix: redisOptions.keyPrefix ? `${redisOptions.keyPrefix}session:` : 'mcp:session:',\n defaultTtlMs: redisOptions.defaultTtlMs,\n },\n logger,\n );\n}\n\n/**\n * Create a pub/sub store for resource subscriptions\n *\n * Pub/Sub requires Redis - Vercel KV does not support pub/sub operations.\n * Use this when you need resource subscriptions with Vercel KV for sessions.\n *\n * @param options - Pub/sub configuration (Redis only)\n * @returns A Redis store driver with pub/sub support\n *\n * @example Hybrid config\n * ```typescript\n * // Use Vercel KV for sessions, Redis for pub/sub\n * const sessionStore = await createSessionStore({ provider: 'vercel-kv' });\n * const pubsubStore = createPubsubStore({ host: 'localhost', port: 6379 });\n * ```\n */\nexport function createPubsubStore(options: PubsubOptions): StoreDriver {\n // PubsubOptions only allows Redis provider, so we can safely cast\n const redisOptions = options as RedisProviderOptions;\n return createRedisStoreDriver(redisOptions);\n}\n"]}
|
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import { FlowBase, FlowRunOptions, ToolContext, ToolEntry } from '../../common';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { AuthInfo } from '@modelcontextprotocol/sdk/server/auth/types.js';
|
|
4
|
-
import { type ToolResponseContent } from '@frontmcp/
|
|
4
|
+
import { type ToolResponseContent } from '@frontmcp/uipack/adapters';
|
|
5
5
|
declare const inputSchema: z.ZodObject<{
|
|
6
6
|
request: z.ZodObject<{
|
|
7
7
|
method: z.ZodLiteral<"tools/call">;
|
|
8
8
|
params: z.ZodObject<{
|
|
9
|
-
task: z.ZodOptional<z.ZodObject<{
|
|
10
|
-
ttl: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodNull]>>;
|
|
11
|
-
pollInterval: z.ZodOptional<z.ZodNumber>;
|
|
12
|
-
}, z.core.$loose>>;
|
|
13
9
|
_meta: z.ZodOptional<z.ZodObject<{
|
|
14
10
|
progressToken: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
15
11
|
"io.modelcontextprotocol/related-task": z.ZodOptional<z.ZodObject<{
|
|
16
12
|
taskId: z.ZodString;
|
|
17
|
-
}, z.core.$
|
|
13
|
+
}, z.core.$strip>>;
|
|
18
14
|
}, z.core.$loose>>;
|
|
15
|
+
task: z.ZodOptional<z.ZodObject<{
|
|
16
|
+
ttl: z.ZodOptional<z.ZodNumber>;
|
|
17
|
+
}, z.core.$strip>>;
|
|
19
18
|
name: z.ZodString;
|
|
20
19
|
arguments: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
21
|
-
}, z.core.$
|
|
20
|
+
}, z.core.$strip>;
|
|
22
21
|
}, z.core.$strip>;
|
|
23
22
|
ctx: z.ZodAny;
|
|
24
23
|
}, z.core.$strip>;
|
|
25
24
|
declare const outputSchema: z.ZodObject<{
|
|
26
25
|
_meta: z.ZodOptional<z.ZodObject<{
|
|
26
|
+
progressToken: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
27
27
|
"io.modelcontextprotocol/related-task": z.ZodOptional<z.ZodObject<{
|
|
28
28
|
taskId: z.ZodString;
|
|
29
|
-
}, z.core.$
|
|
29
|
+
}, z.core.$strip>>;
|
|
30
30
|
}, z.core.$loose>>;
|
|
31
31
|
content: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
32
32
|
type: z.ZodLiteral<"text">;
|
|
@@ -83,6 +83,10 @@ declare const outputSchema: z.ZodObject<{
|
|
|
83
83
|
src: z.ZodString;
|
|
84
84
|
mimeType: z.ZodOptional<z.ZodString>;
|
|
85
85
|
sizes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
86
|
+
theme: z.ZodOptional<z.ZodEnum<{
|
|
87
|
+
light: "light";
|
|
88
|
+
dark: "dark";
|
|
89
|
+
}>>;
|
|
86
90
|
}, z.core.$strip>>>;
|
|
87
91
|
name: z.ZodString;
|
|
88
92
|
title: z.ZodOptional<z.ZodString>;
|
|
@@ -124,9 +128,10 @@ declare const stateSchema: z.ZodObject<{
|
|
|
124
128
|
rawOutput: z.ZodOptional<z.ZodAny>;
|
|
125
129
|
output: z.ZodObject<{
|
|
126
130
|
_meta: z.ZodOptional<z.ZodObject<{
|
|
131
|
+
progressToken: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
127
132
|
"io.modelcontextprotocol/related-task": z.ZodOptional<z.ZodObject<{
|
|
128
133
|
taskId: z.ZodString;
|
|
129
|
-
}, z.core.$
|
|
134
|
+
}, z.core.$strip>>;
|
|
130
135
|
}, z.core.$loose>>;
|
|
131
136
|
content: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
132
137
|
type: z.ZodLiteral<"text">;
|
|
@@ -183,6 +188,10 @@ declare const stateSchema: z.ZodObject<{
|
|
|
183
188
|
src: z.ZodString;
|
|
184
189
|
mimeType: z.ZodOptional<z.ZodString>;
|
|
185
190
|
sizes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
191
|
+
theme: z.ZodOptional<z.ZodEnum<{
|
|
192
|
+
light: "light";
|
|
193
|
+
dark: "dark";
|
|
194
|
+
}>>;
|
|
186
195
|
}, z.core.$strip>>>;
|
|
187
196
|
name: z.ZodString;
|
|
188
197
|
title: z.ZodOptional<z.ZodString>;
|
|
@@ -8,8 +8,8 @@ const zod_1 = require("zod");
|
|
|
8
8
|
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
9
9
|
const errors_1 = require("../../errors");
|
|
10
10
|
const ui_1 = require("../ui");
|
|
11
|
-
const adapters_1 = require("@frontmcp/
|
|
12
|
-
const registry_1 = require("@frontmcp/
|
|
11
|
+
const adapters_1 = require("@frontmcp/uipack/adapters");
|
|
12
|
+
const registry_1 = require("@frontmcp/uipack/registry");
|
|
13
13
|
const inputSchema = zod_1.z.object({
|
|
14
14
|
request: types_js_1.CallToolRequestSchema,
|
|
15
15
|
// z.any() used because ctx is the MCP SDK's ToolCallExtra type which varies by SDK version
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"call-tool.flow.js","sourceRoot":"","sources":["../../../../src/tool/flows/call-tool.flow.ts"],"names":[],"mappings":";;;AAAA,gCAAgC;AAChC,mCAAoC;AACpC,yCASsB;AACtB,6BAAwB;AACxB,iEAAiG;AAEjG,yCAOsB;AACtB,8BAAoC;AAEpC,oDAA+G;AAC/G,oDAA0D;AAG1D,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3B,OAAO,EAAE,gCAAqB;IAC9B,2FAA2F;IAC3F,GAAG,EAAE,OAAC,CAAC,GAAG,EAAE;CACb,CAAC,CAAC;AAEH,MAAM,YAAY,GAAG,+BAAoB,CAAC;AAE1C,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3B,KAAK,EAAE,OAAC,CAAC,WAAW,CAAC;QACnB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/B,SAAS,EAAE,OAAC,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;KACxC,CAAC;IACF,QAAQ,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAyB;IACnD,IAAI,EAAE,OAAC,CAAC,UAAU,CAAC,kBAAS,CAAC;IAC7B,WAAW,EAAE,OAAC,CAAC,UAAU,CAAC,oBAAW,CAAC;IACtC,mDAAmD;IACnD,SAAS,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IAC7B,MAAM,EAAE,YAAY;IACpB,2DAA2D;IAC3D,YAAY,EAAE,O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CAAC,GAAU,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,0CAA0C,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACnG,CAAC;QAED,iDAAiD;QACjD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACrB,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IACvC,CAAC;CACF,CAAA;AAhjBO;IADL,KAAK,CAAC,YAAY,CAAC;;;;8CAmCnB;AAGK;IADL,KAAK,CAAC,UAAU,CAAC;;;;4CAqBjB;AAQK;IADL,KAAK,CAAC,wBAAwB,CAAC;;;;0DA4E/B;AAWK;IADL,KAAK,CAAC,uBAAuB,CAAC;;;;yDAuB9B;AAGK;IADL,KAAK,CAAC,cAAc,CAAC;;;;gDAMrB;AAGK;IADL,KAAK,CAAC,kBAAkB,CAAC;;;;oDAMzB;AAGK;IADL,KAAK,CAAC,eAAe,CAAC;;;;iDAqBtB;AAGK;IADL,KAAK,CAAC,SAAS,CAAC;;;;2CAmBhB;AAGK;IADL,KAAK,CAAC,gBAAgB,CAAC;;;;kDAavB;AAGK;IADL,KAAK,CAAC,kBAAkB,CAAC;;;;oDAMzB;AAGK;IADL,KAAK,CAAC,cAAc,CAAC;;;;gDAMrB;AAQK;IADL,KAAK,CAAC,SAAS,CAAC;;;;2CA6KhB;AAYK;IADL,KAAK,CAAC,UAAU,CAAC;;;;4CAwGjB;AAnjBkB,YAAY;IAPhC,IAAA,aAAI,EAAC;QACJ,IAAI;QACJ,IAAI;QACJ,WAAW;QACX,YAAY;QACZ,MAAM,EAAE,YAAY;KACrB,CAAC;GACmB,YAAY,CAojBhC;kBApjBoB,YAAY","sourcesContent":["// tools/flows/call-tool.flow.ts\nimport { randomUUID } from 'crypto';\nimport {\n Flow,\n FlowBase,\n FlowHooksOf,\n FlowPlan,\n FlowRunOptions,\n ToolContext,\n ToolEntry,\n isOrchestratedMode,\n} from '../../common';\nimport { z } from 'zod';\nimport { CallToolRequestSchema, CallToolResultSchema } from '@modelcontextprotocol/sdk/types.js';\nimport { AuthInfo } from '@modelcontextprotocol/sdk/server/auth/types.js';\nimport {\n InvalidMethodError,\n ToolNotFoundError,\n InvalidInputError,\n InvalidOutputError,\n ToolExecutionError,\n AuthorizationRequiredError,\n} from '../../errors';\nimport { hasUIConfig } from '../ui';\nimport { Scope } from '../../scope';\nimport { resolveServingMode, buildToolResponseContent, type ToolResponseContent } from '@frontmcp/ui/adapters';\nimport { isUIRenderFailure } from '@frontmcp/ui/registry';\nimport { safeStringify } from '@frontmcp/ui/utils';\n\nconst inputSchema = z.object({\n request: CallToolRequestSchema,\n // z.any() used because ctx is the MCP SDK's ToolCallExtra type which varies by SDK version\n ctx: z.any(),\n});\n\nconst outputSchema = CallToolResultSchema;\n\nconst stateSchema = z.object({\n input: z.looseObject({\n name: z.string().min(1).max(64),\n arguments: z.looseObject({}).optional(),\n }),\n authInfo: z.any().optional() as z.ZodType<AuthInfo>,\n tool: z.instanceof(ToolEntry),\n toolContext: z.instanceof(ToolContext),\n // Store the raw executed output for plugins to see\n rawOutput: z.any().optional(),\n output: outputSchema,\n // Tool owner ID for hook filtering (set during parseInput)\n _toolOwnerId: z.string().optional(),\n // UI result from applyUI stage (if UI config exists)\n uiResult: z.any().optional() as z.ZodType<ToolResponseContent | undefined>,\n // UI metadata from rendering (merged into _meta)\n uiMeta: z.record(z.string(), z.unknown()).optional(),\n});\n\nconst plan = {\n pre: [\n 'parseInput',\n 'findTool',\n 'checkToolAuthorization',\n 'createToolCallContext',\n 'acquireQuota',\n 'acquireSemaphore',\n ],\n execute: ['validateInput', 'execute', 'validateOutput'],\n finalize: ['releaseSemaphore', 'releaseQuota', 'applyUI', 'finalize'],\n} as const satisfies FlowPlan<string>;\n\ndeclare global {\n interface ExtendFlows {\n 'tools:call-tool': FlowRunOptions<\n CallToolFlow,\n typeof plan,\n typeof inputSchema,\n typeof outputSchema,\n typeof stateSchema\n >;\n }\n}\n\nconst name = 'tools:call-tool' as const;\nconst { Stage } = FlowHooksOf<'tools:call-tool'>(name);\n\n@Flow({\n name,\n plan,\n inputSchema,\n outputSchema,\n access: 'authorized',\n})\nexport default class CallToolFlow extends FlowBase<typeof name> {\n logger = this.scopeLogger.child('CallToolFlow');\n\n @Stage('parseInput')\n async parseInput() {\n this.logger.verbose('parseInput:start');\n\n let method!: string;\n // NOTE: `any` is intentional - Zod parsing validates these values\n // Using unknown would require redundant type guards after schema validation\n let params: any;\n let ctx: any;\n try {\n const inputData = inputSchema.parse(this.rawInput);\n method = inputData.request.method;\n params = inputData.request.params;\n ctx = inputData.ctx;\n } catch (e) {\n throw new InvalidInputError('Invalid Input', e instanceof z.ZodError ? e.issues : undefined);\n }\n\n if (method !== 'tools/call') {\n this.logger.warn(`parseInput: invalid method \"${method}\"`);\n throw new InvalidMethodError(method, 'tools/call');\n }\n\n // Find the tool early to get its owner ID for hook filtering\n const { name } = params;\n const activeTools = this.scope.tools.getTools(true);\n const tool = activeTools.find((entry) => {\n return entry.fullName === name || entry.name === name;\n });\n\n // Store tool owner ID in state for hook filtering\n const toolOwnerId = tool?.owner?.id;\n\n this.state.set({ input: params, authInfo: ctx.authInfo, _toolOwnerId: toolOwnerId });\n this.logger.verbose('parseInput:done');\n }\n\n @Stage('findTool')\n async findTool() {\n this.logger.verbose('findTool:start');\n // TODO: add support for session based tools\n const activeTools = this.scope.tools.getTools(true);\n this.logger.info(`findTool: discovered ${activeTools.length} active tool(s) (including hidden)`);\n\n const { name } = this.state.required.input;\n const tool = activeTools.find((entry) => {\n return entry.fullName === name || entry.name === name;\n });\n\n if (!tool) {\n this.logger.warn(`findTool: tool \"${name}\" not found`);\n throw new ToolNotFoundError(name);\n }\n\n this.logger = this.logger.child(`CallToolFlow(${name})`);\n this.state.set('tool', tool);\n this.logger.info(`findTool: tool \"${name}\" found`);\n this.logger.verbose('findTool:done');\n }\n\n /**\n * Check if the tool's parent app is authorized.\n * For progressive authorization, tools from unauthorized apps\n * return an AuthorizationRequiredError with an auth_url.\n */\n @Stage('checkToolAuthorization')\n async checkToolAuthorization() {\n this.logger.verbose('checkToolAuthorization:start');\n const { tool, authInfo } = this.state;\n\n // Get authorization from authInfo.extra if available\n const authorization = authInfo?.extra?.['authorization'] as\n | {\n authorizedAppIds?: string[];\n authorizedApps?: Record<string, unknown>;\n }\n | undefined;\n\n // No auth context = public mode, skip authorization check\n if (!authorization) {\n this.logger.verbose('checkToolAuthorization:skip (no auth context)');\n return;\n }\n\n // Get app ID from tool owner (uses existing lineage system)\n const appId = tool?.owner?.id;\n if (!appId) {\n // Tool has no owner = global tool, skip app-level authorization check\n this.logger.verbose('checkToolAuthorization:skip (no owner)');\n return;\n }\n\n // Check if app is authorized using existing session structure\n const isAppAuthorized =\n authorization.authorizedAppIds?.includes(appId) || appId in (authorization.authorizedApps || {});\n\n if (!isAppAuthorized) {\n // Get incremental auth configuration from scope's auth options\n const apps = this.scope.apps.getApps();\n const app = apps.find((a) => a.metadata.id === appId);\n const authOptions = this.scope.auth?.options;\n\n // Determine skippedAppBehavior:\n // 1. Only applies in orchestrated mode with incrementalAuth configured\n // 2. Default to 'anonymous' if not configured (allow anonymous fallback)\n let skippedBehavior: 'anonymous' | 'require-auth' = 'anonymous';\n\n if (authOptions && isOrchestratedMode(authOptions)) {\n // Orchestrated mode - check incrementalAuth config\n const incrementalConfig = authOptions.incrementalAuth;\n if (incrementalConfig) {\n // If incremental auth is disabled, always require auth\n if (incrementalConfig.enabled === false) {\n skippedBehavior = 'require-auth';\n } else {\n skippedBehavior = incrementalConfig.skippedAppBehavior || 'anonymous';\n }\n }\n // If incrementalAuth not configured, default is enabled with 'anonymous' behavior\n }\n // For public/transparent modes, default 'anonymous' behavior applies\n\n if (skippedBehavior === 'anonymous' && app?.metadata?.auth?.mode === 'public') {\n // App supports anonymous - continue with anonymous access\n this.logger.verbose(`checkToolAuthorization: using anonymous for ${appId}`);\n return;\n }\n\n // Require explicit authorization - build auth URL\n const authUrl = this.buildProgressiveAuthUrl(appId, tool?.fullName || '');\n\n this.logger.info(`checkToolAuthorization: authorization required for app \"${appId}\"`);\n throw new AuthorizationRequiredError({\n appId,\n toolId: tool?.fullName || tool?.name || 'unknown',\n authUrl,\n message: `Authorization required for ${appId}. Please authorize to use ${tool?.fullName || tool?.name}.`,\n });\n }\n\n this.logger.verbose('checkToolAuthorization:done');\n }\n\n /**\n * Build the URL for progressive/incremental authorization\n */\n private buildProgressiveAuthUrl(appId: string, toolId: string): string {\n const baseUrl = this.scope.fullPath || '';\n return `${baseUrl}/oauth/authorize?app=${encodeURIComponent(appId)}&tool=${encodeURIComponent(toolId)}`;\n }\n\n @Stage('createToolCallContext')\n async createToolCallContext() {\n this.logger.verbose('createToolCallContext:start');\n const { ctx } = this.input;\n const { tool, input } = this.state.required;\n\n try {\n const context = tool.create(input.arguments, ctx);\n const toolHooks = this.scope.hooks.getClsHooks(tool.record.provide).map((hook) => {\n hook.run = async () => {\n return context[hook.metadata.method]();\n };\n return hook;\n });\n\n this.appendContextHooks(toolHooks);\n context.mark('createToolCallContext');\n this.state.set('toolContext', context);\n this.logger.verbose('createToolCallContext:done');\n } catch (error) {\n this.logger.error('createToolCallContext: failed to create context', error);\n throw new ToolExecutionError(tool.metadata.name, error instanceof Error ? error : undefined);\n }\n }\n\n @Stage('acquireQuota')\n async acquireQuota() {\n this.logger.verbose('acquireQuota:start');\n // used for rate limiting\n this.state.toolContext?.mark('acquireQuota');\n this.logger.verbose('acquireQuota:done');\n }\n\n @Stage('acquireSemaphore')\n async acquireSemaphore() {\n this.logger.verbose('acquireSemaphore:start');\n // used for concurrency control\n this.state.toolContext?.mark('acquireSemaphore');\n this.logger.verbose('acquireSemaphore:done');\n }\n\n @Stage('validateInput')\n async validateInput() {\n this.logger.verbose('validateInput:start');\n const { tool, input } = this.state.required;\n const { toolContext } = this.state;\n if (!toolContext) {\n return;\n }\n toolContext.mark('validateInput');\n\n try {\n toolContext.input = tool.parseInput(input);\n this.logger.verbose('validateInput:done');\n } catch (err) {\n if (err instanceof z.ZodError) {\n throw new InvalidInputError('Invalid tool input', err.issues);\n }\n\n this.logger.error('validateInput: failed to parse input', err);\n throw new InvalidInputError('Unknown error occurred when trying to parse input');\n }\n }\n\n @Stage('execute')\n async execute() {\n this.logger.verbose('execute:start');\n const toolContext = this.state.toolContext;\n if (!toolContext) {\n return;\n }\n toolContext.mark('execute');\n\n try {\n toolContext.output = await toolContext.execute(toolContext.input);\n this.logger.verbose('execute:done');\n } catch (error) {\n this.logger.error('execute: tool execution failed', error);\n throw new ToolExecutionError(\n this.state.tool?.metadata.name || 'unknown',\n error instanceof Error ? error : undefined,\n );\n }\n }\n\n @Stage('validateOutput')\n async validateOutput() {\n this.logger.verbose('validateOutput:start');\n const { toolContext } = this.state;\n if (!toolContext) {\n return;\n }\n toolContext.mark('validateOutput');\n\n // Store the RAW output for plugins (cache, PII, etc.) to inspect\n this.state.set('rawOutput', toolContext.output);\n\n this.logger.verbose('validateOutput:done');\n }\n\n @Stage('releaseSemaphore')\n async releaseSemaphore() {\n this.logger.verbose('releaseSemaphore:start');\n // release concurrency control\n this.state.toolContext?.mark('releaseSemaphore');\n this.logger.verbose('releaseSemaphore:done');\n }\n\n @Stage('releaseQuota')\n async releaseQuota() {\n this.logger.verbose('releaseQuota:start');\n // release rate limiting\n this.state.toolContext?.mark('releaseQuota');\n this.logger.verbose('releaseQuota:done');\n }\n\n /**\n * Apply UI rendering to the tool response.\n * This stage handles all UI-related logic including platform detection,\n * serving mode resolution, and content formatting.\n */\n @Stage('applyUI')\n async applyUI() {\n this.logger.verbose('applyUI:start');\n const { tool, rawOutput, input } = this.state;\n\n // Skip if no tool or no UI config\n if (!tool || !hasUIConfig(tool.metadata)) {\n this.logger.verbose('applyUI:skip (no UI config)');\n return;\n }\n\n try {\n // Cast scope to Scope to access toolUI and notifications\n const scope = this.scope as Scope;\n\n // Get session info for platform detection from authInfo (already in state from parseInput)\n const { authInfo } = this.state;\n const sessionId = authInfo?.sessionId;\n const requestId: string = randomUUID();\n\n // Get platform type: first check sessionIdPayload (detected from user-agent),\n // then fall back to notification service (detected from MCP clientInfo),\n // finally default to 'unknown' (conservative: skip UI for unknown clients)\n const platformType =\n authInfo?.sessionIdPayload?.platformType ??\n (sessionId ? scope.notifications.getPlatformType(sessionId) : undefined) ??\n 'unknown';\n\n // Resolve the effective serving mode based on configuration and client capabilities\n // Default is 'auto' which selects the best mode for the platform\n const configuredMode = tool.metadata.ui.servingMode ?? 'auto';\n const resolvedMode = resolveServingMode({\n configuredMode,\n platformType,\n });\n\n // If client doesn't support UI (e.g., Gemini, unknown, or forced mode not available)\n // skip UI rendering entirely\n if (!resolvedMode.supportsUI || resolvedMode.effectiveMode === null) {\n this.logger.verbose('applyUI: Skipping UI (client does not support it)', {\n tool: tool.metadata.name,\n platform: platformType,\n configuredMode,\n reason: resolvedMode.reason,\n });\n return;\n }\n\n const servingMode = resolvedMode.effectiveMode;\n const useStructuredContent = resolvedMode.useStructuredContent;\n let htmlContent: string | undefined;\n let uiMeta: Record<string, unknown> = {};\n\n if (servingMode === 'static') {\n // For static mode: no additional rendering needed\n // Widget was already registered at server startup\n this.logger.verbose('applyUI: UI using static mode (structured data only)', {\n tool: tool.metadata.name,\n platform: platformType,\n });\n } else if (servingMode === 'hybrid') {\n // For hybrid mode: build the component payload\n const componentPayload = scope.toolUI.buildHybridComponentPayload({\n toolName: tool.metadata.name,\n template: tool.metadata.ui.template,\n uiConfig: tool.metadata.ui,\n });\n\n if (componentPayload) {\n uiMeta = {\n 'ui/component': componentPayload,\n 'ui/type': componentPayload.type,\n };\n }\n\n this.logger.verbose('applyUI: UI using hybrid mode (structured data + component)', {\n tool: tool.metadata.name,\n platform: platformType,\n hasComponent: !!componentPayload,\n componentType: componentPayload?.type,\n componentHash: componentPayload?.hash,\n });\n } else {\n // For inline mode (default): render HTML with data embedded\n const uiRenderResult = await scope.toolUI.renderAndRegisterAsync({\n toolName: tool.metadata.name,\n requestId,\n input:\n input?.arguments && typeof input.arguments === 'object' && !Array.isArray(input.arguments)\n ? (input.arguments as Record<string, unknown>)\n : {},\n output: rawOutput,\n structuredContent: undefined,\n uiConfig: tool.metadata.ui,\n platformType,\n });\n\n // Handle graceful degradation: rendering failed in production\n if (isUIRenderFailure(uiRenderResult)) {\n this.logger.warn('applyUI: UI rendering failed (graceful degradation)', {\n tool: tool.metadata.name,\n reason: uiRenderResult.reason,\n platform: platformType,\n });\n // Proceed without UI - tool result will not have ui/html metadata\n htmlContent = undefined;\n uiMeta = {};\n } else {\n // Extract HTML from platform-specific meta key\n const htmlKey =\n platformType === 'openai' ? 'openai/html' : platformType === 'ext-apps' ? 'ui/html' : 'frontmcp/html';\n htmlContent = uiRenderResult?.meta?.[htmlKey] as string | undefined;\n // Fallback to ui/html for compatibility\n if (!htmlContent) {\n htmlContent = uiRenderResult?.meta?.['ui/html'] as string | undefined;\n }\n uiMeta = uiRenderResult.meta || {};\n }\n }\n\n // Build the response content using the extracted utility\n const uiResult = buildToolResponseContent({\n rawOutput,\n htmlContent,\n servingMode,\n useStructuredContent,\n platformType,\n });\n\n // Store UI result and metadata in state for finalize stage\n this.state.set('uiResult', uiResult);\n this.state.set('uiMeta', uiMeta);\n\n this.logger.verbose('applyUI: UI processed', {\n tool: tool.metadata.name,\n platform: platformType,\n servingMode,\n useStructuredContent,\n format: uiResult.format,\n contentCleared: uiResult.contentCleared,\n });\n } catch (error) {\n // UI rendering failure should not fail the tool call\n const errorMessage = error instanceof Error ? error.message : String(error);\n const errorStack = error instanceof Error ? error.stack : undefined;\n const uiConfig = tool.metadata.ui;\n\n this.logger.error('applyUI: UI rendering failed', {\n tool: tool.metadata.name,\n error: errorMessage,\n stack: errorStack,\n templateType: uiConfig?.template\n ? typeof uiConfig.template === 'function'\n ? 'react-component'\n : typeof uiConfig.template === 'string'\n ? uiConfig.template.endsWith('.tsx') || uiConfig.template.endsWith('.jsx')\n ? 'react-file'\n : 'html-file'\n : 'unknown'\n : 'none',\n });\n\n // In debug mode, also log to console for immediate visibility\n if (process.env['DEBUG'] || process.env['NODE_ENV'] === 'development') {\n console.error('[FrontMCP] UI Rendering Error:', {\n tool: tool.metadata.name,\n error: errorMessage,\n stack: errorStack,\n });\n }\n }\n\n this.logger.verbose('applyUI:done');\n }\n\n /**\n * Finalize the tool response.\n * Validates output, applies UI result from applyUI stage, and sends the response.\n *\n * Note: This stage runs even when execute fails (as part of cleanup).\n * If rawOutput is undefined, it means an error occurred during execution\n * and the error will be propagated by the flow framework - we should not\n * throw a new error here.\n */\n @Stage('finalize')\n async finalize() {\n this.logger.verbose('finalize:start');\n const { tool, rawOutput, uiResult, uiMeta } = this.state;\n\n if (!tool) {\n // No tool found - this is an early failure, just skip finalization\n this.logger.verbose('finalize: skipping (no tool in state)');\n return;\n }\n\n if (rawOutput === undefined) {\n // No output means execute stage failed - skip finalization\n // The original error will be propagated by the flow framework\n this.logger.verbose('finalize: skipping (no output - execute stage likely failed)');\n return;\n }\n\n // Parse and construct the MCP-compliant output using safeParseOutput\n const parseResult = tool.safeParseOutput(rawOutput);\n\n if (!parseResult.success) {\n this.logger.error('finalize: output validation failed', {\n tool: tool.metadata.name,\n errors: parseResult.error,\n });\n throw new InvalidOutputError();\n }\n\n const result = parseResult.data;\n\n // Apply UI result if available (from applyUI stage)\n if (uiResult) {\n result.content = uiResult.content;\n // Set structuredContent from UI result (contains raw tool output)\n // Cast to Record<string, unknown> since MCP protocol expects object type\n if (uiResult.structuredContent !== undefined && uiResult.structuredContent !== null) {\n result.structuredContent = uiResult.structuredContent as Record<string, unknown>;\n }\n if (uiMeta) {\n result._meta = { ...result._meta, ...uiMeta };\n }\n }\n\n // Log the final result being sent\n this.logger.info('finalize: sending response', {\n tool: tool.metadata.name,\n hasContent: Array.isArray(result.content) && result.content.length > 0,\n contentLength: Array.isArray(result.content) ? result.content.length : 0,\n hasStructuredContent: result.structuredContent !== undefined,\n hasMeta: result._meta !== undefined,\n metaKeys: result._meta ? Object.keys(result._meta) : [],\n isError: result.isError,\n });\n\n // Debug: Write full response to file if DEBUG_TOOL_RESPONSE is set\n if (process.env['DEBUG_TOOL_RESPONSE']) {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const fs = require('fs').promises;\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const os = require('os');\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const path = require('path');\n const debugOutput = {\n timestamp: new Date().toISOString(),\n tool: tool.metadata.name,\n rawOutput,\n uiResult,\n uiMeta,\n finalResult: result,\n };\n // Use os.tmpdir() for cross-platform compatibility (works on Windows, macOS, Linux)\n const tempDir = os.tmpdir();\n const defaultPath = path.join(tempDir, 'tool-response-debug.json');\n let outputPath = process.env['DEBUG_TOOL_RESPONSE_PATH'] || defaultPath;\n\n // Path traversal protection: ensure custom path is within allowed directories\n if (process.env['DEBUG_TOOL_RESPONSE_PATH']) {\n const resolvedPath = path.resolve(outputPath);\n const resolvedTempDir = path.resolve(tempDir);\n const cwd = path.resolve(process.cwd());\n\n // Only allow paths within temp directory or current working directory\n const isInTempDir = resolvedPath.startsWith(resolvedTempDir + path.sep) || resolvedPath === resolvedTempDir;\n const isInCwd = resolvedPath.startsWith(cwd + path.sep) || resolvedPath === cwd;\n\n if (!isInTempDir && !isInCwd) {\n console.error(\n `[DEBUG] DEBUG_TOOL_RESPONSE_PATH must be within temp directory (${tempDir}) or current working directory (${cwd}). ` +\n `Falling back to default path.`,\n );\n outputPath = defaultPath;\n }\n }\n\n // Use async write to avoid blocking the event loop (fire-and-forget)\n fs.writeFile(outputPath, JSON.stringify(debugOutput, null, 2))\n .then(() => console.log(`[DEBUG] Tool response written to: ${outputPath}`))\n .catch((err: Error) => console.error(`[DEBUG] Failed to write tool response: ${err.message}`));\n }\n\n // Respond with the properly formatted MCP result\n this.respond(result);\n this.logger.verbose('finalize:done');\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"call-tool.flow.js","sourceRoot":"","sources":["../../../../src/tool/flows/call-tool.flow.ts"],"names":[],"mappings":";;;AAAA,gCAA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CAAC,UAAU,CAAC;;;;4CAqBjB;AAQK;IADL,KAAK,CAAC,wBAAwB,CAAC;;;;0DA4E/B;AAWK;IADL,KAAK,CAAC,uBAAuB,CAAC;;;;yDAuB9B;AAGK;IADL,KAAK,CAAC,cAAc,CAAC;;;;gDAMrB;AAGK;IADL,KAAK,CAAC,kBAAkB,CAAC;;;;oDAMzB;AAGK;IADL,KAAK,CAAC,eAAe,CAAC;;;;iDAqBtB;AAGK;IADL,KAAK,CAAC,SAAS,CAAC;;;;2CAmBhB;AAGK;IADL,KAAK,CAAC,gBAAgB,CAAC;;;;kDAavB;AAGK;IADL,KAAK,CAAC,kBAAkB,CAAC;;;;oDAMzB;AAGK;IADL,KAAK,CAAC,cAAc,CAAC;;;;gDAMrB;AAQK;IADL,KAAK,CAAC,SAAS,CAAC;;;;2CA6KhB;AAYK;IADL,KAAK,CAAC,UAAU,CAAC;;;;4CAwGjB;AAnjBkB,YAAY;IAPhC,IAAA,aAAI,EAAC;QACJ,IAAI;QACJ,IAAI;QACJ,WAAW;QACX,YAAY;QACZ,MAAM,EAAE,YAAY;KACrB,CAAC;GACmB,YAAY,CAojBhC;kBApjBoB,YAAY","sourcesContent":["// tools/flows/call-tool.flow.ts\nimport { randomUUID } from 'crypto';\nimport {\n Flow,\n FlowBase,\n FlowHooksOf,\n FlowPlan,\n FlowRunOptions,\n ToolContext,\n ToolEntry,\n isOrchestratedMode,\n} from '../../common';\nimport { z } from 'zod';\nimport { CallToolRequestSchema, CallToolResultSchema } from '@modelcontextprotocol/sdk/types.js';\nimport { AuthInfo } from '@modelcontextprotocol/sdk/server/auth/types.js';\nimport {\n InvalidMethodError,\n ToolNotFoundError,\n InvalidInputError,\n InvalidOutputError,\n ToolExecutionError,\n AuthorizationRequiredError,\n} from '../../errors';\nimport { hasUIConfig } from '../ui';\nimport { Scope } from '../../scope';\nimport { resolveServingMode, buildToolResponseContent, type ToolResponseContent } from '@frontmcp/uipack/adapters';\nimport { isUIRenderFailure } from '@frontmcp/uipack/registry';\nimport { safeStringify } from '@frontmcp/uipack/utils';\n\nconst inputSchema = z.object({\n request: CallToolRequestSchema,\n // z.any() used because ctx is the MCP SDK's ToolCallExtra type which varies by SDK version\n ctx: z.any(),\n});\n\nconst outputSchema = CallToolResultSchema;\n\nconst stateSchema = z.object({\n input: z.looseObject({\n name: z.string().min(1).max(64),\n arguments: z.looseObject({}).optional(),\n }),\n authInfo: z.any().optional() as z.ZodType<AuthInfo>,\n tool: z.instanceof(ToolEntry),\n toolContext: z.instanceof(ToolContext),\n // Store the raw executed output for plugins to see\n rawOutput: z.any().optional(),\n output: outputSchema,\n // Tool owner ID for hook filtering (set during parseInput)\n _toolOwnerId: z.string().optional(),\n // UI result from applyUI stage (if UI config exists)\n uiResult: z.any().optional() as z.ZodType<ToolResponseContent | undefined>,\n // UI metadata from rendering (merged into _meta)\n uiMeta: z.record(z.string(), z.unknown()).optional(),\n});\n\nconst plan = {\n pre: [\n 'parseInput',\n 'findTool',\n 'checkToolAuthorization',\n 'createToolCallContext',\n 'acquireQuota',\n 'acquireSemaphore',\n ],\n execute: ['validateInput', 'execute', 'validateOutput'],\n finalize: ['releaseSemaphore', 'releaseQuota', 'applyUI', 'finalize'],\n} as const satisfies FlowPlan<string>;\n\ndeclare global {\n interface ExtendFlows {\n 'tools:call-tool': FlowRunOptions<\n CallToolFlow,\n typeof plan,\n typeof inputSchema,\n typeof outputSchema,\n typeof stateSchema\n >;\n }\n}\n\nconst name = 'tools:call-tool' as const;\nconst { Stage } = FlowHooksOf<'tools:call-tool'>(name);\n\n@Flow({\n name,\n plan,\n inputSchema,\n outputSchema,\n access: 'authorized',\n})\nexport default class CallToolFlow extends FlowBase<typeof name> {\n logger = this.scopeLogger.child('CallToolFlow');\n\n @Stage('parseInput')\n async parseInput() {\n this.logger.verbose('parseInput:start');\n\n let method!: string;\n // NOTE: `any` is intentional - Zod parsing validates these values\n // Using unknown would require redundant type guards after schema validation\n let params: any;\n let ctx: any;\n try {\n const inputData = inputSchema.parse(this.rawInput);\n method = inputData.request.method;\n params = inputData.request.params;\n ctx = inputData.ctx;\n } catch (e) {\n throw new InvalidInputError('Invalid Input', e instanceof z.ZodError ? e.issues : undefined);\n }\n\n if (method !== 'tools/call') {\n this.logger.warn(`parseInput: invalid method \"${method}\"`);\n throw new InvalidMethodError(method, 'tools/call');\n }\n\n // Find the tool early to get its owner ID for hook filtering\n const { name } = params;\n const activeTools = this.scope.tools.getTools(true);\n const tool = activeTools.find((entry) => {\n return entry.fullName === name || entry.name === name;\n });\n\n // Store tool owner ID in state for hook filtering\n const toolOwnerId = tool?.owner?.id;\n\n this.state.set({ input: params, authInfo: ctx.authInfo, _toolOwnerId: toolOwnerId });\n this.logger.verbose('parseInput:done');\n }\n\n @Stage('findTool')\n async findTool() {\n this.logger.verbose('findTool:start');\n // TODO: add support for session based tools\n const activeTools = this.scope.tools.getTools(true);\n this.logger.info(`findTool: discovered ${activeTools.length} active tool(s) (including hidden)`);\n\n const { name } = this.state.required.input;\n const tool = activeTools.find((entry) => {\n return entry.fullName === name || entry.name === name;\n });\n\n if (!tool) {\n this.logger.warn(`findTool: tool \"${name}\" not found`);\n throw new ToolNotFoundError(name);\n }\n\n this.logger = this.logger.child(`CallToolFlow(${name})`);\n this.state.set('tool', tool);\n this.logger.info(`findTool: tool \"${name}\" found`);\n this.logger.verbose('findTool:done');\n }\n\n /**\n * Check if the tool's parent app is authorized.\n * For progressive authorization, tools from unauthorized apps\n * return an AuthorizationRequiredError with an auth_url.\n */\n @Stage('checkToolAuthorization')\n async checkToolAuthorization() {\n this.logger.verbose('checkToolAuthorization:start');\n const { tool, authInfo } = this.state;\n\n // Get authorization from authInfo.extra if available\n const authorization = authInfo?.extra?.['authorization'] as\n | {\n authorizedAppIds?: string[];\n authorizedApps?: Record<string, unknown>;\n }\n | undefined;\n\n // No auth context = public mode, skip authorization check\n if (!authorization) {\n this.logger.verbose('checkToolAuthorization:skip (no auth context)');\n return;\n }\n\n // Get app ID from tool owner (uses existing lineage system)\n const appId = tool?.owner?.id;\n if (!appId) {\n // Tool has no owner = global tool, skip app-level authorization check\n this.logger.verbose('checkToolAuthorization:skip (no owner)');\n return;\n }\n\n // Check if app is authorized using existing session structure\n const isAppAuthorized =\n authorization.authorizedAppIds?.includes(appId) || appId in (authorization.authorizedApps || {});\n\n if (!isAppAuthorized) {\n // Get incremental auth configuration from scope's auth options\n const apps = this.scope.apps.getApps();\n const app = apps.find((a) => a.metadata.id === appId);\n const authOptions = this.scope.auth?.options;\n\n // Determine skippedAppBehavior:\n // 1. Only applies in orchestrated mode with incrementalAuth configured\n // 2. Default to 'anonymous' if not configured (allow anonymous fallback)\n let skippedBehavior: 'anonymous' | 'require-auth' = 'anonymous';\n\n if (authOptions && isOrchestratedMode(authOptions)) {\n // Orchestrated mode - check incrementalAuth config\n const incrementalConfig = authOptions.incrementalAuth;\n if (incrementalConfig) {\n // If incremental auth is disabled, always require auth\n if (incrementalConfig.enabled === false) {\n skippedBehavior = 'require-auth';\n } else {\n skippedBehavior = incrementalConfig.skippedAppBehavior || 'anonymous';\n }\n }\n // If incrementalAuth not configured, default is enabled with 'anonymous' behavior\n }\n // For public/transparent modes, default 'anonymous' behavior applies\n\n if (skippedBehavior === 'anonymous' && app?.metadata?.auth?.mode === 'public') {\n // App supports anonymous - continue with anonymous access\n this.logger.verbose(`checkToolAuthorization: using anonymous for ${appId}`);\n return;\n }\n\n // Require explicit authorization - build auth URL\n const authUrl = this.buildProgressiveAuthUrl(appId, tool?.fullName || '');\n\n this.logger.info(`checkToolAuthorization: authorization required for app \"${appId}\"`);\n throw new AuthorizationRequiredError({\n appId,\n toolId: tool?.fullName || tool?.name || 'unknown',\n authUrl,\n message: `Authorization required for ${appId}. Please authorize to use ${tool?.fullName || tool?.name}.`,\n });\n }\n\n this.logger.verbose('checkToolAuthorization:done');\n }\n\n /**\n * Build the URL for progressive/incremental authorization\n */\n private buildProgressiveAuthUrl(appId: string, toolId: string): string {\n const baseUrl = this.scope.fullPath || '';\n return `${baseUrl}/oauth/authorize?app=${encodeURIComponent(appId)}&tool=${encodeURIComponent(toolId)}`;\n }\n\n @Stage('createToolCallContext')\n async createToolCallContext() {\n this.logger.verbose('createToolCallContext:start');\n const { ctx } = this.input;\n const { tool, input } = this.state.required;\n\n try {\n const context = tool.create(input.arguments, ctx);\n const toolHooks = this.scope.hooks.getClsHooks(tool.record.provide).map((hook) => {\n hook.run = async () => {\n return context[hook.metadata.method]();\n };\n return hook;\n });\n\n this.appendContextHooks(toolHooks);\n context.mark('createToolCallContext');\n this.state.set('toolContext', context);\n this.logger.verbose('createToolCallContext:done');\n } catch (error) {\n this.logger.error('createToolCallContext: failed to create context', error);\n throw new ToolExecutionError(tool.metadata.name, error instanceof Error ? error : undefined);\n }\n }\n\n @Stage('acquireQuota')\n async acquireQuota() {\n this.logger.verbose('acquireQuota:start');\n // used for rate limiting\n this.state.toolContext?.mark('acquireQuota');\n this.logger.verbose('acquireQuota:done');\n }\n\n @Stage('acquireSemaphore')\n async acquireSemaphore() {\n this.logger.verbose('acquireSemaphore:start');\n // used for concurrency control\n this.state.toolContext?.mark('acquireSemaphore');\n this.logger.verbose('acquireSemaphore:done');\n }\n\n @Stage('validateInput')\n async validateInput() {\n this.logger.verbose('validateInput:start');\n const { tool, input } = this.state.required;\n const { toolContext } = this.state;\n if (!toolContext) {\n return;\n }\n toolContext.mark('validateInput');\n\n try {\n toolContext.input = tool.parseInput(input);\n this.logger.verbose('validateInput:done');\n } catch (err) {\n if (err instanceof z.ZodError) {\n throw new InvalidInputError('Invalid tool input', err.issues);\n }\n\n this.logger.error('validateInput: failed to parse input', err);\n throw new InvalidInputError('Unknown error occurred when trying to parse input');\n }\n }\n\n @Stage('execute')\n async execute() {\n this.logger.verbose('execute:start');\n const toolContext = this.state.toolContext;\n if (!toolContext) {\n return;\n }\n toolContext.mark('execute');\n\n try {\n toolContext.output = await toolContext.execute(toolContext.input);\n this.logger.verbose('execute:done');\n } catch (error) {\n this.logger.error('execute: tool execution failed', error);\n throw new ToolExecutionError(\n this.state.tool?.metadata.name || 'unknown',\n error instanceof Error ? error : undefined,\n );\n }\n }\n\n @Stage('validateOutput')\n async validateOutput() {\n this.logger.verbose('validateOutput:start');\n const { toolContext } = this.state;\n if (!toolContext) {\n return;\n }\n toolContext.mark('validateOutput');\n\n // Store the RAW output for plugins (cache, PII, etc.) to inspect\n this.state.set('rawOutput', toolContext.output);\n\n this.logger.verbose('validateOutput:done');\n }\n\n @Stage('releaseSemaphore')\n async releaseSemaphore() {\n this.logger.verbose('releaseSemaphore:start');\n // release concurrency control\n this.state.toolContext?.mark('releaseSemaphore');\n this.logger.verbose('releaseSemaphore:done');\n }\n\n @Stage('releaseQuota')\n async releaseQuota() {\n this.logger.verbose('releaseQuota:start');\n // release rate limiting\n this.state.toolContext?.mark('releaseQuota');\n this.logger.verbose('releaseQuota:done');\n }\n\n /**\n * Apply UI rendering to the tool response.\n * This stage handles all UI-related logic including platform detection,\n * serving mode resolution, and content formatting.\n */\n @Stage('applyUI')\n async applyUI() {\n this.logger.verbose('applyUI:start');\n const { tool, rawOutput, input } = this.state;\n\n // Skip if no tool or no UI config\n if (!tool || !hasUIConfig(tool.metadata)) {\n this.logger.verbose('applyUI:skip (no UI config)');\n return;\n }\n\n try {\n // Cast scope to Scope to access toolUI and notifications\n const scope = this.scope as Scope;\n\n // Get session info for platform detection from authInfo (already in state from parseInput)\n const { authInfo } = this.state;\n const sessionId = authInfo?.sessionId;\n const requestId: string = randomUUID();\n\n // Get platform type: first check sessionIdPayload (detected from user-agent),\n // then fall back to notification service (detected from MCP clientInfo),\n // finally default to 'unknown' (conservative: skip UI for unknown clients)\n const platformType =\n authInfo?.sessionIdPayload?.platformType ??\n (sessionId ? scope.notifications.getPlatformType(sessionId) : undefined) ??\n 'unknown';\n\n // Resolve the effective serving mode based on configuration and client capabilities\n // Default is 'auto' which selects the best mode for the platform\n const configuredMode = tool.metadata.ui.servingMode ?? 'auto';\n const resolvedMode = resolveServingMode({\n configuredMode,\n platformType,\n });\n\n // If client doesn't support UI (e.g., Gemini, unknown, or forced mode not available)\n // skip UI rendering entirely\n if (!resolvedMode.supportsUI || resolvedMode.effectiveMode === null) {\n this.logger.verbose('applyUI: Skipping UI (client does not support it)', {\n tool: tool.metadata.name,\n platform: platformType,\n configuredMode,\n reason: resolvedMode.reason,\n });\n return;\n }\n\n const servingMode = resolvedMode.effectiveMode;\n const useStructuredContent = resolvedMode.useStructuredContent;\n let htmlContent: string | undefined;\n let uiMeta: Record<string, unknown> = {};\n\n if (servingMode === 'static') {\n // For static mode: no additional rendering needed\n // Widget was already registered at server startup\n this.logger.verbose('applyUI: UI using static mode (structured data only)', {\n tool: tool.metadata.name,\n platform: platformType,\n });\n } else if (servingMode === 'hybrid') {\n // For hybrid mode: build the component payload\n const componentPayload = scope.toolUI.buildHybridComponentPayload({\n toolName: tool.metadata.name,\n template: tool.metadata.ui.template,\n uiConfig: tool.metadata.ui,\n });\n\n if (componentPayload) {\n uiMeta = {\n 'ui/component': componentPayload,\n 'ui/type': componentPayload.type,\n };\n }\n\n this.logger.verbose('applyUI: UI using hybrid mode (structured data + component)', {\n tool: tool.metadata.name,\n platform: platformType,\n hasComponent: !!componentPayload,\n componentType: componentPayload?.type,\n componentHash: componentPayload?.hash,\n });\n } else {\n // For inline mode (default): render HTML with data embedded\n const uiRenderResult = await scope.toolUI.renderAndRegisterAsync({\n toolName: tool.metadata.name,\n requestId,\n input:\n input?.arguments && typeof input.arguments === 'object' && !Array.isArray(input.arguments)\n ? (input.arguments as Record<string, unknown>)\n : {},\n output: rawOutput,\n structuredContent: undefined,\n uiConfig: tool.metadata.ui,\n platformType,\n });\n\n // Handle graceful degradation: rendering failed in production\n if (isUIRenderFailure(uiRenderResult)) {\n this.logger.warn('applyUI: UI rendering failed (graceful degradation)', {\n tool: tool.metadata.name,\n reason: uiRenderResult.reason,\n platform: platformType,\n });\n // Proceed without UI - tool result will not have ui/html metadata\n htmlContent = undefined;\n uiMeta = {};\n } else {\n // Extract HTML from platform-specific meta key\n const htmlKey =\n platformType === 'openai' ? 'openai/html' : platformType === 'ext-apps' ? 'ui/html' : 'frontmcp/html';\n htmlContent = uiRenderResult?.meta?.[htmlKey] as string | undefined;\n // Fallback to ui/html for compatibility\n if (!htmlContent) {\n htmlContent = uiRenderResult?.meta?.['ui/html'] as string | undefined;\n }\n uiMeta = uiRenderResult.meta || {};\n }\n }\n\n // Build the response content using the extracted utility\n const uiResult = buildToolResponseContent({\n rawOutput,\n htmlContent,\n servingMode,\n useStructuredContent,\n platformType,\n });\n\n // Store UI result and metadata in state for finalize stage\n this.state.set('uiResult', uiResult);\n this.state.set('uiMeta', uiMeta);\n\n this.logger.verbose('applyUI: UI processed', {\n tool: tool.metadata.name,\n platform: platformType,\n servingMode,\n useStructuredContent,\n format: uiResult.format,\n contentCleared: uiResult.contentCleared,\n });\n } catch (error) {\n // UI rendering failure should not fail the tool call\n const errorMessage = error instanceof Error ? error.message : String(error);\n const errorStack = error instanceof Error ? error.stack : undefined;\n const uiConfig = tool.metadata.ui;\n\n this.logger.error('applyUI: UI rendering failed', {\n tool: tool.metadata.name,\n error: errorMessage,\n stack: errorStack,\n templateType: uiConfig?.template\n ? typeof uiConfig.template === 'function'\n ? 'react-component'\n : typeof uiConfig.template === 'string'\n ? uiConfig.template.endsWith('.tsx') || uiConfig.template.endsWith('.jsx')\n ? 'react-file'\n : 'html-file'\n : 'unknown'\n : 'none',\n });\n\n // In debug mode, also log to console for immediate visibility\n if (process.env['DEBUG'] || process.env['NODE_ENV'] === 'development') {\n console.error('[FrontMCP] UI Rendering Error:', {\n tool: tool.metadata.name,\n error: errorMessage,\n stack: errorStack,\n });\n }\n }\n\n this.logger.verbose('applyUI:done');\n }\n\n /**\n * Finalize the tool response.\n * Validates output, applies UI result from applyUI stage, and sends the response.\n *\n * Note: This stage runs even when execute fails (as part of cleanup).\n * If rawOutput is undefined, it means an error occurred during execution\n * and the error will be propagated by the flow framework - we should not\n * throw a new error here.\n */\n @Stage('finalize')\n async finalize() {\n this.logger.verbose('finalize:start');\n const { tool, rawOutput, uiResult, uiMeta } = this.state;\n\n if (!tool) {\n // No tool found - this is an early failure, just skip finalization\n this.logger.verbose('finalize: skipping (no tool in state)');\n return;\n }\n\n if (rawOutput === undefined) {\n // No output means execute stage failed - skip finalization\n // The original error will be propagated by the flow framework\n this.logger.verbose('finalize: skipping (no output - execute stage likely failed)');\n return;\n }\n\n // Parse and construct the MCP-compliant output using safeParseOutput\n const parseResult = tool.safeParseOutput(rawOutput);\n\n if (!parseResult.success) {\n this.logger.error('finalize: output validation failed', {\n tool: tool.metadata.name,\n errors: parseResult.error,\n });\n throw new InvalidOutputError();\n }\n\n const result = parseResult.data;\n\n // Apply UI result if available (from applyUI stage)\n if (uiResult) {\n result.content = uiResult.content;\n // Set structuredContent from UI result (contains raw tool output)\n // Cast to Record<string, unknown> since MCP protocol expects object type\n if (uiResult.structuredContent !== undefined && uiResult.structuredContent !== null) {\n result.structuredContent = uiResult.structuredContent as Record<string, unknown>;\n }\n if (uiMeta) {\n result._meta = { ...result._meta, ...uiMeta };\n }\n }\n\n // Log the final result being sent\n this.logger.info('finalize: sending response', {\n tool: tool.metadata.name,\n hasContent: Array.isArray(result.content) && result.content.length > 0,\n contentLength: Array.isArray(result.content) ? result.content.length : 0,\n hasStructuredContent: result.structuredContent !== undefined,\n hasMeta: result._meta !== undefined,\n metaKeys: result._meta ? Object.keys(result._meta) : [],\n isError: result.isError,\n });\n\n // Debug: Write full response to file if DEBUG_TOOL_RESPONSE is set\n if (process.env['DEBUG_TOOL_RESPONSE']) {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const fs = require('fs').promises;\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const os = require('os');\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const path = require('path');\n const debugOutput = {\n timestamp: new Date().toISOString(),\n tool: tool.metadata.name,\n rawOutput,\n uiResult,\n uiMeta,\n finalResult: result,\n };\n // Use os.tmpdir() for cross-platform compatibility (works on Windows, macOS, Linux)\n const tempDir = os.tmpdir();\n const defaultPath = path.join(tempDir, 'tool-response-debug.json');\n let outputPath = process.env['DEBUG_TOOL_RESPONSE_PATH'] || defaultPath;\n\n // Path traversal protection: ensure custom path is within allowed directories\n if (process.env['DEBUG_TOOL_RESPONSE_PATH']) {\n const resolvedPath = path.resolve(outputPath);\n const resolvedTempDir = path.resolve(tempDir);\n const cwd = path.resolve(process.cwd());\n\n // Only allow paths within temp directory or current working directory\n const isInTempDir = resolvedPath.startsWith(resolvedTempDir + path.sep) || resolvedPath === resolvedTempDir;\n const isInCwd = resolvedPath.startsWith(cwd + path.sep) || resolvedPath === cwd;\n\n if (!isInTempDir && !isInCwd) {\n console.error(\n `[DEBUG] DEBUG_TOOL_RESPONSE_PATH must be within temp directory (${tempDir}) or current working directory (${cwd}). ` +\n `Falling back to default path.`,\n );\n outputPath = defaultPath;\n }\n }\n\n // Use async write to avoid blocking the event loop (fire-and-forget)\n fs.writeFile(outputPath, JSON.stringify(debugOutput, null, 2))\n .then(() => console.log(`[DEBUG] Tool response written to: ${outputPath}`))\n .catch((err: Error) => console.error(`[DEBUG] Failed to write tool response: ${err.message}`));\n }\n\n // Respond with the properly formatted MCP result\n this.respond(result);\n this.logger.verbose('finalize:done');\n }\n}\n"]}
|
|
@@ -1,32 +1,29 @@
|
|
|
1
1
|
import { FlowBase, FlowRunOptions, ToolEntry } from '../../common';
|
|
2
2
|
import 'reflect-metadata';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import type { AIPlatformType } from '@frontmcp/
|
|
4
|
+
import type { AIPlatformType } from '@frontmcp/uipack/adapters';
|
|
5
5
|
import type { AuthInfo } from '@modelcontextprotocol/sdk/server/auth/types.js';
|
|
6
6
|
declare const inputSchema: z.ZodObject<{
|
|
7
7
|
request: z.ZodObject<{
|
|
8
8
|
params: z.ZodOptional<z.ZodObject<{
|
|
9
|
-
task: z.ZodOptional<z.ZodObject<{
|
|
10
|
-
ttl: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodNull]>>;
|
|
11
|
-
pollInterval: z.ZodOptional<z.ZodNumber>;
|
|
12
|
-
}, z.core.$loose>>;
|
|
13
9
|
_meta: z.ZodOptional<z.ZodObject<{
|
|
14
10
|
progressToken: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
15
11
|
"io.modelcontextprotocol/related-task": z.ZodOptional<z.ZodObject<{
|
|
16
12
|
taskId: z.ZodString;
|
|
17
|
-
}, z.core.$
|
|
13
|
+
}, z.core.$strip>>;
|
|
18
14
|
}, z.core.$loose>>;
|
|
19
15
|
cursor: z.ZodOptional<z.ZodString>;
|
|
20
|
-
}, z.core.$
|
|
16
|
+
}, z.core.$strip>>;
|
|
21
17
|
method: z.ZodLiteral<"tools/list">;
|
|
22
18
|
}, z.core.$strip>;
|
|
23
19
|
ctx: z.ZodUnknown;
|
|
24
20
|
}, z.core.$strip>;
|
|
25
21
|
declare const outputSchema: z.ZodObject<{
|
|
26
22
|
_meta: z.ZodOptional<z.ZodObject<{
|
|
23
|
+
progressToken: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
27
24
|
"io.modelcontextprotocol/related-task": z.ZodOptional<z.ZodObject<{
|
|
28
25
|
taskId: z.ZodString;
|
|
29
|
-
}, z.core.$
|
|
26
|
+
}, z.core.$strip>>;
|
|
30
27
|
}, z.core.$loose>>;
|
|
31
28
|
nextCursor: z.ZodOptional<z.ZodString>;
|
|
32
29
|
tools: z.ZodArray<z.ZodObject<{
|
|
@@ -60,6 +57,10 @@ declare const outputSchema: z.ZodObject<{
|
|
|
60
57
|
src: z.ZodString;
|
|
61
58
|
mimeType: z.ZodOptional<z.ZodString>;
|
|
62
59
|
sizes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
60
|
+
theme: z.ZodOptional<z.ZodEnum<{
|
|
61
|
+
light: "light";
|
|
62
|
+
dark: "dark";
|
|
63
|
+
}>>;
|
|
63
64
|
}, z.core.$strip>>>;
|
|
64
65
|
name: z.ZodString;
|
|
65
66
|
title: z.ZodOptional<z.ZodString>;
|
|
@@ -9,8 +9,8 @@ const v4_1 = require("zod/v4");
|
|
|
9
9
|
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
10
10
|
const errors_1 = require("../../errors");
|
|
11
11
|
const ui_1 = require("../ui");
|
|
12
|
-
const build_1 = require("@frontmcp/
|
|
13
|
-
const types_1 = require("@frontmcp/
|
|
12
|
+
const build_1 = require("@frontmcp/uipack/build");
|
|
13
|
+
const types_1 = require("@frontmcp/uipack/types");
|
|
14
14
|
const inputSchema = zod_1.z.object({
|
|
15
15
|
request: types_js_1.ListToolsRequestSchema,
|
|
16
16
|
ctx: zod_1.z.unknown(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools-list.flow.js","sourceRoot":"","sources":["../../../../src/tool/flows/tools-list.flow.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,yCAA6G;AAC7G,4BAA0B;AAC1B,6BAAwB;AACxB,+BAAsC;AACtC,iEAAmG;AACnG,yCAAqE;AACrE,8BAAoC;AACpC,8CAAwE;AACxE,8CAA8C;AAK9C,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3B,OAAO,EAAE,iCAAsB;IAC/B,GAAG,EAAE,OAAC,CAAC,OAAO,EAAE;CACjB,CAAC,CAAC;AAEH,MAAM,YAAY,GAAG,gCAAqB,CAAC;AAE3C,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3B,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,8GAA8G;IAC9G,QAAQ,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAyB;IACnD,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAA2C;IAC5E,KAAK,EAAE,OAAC,CAAC,KAAK,CACZ,OAAC,CAAC,M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GK;IADL,KAAK,CAAC,WAAW,CAAC;;;;8CA4BlB;AAGK;IADL,KAAK,CAAC,kBAAkB,CAAC;;;;qDAmCzB;AAGK;IADL,KAAK,CAAC,YAAY,CAAC;;;;+CAsKnB;AA5RkB,aAAa;IAPjC,IAAA,aAAI,EAAC;QACJ,IAAI;QACJ,IAAI;QACJ,WAAW;QACX,YAAY;QACZ,MAAM,EAAE,YAAY;KACrB,CAAC;GACmB,aAAa,CA6RjC;kBA7RoB,aAAa","sourcesContent":["// tools/flows/list-tools.flow.ts\nimport { Flow, FlowBase, FlowControl, FlowHooksOf, FlowPlan, FlowRunOptions, ToolEntry } from '../../common';\nimport 'reflect-metadata';\nimport { z } from 'zod';\nimport { toJSONSchema } from 'zod/v4';\nimport { ListToolsRequestSchema, ListToolsResultSchema } from '@modelcontextprotocol/sdk/types.js';\nimport { InvalidMethodError, InvalidInputError } from '../../errors';\nimport { hasUIConfig } from '../ui';\nimport { buildCDNInfoForUIType, type UIType } from '@frontmcp/ui/build';\nimport { isUIType } from '@frontmcp/ui/types';\nimport type { AIPlatformType } from '@frontmcp/ui/adapters';\nimport type { Scope } from '../../scope/scope.instance';\nimport type { AuthInfo } from '@modelcontextprotocol/sdk/server/auth/types.js';\n\nconst inputSchema = z.object({\n request: ListToolsRequestSchema,\n ctx: z.unknown(),\n});\n\nconst outputSchema = ListToolsResultSchema;\n\nconst stateSchema = z.object({\n cursor: z.string().optional(),\n // z.any() used because AuthInfo is an external type from @modelcontextprotocol/sdk that varies by SDK version\n authInfo: z.any().optional() as z.ZodType<AuthInfo>,\n platformType: z.string().optional() as z.ZodType<AIPlatformType | undefined>,\n tools: z.array(\n z.object({\n appName: z.string(),\n tool: z.instanceof(ToolEntry),\n }),\n ),\n resolvedTools: z.array(\n z.object({\n appName: z.string(),\n tool: z.instanceof(ToolEntry),\n finalName: z.string(),\n }),\n ),\n});\n\ntype ResponseToolItem = z.infer<typeof outputSchema>['tools'][number];\n\n// TODO: add support for pagination\n// TODO: add support for session based tools\nconst plan = {\n pre: ['parseInput'],\n execute: ['findTools', 'resolveConflicts'],\n post: ['parseTools'],\n} as const satisfies FlowPlan<string>;\n\ndeclare global {\n interface ExtendFlows {\n 'tools:list-tools': FlowRunOptions<\n ToolsListFlow,\n typeof plan,\n typeof inputSchema,\n typeof outputSchema,\n typeof stateSchema\n >;\n }\n}\n\nconst name = 'tools:list-tools' as const;\nconst { Stage } = FlowHooksOf('tools:list-tools');\n\n@Flow({\n name,\n plan,\n inputSchema,\n outputSchema,\n access: 'authorized',\n})\nexport default class ToolsListFlow extends FlowBase<typeof name> {\n logger = this.scopeLogger.child('ToolsListFlow');\n\n private sample<T>(arr: T[], n = 5): T[] {\n return arr.slice(0, n);\n }\n\n @Stage('parseInput')\n async parseInput() {\n this.logger.verbose('parseInput:start');\n\n let method!: string;\n let params: any;\n let ctx: { authInfo?: AuthInfo } | undefined;\n try {\n const inputData = inputSchema.parse(this.rawInput);\n method = inputData.request.method;\n params = inputData.request.params;\n ctx = inputData.ctx as { authInfo?: AuthInfo } | undefined;\n } catch (e) {\n throw new InvalidInputError('Invalid request format', e instanceof z.ZodError ? e.issues : undefined);\n }\n\n if (method !== 'tools/list') {\n this.logger.warn(`parseInput: invalid method \"${method}\"`);\n throw new InvalidMethodError(method, 'tools/list');\n }\n\n // Extract authInfo and detect platform type\n const authInfo = ctx?.authInfo;\n const sessionId = authInfo?.sessionId;\n\n // Cast scope to access notifications service for platform detection\n const scope = this.scope as Scope;\n\n // Get platform type: first check sessionIdPayload (detected from user-agent),\n // then fall back to notification service (detected from MCP clientInfo),\n // finally default to 'unknown'\n const platformType: AIPlatformType =\n authInfo?.sessionIdPayload?.platformType ??\n (sessionId ? scope.notifications?.getPlatformType(sessionId) : undefined) ??\n 'unknown';\n\n this.logger.verbose(`parseInput: detected platform=${platformType}`);\n\n const cursor = params?.cursor;\n if (cursor) this.logger.verbose(`parseInput: cursor=${cursor}`);\n this.state.set({ cursor, authInfo, platformType });\n this.logger.verbose('parseInput:done');\n }\n\n @Stage('findTools')\n async findTools() {\n this.logger.info('findTools:start');\n\n try {\n const apps = this.scope.apps.getApps();\n this.logger.info(`findTools: discovered ${apps.length} app(s)`);\n\n const tools: Array<{ appName: string; tool: ToolEntry }> = [];\n\n const scopeTools = this.scope.tools.getTools();\n this.logger.verbose(`findTools: scope tools=${scopeTools.length}`);\n\n for (const tool of scopeTools) {\n tools.push({ appName: tool.owner.id, tool });\n }\n\n this.logger.info(`findTools: total tools collected=${tools.length}`);\n if (tools.length === 0) {\n this.logger.warn('findTools: no tools found across apps');\n }\n\n this.state.set('tools', tools);\n this.logger.verbose('findTools:done');\n } catch (error) {\n this.logger.error('findTools: failed to collect tools', error);\n throw error;\n }\n }\n\n @Stage('resolveConflicts')\n async resolveConflicts() {\n this.logger.verbose('resolveConflicts:start');\n\n try {\n const found = this.state.required.tools;\n\n const counts = new Map<string, number>();\n for (const { tool } of found) {\n const baseName = tool.metadata.id ?? tool.metadata.name;\n counts.set(baseName, (counts.get(baseName) ?? 0) + 1);\n }\n\n const conflicts = new Set<string>([...counts.entries()].filter(([, n]) => n > 1).map(([k]) => k));\n\n if (conflicts.size > 0) {\n const preview = this.sample(Array.from(conflicts)).join(', ');\n const extra = conflicts.size > 5 ? `, +${conflicts.size - 5} more` : '';\n this.logger.warn(`resolveConflicts: ${conflicts.size} name conflict(s) detected: ${preview}${extra}`);\n } else {\n this.logger.info('resolveConflicts: no name conflicts detected');\n }\n\n const resolved = found.map(({ appName, tool }) => {\n const baseName = tool.metadata.id ?? tool.metadata.name;\n const finalName = conflicts.has(baseName) ? `${appName}:${baseName}` : baseName;\n return { appName, tool, finalName };\n });\n\n this.state.set('resolvedTools', resolved);\n this.logger.verbose('resolveConflicts:done');\n } catch (error) {\n this.logger.error('resolveConflicts: failed to resolve conflicts', error);\n throw error;\n }\n }\n\n @Stage('parseTools')\n async parseTools() {\n this.logger.verbose('parseTools:start');\n\n try {\n const resolved = this.state.required.resolvedTools;\n const platformType = this.state.platformType ?? 'unknown';\n\n // Only OpenAI ChatGPT uses openai/* meta keys\n // ext-apps (SEP-1865) uses ui/* keys per the MCP Apps specification\n const isOpenAIPlatform = platformType === 'openai';\n\n const tools: ResponseToolItem[] = resolved.map(({ finalName, tool }) => {\n // Get the input schema - prefer rawInputSchema (JSON Schema), then convert from tool.inputSchema\n let inputSchema: any;\n if (tool.rawInputSchema) {\n // Already converted to JSON Schema\n inputSchema = tool.rawInputSchema;\n } else if (tool.inputSchema && Object.keys(tool.inputSchema).length > 0) {\n // tool.inputSchema is a ZodRawShape (extracted .shape from ZodObject in ToolInstance constructor)\n // Convert to JSON Schema\n try {\n // as any used here to prevent hard ts-check on tool input that is redundant\n // and just slow down the build process. types here are unnecessary.\n inputSchema = toJSONSchema(z.object(tool.inputSchema));\n } catch (e) {\n this.logger.warn(`Failed to convert inputSchema for tool ${finalName}:`, e);\n inputSchema = { type: 'object', properties: {} };\n }\n } else {\n // No schema defined - use empty object schema\n inputSchema = { type: 'object', properties: {} };\n }\n\n const item: ResponseToolItem = {\n name: finalName,\n title: tool.metadata.name,\n description: tool.metadata.description,\n annotations: tool.metadata.annotations,\n inputSchema,\n };\n\n // Add _meta for tools with UI configuration\n // OpenAI platforms use openai/* keys, other platforms use frontmcp/* keys\n if (hasUIConfig(tool.metadata)) {\n const uiConfig = tool.metadata.ui;\n if (!uiConfig) {\n // This should never happen if hasUIConfig returned true\n return item;\n }\n\n // Get manifest info from registry (if available)\n // Type guard: verify scope has toolUI with required methods before accessing\n const isValidScope = (obj: unknown): obj is Scope => {\n return (\n obj !== null &&\n typeof obj === 'object' &&\n 'toolUI' in obj &&\n typeof (obj as { toolUI?: unknown }).toolUI === 'object' &&\n (obj as { toolUI?: unknown }).toolUI !== null &&\n typeof (obj as { toolUI: { getManifest?: unknown } }).toolUI.getManifest === 'function' &&\n typeof (obj as { toolUI: { detectUIType?: unknown } }).toolUI.detectUIType === 'function'\n );\n };\n\n if (!isValidScope(this.scope)) {\n this.logger.warn(`parseTools: toolUI not available in scope for ${finalName}`);\n return item;\n }\n const scope = this.scope;\n\n // Get manifest and detect UI type with error handling\n let manifest;\n let detectedType: string;\n try {\n manifest = scope.toolUI.getManifest(finalName);\n detectedType = scope.toolUI.detectUIType(uiConfig.template);\n } catch (error) {\n this.logger.warn(`parseTools: failed to access toolUI for ${finalName}`, error);\n return item;\n }\n\n // Use centralized type guard from @frontmcp/ui/types\n const uiType: UIType = manifest?.uiType ?? (isUIType(detectedType) ? detectedType : 'auto');\n\n // Build meta keys based on platform type:\n // - OpenAI: openai/* keys only (ChatGPT proprietary format)\n // - ext-apps: ui/* keys only per SEP-1865 MCP Apps specification\n // - Other platforms: frontmcp/* keys + ui/* for compatibility\n const meta: Record<string, unknown> = {};\n const isExtApps = platformType === 'ext-apps';\n const widgetUri = `ui://widget/${encodeURIComponent(finalName)}.html`;\n\n if (isOpenAIPlatform) {\n // OpenAI-specific meta keys for ChatGPT widget discovery\n // ChatGPT only understands openai/* keys - don't mix with ui/* keys\n meta['openai/outputTemplate'] = widgetUri;\n meta['openai/resultCanProduceWidget'] = true;\n meta['openai/widgetAccessible'] = uiConfig.widgetAccessible ?? false;\n\n // Add invocation status if configured\n if (uiConfig.invocationStatus?.invoking) {\n meta['openai/toolInvocation/invoking'] = uiConfig.invocationStatus.invoking;\n }\n if (uiConfig.invocationStatus?.invoked) {\n meta['openai/toolInvocation/invoked'] = uiConfig.invocationStatus.invoked;\n }\n } else if (isExtApps) {\n // SEP-1865 MCP Apps specification uses ui/* keys only\n meta['ui/resourceUri'] = widgetUri;\n meta['ui/mimeType'] = 'text/html+mcp';\n\n // Add manifest info for ext-apps (uses ui/* namespace)\n meta['ui/cdn'] = buildCDNInfoForUIType(uiType);\n if (manifest) {\n meta['ui/type'] = manifest.uiType;\n meta['ui/manifestUri'] = `ui://widget/${encodeURIComponent(finalName)}/manifest.json`;\n meta['ui/displayMode'] = manifest.displayMode;\n meta['ui/bundlingMode'] = manifest.bundlingMode;\n } else if (uiConfig.template) {\n meta['ui/type'] = uiType;\n }\n } else {\n // FrontMCP meta keys for other platforms (Claude, Cursor, etc.)\n meta['frontmcp/outputTemplate'] = widgetUri;\n meta['frontmcp/resultCanProduceWidget'] = true;\n meta['frontmcp/widgetAccessible'] = uiConfig.widgetAccessible ?? false;\n\n // Add invocation status if configured\n if (uiConfig.invocationStatus?.invoking) {\n meta['frontmcp/toolInvocation/invoking'] = uiConfig.invocationStatus.invoking;\n }\n if (uiConfig.invocationStatus?.invoked) {\n meta['frontmcp/toolInvocation/invoked'] = uiConfig.invocationStatus.invoked;\n }\n\n // Add ui/* keys for compatibility with generic MCP clients\n meta['ui/cdn'] = buildCDNInfoForUIType(uiType);\n if (manifest) {\n meta['ui/type'] = manifest.uiType;\n meta['ui/manifestUri'] = `ui://widget/${encodeURIComponent(finalName)}/manifest.json`;\n meta['ui/displayMode'] = manifest.displayMode;\n meta['ui/bundlingMode'] = manifest.bundlingMode;\n } else if (uiConfig.template) {\n meta['ui/type'] = uiType;\n }\n }\n\n item._meta = meta;\n }\n\n return item;\n });\n\n const preview = this.sample(tools.map((t) => t.name)).join(', ');\n const extra = tools.length > 5 ? `, +${tools.length - 5} more` : '';\n this.logger.info(`parseTools: prepared ${tools.length} tool descriptor(s): ${preview}${extra}`);\n\n this.respond({ tools });\n this.logger.info('parseTools: response sent');\n this.logger.verbose('parseTools:done');\n } catch (error) {\n if (error instanceof FlowControl) throw error;\n this.logger.error('parseTools: failed to parse tools', error);\n throw error;\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tools-list.flow.js","sourceRoot":"","sources":["../../../../src/tool/flows/tools-list.flow.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,yCAA6G;AAC7G,4BAA0B;AAC1B,6BAAwB;AACxB,+BAAsC;AACtC,iEAAmG;AACnG,yCAAqE;AACrE,8BAAoC;AACpC,kDAA4E;AAC5E,kDAAkD;AAKlD,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3B,OAAO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,EAAE,CAAC,CAAC;YACxB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;YAC9C,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;QACzC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,oBAAW;gBAAE,MAAM,KAAK,CAAC;YAC9C,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,mCAAmC,EAAE,KAAK,CAAC,CAAC;YAC9D,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF,CAAA;AArRO;IADL,KAAK,CAAC,YAAY,CAAC;;;;+CA0CnB;AAGK;IADL,KAAK,CAAC,WAAW,CAAC;;;;8CA4BlB;AAGK;IADL,KAAK,CAAC,kBAAkB,CAAC;;;;qDAmCzB;AAGK;IADL,KAAK,CAAC,YAAY,CAAC;;;;+CAsKnB;AA5RkB,aAAa;IAPjC,IAAA,aAAI,EAAC;QACJ,IAAI;QACJ,IAAI;QACJ,WAAW;QACX,YAAY;QACZ,MAAM,EAAE,YAAY;KACrB,CAAC;GACmB,aAAa,CA6RjC;kBA7RoB,aAAa","sourcesContent":["// tools/flows/list-tools.flow.ts\nimport { Flow, FlowBase, FlowControl, FlowHooksOf, FlowPlan, FlowRunOptions, ToolEntry } from '../../common';\nimport 'reflect-metadata';\nimport { z } from 'zod';\nimport { toJSONSchema } from 'zod/v4';\nimport { ListToolsRequestSchema, ListToolsResultSchema } from '@modelcontextprotocol/sdk/types.js';\nimport { InvalidMethodError, InvalidInputError } from '../../errors';\nimport { hasUIConfig } from '../ui';\nimport { buildCDNInfoForUIType, type UIType } from '@frontmcp/uipack/build';\nimport { isUIType } from '@frontmcp/uipack/types';\nimport type { AIPlatformType } from '@frontmcp/uipack/adapters';\nimport type { Scope } from '../../scope/scope.instance';\nimport type { AuthInfo } from '@modelcontextprotocol/sdk/server/auth/types.js';\n\nconst inputSchema = z.object({\n request: ListToolsRequestSchema,\n ctx: z.unknown(),\n});\n\nconst outputSchema = ListToolsResultSchema;\n\nconst stateSchema = z.object({\n cursor: z.string().optional(),\n // z.any() used because AuthInfo is an external type from @modelcontextprotocol/sdk that varies by SDK version\n authInfo: z.any().optional() as z.ZodType<AuthInfo>,\n platformType: z.string().optional() as z.ZodType<AIPlatformType | undefined>,\n tools: z.array(\n z.object({\n appName: z.string(),\n tool: z.instanceof(ToolEntry),\n }),\n ),\n resolvedTools: z.array(\n z.object({\n appName: z.string(),\n tool: z.instanceof(ToolEntry),\n finalName: z.string(),\n }),\n ),\n});\n\ntype ResponseToolItem = z.infer<typeof outputSchema>['tools'][number];\n\n// TODO: add support for pagination\n// TODO: add support for session based tools\nconst plan = {\n pre: ['parseInput'],\n execute: ['findTools', 'resolveConflicts'],\n post: ['parseTools'],\n} as const satisfies FlowPlan<string>;\n\ndeclare global {\n interface ExtendFlows {\n 'tools:list-tools': FlowRunOptions<\n ToolsListFlow,\n typeof plan,\n typeof inputSchema,\n typeof outputSchema,\n typeof stateSchema\n >;\n }\n}\n\nconst name = 'tools:list-tools' as const;\nconst { Stage } = FlowHooksOf('tools:list-tools');\n\n@Flow({\n name,\n plan,\n inputSchema,\n outputSchema,\n access: 'authorized',\n})\nexport default class ToolsListFlow extends FlowBase<typeof name> {\n logger = this.scopeLogger.child('ToolsListFlow');\n\n private sample<T>(arr: T[], n = 5): T[] {\n return arr.slice(0, n);\n }\n\n @Stage('parseInput')\n async parseInput() {\n this.logger.verbose('parseInput:start');\n\n let method!: string;\n let params: any;\n let ctx: { authInfo?: AuthInfo } | undefined;\n try {\n const inputData = inputSchema.parse(this.rawInput);\n method = inputData.request.method;\n params = inputData.request.params;\n ctx = inputData.ctx as { authInfo?: AuthInfo } | undefined;\n } catch (e) {\n throw new InvalidInputError('Invalid request format', e instanceof z.ZodError ? e.issues : undefined);\n }\n\n if (method !== 'tools/list') {\n this.logger.warn(`parseInput: invalid method \"${method}\"`);\n throw new InvalidMethodError(method, 'tools/list');\n }\n\n // Extract authInfo and detect platform type\n const authInfo = ctx?.authInfo;\n const sessionId = authInfo?.sessionId;\n\n // Cast scope to access notifications service for platform detection\n const scope = this.scope as Scope;\n\n // Get platform type: first check sessionIdPayload (detected from user-agent),\n // then fall back to notification service (detected from MCP clientInfo),\n // finally default to 'unknown'\n const platformType: AIPlatformType =\n authInfo?.sessionIdPayload?.platformType ??\n (sessionId ? scope.notifications?.getPlatformType(sessionId) : undefined) ??\n 'unknown';\n\n this.logger.verbose(`parseInput: detected platform=${platformType}`);\n\n const cursor = params?.cursor;\n if (cursor) this.logger.verbose(`parseInput: cursor=${cursor}`);\n this.state.set({ cursor, authInfo, platformType });\n this.logger.verbose('parseInput:done');\n }\n\n @Stage('findTools')\n async findTools() {\n this.logger.info('findTools:start');\n\n try {\n const apps = this.scope.apps.getApps();\n this.logger.info(`findTools: discovered ${apps.length} app(s)`);\n\n const tools: Array<{ appName: string; tool: ToolEntry }> = [];\n\n const scopeTools = this.scope.tools.getTools();\n this.logger.verbose(`findTools: scope tools=${scopeTools.length}`);\n\n for (const tool of scopeTools) {\n tools.push({ appName: tool.owner.id, tool });\n }\n\n this.logger.info(`findTools: total tools collected=${tools.length}`);\n if (tools.length === 0) {\n this.logger.warn('findTools: no tools found across apps');\n }\n\n this.state.set('tools', tools);\n this.logger.verbose('findTools:done');\n } catch (error) {\n this.logger.error('findTools: failed to collect tools', error);\n throw error;\n }\n }\n\n @Stage('resolveConflicts')\n async resolveConflicts() {\n this.logger.verbose('resolveConflicts:start');\n\n try {\n const found = this.state.required.tools;\n\n const counts = new Map<string, number>();\n for (const { tool } of found) {\n const baseName = tool.metadata.id ?? tool.metadata.name;\n counts.set(baseName, (counts.get(baseName) ?? 0) + 1);\n }\n\n const conflicts = new Set<string>([...counts.entries()].filter(([, n]) => n > 1).map(([k]) => k));\n\n if (conflicts.size > 0) {\n const preview = this.sample(Array.from(conflicts)).join(', ');\n const extra = conflicts.size > 5 ? `, +${conflicts.size - 5} more` : '';\n this.logger.warn(`resolveConflicts: ${conflicts.size} name conflict(s) detected: ${preview}${extra}`);\n } else {\n this.logger.info('resolveConflicts: no name conflicts detected');\n }\n\n const resolved = found.map(({ appName, tool }) => {\n const baseName = tool.metadata.id ?? tool.metadata.name;\n const finalName = conflicts.has(baseName) ? `${appName}:${baseName}` : baseName;\n return { appName, tool, finalName };\n });\n\n this.state.set('resolvedTools', resolved);\n this.logger.verbose('resolveConflicts:done');\n } catch (error) {\n this.logger.error('resolveConflicts: failed to resolve conflicts', error);\n throw error;\n }\n }\n\n @Stage('parseTools')\n async parseTools() {\n this.logger.verbose('parseTools:start');\n\n try {\n const resolved = this.state.required.resolvedTools;\n const platformType = this.state.platformType ?? 'unknown';\n\n // Only OpenAI ChatGPT uses openai/* meta keys\n // ext-apps (SEP-1865) uses ui/* keys per the MCP Apps specification\n const isOpenAIPlatform = platformType === 'openai';\n\n const tools: ResponseToolItem[] = resolved.map(({ finalName, tool }) => {\n // Get the input schema - prefer rawInputSchema (JSON Schema), then convert from tool.inputSchema\n let inputSchema: any;\n if (tool.rawInputSchema) {\n // Already converted to JSON Schema\n inputSchema = tool.rawInputSchema;\n } else if (tool.inputSchema && Object.keys(tool.inputSchema).length > 0) {\n // tool.inputSchema is a ZodRawShape (extracted .shape from ZodObject in ToolInstance constructor)\n // Convert to JSON Schema\n try {\n // as any used here to prevent hard ts-check on tool input that is redundant\n // and just slow down the build process. types here are unnecessary.\n inputSchema = toJSONSchema(z.object(tool.inputSchema));\n } catch (e) {\n this.logger.warn(`Failed to convert inputSchema for tool ${finalName}:`, e);\n inputSchema = { type: 'object', properties: {} };\n }\n } else {\n // No schema defined - use empty object schema\n inputSchema = { type: 'object', properties: {} };\n }\n\n const item: ResponseToolItem = {\n name: finalName,\n title: tool.metadata.name,\n description: tool.metadata.description,\n annotations: tool.metadata.annotations,\n inputSchema,\n };\n\n // Add _meta for tools with UI configuration\n // OpenAI platforms use openai/* keys, other platforms use frontmcp/* keys\n if (hasUIConfig(tool.metadata)) {\n const uiConfig = tool.metadata.ui;\n if (!uiConfig) {\n // This should never happen if hasUIConfig returned true\n return item;\n }\n\n // Get manifest info from registry (if available)\n // Type guard: verify scope has toolUI with required methods before accessing\n const isValidScope = (obj: unknown): obj is Scope => {\n return (\n obj !== null &&\n typeof obj === 'object' &&\n 'toolUI' in obj &&\n typeof (obj as { toolUI?: unknown }).toolUI === 'object' &&\n (obj as { toolUI?: unknown }).toolUI !== null &&\n typeof (obj as { toolUI: { getManifest?: unknown } }).toolUI.getManifest === 'function' &&\n typeof (obj as { toolUI: { detectUIType?: unknown } }).toolUI.detectUIType === 'function'\n );\n };\n\n if (!isValidScope(this.scope)) {\n this.logger.warn(`parseTools: toolUI not available in scope for ${finalName}`);\n return item;\n }\n const scope = this.scope;\n\n // Get manifest and detect UI type with error handling\n let manifest;\n let detectedType: string;\n try {\n manifest = scope.toolUI.getManifest(finalName);\n detectedType = scope.toolUI.detectUIType(uiConfig.template);\n } catch (error) {\n this.logger.warn(`parseTools: failed to access toolUI for ${finalName}`, error);\n return item;\n }\n\n // Use centralized type guard from @frontmcp/ui/types\n const uiType: UIType = manifest?.uiType ?? (isUIType(detectedType) ? detectedType : 'auto');\n\n // Build meta keys based on platform type:\n // - OpenAI: openai/* keys only (ChatGPT proprietary format)\n // - ext-apps: ui/* keys only per SEP-1865 MCP Apps specification\n // - Other platforms: frontmcp/* keys + ui/* for compatibility\n const meta: Record<string, unknown> = {};\n const isExtApps = platformType === 'ext-apps';\n const widgetUri = `ui://widget/${encodeURIComponent(finalName)}.html`;\n\n if (isOpenAIPlatform) {\n // OpenAI-specific meta keys for ChatGPT widget discovery\n // ChatGPT only understands openai/* keys - don't mix with ui/* keys\n meta['openai/outputTemplate'] = widgetUri;\n meta['openai/resultCanProduceWidget'] = true;\n meta['openai/widgetAccessible'] = uiConfig.widgetAccessible ?? false;\n\n // Add invocation status if configured\n if (uiConfig.invocationStatus?.invoking) {\n meta['openai/toolInvocation/invoking'] = uiConfig.invocationStatus.invoking;\n }\n if (uiConfig.invocationStatus?.invoked) {\n meta['openai/toolInvocation/invoked'] = uiConfig.invocationStatus.invoked;\n }\n } else if (isExtApps) {\n // SEP-1865 MCP Apps specification uses ui/* keys only\n meta['ui/resourceUri'] = widgetUri;\n meta['ui/mimeType'] = 'text/html+mcp';\n\n // Add manifest info for ext-apps (uses ui/* namespace)\n meta['ui/cdn'] = buildCDNInfoForUIType(uiType);\n if (manifest) {\n meta['ui/type'] = manifest.uiType;\n meta['ui/manifestUri'] = `ui://widget/${encodeURIComponent(finalName)}/manifest.json`;\n meta['ui/displayMode'] = manifest.displayMode;\n meta['ui/bundlingMode'] = manifest.bundlingMode;\n } else if (uiConfig.template) {\n meta['ui/type'] = uiType;\n }\n } else {\n // FrontMCP meta keys for other platforms (Claude, Cursor, etc.)\n meta['frontmcp/outputTemplate'] = widgetUri;\n meta['frontmcp/resultCanProduceWidget'] = true;\n meta['frontmcp/widgetAccessible'] = uiConfig.widgetAccessible ?? false;\n\n // Add invocation status if configured\n if (uiConfig.invocationStatus?.invoking) {\n meta['frontmcp/toolInvocation/invoking'] = uiConfig.invocationStatus.invoking;\n }\n if (uiConfig.invocationStatus?.invoked) {\n meta['frontmcp/toolInvocation/invoked'] = uiConfig.invocationStatus.invoked;\n }\n\n // Add ui/* keys for compatibility with generic MCP clients\n meta['ui/cdn'] = buildCDNInfoForUIType(uiType);\n if (manifest) {\n meta['ui/type'] = manifest.uiType;\n meta['ui/manifestUri'] = `ui://widget/${encodeURIComponent(finalName)}/manifest.json`;\n meta['ui/displayMode'] = manifest.displayMode;\n meta['ui/bundlingMode'] = manifest.bundlingMode;\n } else if (uiConfig.template) {\n meta['ui/type'] = uiType;\n }\n }\n\n item._meta = meta;\n }\n\n return item;\n });\n\n const preview = this.sample(tools.map((t) => t.name)).join(', ');\n const extra = tools.length > 5 ? `, +${tools.length - 5} more` : '';\n this.logger.info(`parseTools: prepared ${tools.length} tool descriptor(s): ${preview}${extra}`);\n\n this.respond({ tools });\n this.logger.info('parseTools: response sent');\n this.logger.verbose('parseTools:done');\n } catch (error) {\n if (error instanceof FlowControl) throw error;\n this.logger.error('parseTools: failed to parse tools', error);\n throw error;\n }\n }\n}\n"]}
|
package/src/tool/ui/index.d.ts
CHANGED
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
* - **static**: Static widget is pre-compiled at startup, client fetches via resources/read
|
|
10
10
|
* - **hybrid**: Shell (React + renderer) cached at startup, component + data in response
|
|
11
11
|
*
|
|
12
|
-
* NOTE: Core Tool UI functionality
|
|
13
|
-
* This module re-exports from @frontmcp/
|
|
12
|
+
* NOTE: Core Tool UI functionality is in @frontmcp/uipack/registry for standalone usage.
|
|
13
|
+
* This module re-exports from @frontmcp/uipack for backwards compatibility.
|
|
14
14
|
*/
|
|
15
|
-
export { ToolUIRegistry, renderToolTemplateAsync, renderToolTemplate, hasUIConfig, isReactComponent, containsMdxSyntax, UI_RESOURCE_SCHEME, isUIResourceUri, isStaticWidgetUri, parseWidgetUri, buildStaticWidgetUri, getUIResourceMimeType, } from '@frontmcp/
|
|
16
|
-
export type { RenderOptions, UIRenderResult, CompileStaticWidgetOptions, HybridComponentPayload, BuildHybridComponentPayloadOptions, RenderTemplateOptions, ParsedWidgetUri, } from '@frontmcp/
|
|
15
|
+
export { ToolUIRegistry, renderToolTemplateAsync, renderToolTemplate, hasUIConfig, isReactComponent, containsMdxSyntax, UI_RESOURCE_SCHEME, isUIResourceUri, isStaticWidgetUri, parseWidgetUri, buildStaticWidgetUri, getUIResourceMimeType, } from '@frontmcp/uipack/registry';
|
|
16
|
+
export type { RenderOptions, UIRenderResult, CompileStaticWidgetOptions, HybridComponentPayload, BuildHybridComponentPayloadOptions, RenderTemplateOptions, ParsedWidgetUri, } from '@frontmcp/uipack/registry';
|
|
17
17
|
export { buildUIMeta } from './platform-adapters';
|
|
18
18
|
export type { UIMetadata, BuildUIMetaOptions } from './platform-adapters';
|
|
19
19
|
export { escapeHtml, formatDate, formatCurrency, uniqueId, jsonEmbed, createTemplateHelpers, resetIdCounter, } from './template-helpers';
|
package/src/tool/ui/index.js
CHANGED
|
@@ -10,15 +10,15 @@
|
|
|
10
10
|
* - **static**: Static widget is pre-compiled at startup, client fetches via resources/read
|
|
11
11
|
* - **hybrid**: Shell (React + renderer) cached at startup, component + data in response
|
|
12
12
|
*
|
|
13
|
-
* NOTE: Core Tool UI functionality
|
|
14
|
-
* This module re-exports from @frontmcp/
|
|
13
|
+
* NOTE: Core Tool UI functionality is in @frontmcp/uipack/registry for standalone usage.
|
|
14
|
+
* This module re-exports from @frontmcp/uipack for backwards compatibility.
|
|
15
15
|
*/
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.StaticWidgetResourceTemplate = exports.createUIResourceHandler = exports.handleUIResourceRead = exports.resetIdCounter = exports.createTemplateHelpers = exports.jsonEmbed = exports.uniqueId = exports.formatCurrency = exports.formatDate = exports.escapeHtml = exports.buildUIMeta = exports.getUIResourceMimeType = exports.buildStaticWidgetUri = exports.parseWidgetUri = exports.isStaticWidgetUri = exports.isUIResourceUri = exports.UI_RESOURCE_SCHEME = exports.containsMdxSyntax = exports.isReactComponent = exports.hasUIConfig = exports.renderToolTemplate = exports.renderToolTemplateAsync = exports.ToolUIRegistry = void 0;
|
|
18
18
|
// ============================================
|
|
19
|
-
// Core Registry (from @frontmcp/
|
|
19
|
+
// Core Registry (from @frontmcp/uipack/registry)
|
|
20
20
|
// ============================================
|
|
21
|
-
var registry_1 = require("@frontmcp/
|
|
21
|
+
var registry_1 = require("@frontmcp/uipack/registry");
|
|
22
22
|
// Registry
|
|
23
23
|
Object.defineProperty(exports, "ToolUIRegistry", { enumerable: true, get: function () { return registry_1.ToolUIRegistry; } });
|
|
24
24
|
// Template rendering
|
package/src/tool/ui/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/tool/ui/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AAEH,+CAA+C;AAC/C,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/tool/ui/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AAEH,+CAA+C;AAC/C,iDAAiD;AACjD,+CAA+C;AAC/C,sDAgBmC;AAfjC,WAAW;AACX,0GAAA,cAAc,OAAA;AACd,qBAAqB;AACrB,mHAAA,uBAAuB,OAAA;AACvB,8GAAA,kBAAkB,OAAA;AAClB,uGAAA,WAAW,OAAA;AACX,4GAAA,gBAAgB,OAAA;AAChB,6GAAA,iBAAiB,OAAA;AACjB,gBAAgB;AAChB,8GAAA,kBAAkB,OAAA;AAClB,2GAAA,eAAe,OAAA;AACf,6GAAA,iBAAiB,OAAA;AACjB,0GAAA,cAAc,OAAA;AACd,gHAAA,oBAAoB,OAAA;AACpB,iHAAA,qBAAqB,OAAA;AAgBvB,+CAA+C;AAC/C,iDAAiD;AACjD,+CAA+C;AAC/C,yDAAkD;AAAzC,gHAAA,WAAW,OAAA;AAGpB,+CAA+C;AAC/C,+CAA+C;AAC/C,+CAA+C;AAC/C,uDAQ4B;AAP1B,8GAAA,UAAU,OAAA;AACV,8GAAA,UAAU,OAAA;AACV,kHAAA,cAAc,OAAA;AACd,4GAAA,QAAQ,OAAA;AACR,6GAAA,SAAS,OAAA;AACT,yHAAA,qBAAqB,OAAA;AACrB,kHAAA,cAAc,OAAA;AAGhB,+CAA+C;AAC/C,iCAAiC;AACjC,+CAA+C;AAC/C,yEAAyE;AACzE,6DAAsF;AAA7E,2HAAA,oBAAoB,OAAA;AAAE,8HAAA,uBAAuB,OAAA;AAGtD,uDAAuD;AACvD,+DAAsE;AAA7D,oIAAA,4BAA4B,OAAA","sourcesContent":["/**\n * Tool UI Module\n *\n * Provides UI template rendering and platform-specific metadata generation\n * for MCP tool responses.\n *\n * Three serving modes:\n * - **inline**: HTML is rendered per-request and embedded in _meta['ui/html']\n * - **static**: Static widget is pre-compiled at startup, client fetches via resources/read\n * - **hybrid**: Shell (React + renderer) cached at startup, component + data in response\n *\n * NOTE: Core Tool UI functionality is in @frontmcp/uipack/registry for standalone usage.\n * This module re-exports from @frontmcp/uipack for backwards compatibility.\n */\n\n// ============================================\n// Core Registry (from @frontmcp/uipack/registry)\n// ============================================\nexport {\n // Registry\n ToolUIRegistry,\n // Template rendering\n renderToolTemplateAsync,\n renderToolTemplate,\n hasUIConfig,\n isReactComponent,\n containsMdxSyntax,\n // URI utilities\n UI_RESOURCE_SCHEME,\n isUIResourceUri,\n isStaticWidgetUri,\n parseWidgetUri,\n buildStaticWidgetUri,\n getUIResourceMimeType,\n} from '@frontmcp/uipack/registry';\n\nexport type {\n // Registry types\n RenderOptions,\n UIRenderResult,\n CompileStaticWidgetOptions,\n HybridComponentPayload,\n BuildHybridComponentPayloadOptions,\n // Template types\n RenderTemplateOptions,\n // URI types\n ParsedWidgetUri,\n} from '@frontmcp/uipack/registry';\n\n// ============================================\n// Platform Adapters (from @frontmcp/ui/adapters)\n// ============================================\nexport { buildUIMeta } from './platform-adapters';\nexport type { UIMetadata, BuildUIMetaOptions } from './platform-adapters';\n\n// ============================================\n// Template Helpers (from @frontmcp/ui/runtime)\n// ============================================\nexport {\n escapeHtml,\n formatDate,\n formatCurrency,\n uniqueId,\n jsonEmbed,\n createTemplateHelpers,\n resetIdCounter,\n} from './template-helpers';\n\n// ============================================\n// SDK-Specific (MCP Integration)\n// ============================================\n// UI Resource Handler - SDK-specific functions for MCP resource handling\nexport { handleUIResourceRead, createUIResourceHandler } from './ui-resource.handler';\nexport type { UIResourceHandleResult, UIResourceHandlerOptions, HandleUIResourceOptions } from './ui-resource.handler';\n\n// UI Resource Templates (for capability advertisement)\nexport { StaticWidgetResourceTemplate } from './ui-resource-template';\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Platform Adapters
|
|
3
3
|
*
|
|
4
|
-
* Re-exports platform adapter functions from @frontmcp/
|
|
4
|
+
* Re-exports platform adapter functions from @frontmcp/uipack/adapters for SDK consumers.
|
|
5
5
|
* This provides a single source of truth for platform-specific metadata building
|
|
6
6
|
* while maintaining backwards compatibility.
|
|
7
7
|
*
|
|
8
8
|
* @see {@link https://docs.agentfront.dev/docs/servers/tools#tool-ui | Tool UI Documentation}
|
|
9
9
|
*/
|
|
10
|
-
export { type AIPlatformType, type UIMetadata, type BuildUIMetaOptions, type BuildToolDiscoveryMetaOptions, buildUIMeta, buildToolDiscoveryMeta, buildOpenAICSP, } from '@frontmcp/
|
|
10
|
+
export { type AIPlatformType, type UIMetadata, type BuildUIMetaOptions, type BuildToolDiscoveryMetaOptions, buildUIMeta, buildToolDiscoveryMeta, buildOpenAICSP, } from '@frontmcp/uipack/adapters';
|