Dedupe MCP-registry tool names across orgs/connectors#152
Merged
Conversation
The upstream @rekog/mcp-nest McpRegistryService is single-tenant: it keys tools by name and warns 'already registered ... Overwriting' if the same name is registered twice. Our internal ToolRegistry is multi-tenant — same tool name can legitimately exist for multiple orgs (e.g. 3 customers each importing the Weclapp adapter) or for multiple connectors in the same org (e.g. 'Udyogi - PROD' and 'Param - Prod' exposing identical schemas). On boot we were emitting one warning per duplicate (12 lines on the production server). Functionally correct — the handler dispatches via getToolForOrg / getTool + connectorIds — but noisy. Now mcpRegistry.registerTool is called only when the name first appears in our ToolRegistry; subsequent registrations under the same name are skipped because the upstream registry already exposes one. On unload, mcpRegistry.removeTool is called only when the last tool with that name leaves our registry — otherwise we'd tear down a name another tenant still needs. Adds ToolRegistry.countByName(name) for O(1) lookups and a small test suite covering it.
6d3a3e6 to
ceee721
Compare
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Silences the `Dynamic tool 'X' already registered in module — Overwriting.` warnings emitted at boot by aligning our registration logic with the upstream library's single-tenant assumption.
Why
Production logs on `cloud.anythingmcp.com` showed 12 such warnings at startup, covering 8 unique tool names. Triage:
Our `ToolRegistry` already handles cross-tenant collisions correctly (`getToolForOrg`, `getTool(name, connectorIds)`). Only the upstream `@rekog/mcp-nest` `McpRegistryService` (single-tenant) was generating noise.
Change
Test plan