| 47 | } |
| 48 | |
| 49 | function hashConfig(config: MCPConfig): string { |
| 50 | if (config.type === 'stdio') { |
| 51 | return JSON.stringify({ |
| 52 | command: config.command, |
| 53 | args: config.args, |
| 54 | env: config.env, |
| 55 | }) |
| 56 | } |
| 57 | if (config.type === 'http') { |
| 58 | return JSON.stringify({ |
| 59 | type: 'http', |
| 60 | url: config.url, |
| 61 | params: config.params, |
| 62 | }) |
| 63 | } |
| 64 | if (config.type === 'sse') { |
| 65 | return JSON.stringify({ |
| 66 | type: 'sse', |
| 67 | url: config.url, |
| 68 | params: config.params, |
| 69 | }) |
| 70 | } |
| 71 | config.type satisfies never |
| 72 | throw new Error( |
| 73 | `Internal error in hashConfig: invalid MCP config type ${config.type}`, |
| 74 | ) |
| 75 | } |
| 76 | |
| 77 | export async function getMCPClient(config: MCPConfig): Promise<string> { |
| 78 | let key = hashConfig(config) |