MCPcopy Create free account
hub / github.com/anus-dev/ANUS / discoverToolsForServer

Method discoverToolsForServer

packages/core/src/tools/tool-registry.ts:262–284  ·  view source on GitHub ↗

* Discover or re-discover tools for a single MCP server. * @param serverName - The name of the server to discover tools from.

(serverName: string)

Source from the content-addressed store, hash-verified

260 * @param serverName - The name of the server to discover tools from.
261 */
262 async discoverToolsForServer(serverName: string): Promise<void> {
263 // Remove any previously discovered tools from this server
264 for (const [name, tool] of this.tools.entries()) {
265 if (tool instanceof DiscoveredMCPTool && tool.serverName === serverName) {
266 this.tools.delete(name);
267 }
268 }
269
270 this.config.getPromptRegistry().removePromptsByServer(serverName);
271
272 const mcpServers = this.config.getMcpServers() ?? {};
273 const serverConfig = mcpServers[serverName];
274 if (serverConfig) {
275 await discoverMcpTools(
276 { [serverName]: serverConfig },
277 undefined,
278 this,
279 this.config.getPromptRegistry(),
280 this.config.getDebugMode(),
281 this.config.getWorkspaceContext(),
282 );
283 }
284 }
285
286 private async discoverAndRegisterToolsFromCommand(): Promise<void> {
287 const discoveryCmd = this.config.getToolDiscoveryCommand();

Callers 1

mcpCommand.tsFile · 0.80

Calls 6

discoverMcpToolsFunction · 0.85
removePromptsByServerMethod · 0.80
getPromptRegistryMethod · 0.80
getMcpServersMethod · 0.80
getDebugModeMethod · 0.80
getWorkspaceContextMethod · 0.80

Tested by

no test coverage detected