Use simple name for MCP tools where possible. (#4459)

This commit is contained in:
Tommaso Sciortino
2025-07-18 14:29:09 -07:00
committed by GitHub
parent d7041a6595
commit b5f5ea2c31
6 changed files with 96 additions and 176 deletions

View File

@@ -18,7 +18,7 @@ type ToolParams = Record<string, unknown>;
export class DiscoveredTool extends BaseTool<ToolParams, ToolResult> {
constructor(
private readonly config: Config,
readonly name: string,
name: string,
readonly description: string,
readonly parameterSchema: Record<string, unknown>,
) {
@@ -138,10 +138,14 @@ export class ToolRegistry {
*/
registerTool(tool: Tool): void {
if (this.tools.has(tool.name)) {
// Decide on behavior: throw error, log warning, or allow overwrite
console.warn(
`Tool with name "${tool.name}" is already registered. Overwriting.`,
);
if (tool instanceof DiscoveredMCPTool) {
tool = tool.asFullyQualifiedTool();
} else {
// Decide on behavior: throw error, log warning, or allow overwrite
console.warn(
`Tool with name "${tool.name}" is already registered. Overwriting.`,
);
}
}
this.tools.set(tool.name, tool);
}