An adapter library for Model Context Protocol (MCP) SSE servers to connect as stdio.
AnyMCP provides a bridge between SSE-based (Server-Sent Events) MCP servers and standard input/output (stdio). It allows you to connect to remote model servers that implement MCP over SSE and interact with them using traditional stdio interfaces.
- Connect to MCP servers via SSE endpoints
- Bridge SSE communication to standard input/output
- Maintain persistent connections with automatic reconnection
- Support for authentication via bearer tokens
- Comprehensive logging with adjustable verbosity
- Configurable timeouts and heartbeat intervals
This package is meant to be used with Arcee AnyMCP. Arcee AnyMCP makes it super easy to deploy your own MCP servers.
pip install anymcp
git clone https://github.com/arcee-ai/anymcp.git
cd anymcp
pip install -e .
Connect to an SSE-based MCP server:
anymcp connect http://localhost:8000/sse
With authentication:
anymcp connect http://localhost:8000/sse --token YOUR_AUTH_TOKEN
Add custom headers:
anymcp connect http://localhost:8000/sse --header "X-Custom-Header=Value"
Enable debug logging:
anymcp connect http://localhost:8000/sse --debug
Use AnyMCP in your Python applications:
import asyncio
from anymcp import connect_sse_as_stdio
async def main():
async with connect_sse_as_stdio(
sse_url="http://localhost:8000/sse",
token="YOUR_AUTH_TOKEN",
timeout=5.0,
sse_read_timeout=300.0
) as (reader, writer):
# Now your application can communicate with the MCP server
# through reader and writer streams
pass
if __name__ == "__main__":
asyncio.run(main())
# Install in development mode
pip install -e ".[dev]"
make test
# Format code
make style
# Check code quality
make quality
# Build package
make pip
# Upload to PyPI
make pip-upload
# Build Docker image
make docker-buildx
# Build and push Docker image
make docker-buildx-push
Contributions are welcome! Please feel free to submit a Pull Request.