MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / registerToolsRoutes

Function registerToolsRoutes

packages/server/src/routes/tools.ts:54–161  ·  view source on GitHub ↗
(
  app: ToolsRouteHost,
  ix: IInstantiationService,
)

Source from the content-addressed store, hash-verified

52}
53
54export 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 {

Callers 1

registerApiV1RoutesFunction · 0.90

Calls 11

defineRouteFunction · 0.90
okEnvelopeFunction · 0.90
parseActionSuffixFunction · 0.90
errEnvelopeFunction · 0.90
sendMappedErrorFunction · 0.70
invokeFunctionMethod · 0.65
listMethod · 0.65
getMethod · 0.65
sendMethod · 0.65
restartMethod · 0.65
postMethod · 0.65

Tested by

no test coverage detected