Skip to content

Reload one connector's tools without walking the whole registry - #1773

Merged
helpcodeai merged 2 commits into
mainfrom
fix/registry-reload-by-connector
Nov 17, 2026
Merged

helpcodeai merged 2 commits into
mainfrom
fix/registry-reload-by-connector

Conversation

@helpcodeai

Copy link
Copy Markdown
Contributor

Summary

Every connector reload walked the whole tool registry. Toggling one tool in the dashboard reloads its connector, and so does the registry catch-up after a deploy or an ops step. On a large Cloud registry (316k tools), each reload ran three passes over all tools of all organizations: getAllTools().filter, the unregisterConnectorTools loop, and a full rebuild of the name index. A burst of toggles (13 in a minute) or a catch-up of a few hundred connectors held the event loop long enough to slow every /mcp request for minutes.

A reload now only touches the connector it reloads.

Changes

  • unregisterConnectorTools reads the connector's tools from the per-connector index that already exists. It removes each tool from the other indexes one by one instead of rebuilding the name index.
  • The name index is now a Map per name, like the org and connector indexes. Removing one tool from a name that thousands of installs of a catalog adapter share costs O(1). Lookups (getTool, getToolForOrg, countByName) keep the same first-registered order.
  • When a tool is registered again under the same id, it replaces its entry in the name index instead of adding a second one. Before, countByName counted the tool twice and getTool kept returning the old object until the next unregister.
  • reloadConnectorTools uses getToolsForConnectors([id]) instead of getAllTools().filter.
  • countByConnector, used by the catch-up, reads the index sizes.

Behaviour is the same in Cloud and self-hosted. Self-hosted registries are small, so the gain there is minor.

Type

  • Bug fix
  • New feature
  • Documentation
  • Refactoring
  • Performance improvement
  • Other (describe below)

Testing

  • Added/updated unit tests
  • Tested manually (describe steps below)
  • No tests needed (explain why)

New tests in tool-registry.spec.ts:

  • a re-registered id keeps a single name entry and returns the new object;
  • a rename moves the tool to the new name;
  • other connectors under a shared name keep their order after an unregister;
  • countByConnector reads from the index;
  • a timing guard: 100 reloads of one connector in a registry of 200k tools spread over 20k connectors.

On this machine the timing guard takes 1 ms. The old code took 1,045 ms for the same test and fails the 250 ms limit, together with the two tests on re-registration.

Commands, all in packages/backend, on a fresh npm ci with Prisma generated:

  • npx tsc --noEmit -p tsconfig.json: no errors.
  • npm run lint: no changes.
  • npx jest src/mcp-server src/mcp-servers src/connectors/tools --maxWorkers=4: 55 suites passed, 3 skipped; 1,228 tests passed, 43 skipped.

Checklist

  • My code follows the existing code style
  • I have tested my changes locally
  • I have updated documentation (if applicable)
  • All existing tests pass (npm test): the full suite runs in CI
  • This PR has a descriptive title

Related Issues

None.

@helpcodeai
helpcodeai enabled auto-merge (squash) November 17, 2026 17:06
@helpcodeai
helpcodeai merged commit d45c8e0 into main Nov 17, 2026
16 checks passed
@helpcodeai
helpcodeai deleted the fix/registry-reload-by-connector branch November 17, 2026 17:30
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant