Metadata-Version: 2.4
Name: asyncmcp
Version: 0.1.1
Summary: Async MCP Transport layer for queue and async based systems
Project-URL: Homepage, https://github.com/bh-rat/asyncmcp
Project-URL: Repository, https://github.com/bh-rat/asyncmcp
Project-URL: Documentation, https://github.com/bh-rat/asyncmcp#readme
Project-URL: Bug Tracker, https://github.com/bh-rat/asyncmcp/issues
Project-URL: Changelog, https://github.com/bh-rat/asyncmcp/blob/main/CHANGELOG.md
Author-email: Bharat Geleda <bharatgeleda@gmail.com>
License: Apache-2.0
License-File: LICENSE
Keywords: async,automation,aws,llm,mcp,queue,sns,sqs
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Communications
Classifier: Topic :: Internet
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Distributed Computing
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: anyio>=4.9.0
Requires-Dist: boto3<2.0.0,>=1.38.36
Requires-Dist: mcp<2.0.0,>=1.9.4
Requires-Dist: mypy>=1.16.1
Requires-Dist: orjson<4.0.0,>=3.10.0
Provides-Extra: aws
Requires-Dist: awscli<2.0.0,>=1.40.35; extra == 'aws'
Provides-Extra: cli
Requires-Dist: python-dotenv>=1.0.0; extra == 'cli'
Requires-Dist: typer>=0.12.4; extra == 'cli'
Provides-Extra: dev
Requires-Dist: localstack<5.0.0,>=4.5.0; extra == 'dev'
Provides-Extra: rich
Requires-Dist: rich>=13.9.4; extra == 'rich'
Description-Content-Type: text/markdown

# asyncmcp - Async transport layers for MCP 


[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
[![Python Version](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/downloads/)


---

## Overview


A regular MCP Server but working over queues :


Quoting from the [official description](https://modelcontextprotocol.io/introduction) :<br/> 
> MCP is an open protocol that standardizes how applications provide context to LLMs.

But a lot of this context is not always readily available and takes time for the applications to process - think batch processing APIs, webhooks or queues. <br/> 
In these cases, the MCP server would have to expose a light-weight polling wrapper in the MCP layer to wait for the tasks to be done.

asyncmcp explores supporting these async transport layer implementations for MCP clients and servers, beyond the officially supported stdio and HTTP Streamable transports. 

The whole idea of an **MCP server with async transport layer** is that it doesn't have to respond immediately to any requests. It can choose to direct them to internal queues for processing and the client doesn't have to stick around for the response.

## Current capabilities

### Transport layer : sns-sqs

- Server : Transport layer that listens to a queue for MCP requests and writes the responses to a topic
- Client : Transport layer that writes requests to a topic and listens to a queue for responses

## Installation and Usage

```bash
# Using uv (recommended)
uv add asyncmcp
```

```bash
# Using pip  
pip install asyncmcp
```

### Basic server setup

Note : we don't support FastMCP yet. The examples in this repo uses the [basic way of creating MCP servers and client](https://modelcontextprotocol.io/docs/concepts/architecture#implementation-example) 
<br/>
Here’s a basic example of implementing an MCP server which supports sns-sqs as the transport layer:

```python
import boto3
from asyncmcp.sns_sqs.server import sns_sqs_server, SnsSqsTransportConfig

# Configure transport
config = SnsSqsTransportConfig(
    sqs_queue_url="https://sqs.region.amazonaws.com/account/service-queue",
    sns_topic_arn="arn:aws:sns:region:account:mcp-responses",
    sqs_client=boto3.client('sqs'),
    sns_client=boto3.client('sns')
)  # more configurable params available.


async def main():
    async with sns_sqs_server(config) as (read_stream, write_stream):
        # Your MCP server logic here
        pass
```

### Basic client setup

Here’s a basic example of implementing an MCP client which supports sns-sqs as the transport layer:

```python
import boto3
from asyncmcp.sns_sqs.client import sns_sqs_client
from asyncmcp import SnsSqsTransportConfig

# Configure transport
config = SnsSqsTransportConfig(
    sqs_queue_url="https://sqs.region.amazonaws.com/account/client-queue",
    sns_topic_arn="arn:aws:sns:region:account:mcp-requests",
    sqs_client=boto3.client('sqs'),
    sns_client=boto3.client('sns')
)  # more configurable params available.


async def main():
    async with sns_sqs_client(config) as (read_stream, write_stream):
        # Your MCP client logic here
        pass
```

You can check full examples at `/examples/website_server.py` and `/examples/website_client.py`. 
<br/>
Read more at `/examples/README.md`

## Limitations

- **Message Size**: For SQS - message size limits are applicable (256KB standard, 2MB extended)
- **Response Handling**: Async nature means responses may not be immediate
- **Session Context**: Storage mechanism handled by server application, not transport
- **Ordering**: Standard SQS doesn't guarantee message ordering

## Testing

### Unit Tests

```bash
uv run pytest
```



## Contributing

We welcome contributions and discussions about async MCP architectures!

### Development Setup

```bash
git clone https://github.com/bharatgeleda/asyncmcp.git
cd asyncmcp
uv sync
```

---

## License

Apache License 2.0 - see [LICENSE](LICENSE) file for details.

## Links

- **MCP Specification**: [https://spec.modelcontextprotocol.io](https://spec.modelcontextprotocol.io)
