MCPcopy Create free account
hub / github.com/arctic-cli/interface / tools

Function tools

packages/arctic/src/mcp/index.ts:388–418  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

386 }
387
388 export async function tools() {
389 const result: Record<string, Tool> = {}
390 const s = await state()
391 const clientsSnapshot = await clients()
392
393 for (const [clientName, client] of Object.entries(clientsSnapshot)) {
394 // Only include tools from connected MCPs (skip disabled ones)
395 if (s.status[clientName]?.status !== "connected") {
396 continue
397 }
398
399 const tools = await client.tools().catch((e) => {
400 log.error("failed to get tools", { clientName, error: e.message })
401 const failedStatus = {
402 status: "failed" as const,
403 error: e instanceof Error ? e.message : String(e),
404 }
405 s.status[clientName] = failedStatus
406 delete s.clients[clientName]
407 })
408 if (!tools) {
409 continue
410 }
411 for (const [toolName, tool] of Object.entries(tools)) {
412 const sanitizedClientName = clientName.replace(/[^a-zA-Z0-9_-]/g, "_")
413 const sanitizedToolName = toolName.replace(/[^a-zA-Z0-9_-]/g, "_")
414 result[sanitizedClientName + "_" + sanitizedToolName] = tool
415 }
416 }
417 return result
418 }
419
420 /**
421 * Start OAuth authentication flow for an MCP server.

Callers

nothing calls this directly

Calls 2

stateFunction · 0.85
clientsFunction · 0.85

Tested by

no test coverage detected