Skip to main content

An adapter library for Model Context Protocol (MCP) SSE servers to connect as stdio

Project description

AnyMCP

An adapter library for Model Context Protocol (MCP) SSE servers to connect as stdio.

Overview

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.

Features

  • 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.

Installation

Using pip

pip install anymcp

From source

git clone https://github.com/arcee-ai/anymcp.git
cd anymcp
pip install -e .

Usage

Command Line Interface

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

Python API

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())

Development

Setup

# Install in development mode
pip install -e ".[dev]"

Running Tests

make test

Code Quality

# Format code
make style

# Check code quality
make quality

Building

# Build package
make pip

# Upload to PyPI
make pip-upload

Docker

# Build Docker image
make docker-buildx

# Build and push Docker image
make docker-buildx-push

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

anymcp-0.0.2.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

anymcp-0.0.2-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file anymcp-0.0.2.tar.gz.

File metadata

  • Download URL: anymcp-0.0.2.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for anymcp-0.0.2.tar.gz
Algorithm Hash digest
SHA256 a39f15f72c74bd2a01b3eed63de757e018a0a9574c1ddfb47654d3233936cff3
MD5 4e351b9ead426a4397fce85cb65e2b8d
BLAKE2b-256 b8cc8a41399e153c4b2d6b9d23f223c893975dd289cd8df3df28b0179dccff3e

See more details on using hashes here.

File details

Details for the file anymcp-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: anymcp-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for anymcp-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1d8c67e02c395f18420554dea170726f722b8925523e751dc23889829446889b
MD5 fb9eb0de7962624f76df3efd9e907fbf
BLAKE2b-256 212e3c1968115fe5269fe66e7ba11596aa6b7c28cb96602088734c5128e92e0c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page