mcp-http-transport
HTTP/SSE transport for MCP servers with hot reload support
🎯 Problem Solved
When developing MCP servers, every code change requires restarting Claude Desktop. This breaks:
- ❌ Your conversation context
- ❌ Your development flow
- ❌ Your productivity (>1 minute per iteration)
With mcp-http-transport:
- ✅ Hot reload without Claude Desktop restart
- ✅ Automatic reconnection on server restart
- ✅ Development cycle < 5 seconds
- ✅ Zero modification to your MCP handlers
🚀 Quick Start
Installation
pip install mcp-http-transport
Basic Usage
import os
from mcp.server import Server
from mcp_http_transport import MCPTransportManager
# Your existing MCP server
server = Server("my-mcp-server")
@server.list_tools()
async def list_tools():
return [...] # Your tools
@server.call_tool()
async def call_tool(name, arguments):
return [...] # Your handlers
# Add transport layer (NO changes to handlers!)
async def main():
transport = MCPTransportManager(
server=server,
transport_mode=os.getenv("MCP_TRANSPORT", "stdio"),
host=os.getenv("MCP_HTTP_HOST", "localhost"),
port=int(os.getenv("MCP_HTTP_PORT", "3000")),
)
await transport.start()
if __name__ == "__main__":
import asyncio
asyncio.run(main())
Configuration
.env file:
# Transport mode: "stdio" (default) or "http"
MCP_TRANSPORT=http
MCP_HTTP_HOST=localhost
MCP_HTTP_PORT=3000
Claude Desktop config:
{
"mcpServers": {
"my-server": {
"url": "http://localhost:3000/sse"
}
}
}
That's it! Now when you modify your code:
- Watchdog detects change → restarts server
- Claude Desktop reconnects automatically
- No manual restart needed!
📚 Documentation
Transport Modes
| Mode | Use Case | Pros | Cons |
|---|---|---|---|
| stdio (default) | Production | Simple, minimal overhead | No hot reload |
| http | Development | Hot reload, auto-reconnect | Requires port |
Environment Variables
MCP_TRANSPORT:"stdio"or"http"(default:"stdio")MCP_HTTP_HOST: HTTP server host (default:"localhost")MCP_HTTP_PORT: HTTP server port (default:3000)
With Watchdog (Hot Reload)
Install watchdog:
pip install watchdog
Create wrapper script (mcp-server-wrapper.sh):
#!/bin/bash
cd /path/to/your/project
if [ "$MCP_DEV_MODE" = "1" ]; then
echo "[MCP] Dev mode - auto-reload enabled"
exec python -m watchdog.watchmedo auto-restart \
-d your_package \
-p "*.py" \
-R \
--interval 1.0 \
--debounce-interval 0.5 \
-- python -m your_package.mcp_server
else
exec python -m your_package.mcp_server
fi
Claude Desktop config:
{
"mcpServers": {
"my-server": {
"command": "/path/to/mcp-server-wrapper.sh",
"env": {
"MCP_DEV_MODE": "1",
"MCP_TRANSPORT": "http",
"MCP_HTTP_PORT": "3000"
}
}
}
}
🏗️ Architecture
┌─────────────────┐
│ Claude Desktop │
└────────┬────────┘
│
├─── stdio (default)
│ └─> stdin/stdout pipes
│
└─── http (dev)
├─> GET /sse (Server-Sent Events)
└─> POST /messages/ (JSON-RPC)
HTTP/SSE Flow:
- Client:
GET http://localhost:3000/sse→ establishes SSE stream - Client:
POST http://localhost:3000/messages/→ sends JSON-RPC requests - Server: responds via SSE stream
- Watchdog restarts server → Client reconnects automatically
🔧 Advanced Usage
Multiple MCP Servers
Run multiple MCP servers on different ports:
{
"mcpServers": {
"server-1": {
"url": "http://localhost:3000/sse"
},
"server-2": {
"url": "http://localhost:3001/sse"
}
}
}
Custom Host/Port
transport = MCPTransportManager(
server=server,
transport_mode="http",
host="0.0.0.0", # Listen on all interfaces
port=8080,
)
Switching Back to Stdio
Just remove or change the environment variable:
# Back to stdio (production)
MCP_TRANSPORT=stdio
Or omit it entirely (defaults to stdio).
🧪 Testing
# Install dev dependencies
pip install mcp-http-transport[dev]
# Run tests
pytest
# With coverage
pytest --cov=mcp_http_transport
🤝 Contributing
Contributions welcome! This package was extracted from a real-world MCP server to benefit the community.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
📄 License
MIT License - see LICENSE file for details.
🙏 Credits
- Built for MCP (Model Context Protocol)
- Inspired by real-world pain points in MCP development
- Uses Starlette and Uvicorn
⚠️ Known Issues (v0.2.0)
Compatibility with mcp-remote
Status: The HTTP/SSE server implementation is not yet fully compatible with mcp-remote (the official Node.js proxy).
Symptoms:
mcp-remotefails with SSE header errors- POST endpoint works (HTTP 202) but connection drops
Workaround:
- Use stdio transport (default) for Claude Desktop
- Use
mcp-stdio-proxy(Python) when available - Or implement your own client that follows MCP HTTP/SSE spec
Contributing: We welcome PRs to fix compatibility! See the repository for details.
🐛 Troubleshooting
Port Already in Use
# Find process using port
lsof -ti:3000
# Kill process
lsof -ti:3000 | xargs kill -9
# Or use different port
MCP_HTTP_PORT=3001
Claude Desktop Not Reconnecting
Cause: SSE retry delay (2-5s is normal)
Solution: Wait a few seconds after server restart. Claude Desktop will show "Reconnecting..." then connect automatically.
HTTP Mode Not Working
Check:
- Server logs:
tail -f /tmp/mcp-server-debug.log - Test endpoint:
curl http://localhost:3000/sse - Verify Claude Desktop config has correct URL
📊 Comparison
| Feature | stdio | http |
|---|---|---|
| Setup | Simple | Medium |
| Hot Reload | ❌ | ✅ |
| Auto-Reconnect | ❌ | ✅ |
| Production Ready | ✅ | ⚠️ Dev only |
| Multi-client | ❌ | ✅ |
| Overhead | Minimal | Very Low |
Made with ❤️ for the MCP community
If this package saves you time, consider ⭐ starring the repo!
Metadata
Release files for mcp-http-transport 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| mcp_http_transport-0.2.0.tar.gz | 6.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mcp_http_transport-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.5 kB
Release files / mcp_http_transport-0.2.0.tar.gz
| Download URL | mcp_http_transport-0.2.0.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
768549ef16c209740320da63eecfcd6c8bb20fded89d2d5ecfccc7c57e0a6320
|
|
BLAKE2b-256 checksum How to use checksums |
58842e6dd7fd4901e4c721a6068a0dd18f1259e906f46daf81653d360da9c77a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.11
|
Release files / mcp_http_transport-0.2.0-py3-none-any.whl
| Download URL | mcp_http_transport-0.2.0-py3-none-any.whl |
|---|---|
| Size | 7.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e4c9df3f3318b242675c2332bf415c423fe4e66c222863826c25f086c217d9b8
|
|
BLAKE2b-256 checksum How to use checksums |
c8455ca5f1c4a1f3e5c268b6290d8f32fbf9bc2f7e7a0fa38cdaa06e68314e5f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.11
|
Security for mcp-http-transport 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.