@frontmcp/testing 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/auth/mock-api-server.d.ts +99 -0
- package/src/auth/mock-api-server.js +200 -0
- package/src/auth/mock-api-server.js.map +1 -0
- package/src/auth/mock-oauth-server.d.ts +85 -0
- package/src/auth/mock-oauth-server.js +253 -0
- package/src/auth/mock-oauth-server.js.map +1 -0
- package/src/client/mcp-test-client.builder.d.ts +43 -1
- package/src/client/mcp-test-client.builder.js +52 -0
- package/src/client/mcp-test-client.builder.js.map +1 -1
- package/src/client/mcp-test-client.js +22 -14
- package/src/client/mcp-test-client.js.map +1 -1
- package/src/client/mcp-test-client.types.d.ts +67 -6
- package/src/client/mcp-test-client.types.js +9 -0
- package/src/client/mcp-test-client.types.js.map +1 -1
- package/src/example-tools/index.d.ts +19 -0
- package/src/example-tools/index.js +40 -0
- package/src/example-tools/index.js.map +1 -0
- package/src/example-tools/tool-configs.d.ts +170 -0
- package/src/example-tools/tool-configs.js +222 -0
- package/src/example-tools/tool-configs.js.map +1 -0
- package/src/expect.d.ts +6 -5
- package/src/expect.js.map +1 -1
- package/src/fixtures/fixture-types.d.ts +19 -0
- package/src/fixtures/fixture-types.js.map +1 -1
- package/src/fixtures/test-fixture.d.ts +3 -1
- package/src/fixtures/test-fixture.js +35 -4
- package/src/fixtures/test-fixture.js.map +1 -1
- package/src/index.d.ts +7 -0
- package/src/index.js +40 -1
- package/src/index.js.map +1 -1
- package/src/matchers/matcher-types.js.map +1 -1
- package/src/matchers/mcp-matchers.d.ts +7 -0
- package/src/matchers/mcp-matchers.js +8 -4
- package/src/matchers/mcp-matchers.js.map +1 -1
- package/src/platform/index.d.ts +28 -0
- package/src/platform/index.js +47 -0
- package/src/platform/index.js.map +1 -0
- package/src/platform/platform-client-info.d.ts +97 -0
- package/src/platform/platform-client-info.js +155 -0
- package/src/platform/platform-client-info.js.map +1 -0
- package/src/platform/platform-types.d.ts +72 -0
- package/src/platform/platform-types.js +110 -0
- package/src/platform/platform-types.js.map +1 -0
- package/src/server/test-server.d.ts +4 -0
- package/src/server/test-server.js +58 -3
- package/src/server/test-server.js.map +1 -1
- package/src/transport/streamable-http.transport.js +6 -0
- package/src/transport/streamable-http.transport.js.map +1 -1
- package/src/transport/transport.interface.d.ts +3 -0
- package/src/transport/transport.interface.js.map +1 -1
- package/src/ui/ui-assertions.d.ts +59 -0
- package/src/ui/ui-assertions.js +152 -0
- package/src/ui/ui-assertions.js.map +1 -1
- package/src/ui/ui-matchers.d.ts +8 -0
- package/src/ui/ui-matchers.js +218 -0
- package/src/ui/ui-matchers.js.map +1 -1
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* @file mcp-test-client.types.ts
|
|
3
3
|
* @description Type definitions for the MCP Test Client
|
|
4
4
|
*/
|
|
5
|
-
import type { InitializeResult, ListToolsResult, CallToolResult, ListResourcesResult, ReadResourceResult, ListResourceTemplatesResult, ListPromptsResult, GetPromptResult, Tool, Resource, ResourceTemplate, Prompt } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
+
import type { InitializeResult, ListToolsResult, CallToolResult, ListResourcesResult, ReadResourceResult, ListResourceTemplatesResult, ListPromptsResult, GetPromptResult, Tool, Resource, ResourceTemplate, Prompt, Implementation } from '@modelcontextprotocol/sdk/types.js';
|
|
6
|
+
import type { TestPlatformType } from '../platform/platform-types';
|
|
6
7
|
/**
|
|
7
8
|
* Simplified JSON-RPC request type for testing
|
|
8
9
|
*/
|
|
@@ -33,6 +34,45 @@ export interface TestAuthConfig {
|
|
|
33
34
|
/** Additional headers to include in requests */
|
|
34
35
|
headers?: Record<string, string>;
|
|
35
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Client information sent during MCP initialization.
|
|
39
|
+
* Re-exported from MCP SDK's Implementation type.
|
|
40
|
+
* Also used for User-Agent header to enable platform detection.
|
|
41
|
+
*
|
|
42
|
+
* Includes: name, version, title?, description?, icons?
|
|
43
|
+
*/
|
|
44
|
+
export type ClientInfo = Implementation;
|
|
45
|
+
/**
|
|
46
|
+
* MCP Apps extension key used for ext-apps platform detection.
|
|
47
|
+
* When a client sends this capability, the server detects it as an ext-apps client.
|
|
48
|
+
*/
|
|
49
|
+
export declare const MCP_APPS_EXTENSION_KEY: "io.modelcontextprotocol/ui";
|
|
50
|
+
/**
|
|
51
|
+
* MCP Apps extension capability configuration.
|
|
52
|
+
*/
|
|
53
|
+
export interface McpAppsExtension {
|
|
54
|
+
/** Supported MIME types (e.g., ['text/html+mcp']) */
|
|
55
|
+
mimeTypes?: string[];
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Experimental capabilities for MCP clients.
|
|
59
|
+
*/
|
|
60
|
+
export interface ExperimentalCapabilities {
|
|
61
|
+
/** MCP Apps (ext-apps) extension capability */
|
|
62
|
+
[MCP_APPS_EXTENSION_KEY]?: McpAppsExtension;
|
|
63
|
+
/** Other experimental capabilities */
|
|
64
|
+
[key: string]: unknown;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Client capabilities sent during MCP initialization.
|
|
68
|
+
* These capabilities enable platform-specific detection and features.
|
|
69
|
+
*/
|
|
70
|
+
export interface TestClientCapabilities {
|
|
71
|
+
/** Sampling capabilities */
|
|
72
|
+
sampling?: Record<string, unknown>;
|
|
73
|
+
/** Experimental capabilities including MCP Apps extension */
|
|
74
|
+
experimental?: ExperimentalCapabilities;
|
|
75
|
+
}
|
|
36
76
|
export interface McpTestClientConfig {
|
|
37
77
|
/** Base URL of the MCP server */
|
|
38
78
|
baseUrl: string;
|
|
@@ -52,11 +92,32 @@ export interface McpTestClientConfig {
|
|
|
52
92
|
debug?: boolean;
|
|
53
93
|
/** MCP protocol version to request (default: '2024-11-05') */
|
|
54
94
|
protocolVersion?: string;
|
|
55
|
-
/** Client info to send during initialization */
|
|
56
|
-
clientInfo?:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
95
|
+
/** Client info to send during initialization and for platform detection */
|
|
96
|
+
clientInfo?: ClientInfo;
|
|
97
|
+
/**
|
|
98
|
+
* Client capabilities sent during MCP initialization.
|
|
99
|
+
* Use this to enable platform-specific detection via capability extensions.
|
|
100
|
+
*
|
|
101
|
+
* Example for ext-apps:
|
|
102
|
+
* ```typescript
|
|
103
|
+
* capabilities: {
|
|
104
|
+
* experimental: {
|
|
105
|
+
* 'io.modelcontextprotocol/ui': { mimeTypes: ['text/html+mcp'] }
|
|
106
|
+
* }
|
|
107
|
+
* }
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
capabilities?: TestClientCapabilities;
|
|
111
|
+
/**
|
|
112
|
+
* Platform type for testing platform-specific meta keys.
|
|
113
|
+
* When set, automatically configures clientInfo and capabilities for platform detection.
|
|
114
|
+
*
|
|
115
|
+
* Platform-specific behavior:
|
|
116
|
+
* - `openai`: Uses openai/* meta keys
|
|
117
|
+
* - `ext-apps`: Uses ui/* meta keys per SEP-1865, sets io.modelcontextprotocol/ui capability
|
|
118
|
+
* - Others: Uses frontmcp/* + ui/* keys for compatibility
|
|
119
|
+
*/
|
|
120
|
+
platform?: TestPlatformType;
|
|
60
121
|
}
|
|
61
122
|
export interface McpResponse<T> {
|
|
62
123
|
/** Whether the request succeeded */
|
|
@@ -4,4 +4,13 @@
|
|
|
4
4
|
* @description Type definitions for the MCP Test Client
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.MCP_APPS_EXTENSION_KEY = void 0;
|
|
8
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
9
|
+
// CLIENT CAPABILITIES
|
|
10
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
11
|
+
/**
|
|
12
|
+
* MCP Apps extension key used for ext-apps platform detection.
|
|
13
|
+
* When a client sends this capability, the server detects it as an ext-apps client.
|
|
14
|
+
*/
|
|
15
|
+
exports.MCP_APPS_EXTENSION_KEY = 'io.modelcontextprotocol/ui';
|
|
7
16
|
//# sourceMappingURL=mcp-test-client.types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-test-client.types.js","sourceRoot":"","sources":["../../../src/client/mcp-test-client.types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * @file mcp-test-client.types.ts\n * @description Type definitions for the MCP Test Client\n */\n\nimport type {\n InitializeResult,\n ListToolsResult,\n CallToolResult,\n ListResourcesResult,\n ReadResourceResult,\n ListResourceTemplatesResult,\n ListPromptsResult,\n GetPromptResult,\n Tool,\n Resource,\n ResourceTemplate,\n Prompt,\n} from '@modelcontextprotocol/sdk/types.js';\n\n// ═══════════════════════════════════════════════════════════════════\n// JSON-RPC TYPES (simplified for testing)\n// ═══════════════════════════════════════════════════════════════════\n\n/**\n * Simplified JSON-RPC request type for testing\n */\nexport interface JSONRPCRequest {\n jsonrpc: '2.0';\n id?: string | number;\n method: string;\n params?: Record<string, unknown>;\n}\n\n/**\n * Simplified JSON-RPC response type for testing\n */\nexport interface JSONRPCResponse {\n jsonrpc: '2.0';\n id: string | number | null;\n result?: unknown;\n error?: {\n code: number;\n message: string;\n data?: unknown;\n };\n}\n\n// ═══════════════════════════════════════════════════════════════════\n// TRANSPORT TYPES\n// ═══════════════════════════════════════════════════════════════════\n\nexport type TestTransportType = 'sse' | 'streamable-http';\n\nexport type TransportState = 'disconnected' | 'connecting' | 'connected' | 'error';\n\n// ═══════════════════════════════════════════════════════════════════\n// AUTH TYPES\n// ═══════════════════════════════════════════════════════════════════\n\nexport interface TestAuthConfig {\n /** Bearer token for authentication */\n token?: string;\n /** Additional headers to include in requests */\n headers?: Record<string, string>;\n}\n\n// ═══════════════════════════════════════════════════════════════════\n// CLIENT CONFIG\n// ═══════════════════════════════════════════════════════════════════\n\nexport interface McpTestClientConfig {\n /** Base URL of the MCP server */\n baseUrl: string;\n /** Transport type to use (default: 'streamable-http') */\n transport?: TestTransportType;\n /** Authentication configuration */\n auth?: TestAuthConfig;\n /**\n * Enable public mode - skip authentication entirely.\n * When true, no Authorization header is sent and anonymous token is not requested.\n * Use this for testing public/unauthenticated endpoints in CI/CD pipelines.\n */\n publicMode?: boolean;\n /** Request timeout in milliseconds (default: 30000) */\n timeout?: number;\n /** Enable debug logging (default: false) */\n debug?: boolean;\n /** MCP protocol version to request (default: '2024-11-05') */\n protocolVersion?: string;\n /** Client info to send during initialization */\n clientInfo?: {\n name: string;\n version: string;\n };\n}\n\n// ═══════════════════════════════════════════════════════════════════\n// RESPONSE TYPES\n// ═══════════════════════════════════════════════════════════════════\n\nexport interface McpResponse<T> {\n /** Whether the request succeeded */\n success: boolean;\n /** Response data (if successful) */\n data?: T;\n /** Error information (if failed) */\n error?: McpErrorInfo;\n /** Request duration in milliseconds */\n durationMs: number;\n /** Request ID used for this request */\n requestId: string | number;\n}\n\nexport interface McpErrorInfo {\n /** JSON-RPC error code */\n code: number;\n /** Error message */\n message: string;\n /** Additional error data */\n data?: unknown;\n}\n\n// ═══════════════════════════════════════════════════════════════════\n// TOOL RESULT WRAPPER\n// ═══════════════════════════════════════════════════════════════════\n\nexport interface ToolResultWrapper {\n /** Raw CallToolResult from MCP */\n raw: CallToolResult;\n /** Whether the tool call was successful (no isError flag) */\n isSuccess: boolean;\n /** Whether the tool call failed */\n isError: boolean;\n /** Error information if failed */\n error?: McpErrorInfo;\n /** Duration of the tool call in ms */\n durationMs: number;\n /**\n * Parse tool output as JSON\n *\n * For Tool UI responses: returns structuredContent (the typed output)\n * For regular responses: parses text content as JSON\n */\n json<T = unknown>(): T;\n /** Get first text content */\n text(): string | undefined;\n /** Check if response has text content */\n hasTextContent(): boolean;\n /** Check if response has image content */\n hasImageContent(): boolean;\n /** Check if response has resource content */\n hasResourceContent(): boolean;\n /** Check if response has Tool UI metadata (ui/html in _meta) */\n hasToolUI(): boolean;\n}\n\n// ═══════════════════════════════════════════════════════════════════\n// RESOURCE CONTENT WRAPPER\n// ═══════════════════════════════════════════════════════════════════\n\nexport interface ResourceContentWrapper {\n /** Raw ReadResourceResult from MCP */\n raw: ReadResourceResult;\n /** Whether the read was successful */\n isSuccess: boolean;\n /** Whether the read failed */\n isError: boolean;\n /** Error information if failed */\n error?: McpErrorInfo;\n /** Duration in ms */\n durationMs: number;\n /** Parse text content as JSON */\n json<T = unknown>(): T;\n /** Get text content */\n text(): string | undefined;\n /** Get MIME type */\n mimeType(): string | undefined;\n /** Check if has specific MIME type */\n hasMimeType(type: string): boolean;\n}\n\n// ═══════════════════════════════════════════════════════════════════\n// PROMPT RESULT WRAPPER\n// ═══════════════════════════════════════════════════════════════════\n\nexport interface PromptResultWrapper {\n /** Raw GetPromptResult from MCP */\n raw: GetPromptResult;\n /** Whether the get was successful */\n isSuccess: boolean;\n /** Whether the get failed */\n isError: boolean;\n /** Error information if failed */\n error?: McpErrorInfo;\n /** Duration in ms */\n durationMs: number;\n /** Messages in the prompt */\n messages: GetPromptResult['messages'];\n /** Description from prompt result */\n description?: string;\n}\n\n// ═══════════════════════════════════════════════════════════════════\n// LOGGING TYPES\n// ═══════════════════════════════════════════════════════════════════\n\nexport type LogLevel = 'debug' | 'info' | 'warn' | 'error';\n\nexport interface LogEntry {\n /** Log level */\n level: LogLevel;\n /** Log message */\n message: string;\n /** Timestamp */\n timestamp: Date;\n /** Additional data */\n data?: unknown;\n}\n\nexport interface RequestTrace {\n /** Request that was sent */\n request: {\n method: string;\n params?: unknown;\n id: string | number;\n };\n /** Response that was received */\n response: {\n result?: unknown;\n error?: McpErrorInfo;\n };\n /** Duration in milliseconds */\n durationMs: number;\n /** Timestamp of the request */\n timestamp: Date;\n}\n\n// ═══════════════════════════════════════════════════════════════════\n// NOTIFICATION TYPES\n// ═══════════════════════════════════════════════════════════════════\n\nexport interface NotificationEntry {\n /** Notification method */\n method: string;\n /** Notification params */\n params?: unknown;\n /** Timestamp received */\n timestamp: Date;\n}\n\nexport interface ProgressUpdate {\n /** Progress value (0-100 or custom) */\n progress: number;\n /** Total value */\n total?: number;\n /** Progress token */\n progressToken?: string | number;\n /** Timestamp */\n timestamp: Date;\n}\n\n// ═══════════════════════════════════════════════════════════════════\n// SESSION TYPES\n// ═══════════════════════════════════════════════════════════════════\n\nexport interface SessionInfo {\n /** Session ID */\n id: string;\n /** When the session was created */\n createdAt: Date;\n /** When the last request was made */\n lastActivityAt: Date;\n /** Number of requests made in this session */\n requestCount: number;\n}\n\n// ═══════════════════════════════════════════════════════════════════\n// AUTH STATE\n// ═══════════════════════════════════════════════════════════════════\n\nexport interface AuthState {\n /** Whether the user is anonymous (no token) */\n isAnonymous: boolean;\n /** Current token (if any) */\n token?: string;\n /** Scopes from the token */\n scopes: string[];\n /** User information from token */\n user?: {\n sub: string;\n email?: string;\n name?: string;\n };\n}\n\n// ═══════════════════════════════════════════════════════════════════\n// RE-EXPORTS FROM MCP SDK\n// ═══════════════════════════════════════════════════════════════════\n\nexport type {\n InitializeResult,\n ListToolsResult,\n CallToolResult,\n ListResourcesResult,\n ReadResourceResult,\n ListResourceTemplatesResult,\n ListPromptsResult,\n GetPromptResult,\n Tool,\n Resource,\n ResourceTemplate,\n Prompt,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"mcp-test-client.types.js","sourceRoot":"","sources":["../../../src/client/mcp-test-client.types.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA2EH,sEAAsE;AACtE,sBAAsB;AACtB,sEAAsE;AAEtE;;;GAGG;AACU,QAAA,sBAAsB,GAAG,4BAAqC,CAAC","sourcesContent":["/**\n * @file mcp-test-client.types.ts\n * @description Type definitions for the MCP Test Client\n */\n\nimport type {\n InitializeResult,\n ListToolsResult,\n CallToolResult,\n ListResourcesResult,\n ReadResourceResult,\n ListResourceTemplatesResult,\n ListPromptsResult,\n GetPromptResult,\n Tool,\n Resource,\n ResourceTemplate,\n Prompt,\n Implementation,\n} from '@modelcontextprotocol/sdk/types.js';\nimport type { TestPlatformType } from '../platform/platform-types';\n\n// ═══════════════════════════════════════════════════════════════════\n// JSON-RPC TYPES (simplified for testing)\n// ═══════════════════════════════════════════════════════════════════\n\n/**\n * Simplified JSON-RPC request type for testing\n */\nexport interface JSONRPCRequest {\n jsonrpc: '2.0';\n id?: string | number;\n method: string;\n params?: Record<string, unknown>;\n}\n\n/**\n * Simplified JSON-RPC response type for testing\n */\nexport interface JSONRPCResponse {\n jsonrpc: '2.0';\n id: string | number | null;\n result?: unknown;\n error?: {\n code: number;\n message: string;\n data?: unknown;\n };\n}\n\n// ═══════════════════════════════════════════════════════════════════\n// TRANSPORT TYPES\n// ═══════════════════════════════════════════════════════════════════\n\nexport type TestTransportType = 'sse' | 'streamable-http';\n\nexport type TransportState = 'disconnected' | 'connecting' | 'connected' | 'error';\n\n// ═══════════════════════════════════════════════════════════════════\n// AUTH TYPES\n// ═══════════════════════════════════════════════════════════════════\n\nexport interface TestAuthConfig {\n /** Bearer token for authentication */\n token?: string;\n /** Additional headers to include in requests */\n headers?: Record<string, string>;\n}\n\n/**\n * Client information sent during MCP initialization.\n * Re-exported from MCP SDK's Implementation type.\n * Also used for User-Agent header to enable platform detection.\n *\n * Includes: name, version, title?, description?, icons?\n */\nexport type ClientInfo = Implementation;\n\n// ═══════════════════════════════════════════════════════════════════\n// CLIENT CAPABILITIES\n// ═══════════════════════════════════════════════════════════════════\n\n/**\n * MCP Apps extension key used for ext-apps platform detection.\n * When a client sends this capability, the server detects it as an ext-apps client.\n */\nexport const MCP_APPS_EXTENSION_KEY = 'io.modelcontextprotocol/ui' as const;\n\n/**\n * MCP Apps extension capability configuration.\n */\nexport interface McpAppsExtension {\n /** Supported MIME types (e.g., ['text/html+mcp']) */\n mimeTypes?: string[];\n}\n\n/**\n * Experimental capabilities for MCP clients.\n */\nexport interface ExperimentalCapabilities {\n /** MCP Apps (ext-apps) extension capability */\n [MCP_APPS_EXTENSION_KEY]?: McpAppsExtension;\n /** Other experimental capabilities */\n [key: string]: unknown;\n}\n\n/**\n * Client capabilities sent during MCP initialization.\n * These capabilities enable platform-specific detection and features.\n */\nexport interface TestClientCapabilities {\n /** Sampling capabilities */\n sampling?: Record<string, unknown>;\n /** Experimental capabilities including MCP Apps extension */\n experimental?: ExperimentalCapabilities;\n}\n\n// ═══════════════════════════════════════════════════════════════════\n// CLIENT CONFIG\n// ═══════════════════════════════════════════════════════════════════\n\nexport interface McpTestClientConfig {\n /** Base URL of the MCP server */\n baseUrl: string;\n /** Transport type to use (default: 'streamable-http') */\n transport?: TestTransportType;\n /** Authentication configuration */\n auth?: TestAuthConfig;\n /**\n * Enable public mode - skip authentication entirely.\n * When true, no Authorization header is sent and anonymous token is not requested.\n * Use this for testing public/unauthenticated endpoints in CI/CD pipelines.\n */\n publicMode?: boolean;\n /** Request timeout in milliseconds (default: 30000) */\n timeout?: number;\n /** Enable debug logging (default: false) */\n debug?: boolean;\n /** MCP protocol version to request (default: '2024-11-05') */\n protocolVersion?: string;\n /** Client info to send during initialization and for platform detection */\n clientInfo?: ClientInfo;\n /**\n * Client capabilities sent during MCP initialization.\n * Use this to enable platform-specific detection via capability extensions.\n *\n * Example for ext-apps:\n * ```typescript\n * capabilities: {\n * experimental: {\n * 'io.modelcontextprotocol/ui': { mimeTypes: ['text/html+mcp'] }\n * }\n * }\n * ```\n */\n capabilities?: TestClientCapabilities;\n /**\n * Platform type for testing platform-specific meta keys.\n * When set, automatically configures clientInfo and capabilities for platform detection.\n *\n * Platform-specific behavior:\n * - `openai`: Uses openai/* meta keys\n * - `ext-apps`: Uses ui/* meta keys per SEP-1865, sets io.modelcontextprotocol/ui capability\n * - Others: Uses frontmcp/* + ui/* keys for compatibility\n */\n platform?: TestPlatformType;\n}\n\n// ═══════════════════════════════════════════════════════════════════\n// RESPONSE TYPES\n// ═══════════════════════════════════════════════════════════════════\n\nexport interface McpResponse<T> {\n /** Whether the request succeeded */\n success: boolean;\n /** Response data (if successful) */\n data?: T;\n /** Error information (if failed) */\n error?: McpErrorInfo;\n /** Request duration in milliseconds */\n durationMs: number;\n /** Request ID used for this request */\n requestId: string | number;\n}\n\nexport interface McpErrorInfo {\n /** JSON-RPC error code */\n code: number;\n /** Error message */\n message: string;\n /** Additional error data */\n data?: unknown;\n}\n\n// ═══════════════════════════════════════════════════════════════════\n// TOOL RESULT WRAPPER\n// ═══════════════════════════════════════════════════════════════════\n\nexport interface ToolResultWrapper {\n /** Raw CallToolResult from MCP */\n raw: CallToolResult;\n /** Whether the tool call was successful (no isError flag) */\n isSuccess: boolean;\n /** Whether the tool call failed */\n isError: boolean;\n /** Error information if failed */\n error?: McpErrorInfo;\n /** Duration of the tool call in ms */\n durationMs: number;\n /**\n * Parse tool output as JSON\n *\n * For Tool UI responses: returns structuredContent (the typed output)\n * For regular responses: parses text content as JSON\n */\n json<T = unknown>(): T;\n /** Get first text content */\n text(): string | undefined;\n /** Check if response has text content */\n hasTextContent(): boolean;\n /** Check if response has image content */\n hasImageContent(): boolean;\n /** Check if response has resource content */\n hasResourceContent(): boolean;\n /** Check if response has Tool UI metadata (ui/html in _meta) */\n hasToolUI(): boolean;\n}\n\n// ═══════════════════════════════════════════════════════════════════\n// RESOURCE CONTENT WRAPPER\n// ═══════════════════════════════════════════════════════════════════\n\nexport interface ResourceContentWrapper {\n /** Raw ReadResourceResult from MCP */\n raw: ReadResourceResult;\n /** Whether the read was successful */\n isSuccess: boolean;\n /** Whether the read failed */\n isError: boolean;\n /** Error information if failed */\n error?: McpErrorInfo;\n /** Duration in ms */\n durationMs: number;\n /** Parse text content as JSON */\n json<T = unknown>(): T;\n /** Get text content */\n text(): string | undefined;\n /** Get MIME type */\n mimeType(): string | undefined;\n /** Check if has specific MIME type */\n hasMimeType(type: string): boolean;\n}\n\n// ═══════════════════════════════════════════════════════════════════\n// PROMPT RESULT WRAPPER\n// ═══════════════════════════════════════════════════════════════════\n\nexport interface PromptResultWrapper {\n /** Raw GetPromptResult from MCP */\n raw: GetPromptResult;\n /** Whether the get was successful */\n isSuccess: boolean;\n /** Whether the get failed */\n isError: boolean;\n /** Error information if failed */\n error?: McpErrorInfo;\n /** Duration in ms */\n durationMs: number;\n /** Messages in the prompt */\n messages: GetPromptResult['messages'];\n /** Description from prompt result */\n description?: string;\n}\n\n// ═══════════════════════════════════════════════════════════════════\n// LOGGING TYPES\n// ═══════════════════════════════════════════════════════════════════\n\nexport type LogLevel = 'debug' | 'info' | 'warn' | 'error';\n\nexport interface LogEntry {\n /** Log level */\n level: LogLevel;\n /** Log message */\n message: string;\n /** Timestamp */\n timestamp: Date;\n /** Additional data */\n data?: unknown;\n}\n\nexport interface RequestTrace {\n /** Request that was sent */\n request: {\n method: string;\n params?: unknown;\n id: string | number;\n };\n /** Response that was received */\n response: {\n result?: unknown;\n error?: McpErrorInfo;\n };\n /** Duration in milliseconds */\n durationMs: number;\n /** Timestamp of the request */\n timestamp: Date;\n}\n\n// ═══════════════════════════════════════════════════════════════════\n// NOTIFICATION TYPES\n// ═══════════════════════════════════════════════════════════════════\n\nexport interface NotificationEntry {\n /** Notification method */\n method: string;\n /** Notification params */\n params?: unknown;\n /** Timestamp received */\n timestamp: Date;\n}\n\nexport interface ProgressUpdate {\n /** Progress value (0-100 or custom) */\n progress: number;\n /** Total value */\n total?: number;\n /** Progress token */\n progressToken?: string | number;\n /** Timestamp */\n timestamp: Date;\n}\n\n// ═══════════════════════════════════════════════════════════════════\n// SESSION TYPES\n// ═══════════════════════════════════════════════════════════════════\n\nexport interface SessionInfo {\n /** Session ID */\n id: string;\n /** When the session was created */\n createdAt: Date;\n /** When the last request was made */\n lastActivityAt: Date;\n /** Number of requests made in this session */\n requestCount: number;\n}\n\n// ═══════════════════════════════════════════════════════════════════\n// AUTH STATE\n// ═══════════════════════════════════════════════════════════════════\n\nexport interface AuthState {\n /** Whether the user is anonymous (no token) */\n isAnonymous: boolean;\n /** Current token (if any) */\n token?: string;\n /** Scopes from the token */\n scopes: string[];\n /** User information from token */\n user?: {\n sub: string;\n email?: string;\n name?: string;\n };\n}\n\n// ═══════════════════════════════════════════════════════════════════\n// RE-EXPORTS FROM MCP SDK\n// ═══════════════════════════════════════════════════════════════════\n\nexport type {\n InitializeResult,\n ListToolsResult,\n CallToolResult,\n ListResourcesResult,\n ReadResourceResult,\n ListResourceTemplatesResult,\n ListPromptsResult,\n GetPromptResult,\n Tool,\n Resource,\n ResourceTemplate,\n Prompt,\n};\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file example-tools/index.ts
|
|
3
|
+
* @description Barrel export for example tool configurations.
|
|
4
|
+
*
|
|
5
|
+
* These configurations provide consistent test fixtures for platform E2E testing.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import {
|
|
10
|
+
* BASIC_UI_TOOL_CONFIG,
|
|
11
|
+
* FULL_UI_TOOL_CONFIG,
|
|
12
|
+
* generateBasicUIToolOutput,
|
|
13
|
+
* EXPECTED_OPENAI_TOOL_CALL_META_KEYS,
|
|
14
|
+
* } from '@frontmcp/testing';
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export { BASIC_UI_TOOL_CONFIG, FULL_UI_TOOL_CONFIG, basicUIToolInputSchema, basicUIToolOutputSchema, fullUIToolInputSchema, fullUIToolOutputSchema, } from './tool-configs';
|
|
18
|
+
export { generateBasicUIToolOutput, generateFullUIToolOutput } from './tool-configs';
|
|
19
|
+
export { EXPECTED_OPENAI_TOOLS_LIST_META_KEYS, EXPECTED_OPENAI_TOOL_CALL_META_KEYS, EXPECTED_EXTAPPS_TOOLS_LIST_META_KEYS, EXPECTED_EXTAPPS_TOOL_CALL_META_KEYS, EXPECTED_FRONTMCP_TOOLS_LIST_META_KEYS, EXPECTED_FRONTMCP_TOOL_CALL_META_KEYS, } from './tool-configs';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file example-tools/index.ts
|
|
4
|
+
* @description Barrel export for example tool configurations.
|
|
5
|
+
*
|
|
6
|
+
* These configurations provide consistent test fixtures for platform E2E testing.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import {
|
|
11
|
+
* BASIC_UI_TOOL_CONFIG,
|
|
12
|
+
* FULL_UI_TOOL_CONFIG,
|
|
13
|
+
* generateBasicUIToolOutput,
|
|
14
|
+
* EXPECTED_OPENAI_TOOL_CALL_META_KEYS,
|
|
15
|
+
* } from '@frontmcp/testing';
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.EXPECTED_FRONTMCP_TOOL_CALL_META_KEYS = exports.EXPECTED_FRONTMCP_TOOLS_LIST_META_KEYS = exports.EXPECTED_EXTAPPS_TOOL_CALL_META_KEYS = exports.EXPECTED_EXTAPPS_TOOLS_LIST_META_KEYS = exports.EXPECTED_OPENAI_TOOL_CALL_META_KEYS = exports.EXPECTED_OPENAI_TOOLS_LIST_META_KEYS = exports.generateFullUIToolOutput = exports.generateBasicUIToolOutput = exports.fullUIToolOutputSchema = exports.fullUIToolInputSchema = exports.basicUIToolOutputSchema = exports.basicUIToolInputSchema = exports.FULL_UI_TOOL_CONFIG = exports.BASIC_UI_TOOL_CONFIG = void 0;
|
|
20
|
+
// Tool configurations
|
|
21
|
+
var tool_configs_1 = require("./tool-configs");
|
|
22
|
+
Object.defineProperty(exports, "BASIC_UI_TOOL_CONFIG", { enumerable: true, get: function () { return tool_configs_1.BASIC_UI_TOOL_CONFIG; } });
|
|
23
|
+
Object.defineProperty(exports, "FULL_UI_TOOL_CONFIG", { enumerable: true, get: function () { return tool_configs_1.FULL_UI_TOOL_CONFIG; } });
|
|
24
|
+
Object.defineProperty(exports, "basicUIToolInputSchema", { enumerable: true, get: function () { return tool_configs_1.basicUIToolInputSchema; } });
|
|
25
|
+
Object.defineProperty(exports, "basicUIToolOutputSchema", { enumerable: true, get: function () { return tool_configs_1.basicUIToolOutputSchema; } });
|
|
26
|
+
Object.defineProperty(exports, "fullUIToolInputSchema", { enumerable: true, get: function () { return tool_configs_1.fullUIToolInputSchema; } });
|
|
27
|
+
Object.defineProperty(exports, "fullUIToolOutputSchema", { enumerable: true, get: function () { return tool_configs_1.fullUIToolOutputSchema; } });
|
|
28
|
+
// Execution helpers
|
|
29
|
+
var tool_configs_2 = require("./tool-configs");
|
|
30
|
+
Object.defineProperty(exports, "generateBasicUIToolOutput", { enumerable: true, get: function () { return tool_configs_2.generateBasicUIToolOutput; } });
|
|
31
|
+
Object.defineProperty(exports, "generateFullUIToolOutput", { enumerable: true, get: function () { return tool_configs_2.generateFullUIToolOutput; } });
|
|
32
|
+
// Expected meta keys
|
|
33
|
+
var tool_configs_3 = require("./tool-configs");
|
|
34
|
+
Object.defineProperty(exports, "EXPECTED_OPENAI_TOOLS_LIST_META_KEYS", { enumerable: true, get: function () { return tool_configs_3.EXPECTED_OPENAI_TOOLS_LIST_META_KEYS; } });
|
|
35
|
+
Object.defineProperty(exports, "EXPECTED_OPENAI_TOOL_CALL_META_KEYS", { enumerable: true, get: function () { return tool_configs_3.EXPECTED_OPENAI_TOOL_CALL_META_KEYS; } });
|
|
36
|
+
Object.defineProperty(exports, "EXPECTED_EXTAPPS_TOOLS_LIST_META_KEYS", { enumerable: true, get: function () { return tool_configs_3.EXPECTED_EXTAPPS_TOOLS_LIST_META_KEYS; } });
|
|
37
|
+
Object.defineProperty(exports, "EXPECTED_EXTAPPS_TOOL_CALL_META_KEYS", { enumerable: true, get: function () { return tool_configs_3.EXPECTED_EXTAPPS_TOOL_CALL_META_KEYS; } });
|
|
38
|
+
Object.defineProperty(exports, "EXPECTED_FRONTMCP_TOOLS_LIST_META_KEYS", { enumerable: true, get: function () { return tool_configs_3.EXPECTED_FRONTMCP_TOOLS_LIST_META_KEYS; } });
|
|
39
|
+
Object.defineProperty(exports, "EXPECTED_FRONTMCP_TOOL_CALL_META_KEYS", { enumerable: true, get: function () { return tool_configs_3.EXPECTED_FRONTMCP_TOOL_CALL_META_KEYS; } });
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/example-tools/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH,sBAAsB;AACtB,+CAOwB;AANtB,oHAAA,oBAAoB,OAAA;AACpB,mHAAA,mBAAmB,OAAA;AACnB,sHAAA,sBAAsB,OAAA;AACtB,uHAAA,uBAAuB,OAAA;AACvB,qHAAA,qBAAqB,OAAA;AACrB,sHAAA,sBAAsB,OAAA;AAGxB,oBAAoB;AACpB,+CAAqF;AAA5E,yHAAA,yBAAyB,OAAA;AAAE,wHAAA,wBAAwB,OAAA;AAE5D,qBAAqB;AACrB,+CAOwB;AANtB,oIAAA,oCAAoC,OAAA;AACpC,mIAAA,mCAAmC,OAAA;AACnC,qIAAA,qCAAqC,OAAA;AACrC,oIAAA,oCAAoC,OAAA;AACpC,sIAAA,sCAAsC,OAAA;AACtC,qIAAA,qCAAqC,OAAA","sourcesContent":["/**\n * @file example-tools/index.ts\n * @description Barrel export for example tool configurations.\n *\n * These configurations provide consistent test fixtures for platform E2E testing.\n *\n * @example\n * ```typescript\n * import {\n * BASIC_UI_TOOL_CONFIG,\n * FULL_UI_TOOL_CONFIG,\n * generateBasicUIToolOutput,\n * EXPECTED_OPENAI_TOOL_CALL_META_KEYS,\n * } from '@frontmcp/testing';\n * ```\n */\n\n// Tool configurations\nexport {\n BASIC_UI_TOOL_CONFIG,\n FULL_UI_TOOL_CONFIG,\n basicUIToolInputSchema,\n basicUIToolOutputSchema,\n fullUIToolInputSchema,\n fullUIToolOutputSchema,\n} from './tool-configs';\n\n// Execution helpers\nexport { generateBasicUIToolOutput, generateFullUIToolOutput } from './tool-configs';\n\n// Expected meta keys\nexport {\n EXPECTED_OPENAI_TOOLS_LIST_META_KEYS,\n EXPECTED_OPENAI_TOOL_CALL_META_KEYS,\n EXPECTED_EXTAPPS_TOOLS_LIST_META_KEYS,\n EXPECTED_EXTAPPS_TOOL_CALL_META_KEYS,\n EXPECTED_FRONTMCP_TOOLS_LIST_META_KEYS,\n EXPECTED_FRONTMCP_TOOL_CALL_META_KEYS,\n} from './tool-configs';\n"]}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file tool-configs.ts
|
|
3
|
+
* @description Shared tool configurations for platform E2E testing.
|
|
4
|
+
*
|
|
5
|
+
* These configurations provide consistent test fixtures for validating
|
|
6
|
+
* platform-specific meta key behavior across E2E test projects.
|
|
7
|
+
*
|
|
8
|
+
* @example Usage in E2E tool implementation
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { Tool, ToolContext } from '@frontmcp/sdk';
|
|
11
|
+
* import { BASIC_UI_TOOL_CONFIG, FULL_UI_TOOL_CONFIG } from '@frontmcp/testing';
|
|
12
|
+
*
|
|
13
|
+
* @Tool({
|
|
14
|
+
* name: BASIC_UI_TOOL_CONFIG.name,
|
|
15
|
+
* description: BASIC_UI_TOOL_CONFIG.description,
|
|
16
|
+
* ui: BASIC_UI_TOOL_CONFIG.ui,
|
|
17
|
+
* })
|
|
18
|
+
* export class BasicUITool extends ToolContext<typeof inputSchema, typeof outputSchema> {
|
|
19
|
+
* async execute(input) {
|
|
20
|
+
* return { message: `Hello, ${input.name}!`, timestamp: Date.now() };
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
import { z } from 'zod';
|
|
26
|
+
/**
|
|
27
|
+
* Input schema for the basic UI tool.
|
|
28
|
+
*/
|
|
29
|
+
export declare const basicUIToolInputSchema: z.ZodObject<{
|
|
30
|
+
name: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
/**
|
|
33
|
+
* Output schema for the basic UI tool.
|
|
34
|
+
*/
|
|
35
|
+
export declare const basicUIToolOutputSchema: z.ZodObject<{
|
|
36
|
+
message: z.ZodString;
|
|
37
|
+
timestamp: z.ZodNumber;
|
|
38
|
+
}, z.core.$strip>;
|
|
39
|
+
/**
|
|
40
|
+
* Basic UI tool configuration with minimal UI config.
|
|
41
|
+
* Use this for testing that platform-specific meta keys are correctly applied.
|
|
42
|
+
*/
|
|
43
|
+
export declare const BASIC_UI_TOOL_CONFIG: {
|
|
44
|
+
readonly name: "platform-test-basic";
|
|
45
|
+
readonly description: "Basic UI tool for platform testing";
|
|
46
|
+
readonly inputSchema: z.ZodObject<{
|
|
47
|
+
name: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
48
|
+
}, z.core.$strip>;
|
|
49
|
+
readonly outputSchema: z.ZodObject<{
|
|
50
|
+
message: z.ZodString;
|
|
51
|
+
timestamp: z.ZodNumber;
|
|
52
|
+
}, z.core.$strip>;
|
|
53
|
+
readonly ui: {
|
|
54
|
+
/**
|
|
55
|
+
* Simple template that displays the output.
|
|
56
|
+
* Works with all platforms.
|
|
57
|
+
*/
|
|
58
|
+
readonly template: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Input schema for the full UI tool.
|
|
63
|
+
*/
|
|
64
|
+
export declare const fullUIToolInputSchema: z.ZodObject<{
|
|
65
|
+
name: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
66
|
+
count: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
67
|
+
}, z.core.$strip>;
|
|
68
|
+
/**
|
|
69
|
+
* Output schema for the full UI tool.
|
|
70
|
+
*/
|
|
71
|
+
export declare const fullUIToolOutputSchema: z.ZodObject<{
|
|
72
|
+
message: z.ZodString;
|
|
73
|
+
count: z.ZodNumber;
|
|
74
|
+
items: z.ZodArray<z.ZodString>;
|
|
75
|
+
timestamp: z.ZodNumber;
|
|
76
|
+
}, z.core.$strip>;
|
|
77
|
+
/**
|
|
78
|
+
* Full UI tool configuration with all UI options.
|
|
79
|
+
* Use this for testing comprehensive platform-specific meta key behavior.
|
|
80
|
+
*/
|
|
81
|
+
export declare const FULL_UI_TOOL_CONFIG: {
|
|
82
|
+
readonly name: "platform-test-full";
|
|
83
|
+
readonly description: "Full UI tool with all options for comprehensive platform testing";
|
|
84
|
+
readonly inputSchema: z.ZodObject<{
|
|
85
|
+
name: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
86
|
+
count: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
87
|
+
}, z.core.$strip>;
|
|
88
|
+
readonly outputSchema: z.ZodObject<{
|
|
89
|
+
message: z.ZodString;
|
|
90
|
+
count: z.ZodNumber;
|
|
91
|
+
items: z.ZodArray<z.ZodString>;
|
|
92
|
+
timestamp: z.ZodNumber;
|
|
93
|
+
}, z.core.$strip>;
|
|
94
|
+
readonly ui: {
|
|
95
|
+
/**
|
|
96
|
+
* Template with more complex UI elements.
|
|
97
|
+
*/
|
|
98
|
+
readonly template: string;
|
|
99
|
+
/**
|
|
100
|
+
* Widget is accessible for callback invocations.
|
|
101
|
+
*/
|
|
102
|
+
readonly widgetAccessible: true;
|
|
103
|
+
/**
|
|
104
|
+
* Invocation status messages for OpenAI.
|
|
105
|
+
*/
|
|
106
|
+
readonly invocationStatus: {
|
|
107
|
+
readonly invoking: "Processing request...";
|
|
108
|
+
readonly invoked: "Request completed";
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Content Security Policy configuration.
|
|
112
|
+
*/
|
|
113
|
+
readonly csp: {
|
|
114
|
+
readonly connectDomains: readonly ["https://api.example.com"];
|
|
115
|
+
readonly resourceDomains: readonly ["https://cdn.example.com"];
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Display mode for the widget.
|
|
119
|
+
*/
|
|
120
|
+
readonly displayMode: "inline";
|
|
121
|
+
/**
|
|
122
|
+
* Prefers border around the widget.
|
|
123
|
+
*/
|
|
124
|
+
readonly prefersBorder: true;
|
|
125
|
+
/**
|
|
126
|
+
* Custom sandbox domain.
|
|
127
|
+
*/
|
|
128
|
+
readonly sandboxDomain: "sandbox.example.com";
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Generate output for the basic UI tool.
|
|
133
|
+
*/
|
|
134
|
+
export declare function generateBasicUIToolOutput(input: z.infer<typeof basicUIToolInputSchema>): {
|
|
135
|
+
message: string;
|
|
136
|
+
timestamp: number;
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Generate output for the full UI tool.
|
|
140
|
+
*/
|
|
141
|
+
export declare function generateFullUIToolOutput(input: z.infer<typeof fullUIToolInputSchema>): {
|
|
142
|
+
message: string;
|
|
143
|
+
count: number;
|
|
144
|
+
items: string[];
|
|
145
|
+
timestamp: number;
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Expected meta keys for OpenAI platform in tools/list response.
|
|
149
|
+
*/
|
|
150
|
+
export declare const EXPECTED_OPENAI_TOOLS_LIST_META_KEYS: readonly ["openai/outputTemplate", "openai/resultCanProduceWidget", "openai/widgetAccessible"];
|
|
151
|
+
/**
|
|
152
|
+
* Expected meta keys for OpenAI platform in tools/call response.
|
|
153
|
+
*/
|
|
154
|
+
export declare const EXPECTED_OPENAI_TOOL_CALL_META_KEYS: readonly ["openai/html", "openai/mimeType", "openai/type"];
|
|
155
|
+
/**
|
|
156
|
+
* Expected meta keys for ext-apps platform in tools/list response (SEP-1865).
|
|
157
|
+
*/
|
|
158
|
+
export declare const EXPECTED_EXTAPPS_TOOLS_LIST_META_KEYS: readonly ["ui/resourceUri", "ui/mimeType", "ui/cdn", "ui/type"];
|
|
159
|
+
/**
|
|
160
|
+
* Expected meta keys for ext-apps platform in tools/call response (SEP-1865).
|
|
161
|
+
*/
|
|
162
|
+
export declare const EXPECTED_EXTAPPS_TOOL_CALL_META_KEYS: readonly ["ui/html", "ui/mimeType", "ui/type"];
|
|
163
|
+
/**
|
|
164
|
+
* Expected meta keys for FrontMCP platforms in tools/list response (Claude, Cursor, etc.).
|
|
165
|
+
*/
|
|
166
|
+
export declare const EXPECTED_FRONTMCP_TOOLS_LIST_META_KEYS: readonly ["frontmcp/outputTemplate", "frontmcp/resultCanProduceWidget", "ui/cdn", "ui/type"];
|
|
167
|
+
/**
|
|
168
|
+
* Expected meta keys for FrontMCP platforms in tools/call response (Claude, Cursor, etc.).
|
|
169
|
+
*/
|
|
170
|
+
export declare const EXPECTED_FRONTMCP_TOOL_CALL_META_KEYS: readonly ["frontmcp/html", "frontmcp/mimeType", "ui/html", "ui/mimeType"];
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file tool-configs.ts
|
|
4
|
+
* @description Shared tool configurations for platform E2E testing.
|
|
5
|
+
*
|
|
6
|
+
* These configurations provide consistent test fixtures for validating
|
|
7
|
+
* platform-specific meta key behavior across E2E test projects.
|
|
8
|
+
*
|
|
9
|
+
* @example Usage in E2E tool implementation
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { Tool, ToolContext } from '@frontmcp/sdk';
|
|
12
|
+
* import { BASIC_UI_TOOL_CONFIG, FULL_UI_TOOL_CONFIG } from '@frontmcp/testing';
|
|
13
|
+
*
|
|
14
|
+
* @Tool({
|
|
15
|
+
* name: BASIC_UI_TOOL_CONFIG.name,
|
|
16
|
+
* description: BASIC_UI_TOOL_CONFIG.description,
|
|
17
|
+
* ui: BASIC_UI_TOOL_CONFIG.ui,
|
|
18
|
+
* })
|
|
19
|
+
* export class BasicUITool extends ToolContext<typeof inputSchema, typeof outputSchema> {
|
|
20
|
+
* async execute(input) {
|
|
21
|
+
* return { message: `Hello, ${input.name}!`, timestamp: Date.now() };
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.EXPECTED_FRONTMCP_TOOL_CALL_META_KEYS = exports.EXPECTED_FRONTMCP_TOOLS_LIST_META_KEYS = exports.EXPECTED_EXTAPPS_TOOL_CALL_META_KEYS = exports.EXPECTED_EXTAPPS_TOOLS_LIST_META_KEYS = exports.EXPECTED_OPENAI_TOOL_CALL_META_KEYS = exports.EXPECTED_OPENAI_TOOLS_LIST_META_KEYS = exports.FULL_UI_TOOL_CONFIG = exports.fullUIToolOutputSchema = exports.fullUIToolInputSchema = exports.BASIC_UI_TOOL_CONFIG = exports.basicUIToolOutputSchema = exports.basicUIToolInputSchema = void 0;
|
|
28
|
+
exports.generateBasicUIToolOutput = generateBasicUIToolOutput;
|
|
29
|
+
exports.generateFullUIToolOutput = generateFullUIToolOutput;
|
|
30
|
+
const zod_1 = require("zod");
|
|
31
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
32
|
+
// BASIC UI TOOL CONFIG
|
|
33
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
34
|
+
/**
|
|
35
|
+
* Input schema for the basic UI tool.
|
|
36
|
+
*/
|
|
37
|
+
exports.basicUIToolInputSchema = zod_1.z.object({
|
|
38
|
+
name: zod_1.z.string().optional().default('World'),
|
|
39
|
+
});
|
|
40
|
+
/**
|
|
41
|
+
* Output schema for the basic UI tool.
|
|
42
|
+
*/
|
|
43
|
+
exports.basicUIToolOutputSchema = zod_1.z.object({
|
|
44
|
+
message: zod_1.z.string(),
|
|
45
|
+
timestamp: zod_1.z.number(),
|
|
46
|
+
});
|
|
47
|
+
/**
|
|
48
|
+
* Basic UI tool configuration with minimal UI config.
|
|
49
|
+
* Use this for testing that platform-specific meta keys are correctly applied.
|
|
50
|
+
*/
|
|
51
|
+
exports.BASIC_UI_TOOL_CONFIG = {
|
|
52
|
+
name: 'platform-test-basic',
|
|
53
|
+
description: 'Basic UI tool for platform testing',
|
|
54
|
+
inputSchema: exports.basicUIToolInputSchema,
|
|
55
|
+
outputSchema: exports.basicUIToolOutputSchema,
|
|
56
|
+
ui: {
|
|
57
|
+
/**
|
|
58
|
+
* Simple template that displays the output.
|
|
59
|
+
* Works with all platforms.
|
|
60
|
+
*/
|
|
61
|
+
template: `
|
|
62
|
+
<div class="platform-test-basic">
|
|
63
|
+
<h1>Platform Test - Basic</h1>
|
|
64
|
+
<p>Message: {output.message}</p>
|
|
65
|
+
<p>Timestamp: {output.timestamp}</p>
|
|
66
|
+
</div>
|
|
67
|
+
`.trim(),
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
71
|
+
// FULL UI TOOL CONFIG
|
|
72
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
73
|
+
/**
|
|
74
|
+
* Input schema for the full UI tool.
|
|
75
|
+
*/
|
|
76
|
+
exports.fullUIToolInputSchema = zod_1.z.object({
|
|
77
|
+
name: zod_1.z.string().optional().default('World'),
|
|
78
|
+
count: zod_1.z.number().optional().default(1),
|
|
79
|
+
});
|
|
80
|
+
/**
|
|
81
|
+
* Output schema for the full UI tool.
|
|
82
|
+
*/
|
|
83
|
+
exports.fullUIToolOutputSchema = zod_1.z.object({
|
|
84
|
+
message: zod_1.z.string(),
|
|
85
|
+
count: zod_1.z.number(),
|
|
86
|
+
items: zod_1.z.array(zod_1.z.string()),
|
|
87
|
+
timestamp: zod_1.z.number(),
|
|
88
|
+
});
|
|
89
|
+
/**
|
|
90
|
+
* Full UI tool configuration with all UI options.
|
|
91
|
+
* Use this for testing comprehensive platform-specific meta key behavior.
|
|
92
|
+
*/
|
|
93
|
+
exports.FULL_UI_TOOL_CONFIG = {
|
|
94
|
+
name: 'platform-test-full',
|
|
95
|
+
description: 'Full UI tool with all options for comprehensive platform testing',
|
|
96
|
+
inputSchema: exports.fullUIToolInputSchema,
|
|
97
|
+
outputSchema: exports.fullUIToolOutputSchema,
|
|
98
|
+
ui: {
|
|
99
|
+
/**
|
|
100
|
+
* Template with more complex UI elements.
|
|
101
|
+
*/
|
|
102
|
+
template: `
|
|
103
|
+
<div class="platform-test-full">
|
|
104
|
+
<h1>Platform Test - Full</h1>
|
|
105
|
+
<div class="message-box">
|
|
106
|
+
<strong>Message:</strong> {output.message}
|
|
107
|
+
</div>
|
|
108
|
+
<div class="count-box">
|
|
109
|
+
<strong>Count:</strong> {output.count}
|
|
110
|
+
</div>
|
|
111
|
+
<div class="items-list">
|
|
112
|
+
<strong>Items:</strong>
|
|
113
|
+
<ul>
|
|
114
|
+
{output.items.map(item => <li key={item}>{item}</li>)}
|
|
115
|
+
</ul>
|
|
116
|
+
</div>
|
|
117
|
+
<footer>
|
|
118
|
+
<small>Generated at: {new Date(output.timestamp).toISOString()}</small>
|
|
119
|
+
</footer>
|
|
120
|
+
</div>
|
|
121
|
+
`.trim(),
|
|
122
|
+
/**
|
|
123
|
+
* Widget is accessible for callback invocations.
|
|
124
|
+
*/
|
|
125
|
+
widgetAccessible: true,
|
|
126
|
+
/**
|
|
127
|
+
* Invocation status messages for OpenAI.
|
|
128
|
+
*/
|
|
129
|
+
invocationStatus: {
|
|
130
|
+
invoking: 'Processing request...',
|
|
131
|
+
invoked: 'Request completed',
|
|
132
|
+
},
|
|
133
|
+
/**
|
|
134
|
+
* Content Security Policy configuration.
|
|
135
|
+
*/
|
|
136
|
+
csp: {
|
|
137
|
+
connectDomains: ['https://api.example.com'],
|
|
138
|
+
resourceDomains: ['https://cdn.example.com'],
|
|
139
|
+
},
|
|
140
|
+
/**
|
|
141
|
+
* Display mode for the widget.
|
|
142
|
+
*/
|
|
143
|
+
displayMode: 'inline',
|
|
144
|
+
/**
|
|
145
|
+
* Prefers border around the widget.
|
|
146
|
+
*/
|
|
147
|
+
prefersBorder: true,
|
|
148
|
+
/**
|
|
149
|
+
* Custom sandbox domain.
|
|
150
|
+
*/
|
|
151
|
+
sandboxDomain: 'sandbox.example.com',
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
155
|
+
// TOOL EXECUTION HELPERS
|
|
156
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
157
|
+
/**
|
|
158
|
+
* Generate output for the basic UI tool.
|
|
159
|
+
*/
|
|
160
|
+
function generateBasicUIToolOutput(input) {
|
|
161
|
+
return {
|
|
162
|
+
message: `Hello, ${input.name}!`,
|
|
163
|
+
timestamp: Date.now(),
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Generate output for the full UI tool.
|
|
168
|
+
*/
|
|
169
|
+
function generateFullUIToolOutput(input) {
|
|
170
|
+
const items = [];
|
|
171
|
+
for (let i = 1; i <= input.count; i++) {
|
|
172
|
+
items.push(`Item ${i}`);
|
|
173
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
message: `Hello, ${input.name}! You requested ${input.count} item(s).`,
|
|
176
|
+
count: input.count,
|
|
177
|
+
items,
|
|
178
|
+
timestamp: Date.now(),
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
182
|
+
// EXPECTED META KEYS
|
|
183
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
184
|
+
/**
|
|
185
|
+
* Expected meta keys for OpenAI platform in tools/list response.
|
|
186
|
+
*/
|
|
187
|
+
exports.EXPECTED_OPENAI_TOOLS_LIST_META_KEYS = [
|
|
188
|
+
'openai/outputTemplate',
|
|
189
|
+
'openai/resultCanProduceWidget',
|
|
190
|
+
'openai/widgetAccessible',
|
|
191
|
+
];
|
|
192
|
+
/**
|
|
193
|
+
* Expected meta keys for OpenAI platform in tools/call response.
|
|
194
|
+
*/
|
|
195
|
+
exports.EXPECTED_OPENAI_TOOL_CALL_META_KEYS = ['openai/html', 'openai/mimeType', 'openai/type'];
|
|
196
|
+
/**
|
|
197
|
+
* Expected meta keys for ext-apps platform in tools/list response (SEP-1865).
|
|
198
|
+
*/
|
|
199
|
+
exports.EXPECTED_EXTAPPS_TOOLS_LIST_META_KEYS = ['ui/resourceUri', 'ui/mimeType', 'ui/cdn', 'ui/type'];
|
|
200
|
+
/**
|
|
201
|
+
* Expected meta keys for ext-apps platform in tools/call response (SEP-1865).
|
|
202
|
+
*/
|
|
203
|
+
exports.EXPECTED_EXTAPPS_TOOL_CALL_META_KEYS = ['ui/html', 'ui/mimeType', 'ui/type'];
|
|
204
|
+
/**
|
|
205
|
+
* Expected meta keys for FrontMCP platforms in tools/list response (Claude, Cursor, etc.).
|
|
206
|
+
*/
|
|
207
|
+
exports.EXPECTED_FRONTMCP_TOOLS_LIST_META_KEYS = [
|
|
208
|
+
'frontmcp/outputTemplate',
|
|
209
|
+
'frontmcp/resultCanProduceWidget',
|
|
210
|
+
'ui/cdn',
|
|
211
|
+
'ui/type',
|
|
212
|
+
];
|
|
213
|
+
/**
|
|
214
|
+
* Expected meta keys for FrontMCP platforms in tools/call response (Claude, Cursor, etc.).
|
|
215
|
+
*/
|
|
216
|
+
exports.EXPECTED_FRONTMCP_TOOL_CALL_META_KEYS = [
|
|
217
|
+
'frontmcp/html',
|
|
218
|
+
'frontmcp/mimeType',
|
|
219
|
+
'ui/html',
|
|
220
|
+
'ui/mimeType',
|
|
221
|
+
];
|
|
222
|
+
//# sourceMappingURL=tool-configs.js.map
|