(method: string, params: unknown)
| 33 | } |
| 34 | |
| 35 | async function handleRequest(method: string, params: unknown): Promise<unknown> { |
| 36 | switch (method) { |
| 37 | case 'initialize': |
| 38 | return { |
| 39 | protocolVersion: supportedProtocolVersion(params), |
| 40 | capabilities: { |
| 41 | tools: {}, |
| 42 | }, |
| 43 | serverInfo: { |
| 44 | name: MCP_SERVER_NAME, |
| 45 | version: readVersion(), |
| 46 | }, |
| 47 | }; |
| 48 | case 'ping': |
| 49 | return {}; |
| 50 | case 'tools/list': |
| 51 | return { tools: listCommandTools() }; |
| 52 | case 'tools/call': |
| 53 | return await callTool(params); |
| 54 | default: |
| 55 | throw new JsonRpcMethodNotFoundError(`Unsupported MCP method: ${method}`); |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | async function callTool(params: unknown): Promise<ToolResult> { |
| 60 | const record = asRecord(params); |
no test coverage detected