* Create all tool handlers * * Creates handlers for publicly exposed tools: * - chat_with_addie * - Directory tools (list_members, list_agents, etc.) * - Evaluation tools (probe, compliance, RFP, IO execution) * - Agent context tools (save_agent, list_saved_agents, remove_saved_agent) * - Val
()
| 99 | * - Validation tools (validate_json, get_schema, validate_adagents) |
| 100 | */ |
| 101 | function createAllHandlers() { |
| 102 | const handlers = new Map<string, (args: Record<string, unknown>, authContext?: MCPAuthContext) => Promise<unknown>>(); |
| 103 | |
| 104 | // Directory tool handlers use the existing MCPToolHandler |
| 105 | const directoryHandler = new MCPToolHandler(); |
| 106 | for (const tool of TOOL_DEFINITIONS) { |
| 107 | handlers.set(tool.name, async (args, auth) => { |
| 108 | return directoryHandler.handleToolCall(tool.name, args, auth); |
| 109 | }); |
| 110 | } |
| 111 | |
| 112 | // Chat tool handler (conversational AI wrapper) |
| 113 | const chatHandlers = createChatToolHandler(); |
| 114 | for (const [name, handler] of chatHandlers) { |
| 115 | handlers.set(name, async (args, auth) => { |
| 116 | const result = await handler(args, auth); |
| 117 | return { content: [{ type: 'text', text: result }] }; |
| 118 | }); |
| 119 | } |
| 120 | |
| 121 | // Member tools (eval + agent context) — need per-request auth bridging |
| 122 | const memberToolDefs = [...EVAL_TOOL_DEFINITIONS, ...AGENT_CONTEXT_TOOL_DEFINITIONS]; |
| 123 | for (const tool of memberToolDefs) { |
| 124 | handlers.set(tool.name, createMemberToolHandler(tool.name)); |
| 125 | } |
| 126 | |
| 127 | // Stateless tools (schema + property validation) — created once |
| 128 | const statelessHandlers = createStatelessToolHandlers(); |
| 129 | for (const [name, handler] of statelessHandlers) { |
| 130 | handlers.set(name, async (args) => handler(args)); |
| 131 | } |
| 132 | |
| 133 | return { handlers, directoryHandler }; |
| 134 | } |
| 135 | |
| 136 | /** |
| 137 | * MCP Server instance with lazy initialization |
no test coverage detected