Overview

The SNS+SQS transport combines AWS Simple Notification Service (SNS) topics with SQS queues to provide powerful pub/sub messaging with fanout capabilities. Perfect for broadcasting messages to multiple consumers and event-driven architectures.
SNS+SQS transport uses topic-based routing where servers subscribe to topics and clients can broadcast messages to multiple subscribers simultaneously.

Examples

View complete working examples in the GitHub repository:

Quick Start

Basic Usage

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

Configuration

Server Configuration

Class: 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.

Client Configuration

Class: SnsSqsClientConfig
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.