MCPcopy Create free account
hub / github.com/TanStack/ai / probe

Function probe

examples/ts-react-chat/src/routes/api.mcp-status.ts:36–68  ·  view source on GitHub ↗
(
  name: string,
  makeTransport: () => Transport,
)

Source from the content-addressed store, hash-verified

34}
35
36async 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
70export const Route = createFileRoute('/api/mcp-status')({
71 server: {

Callers 1

api.mcp-status.tsFile · 0.70

Calls 5

createMCPClientFunction · 0.90
resourcesMethod · 0.80
promptsMethod · 0.80
closeMethod · 0.65
toolsMethod · 0.45

Tested by

no test coverage detected