Repository navigation
Reload one connector's tools without walking the whole registry - #1773
Merged
Merged
Conversation
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
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, theunregisterConnectorToolsloop, 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/mcprequest for minutes.A reload now only touches the connector it reloads.
Changes
unregisterConnectorToolsreads 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.Mapper 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.countByNamecounted the tool twice andgetToolkept returning the old object until the next unregister.reloadConnectorToolsusesgetToolsForConnectors([id])instead ofgetAllTools().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
Testing
New tests in
tool-registry.spec.ts:countByConnectorreads from the index;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 freshnpm ciwith 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
npm test): the full suite runs in CIRelated Issues
None.