UNPKG

@odel/module-sdk

Version:

SDK for building Odel modules - MCP protocol over HTTP for Cloudflare Workers

58 lines 1.86 kB
/** * Testing utilities for Odel modules * * @example * ```typescript * import { testMCPCompliance, testTool, expectSuccess } from '@odel/module-sdk/testing'; * ``` */ export { testMCPCompliance } from './mcp-compliance'; export type { MCPTestContext } from './mcp-compliance'; export { expectSuccess, expectError } from './assertions'; /** * Create a JSON-RPC MCP request * * @param method - MCP method name (e.g., 'tools/list', 'tools/call') * @param params - Optional parameters for the method * @param id - Request ID (defaults to current timestamp) * * @example * ```typescript * const request = createMCPRequest('tools/list', { extended: true }); * const response = await worker.fetch(request, env, ctx); * ``` */ export declare function createMCPRequest(method: string, params?: Record<string, any>, id?: number): Request; /** * Test a tool by calling it with given input * * @param worker - The module's ExportedHandler * @param toolName - Name of the tool to test * @param input - Input parameters for the tool * @param options - Optional configuration * @returns The parsed tool response * * @example * ```typescript * import { testTool, expectSuccess } from '@odel/module-sdk/testing'; * import worker from './src/index'; * * test('add tool works', async () => { * const result = await testTool(worker, 'add', { a: 1, b: 2 }); * expectSuccess(result); * expect(result.result).toBe(3); * }); * ``` */ export declare function testTool<T = any>(worker: ExportedHandler<any>, toolName: string, input: Record<string, unknown>, options?: { env?: any; context?: { userId?: string; conversationId?: string; displayName?: string; secrets?: Record<string, string>; timestamp?: number; requestId?: string; }; }): Promise<T>; //# sourceMappingURL=index.d.ts.map