Claude Code disconnects 'infrastructure' MCP server after successful initialization
Resolved 💬 3 comments Opened Oct 6, 2025 by bharris52468 Closed Oct 10, 2025
Description
Claude Code successfully initializes an MCP server but then immediately disconnects it. This only happens with a server named 'infrastructure', not with an identically-structured server named 'documentation'.
Behavior
- Working Server: 'documentation' MCP server connects and stays connected
- Failing Server: 'infrastructure' MCP server completes MCP handshake but disconnects immediately after initialization
- Both servers use identical structure and minimal implementation (70 lines)
- The infrastructure server works correctly in manual testing outside Claude Code
Steps to Reproduce
- Create minimal MCP server named 'infrastructure' with structure identical to working 'documentation' server
- Configure in managed-mcp.json
- Start Claude Code session
- Observe server connects during initialization but disconnects immediately
Environment
- Claude Code version: Latest (as of 2025-10-06)
- Server type: MCP server using mcp.server.stdio
- Python version: 3.x
- Server code: 70 lines, minimal implementation with single resource
Configuration
// /etc/claude-code/managed-mcp.json (currently only has working 'documentation' server)
{
"mcpServers": {
"documentation": {
"command": "/home/bharris52468/mcp-servers/documentation/venv/bin/python",
"args": ["/home/bharris52468/mcp-servers/documentation/server.py"],
"env": {
"DOCS_BASE_PATH": "/home/bharris52468/projects/documentation"
}
}
}
}
Minimal Server Implementation
#!/usr/bin/env python3
"""
Minimal Infrastructure MCP Server
Single resource: IT13 systemd service list
"""
import asyncio
import subprocess
from mcp.server import Server
from mcp.server.stdio import stdio_server
from mcp.types import Resource, TextContent
# Initialize server
server = Server("infrastructure")
@server.list_resources()
async def list_resources() -> list[Resource]:
"""List available infrastructure resources."""
return [
Resource(
uri="infra://it13/services",
name="IT13 Systemd Services",
mimeType="text/plain",
description="List of systemd services on IT13",
)
]
@server.read_resource()
async def read_resource(uri: str) -> str:
"""Read infrastructure resource content."""
if uri == "infra://it13/services":
try:
result = subprocess.run(
["systemctl", "list-units", "--type=service", "--all", "--no-pager"],
capture_output=True,
text=True,
timeout=10,
)
return result.stdout
except subprocess.TimeoutExpired:
return "ERROR: systemctl command timed out"
except Exception as e:
return f"ERROR: {e}"
raise ValueError(f"Unknown resource: {uri}")
async def main():
"""Run the MCP server."""
async with stdio_server() as (read_stream, write_stream):
await server.run(
read_stream,
write_stream,
server.create_initialization_options(),
)
if __name__ == "__main__":
asyncio.run(main())
Expected Behavior
Server should remain connected after initialization, just like the 'documentation' server.
Actual Behavior
Server disconnects immediately after completing MCP handshake with Claude Code.
Additional Notes
- Manual testing shows the server initializes successfully
- The 'documentation' server with identical structure works correctly
- Issue appears specific to server name 'infrastructure' or some interaction with Claude Code's server management
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗