### Run Basic SQS Example Source: https://asyncmcp.mintlify.app/guides/local-development Commands to run the basic SQS example for AsyncMCP. This involves starting a server and a client, both configured to use SQS for transport. ```bash # Terminal 1: Start server uv run examples/website_server.py --transport sqs # Terminal 2: Start client uv run examples/website_client.py --transport sqs ``` -------------------------------- ### Run Webhook Example Source: https://asyncmcp.mintlify.app/guides/local-development Commands to run the webhook example for AsyncMCP. This involves starting a server and a client with specified ports for communication. ```bash # Terminal 1: Start server uv run examples/webhook_server.py --server-port 8000 # Terminal 2: Start client uv run examples/webhook_client.py --server-port 8000 --webhook-port 8001 ``` -------------------------------- ### Running AsyncMCP Examples - Setup Resources Source: https://asyncmcp.mintlify.app/examples/basic-examples Command to run a setup script that configures necessary resources, likely for the SQS queues used by the proxy example. ```bash uv run examples/setup.py ``` -------------------------------- ### Start LocalStack Source: https://asyncmcp.mintlify.app/quickstart Starts the LocalStack service, which will be accessible at http://localhost:4566 for local AWS testing. ```bash localstack start ``` -------------------------------- ### Running AsyncMCP Examples - LocalStack Start Source: https://asyncmcp.mintlify.app/examples/basic-examples Command to start LocalStack, a cloud service emulator, which is used in the proxy example for SQS communication. ```bash localstack start ``` -------------------------------- ### Run SNS+SQS Example Source: https://asyncmcp.mintlify.app/guides/local-development Commands to run the SNS+SQS example for AsyncMCP. This setup uses both SNS for topic management and SQS for message queuing. ```bash # Terminal 1: Start server uv run examples/website_server.py # Terminal 2: Start client uv run examples/website_client.py ``` -------------------------------- ### Setup Resources Source: https://asyncmcp.mintlify.app/guides/local-development Command to run a Python script for setting up necessary AWS resources locally using `uv` and `examples/setup.py`. ```bash uv run examples/setup.py ``` -------------------------------- ### Start LocalStack Source: https://asyncmcp.mintlify.app/guides/local-development Command to start the LocalStack local cloud service environment. ```bash localstack start ``` -------------------------------- ### Start Development Server Source: https://asyncmcp.mintlify.app/guides/local-development Placeholder command to start your AsyncMCP server during development. ```bash # Run your MCP server/client uv run your_server.py ``` -------------------------------- ### Install LocalStack Source: https://asyncmcp.mintlify.app/guides/local-development Provides commands to install LocalStack using pip, Docker, or Homebrew. ```bash # Using pip pip install localstack # Using Docker docker pull localstack/localstack # Using Homebrew (macOS) brew install localstack ``` -------------------------------- ### Running AsyncMCP Examples - Run Client Source: https://asyncmcp.mintlify.app/examples/basic-examples Command to run the AsyncMCP client example script. ```bash uv run client.py ``` -------------------------------- ### Running AsyncMCP Examples - Run Server Source: https://asyncmcp.mintlify.app/examples/basic-examples Command to run the AsyncMCP server example script. ```bash uv run server.py ``` -------------------------------- ### Clone and Install Asyncmcp Source: https://asyncmcp.mintlify.app/guides/local-development Clones the asyncmcp repository and installs its dependencies using uv. ```bash # Clone repository git clone https://github.com/bh-rat/asyncmcp.git cd asyncmcp # Install with uv uv sync ``` -------------------------------- ### Install LocalStack using uv Source: https://asyncmcp.mintlify.app/quickstart Installs the localstack package using the uv package manager, which is required for local AWS simulation. ```bash uv add localstack ``` -------------------------------- ### Install asyncmcp using uv Source: https://asyncmcp.mintlify.app/quickstart Installs the asyncmcp package using the uv package manager. This command adds asyncmcp to your current project's dependencies. ```bash # Add to current project uv add asyncmcp # Install globally uv tool install asyncmcp ``` -------------------------------- ### Asyncmcp SQS Server Example Source: https://asyncmcp.mintlify.app/examples/basic-examples Demonstrates how to set up an asyncmcp server using the SQS transport. It includes defining tools and handling tool calls. Requires boto3 and asyncmcp libraries. ```python #!/usr/bin/env python3 import asyncio import boto3 from mcp.server.lowlevel import Server from mcp import types from asyncmcp.sqs import sqs_server from asyncmcp import SqsServerConfig # Create MCP server app = Server("hello-world") @app.list_tools() async def list_tools(): return [ types.Tool( name="greet", description="Say hello", inputSchema={ "type": "object", "properties": { "name": {"type": "string"} }, "required": ["name"] } ) ] @app.call_tool() async def call_tool(name: str, arguments: dict): if name == "greet": return [types.TextContent( type="text", text=f"Hello, {arguments['name']}!" )] async def main(): config = SqsServerConfig( read_queue_url="http://localhost:4566/000000000000/mcp-requests" ) sqs_client = boto3.client( 'sqs', endpoint_url='http://localhost:4566', region_name='us-east-1', aws_access_key_id='test', aws_secret_access_key='test' ) async with sqs_server(config, sqs_client) as (read, write): await app.run(read, write, types.InitializationOptions()) if __name__ == "__main__": asyncio.run(main()) ``` -------------------------------- ### Start and Verify LocalStack Source: https://asyncmcp.mintlify.app/guides/local-development Commands to start the LocalStack service and check its running status. ```bash # Start LocalStack localstack start # Verify it's running localstack status ``` -------------------------------- ### Asyncmcp SQS Client Example Source: https://asyncmcp.mintlify.app/examples/basic-examples Demonstrates how to set up an asyncmcp client using the SQS transport to interact with a server. It shows how to initialize the client and call tools. Requires boto3 and asyncmcp libraries. ```python #!/usr/bin/env python3 import asyncio import boto3 from mcp.client import ClientSession from asyncmcp.sqs import sqs_client from asyncmcp import SqsClientConfig async def main(): config = SqsClientConfig( read_queue_url="http://localhost:4566/000000000000/mcp-requests", response_queue_url="http://localhost:4566/000000000000/mcp-responses" ) sqs_boto_client = boto3.client( 'sqs', endpoint_url='http://localhost:4566', region_name='us-east-1', aws_access_key_id='test', aws_secret_access_key='test' ) async with sqs_client(config, sqs_boto_client) as (read, write): async with ClientSession(read, write) as session: await session.initialize() result = await session.call_tool( "greet", arguments={"name": "asyncmcp"} ) print(result.content[0].text) # Output: Hello, asyncmcp! if __name__ == "__main__": asyncio.run(main()) ``` -------------------------------- ### AsyncMCP Proxy Example with SQS Source: https://asyncmcp.mintlify.app/examples/basic-examples Sets up an AsyncMCP proxy server that forwards requests to an SQS queue. This example configures the proxy to use LocalStack for SQS and demonstrates how to create the proxy server with specified backend configurations and port. ```python #!/usr/bin/env python3 import asyncio import boto3 from asyncmcp.proxy import create_proxy_server from asyncmcp.sqs.utils import SqsClientConfig async def main(): # Configure SQS backend backend_config = SqsClientConfig( read_queue_url="http://localhost:4566/000000000000/mcp-requests", response_queue_url="http://localhost:4566/000000000000/mcp-responses" ) sqs_client = boto3.client( 'sqs', endpoint_url='http://localhost:4566', region_name='us-east-1', aws_access_key_id='test', aws_secret_access_key='test' ) # Create proxy server proxy = create_proxy_server( backend_transport="sqs", backend_config=backend_config, backend_clients={"sqs_client": sqs_client}, port=8080 ) print("Proxy running on http://localhost:8080/mcp") await proxy.run() if __name__ == "__main__": asyncio.run(main()) ``` -------------------------------- ### AsyncMCP Server Example Source: https://asyncmcp.mintlify.app/examples/basic-examples Sets up a FastAPI server using AsyncMCP to handle tool calls. It defines a 'echo' tool that echoes back the provided message. This server can be interacted with by an AsyncMCP client. ```python #!/usr/bin/env python3 from fastapi import FastAPI import uvicorn from mcp.server.lowlevel import Server from mcp import types from asyncmcp.webhook.manager import WebhookSessionManager from asyncmcp import WebhookServerConfig app = FastAPI() mcp_server = Server("webhook-example") @mcp_server.list_tools() async def list_tools(): return [ types.Tool( name="echo", description="Echo back the input", inputSchema={ "type": "object", "properties": { "message": {"type": "string"} }, "required": ["message"] } ) ] @mcp_server.on_tool_call() async def call_tool(name: str, arguments: dict): if name == "echo": return [types.TextContent( type="text", text=f"Echo: {arguments['message']}" )] config = WebhookServerConfig() session_manager = WebhookSessionManager(mcp_server, config) app.mount("/mcp", session_manager.asgi_app()) if __name__ == "__main__": uvicorn.run(app, host="0.0.0.0", port=8000) ``` -------------------------------- ### AsyncMCP Client Example Source: https://asyncmcp.mintlify.app/examples/basic-examples Demonstrates how to create an AsyncMCP client that connects to an AsyncMCP server via webhooks. It initializes a client session, calls the 'echo' tool on the server, and prints the response. It also includes a basic FastAPI webhook server to receive responses. ```python #!/usr/bin/env python3 import asyncio from fastapi import FastAPI, Request import uvicorn from mcp.client import ClientSession from asyncmcp import webhook_client, WebhookClientConfig webhook_app = FastAPI() @webhook_app.post("/webhook") async def receive_webhook(request: Request): # Handle webhook response body = await request.json() print(f"Received: {body}") return {"status": "ok"} async def run_client(): config = WebhookClientConfig( server_url="http://localhost:8000/mcp/request", webhook_url="http://localhost:8001/webhook" ) async with webhook_client(config) as (read, write, client): async with ClientSession(read, write) as session: await session.initialize() result = await session.call_tool( "echo", arguments={"message": "Hello Webhooks!"} ) print(result.content[0].text) # Output: Echo: Hello Webhooks! async def main(): # Start webhook server webhook_config = uvicorn.Config( webhook_app, host="0.0.0.0", port=8001, log_level="error" ) webhook_server = uvicorn.Server(webhook_config) webhook_task = asyncio.create_task(webhook_server.serve()) await asyncio.sleep(1) # Run client await run_client() webhook_task.cancel() if __name__ == "__main__": asyncio.run(main()) ``` -------------------------------- ### AsyncMCP Development Environment Variables Source: https://asyncmcp.mintlify.app/guides/local-development Example `.env` file content for configuring AWS services to use LocalStack during development. ```bash # .env file for development AWS_ENDPOINT_URL=http://localhost:4566 AWS_REGION=us-east-1 AWS_ACCESS_KEY_ID=test AWS_SECRET_ACCESS_KEY=test LOCALSTACK_HOST=localhost:4566 ``` -------------------------------- ### Run Tests Source: https://asyncmcp.mintlify.app/guides/local-development Command to execute all tests using `uv` and `pytest`. ```bash uv run pytest tests/ ``` -------------------------------- ### Create SNS Topics with Boto3 Source: https://asyncmcp.mintlify.app/guides/local-development Initializes Boto3 SNS client for LocalStack to create SNS topics. ```python sns = boto3.client("sns", **config) ``` -------------------------------- ### Async SQS Server Example Source: https://asyncmcp.mintlify.app/introduction Demonstrates how to create an MCP server with an asynchronous SQS transport using boto3 and asyncmcp. It configures the SQS queue, defines a tool to process data, and runs the server with the SQS transport. ```python import boto3 from asyncmcp.sqs import sqs_server from asyncmcp import SqsServerConfig from mcp.server.lowlevel import Server # Configure transport config = SqsServerConfig( read_queue_url="https://sqs.region.amazonaws.com/account/requests" ) # Create MCP server app = Server("my-async-server") # Add your tools @app.call_tool() async def process_data(name: str, arguments: dict): # Long-running operation result = await process_large_dataset(arguments["data"]) return [{"type": "text", "text": str(result)}] # Run with SQS transport async def main(): sqs_client = boto3.client('sqs') async with sqs_server(config, sqs_client) as (read, write): await app.run(read, write, InitializationOptions()) ``` -------------------------------- ### Asyncmcp Initialization Protocol Example Source: https://asyncmcp.mintlify.app/concepts/overview Demonstrates the client's 'initialize' request payload, including the 'response_queue_url' for asynchronous response delivery and 'clientInfo'. This protocol allows asyncmcp to establish custom transport connections. ```json { "jsonrpc": "2.0", "method": "initialize", "params": { "response_queue_url": "https://sqs.region.amazonaws.com/account/client-responses", "clientInfo": { "name": "example-client", "version": "1.0.0" } } } ``` -------------------------------- ### List AWS Resources with LocalStack Source: https://asyncmcp.mintlify.app/guides/local-development AWS CLI commands to list SQS queues and SNS topics when using LocalStack as the endpoint. ```bash # List SQS queues aws --endpoint-url=http://localhost:4566 sqs list-queues # List SNS topics aws --endpoint-url=http://localhost:4566 sns list-topics ``` -------------------------------- ### View LocalStack Logs Source: https://asyncmcp.mintlify.app/guides/local-development Command to view the logs from the running LocalStack instance in real-time. ```bash localstack logs -f ``` -------------------------------- ### Async SQS Server Example Source: https://asyncmcp.mintlify.app/index Demonstrates how to create an MCP server with an asynchronous SQS transport using boto3 and asyncmcp. It configures the SQS queue, defines a tool to process data, and runs the server with the SQS transport. ```python import boto3 from asyncmcp.sqs import sqs_server from asyncmcp import SqsServerConfig from mcp.server.lowlevel import Server # Configure transport config = SqsServerConfig( read_queue_url="https://sqs.region.amazonaws.com/account/requests" ) # Create MCP server app = Server("my-async-server") # Add your tools @app.call_tool() async def process_data(name: str, arguments: dict): # Long-running operation result = await process_large_dataset(arguments["data"]) return [{"type": "text", "text": str(result)}] # Run with SQS transport async def main(): sqs_client = boto3.client('sqs') async with sqs_server(config, sqs_client) as (read, write): await app.run(read, write, InitializationOptions()) ``` -------------------------------- ### Create and Run Proxy Server (Python) Source: https://asyncmcp.mintlify.app/proxy Demonstrates how to create and run an AsyncMCP proxy server using Python. It configures a backend transport (SQS in this example) and specifies necessary configurations and clients. The proxy listens on a specified port and clients can connect to it. ```python from asyncmcp.proxy import create_proxy_server from asyncmcp.sqs.utils import SqsClientConfig import boto3 # Configure backend backend_config = SqsClientConfig( read_queue_url="https://sqs.region.amazonaws.com/123/requests", response_queue_url="https://sqs.region.amazonaws.com/123/responses" ) # Create and run proxy proxy = create_proxy_server( backend_transport="sqs", backend_config=backend_config, backend_clients={"sqs_client": boto3.client("sqs")}, port=8080 ) await proxy.run() # Clients connect to http://localhost:8080/mcp ``` -------------------------------- ### Run Proxy Server from Command Line (Bash) Source: https://asyncmcp.mintlify.app/proxy Provides examples of how to run the AsyncMCP proxy server directly from the command line using Python's module execution. It shows how to specify the backend transport and port, and how to enable authentication. ```bash # Run with SQS backend python -m asyncmcp.proxy --backend sqs --port 8080 # Run with authentication python -m asyncmcp.proxy --backend sqs --auth-token "secret" ``` -------------------------------- ### Run Pytest with Coverage and Markers Source: https://asyncmcp.mintlify.app/guides/local-development Commands for running tests using `pytest`, including options for code coverage and filtering tests by markers. ```bash # Run all tests uv run pytest # Run with coverage uv run pytest --cov=asyncmcp --cov-report=html # Run specific markers uv run pytest -m unit uv run pytest -m integration # Run specific test module uv run pytest tests/sqs/test_integration.py # Run tests with specific markers uv run pytest -m integration uv run pytest -m unit ``` -------------------------------- ### Configure AWS CLI for LocalStack Source: https://asyncmcp.mintlify.app/guides/local-development Configures the AWS CLI with dummy credentials and region for LocalStack integration. ```bash # Configure for LocalStack aws configure set aws_access_key_id test aws configure set aws_secret_access_key test aws configure set region us-east-1 ``` -------------------------------- ### Create SQS Queues with Boto3 Source: https://asyncmcp.mintlify.app/guides/local-development Python script using Boto3 to create multiple SQS queues with specified attributes for LocalStack. ```python #!/usr/bin/env python3 import boto3 # LocalStack configuration config = { "endpoint_url": "http://localhost:4566", "region_name": "us-east-1", "aws_access_key_id": "test", "aws_secret_access_key": "test" } sqs = boto3.client("sqs", **config) # Create queues queues = [ "mcp-requests", "mcp-responses", "mcp-processor", "mcp-consumer" ] for queue_name in queues: response = sqs.create_queue( QueueName=queue_name, Attributes={ 'ReceiveMessageWaitTimeSeconds': '20', 'VisibilityTimeout': '30' } ) print(f"✅ Created queue: {response['QueueUrl']}") ``` -------------------------------- ### SNS+SQS Server Basic Usage Source: https://asyncmcp.mintlify.app/transports/sns-sqs Demonstrates the basic setup for an SNS+SQS server in asyncmcp. It shows how to configure the server with an SQS queue URL and integrate with SQS and SNS clients. ```python # Server from asyncmcp.sns_sqs import sns_sqs_server from asyncmcp import SnsSqsServerConfig config = SnsSqsServerConfig( sqs_queue_url="https://sqs.region.amazonaws.com/account/server-queue" ) async with sns_sqs_server(config, sqs_client, sns_client) as (read, write): await app.run(read, write, init_options) ``` -------------------------------- ### SNS+SQS Client Basic Usage Source: https://asyncmcp.mintlify.app/transports/sns-sqs Illustrates the basic setup for an SNS+SQS client in asyncmcp. It shows how to configure the client with SNS topic ARN and SQS queue URL, and integrate with clients and sessions. ```python # Client from asyncmcp.sns_sqs import sns_sqs_client from asyncmcp import SnsSqsClientConfig config = SnsSqsClientConfig( sns_topic_arn="arn:aws:sns:region:account:requests", sqs_queue_url="https://sqs.region.amazonaws.com/account/client-queue" ) async with sns_sqs_client(config, sqs_client, sns_client, client_topic_arn) as (read, write): async with ClientSession(read, write) as session: await session.initialize() ``` -------------------------------- ### Create SNS Topics and Subscribe SQS Source: https://asyncmcp.mintlify.app/guides/local-development This Python script creates SNS topics and subscribes an SQS queue to the 'mcp-requests' topic. It demonstrates basic AWS SNS and SQS interaction for message brokering. ```python topics = [ "mcp-requests", "mcp-responses" ] for topic_name in topics: response = sns.create_topic(Name=topic_name) print(f"✅ Created topic: {response['TopicArn']}") # Subscribe queues to topics if topic_name == "mcp-requests": sns.subscribe( TopicArn=response['TopicArn'], Protocol='sqs', Endpoint=f"arn:aws:sqs:us-east-1:000000000000:mcp-processor" ) ``` -------------------------------- ### Monitor SQS Queue Depth Source: https://asyncmcp.mintlify.app/guides/local-development AWS CLI command to check the number of messages in an SQS queue using the LocalStack endpoint. ```bash # Check queue depth aws --endpoint-url=http://localhost:4566 sqs get-queue-attributes \ --queue-url http://localhost:4566/000000000000/mcp-requests \ --attribute-names ApproximateNumberOfMessages ``` -------------------------------- ### Asyncmcp Introduction and Usage Source: https://asyncmcp.mintlify.app/introduction Provides an introduction to asyncmcp, explaining its purpose in enabling asynchronous communication for MCP servers via queues and webhooks. It details why async transports are beneficial for batch processing, webhooks, queue systems, and long operations. The documentation also outlines the supported transports and how to use asyncmcp, differentiating between controlling the client and not controlling the client. ```markdown # Introduction Async transport layers for Model Context Protocol - enabling queue-based and webhook communication for MCP servers asyncmcp is currently in **alpha**. APIs may change as we refine the implementation based on community feedback.**What’s not supported yet:** * Direct integration with standard MCP clients (Claude, Cursor, etc.) without using the proxy server. All MCP servers will only work with standard clients through the asyncmcp proxy bridge. * Advanced features like sampling, elicitation are not supported on all transports. ## [​](https://asyncmcp.mintlify.app/introduction#what-is-asyncmcp%3F) What is asyncmcp? asyncmcp provides custom asynchronous transport layers for the [Model Context Protocol (MCP)](https://modelcontextprotocol.io), enabling MCP servers to handle requests through queues, topics, and webhooks rather than requiring immediate responses through standard stdio or HTTP transports. MCP Server working over AWS SQS queues ## [​](https://asyncmcp.mintlify.app/introduction#why-async-transports%3F) Why Async Transports? Traditional MCP transports (stdio, HTTP) require synchronous request-response patterns. However, many real-world contexts aren’t immediately available: ## Batch Processing APIs that process data in batches and return results later ## Webhooks Services that notify through webhooks when processing completes ## Queue Systems Message queues that decouple producers from consumers ## Long Operations Tasks that take minutes or hours to complete ## [​](https://asyncmcp.mintlify.app/introduction#supported-transports) Supported Transports * SQS * SNS+SQS * Webhook * StreamableHTTP+Webhook **AWS Simple Queue Service** - Point-to-point messaging * Direct queue-to-queue communication * Guaranteed message delivery * Simple, cost-effective for basic async needs ## [​](https://asyncmcp.mintlify.app/introduction#how-to-use-asyncmcp) How to use asyncmcp The approach depends on whether you control the client implementation: ### [​](https://asyncmcp.mintlify.app/introduction#you-control-the-client) You Control the Client If you’re building your own client application, you can directly use asyncmcp transports: 1. **Choose a transport** based on your requirements: * **SQS** : Simple queue-based async, ideal for basic request-response patterns * **SNS+SQS** : Topic-based routing for multiple subscribers or fanout scenarios * **Webhook** : HTTP-based async for web services and existing infrastructure * **StreamableHTTP+Webhook** : Hybrid approach for mixed sync/async operations 2. **Implement both sides** using the matching transport client and server 3. **See examples** in the [Quick Example](https://asyncmcp.mintlify.app/introduction#quick-example) section below or browse the [Examples](https://asyncmcp.mintlify.app/examples/basic-examples) documentation ``` -------------------------------- ### Asyncmcp Introduction and Usage Source: https://asyncmcp.mintlify.app/index Provides an introduction to asyncmcp, explaining its purpose in enabling asynchronous communication for MCP servers via queues and webhooks. It details why async transports are beneficial for batch processing, webhooks, queue systems, and long operations. The documentation also outlines the supported transports and how to use asyncmcp, differentiating between controlling the client and not controlling the client. ```markdown # Introduction Async transport layers for Model Context Protocol - enabling queue-based and webhook communication for MCP servers asyncmcp is currently in **alpha**. APIs may change as we refine the implementation based on community feedback.**What’s not supported yet:** * Direct integration with standard MCP clients (Claude, Cursor, etc.) without using the proxy server. All MCP servers will only work with standard clients through the asyncmcp proxy bridge. * Advanced features like sampling, elicitation are not supported on all transports. ## [​](https://asyncmcp.mintlify.app/introduction#what-is-asyncmcp%3F) What is asyncmcp? asyncmcp provides custom asynchronous transport layers for the [Model Context Protocol (MCP)](https://modelcontextprotocol.io), enabling MCP servers to handle requests through queues, topics, and webhooks rather than requiring immediate responses through standard stdio or HTTP transports. MCP Server working over AWS SQS queues ## [​](https://asyncmcp.mintlify.app/introduction#why-async-transports%3F) Why Async Transports? Traditional MCP transports (stdio, HTTP) require synchronous request-response patterns. However, many real-world contexts aren’t immediately available: ## Batch Processing APIs that process data in batches and return results later ## Webhooks Services that notify through webhooks when processing completes ## Queue Systems Message queues that decouple producers from consumers ## Long Operations Tasks that take minutes or hours to complete ## [​](https://asyncmcp.mintlify.app/introduction#supported-transports) Supported Transports * SQS * SNS+SQS * Webhook * StreamableHTTP+Webhook **AWS Simple Queue Service** - Point-to-point messaging * Direct queue-to-queue communication * Guaranteed message delivery * Simple, cost-effective for basic async needs ## [​](https://asyncmcp.mintlify.app/introduction#how-to-use-asyncmcp) How to use asyncmcp The approach depends on whether you control the client implementation: ### [​](https://asyncmcp.mintlify.app/introduction#you-control-the-client) You Control the Client If you’re building your own client application, you can directly use asyncmcp transports: 1. **Choose a transport** based on your requirements: * **SQS** : Simple queue-based async, ideal for basic request-response patterns * **SNS+SQS** : Topic-based routing for multiple subscribers or fanout scenarios * **Webhook** : HTTP-based async for web services and existing infrastructure * **StreamableHTTP+Webhook** : Hybrid approach for mixed sync/async operations 2. **Implement both sides** using the matching transport client and server 3. **See examples** in the [Quick Example](https://asyncmcp.mintlify.app/introduction#quick-example) section below or browse the [Examples](https://asyncmcp.mintlify.app/examples/basic-examples) documentation ``` -------------------------------- ### SQS Client Basic Usage Source: https://asyncmcp.mintlify.app/transports/sqs Illustrates the basic usage of the SQS client transport. It configures the client with read and response queue URLs, establishes a session, and initializes it. ```python from asyncmcp.sqs import sqs_client from asyncmcp import SqsClientConfig config = SqsClientConfig( read_queue_url="https://sqs.region.amazonaws.com/account/requests", response_queue_url="https://sqs.region.amazonaws.com/account/responses" ) async with sqs_client(config, sqs_client) as (read, write): async with ClientSession(read, write) as session: await session.initialize() ``` -------------------------------- ### SQS Server Basic Usage Source: https://asyncmcp.mintlify.app/transports/sqs Demonstrates the basic usage of the SQS server transport. It configures the server to read from a specified queue URL and then runs the application with the provided read and write interfaces. ```python from asyncmcp.sqs import sqs_server from asyncmcp import SqsServerConfig config = SqsServerConfig( read_queue_url="https://sqs.region.amazonaws.com/account/requests" ) async with sqs_server(config, sqs_client) as (read, write): await app.run(read, write, init_options) ``` -------------------------------- ### Webhook Transport Server Usage Source: https://asyncmcp.mintlify.app/transports/webhook Demonstrates how to set up a FastAPI server to handle incoming webhook requests using the WebhookSessionManager. ```python from asyncmcp.webhook import WebhookSessionManager from fastapi import FastAPI, Request # Assuming mcp_app is initialized elsewhere # from asyncmcp import AsyncMCPApp # mcp_app = AsyncMCPApp() app = FastAPI() manager = WebhookSessionManager(mcp_app) @app.post("/mcp/request") async def handle_request(request: Request): return await manager.handle_request(request) ``` -------------------------------- ### Webhook Server Configuration Parameters Source: https://asyncmcp.mintlify.app/transports/webhook Details the configuration parameters available for the Webhook transport server, including timeouts and retry settings. ```APIDOC WebhookServerConfig: timeout_seconds: float (default: "30.0") HTTP timeout for sending webhooks to clients. max_retries: int (default: "0") Number of retry attempts for failed webhook deliveries (default: no retries). transport_timeout_seconds: float (Optional) Optional overall transport timeout. ``` -------------------------------- ### StreamableHTTP + Webhook Client Configuration Source: https://asyncmcp.mintlify.app/transports/streamable-http-webhook Sets up the StreamableHTTP + Webhook transport client for asyncmcp. It requires the server URL and a webhook URL for receiving asynchronous responses. ```python # Client from asyncmcp.streamable_http_webhook import ( streamable_http_webhook_client, StreamableHTTPWebhookClientConfig ) config = StreamableHTTPWebhookClientConfig( server_url="http://api.example.com/mcp", webhook_url="http://client.example.com/webhook" ) async with streamable_http_webhook_client(config) as (read_stream, write_stream, client): # Use the streams for MCP communication # Quick tool - uses SSE # Async tool - uses webhook pass ``` -------------------------------- ### WebhookClient Configuration Parameters Source: https://asyncmcp.mintlify.app/transports/webhook Configuration options for the WebhookClient, specifying the server URL, request timeouts, retry attempts, and client identification. ```APIDOC WebhookClientConfig: server_url: string default: "http://localhost:8000/mcp/request" description: URL of the server’s HTTP endpoint. Example: `https://api.example.com/mcp/request` timeout_seconds: float default: "30.0" description: HTTP request timeout in seconds. max_retries: int default: "0" description: Number of retry attempts for failed requests (default: no retries). client_id: string description: Unique client identifier. Auto-generated if not provided. transport_timeout_seconds: float description: Optional overall transport timeout. ``` -------------------------------- ### Webhook Transport Client Usage Source: https://asyncmcp.mintlify.app/transports/webhook Illustrates how to configure and use the webhook client to send requests and receive asynchronous responses. ```python from asyncmcp.webhook import webhook_client from asyncmcp import WebhookClientConfig from asyncmcp.session import ClientSession config = WebhookClientConfig( server_url="https://api.example.com/mcp/request" ) async with webhook_client(config, webhook_path="/webhook") as client: async with ClientSession(client.read, client.write) as session: # Webhook URL provided automatically in initialize await session.initialize() ``` -------------------------------- ### SQS Client Configuration Parameters Source: https://asyncmcp.mintlify.app/transports/sqs Details the configuration parameters available for the SQS client transport, including read and response queue URLs. ```APIDOC SqsClientConfig: read_queue_url: string (required) - URL of the SQS queue where the client sends requests. response_queue_url: string (required) - URL of the SQS queue where the client receives responses. ``` -------------------------------- ### SNS+SQS Server Configuration Parameters Source: https://asyncmcp.mintlify.app/transports/sns-sqs Details the configuration parameters for the SNS+SQS server in asyncmcp. This includes settings for SQS queue URL, message polling, and message visibility. ```APIDOC SnsSqsServerConfig: sqs_queue_url: string (required) URL of the SQS queue where the server receives messages from SNS topic. Example: `https://sqs.us-east-1.amazonaws.com/123456789/mcp-server-queue` max_messages: int (default: "10") Maximum messages to retrieve per poll (1-10). wait_time_seconds: int (default: "20") Long polling duration (0-20) for SQS. visibility_timeout_seconds: int (default: "30") Seconds a message remains invisible after retrieval. poll_interval_seconds: float (default: "5.0") Seconds between queue polling attempts. message_attributes: dict Custom attributes to include with messages. ``` -------------------------------- ### SnsSqsClientConfig Parameters Source: https://asyncmcp.mintlify.app/transports/sns-sqs Configuration parameters for the SnsSqsClientConfig class, used to set up the SNS/SQS transport. This includes the SQS queue URL, SNS topic ARN, an optional client ID, and custom message attributes. ```APIDOC SnsSqsClientConfig: __init__(sqs_queue_url: str, sns_topic_arn: str, client_id: str = None, message_attributes: dict = None) sqs_queue_url: string required URL of the client’s SQS queue for receiving responses. Example: https://sqs.us-east-1.amazonaws.com/123456789/mcp-client-queue sns_topic_arn: string required ARN of the SNS topic for publishing requests. Example: arn:aws:sns:us-east-1:123456789:mcp-requests client_id: string Unique client identifier. Auto-generated if not provided. message_attributes: dict Custom attributes to include with messages. ``` -------------------------------- ### Run AsyncMCP Proxy with SQS Backend Source: https://asyncmcp.mintlify.app/proxy This command deploys the AsyncMCP proxy using Docker, configuring it to use SQS as the backend transport and setting the AWS region to us-east-1. It maps port 8080 on the host to port 8080 in the container. ```docker docker run -p 8080:8080 \ -e BACKEND_TRANSPORT=sqs \ -e AWS_REGION=us-east-1 \ asyncmcp-proxy:latest ``` -------------------------------- ### Connect MCP Client using StreamableHTTP Source: https://asyncmcp.mintlify.app/proxy This JavaScript code demonstrates how to instantiate an MCP client using the StreamableHTTP transport. It configures the client to connect to the proxy running locally on port 8080. ```javascript const client = new MCPClient({ transport: { type: "streamable-http", url: "http://localhost:8080/mcp" } }); ``` -------------------------------- ### SQS Client Configuration Parameters Source: https://asyncmcp.mintlify.app/transports/sqs Configuration options for the SQS client, specifying queue URLs, client identification, message attributes, and transport timeouts. ```APIDOC SqsClientConfig: read_queue_url: string (required) URL of the server’s request queue. Example: https://sqs.us-east-1.amazonaws.com/123456789/mcp-requests response_queue_url: string (required) URL of the client’s response queue. Can be pre-created or dynamically generated. Example: https://sqs.us-east-1.amazonaws.com/123456789/mcp-responses client_id: string (optional) Unique client identifier. Auto-generated if not provided. message_attributes: dict (optional) Custom attributes to include with messages. transport_timeout_seconds: float (optional) Optional overall transport timeout. ``` -------------------------------- ### StreamableHTTP + Webhook Server Configuration Source: https://asyncmcp.mintlify.app/transports/streamable-http-webhook Configures the StreamableHTTP + Webhook transport for the asyncmcp server. It allows specifying which tools should use webhook delivery for asynchronous operations. ```python # Server with selective routing from asyncmcp.streamable_http_webhook import ( StreamableHTTPWebhookSessionManager, StreamableHTTPWebhookConfig ) # Configure the transport config = StreamableHTTPWebhookConfig() # Define which tools use webhook webhook_tools = {"process_batch", "analyze_large_dataset"} manager = StreamableHTTPWebhookSessionManager( mcp_app, config, webhook_tools=webhook_tools ) # FastAPI integration @app.post("/mcp") async def handle_mcp(request: Request): return await manager.handle_request(request) ``` -------------------------------- ### Streamable HTTP Webhook Server Configuration Source: https://asyncmcp.mintlify.app/transports/streamable-http-webhook Configures the server-side behavior for the Streamable HTTP Webhook transport. Options include enabling JSON responses, setting various timeouts for SSE and webhook delivery, and configuring retry attempts for webhooks. ```APIDOC StreamableHTTPWebhookConfig: json_response: boolean (default: "false") - Use JSON responses instead of SSE streaming. Set to false for SSE. timeout_seconds: float (default: "30.0") - HTTP timeout for SSE responses. webhook_timeout: float (default: "30.0") - Timeout for webhook delivery attempts. webhook_max_retries: int (default: "1") - Maximum retry attempts for failed webhook deliveries. transport_timeout_seconds: float (Optional) - Overall transport timeout. ``` -------------------------------- ### SQS Server Configuration Parameters Source: https://asyncmcp.mintlify.app/transports/sqs Details the configuration parameters available for the SQS server transport, including queue URL, message limits, polling settings, and message attributes. ```APIDOC SqsServerConfig: read_queue_url: string (required) - URL of the SQS queue where the server receives requests. Example: `https://sqs.us-east-1.amazonaws.com/123456789/mcp-requests` max_messages: int (default: "10") - Maximum messages to retrieve per poll (1-10). wait_time_seconds: int (default: "20") - Long polling duration (0-20). Use 20 for cost optimization. visibility_timeout_seconds: int (default: "30") - Seconds a message remains invisible after retrieval. poll_interval_seconds: float (default: "5.0") - Seconds between queue polling attempts. Lower values reduce latency but increase costs. message_attributes: dict - Custom attributes to include with messages. transport_timeout_seconds: float (optional) - Optional overall transport timeout. ``` -------------------------------- ### Streamable HTTP Webhook Client Configuration Source: https://asyncmcp.mintlify.app/transports/streamable-http-webhook Configures the client-side behavior for the Streamable HTTP Webhook transport. This includes specifying the server URL, webhook URL for async responses, request timeouts, maximum retries, and a unique client identifier. ```APIDOC StreamableHTTPWebhookClientConfig: server_url: string (default: "http://localhost:8000/mcp") - StreamableHTTP endpoint URL. Example: `http://api.example.com/mcp` webhook_url: string (default: "http://localhost:8001/webhook") - Webhook URL for async responses. Example: `http://client.example.com/webhook` timeout_seconds: float (default: "30.0") - HTTP request timeout in seconds. max_retries: int (default: "1") - Number of retry attempts for failed requests. client_id: string (Optional) - Unique client identifier. Auto-generated if not provided. transport_timeout_seconds: float (Optional) - Optional overall transport timeout. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.