Skip to main content
Glama
index.ts2.93 kB
import type { Services } from '../services.js'; import { ToolError, type ToolResult } from './types.js'; import { handlePlan } from './plan-handler.js'; import { handleRequirement } from './requirement-handler.js'; import { handleSolution } from './solution-handler.js'; import { handleDecision } from './decision-handler.js'; import { handlePhase } from './phase-handler.js'; import { handleArtifact } from './artifact-handler.js'; import { handleLink } from './link-handler.js'; import { handleQuery } from './query-handler.js'; import { handleBatch } from './batch-handler.js'; // Re-export types and utilities export { ToolError, createSuccessResponse, type ToolResult, type HandlerFn } from './types.js'; // Re-export individual handlers export { handlePlan } from './plan-handler.js'; export { handleRequirement } from './requirement-handler.js'; export { handleSolution } from './solution-handler.js'; export { handleDecision } from './decision-handler.js'; export { handlePhase } from './phase-handler.js'; export { handleArtifact } from './artifact-handler.js'; export { handleLink } from './link-handler.js'; export { handleQuery } from './query-handler.js'; export { handleBatch } from './batch-handler.js'; // Unified handleToolCall for backward compatibility with tests export async function handleToolCall( name: string, args: Record<string, unknown>, services: Services ): Promise<ToolResult> { try { switch (name) { case 'plan': return await handlePlan(args as { action: string; [key: string]: unknown }, services); case 'requirement': return await handleRequirement(args as { action: string; [key: string]: unknown }, services); case 'solution': return await handleSolution(args as { action: string; [key: string]: unknown }, services); case 'decision': return await handleDecision(args as { action: string; [key: string]: unknown }, services); case 'phase': return await handlePhase(args as { action: string; [key: string]: unknown }, services); case 'artifact': return await handleArtifact(args as { action: string; [key: string]: unknown }, services); case 'link': return await handleLink(args as { action: string; [key: string]: unknown }, services); case 'query': return await handleQuery(args as { action: string; [key: string]: unknown }, services); case 'batch': return await handleBatch(args as { planId: string; operations: unknown[] }, services); default: throw new ToolError('MethodNotFound', `Unknown tool: ${name}`); } } catch (error) { if (error instanceof ToolError) { throw error; } // Handle various error types safely const message = error instanceof Error ? (error.message !== '' ? error.message : 'Error without message') : 'Unknown error'; throw new ToolError('InternalError', message); } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cppmyjob/cpp-mcp-planner'

If you have feedback or need assistance with the MCP directory API, please join our Discord server