Tool Duplication in MCP SSE Server Connections Across Projects

Resolved 💬 9 comments Opened Jun 14, 2025 by joemocha Closed Dec 30, 2025

Bug Report: MCP SSE Server Tool Duplication in Claude Code

Summary

Claude Code exhibits tool duplication when the same MCP SSE server is configured across multiple projects. Tools from the MCP server accumulate rather than being properly isolated per project, resulting in duplicate tool listings.

Environment

  • Claude Code Version: Current (as of 2025-06-14)
  • OS: Linux 6.8.0-60-generic
  • MCP Server Type: SSE (Server-Sent Events)

Steps to Reproduce

  1. Configure an MCP SSE server in Project A (e.g., /home/foo/docker)

``json
"mcpServers": {
"context7": {
"type": "sse",
"url": "http://mcp.foo.dev/context7/sse"
}
}
``

  1. Configure the same MCP SSE server in Project B (e.g., /home/foo/workbook/a2a-platform)

``json
"mcpServers": {
"context7": {
"type": "sse",
"url": "http://mcp.foo.dev/context7/sse"
}
}
``

  1. Open Claude Code in Project A - observe correct tool count (e.g., 2 tools)
  2. Switch to Project B - observe duplicated tools (e.g., 4 tools instead of 2)

Expected Behavior

Each project should maintain isolated MCP connections. When switching projects, tools from the previous project's MCP servers should be cleared, and only the current project's MCP tools should be available.

Actual Behavior

Tools from MCP SSE servers persist across project sessions, causing duplicate tool registrations. The same server that correctly reports 2 tools shows 4 tools (2x duplication) in projects where the session state has accumulated.

Root Cause Analysis

The issue appears to be a session state management bug where:

  1. SSE connections or their tool registrations persist when switching between projects
  2. Tool registry is not properly cleared when changing project contexts
  3. Session data in ~/.claude/projects/[encoded-path]/*.jsonl retains duplicate tool information

Workaround

Clearing the session files resolves the issue temporarily:

rm ~/.claude/projects/[encoded-project-path]/*.jsonl

Technical Details

  • Configuration files (~/.claude.json) show correct, non-duplicated MCP server entries
  • The MCP server itself correctly reports the proper number of tools
  • The duplication occurs client-side in Claude Code's session management
  • Issue persists even after closing and reopening Claude Code sessions
  • Only affects SSE-type MCP servers (not confirmed for stdio-type)

Impact

This bug causes confusion as users see duplicate tools in the MCP tool list, potentially leading to:

  • Incorrect tool counts in the UI
  • Possible performance implications with duplicate SSE connections
  • User confusion about which tools are actually available

Suggested Fix

  1. Ensure SSE connections are properly terminated when switching project contexts
  2. Clear tool registry when loading a new project's MCP configuration
  3. Prevent accumulation of tool definitions in session state files
  4. Add proper isolation between project MCP connections

View original on GitHub ↗

This issue has 9 comments on GitHub. Read the full discussion on GitHub ↗