Tool Duplication in MCP SSE Server Connections Across Projects
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
- 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"
}
}
- 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"
}
}
- Open Claude Code in Project A - observe correct tool count (e.g., 2 tools)
- 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:
- SSE connections or their tool registrations persist when switching between projects
- Tool registry is not properly cleared when changing project contexts
- Session data in
~/.claude/projects/[encoded-path]/*.jsonlretains 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
- Ensure SSE connections are properly terminated when switching project contexts
- Clear tool registry when loading a new project's MCP configuration
- Prevent accumulation of tool definitions in session state files
- Add proper isolation between project MCP connections
This issue has 9 comments on GitHub. Read the full discussion on GitHub ↗