( name: string, makeTransport: () => Transport, )
| 34 | } |
| 35 | |
| 36 | async function probe( |
| 37 | name: string, |
| 38 | makeTransport: () => Transport, |
| 39 | ): Promise<ServerStatus> { |
| 40 | try { |
| 41 | const client = await createMCPClient({ transport: makeTransport() }) |
| 42 | try { |
| 43 | const tools = (await client.tools()).map((t) => t.name) |
| 44 | // Check the advertised capabilities instead of catch-all-ing the list |
| 45 | // calls: a server without the capability reports "none", while a real |
| 46 | // transport/protocol failure propagates to the outer catch and is |
| 47 | // surfaced as a probe error (not silently collapsed to []). |
| 48 | const resources = client.capabilities.resources |
| 49 | ? (await client.resources()).map((x) => x.uri) |
| 50 | : [] |
| 51 | const prompts = client.capabilities.prompts |
| 52 | ? (await client.prompts()).map((x) => x.name) |
| 53 | : [] |
| 54 | return { name, connected: true, tools, resources, prompts } |
| 55 | } finally { |
| 56 | await client.close() |
| 57 | } |
| 58 | } catch (error) { |
| 59 | return { |
| 60 | name, |
| 61 | connected: false, |
| 62 | tools: [], |
| 63 | resources: [], |
| 64 | prompts: [], |
| 65 | error: error instanceof Error ? error.message : String(error), |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | export const Route = createFileRoute('/api/mcp-status')({ |
| 71 | server: { |
no test coverage detected