( toolManifest: ToolManifestEntry, toolModule: ImportedToolModule, )
| 295 | } |
| 296 | |
| 297 | function registerToolFromManifest( |
| 298 | toolManifest: ToolManifestEntry, |
| 299 | toolModule: ImportedToolModule, |
| 300 | ): void { |
| 301 | if (!server) { |
| 302 | throw new Error('Tool registry has not been initialized.'); |
| 303 | } |
| 304 | |
| 305 | const toolName = toolManifest.names.mcp; |
| 306 | if (registryState.tools.has(toolName)) { |
| 307 | return; |
| 308 | } |
| 309 | |
| 310 | const outputSchema = toolManifest.outputSchema |
| 311 | ? getMcpOutputSchemaForRegistration(toolManifest.outputSchema) |
| 312 | : undefined; |
| 313 | |
| 314 | const registeredTool = server.registerTool( |
| 315 | toolName, |
| 316 | { |
| 317 | description: toolManifest.description ?? '', |
| 318 | inputSchema: toolModule.schema, |
| 319 | ...(outputSchema ? { outputSchema } : {}), |
| 320 | annotations: toolManifest.annotations, |
| 321 | }, |
| 322 | (args: unknown): Promise<ToolResponse> => invokeRegisteredTool(toolName, toolModule, args), |
| 323 | ); |
| 324 | registryState.tools.set(toolName, registeredTool); |
| 325 | } |
| 326 | |
| 327 | function shouldExposeTool( |
| 328 | toolManifest: ToolManifestEntry, |
no test coverage detected