Skip to content

[Bug] disconnectMCP() permanently wipes all custom tools from the registry #1034

Closed

Description

@akramcodez

Description

Whenever an MCP server disconnects (due to a restart, shutdown, or crash), tool-manager.ts handles the cleanup by completely resetting the tool registry back to static defaults. It calls this.customTools.clear(), completely wiping out all user-defined custom tools. The only way to recover them is to restart Nanocoder.

Environment

  • OS: Any
  • Node version: Node 18+
  • Nanocoder version: 1.30.0
  • Provider: N/A
  • Model: N/A

Steps to Reproduce

  1. Start Nanocoder and ensure you have custom tools loaded in your workspace.
  2. Connect to an MCP server.
  3. Have the MCP server disconnect or explicitly disconnect it.
  4. Try to use your custom tools—they are gone.

Expected Behavior

Disconnecting from an MCP server should only unregister the MCP-provided tools, leaving workspace custom tools intact.

Actual Behavior

disconnectMCP() resets the entire registry to allToolExports (built-ins only) and clears this.customTools.

Additional Context

  • I have searched existing issues to ensure this is not a duplicate
  • I can reproduce this issue consistently
  • This issue occurs with the latest version of nanocoder

Implementation Notes

Fix in source/tools/tool-manager.ts lines 370-385. Remove this.registry = ToolRegistry.fromToolExports(...) and this.customTools.clear(). Only call this.registry.unregisterMany(mcpToolNames).

Activity

  1. added
    bug
    high-priority
    on Aug 29, 2026
  2. DeepamJha commented on Aug 30, 2026

    @DeepamJha
    Contributor

    Hey @akramcodez, happy to help with this one if it's still available. Could you assign it to me?

  3. added a commit that references this issue on Aug 30, 2026
    5b8c4a5
  4. added
    area:vscode
    on Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vscodebughigh-priority

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions