( app: ToolsRouteHost, ix: IInstantiationService, )
| 52 | } |
| 53 | |
| 54 | export function registerToolsRoutes( |
| 55 | app: ToolsRouteHost, |
| 56 | ix: IInstantiationService, |
| 57 | ): void { |
| 58 | // GET /tools ---------------------------------------------------------- |
| 59 | const listToolsRoute = defineRoute( |
| 60 | { |
| 61 | method: 'GET', |
| 62 | path: '/tools', |
| 63 | querystring: listToolsQuerySchema, |
| 64 | success: { data: listToolsResponseSchema }, |
| 65 | description: 'List available tools', |
| 66 | tags: ['tools'], |
| 67 | }, |
| 68 | async (req, reply) => { |
| 69 | try { |
| 70 | const tools = await ix.invokeFunction((a) => |
| 71 | a.get(IToolService).list(req.query.session_id), |
| 72 | ); |
| 73 | reply.send(okEnvelope({ tools }, req.id)); |
| 74 | } catch (err) { |
| 75 | sendMappedError(reply, req.id, err); |
| 76 | } |
| 77 | }, |
| 78 | ); |
| 79 | app.get( |
| 80 | listToolsRoute.path, |
| 81 | listToolsRoute.options, |
| 82 | listToolsRoute.handler as Parameters<ToolsRouteHost['get']>[2], |
| 83 | ); |
| 84 | |
| 85 | // GET /mcp/servers ---------------------------------------------------- |
| 86 | const listMcpServersRoute = defineRoute( |
| 87 | { |
| 88 | method: 'GET', |
| 89 | path: '/mcp/servers', |
| 90 | success: { data: listMcpServersResponseSchema }, |
| 91 | description: 'List configured MCP servers', |
| 92 | tags: ['tools'], |
| 93 | }, |
| 94 | async (req, reply) => { |
| 95 | try { |
| 96 | const servers = await ix.invokeFunction((a) => a.get(IMcpService).list()); |
| 97 | reply.send(okEnvelope({ servers }, req.id)); |
| 98 | } catch (err) { |
| 99 | sendMappedError(reply, req.id, err); |
| 100 | } |
| 101 | }, |
| 102 | ); |
| 103 | app.get( |
| 104 | listMcpServersRoute.path, |
| 105 | listMcpServersRoute.options, |
| 106 | listMcpServersRoute.handler as Parameters<ToolsRouteHost['get']>[2], |
| 107 | ); |
| 108 | |
| 109 | // POST /mcp/servers/{mcp_server_id}:restart --------------------------- |
| 110 | const restartMcpServerRoute = defineRoute( |
| 111 | { |
no test coverage detected