Amazon MQ · Async Messaging · MCP Architecture · 2026-11-20

Amazon MQ for MCP Servers: Async Tool Dispatch, ActiveMQ STOMP and Virtual Topics, RabbitMQ Exchanges and Confirms, and HA Failover

MCP servers that handle only fast operations — sub-second queries, quick API calls — can run entirely synchronously. But as soon as a tool calls a report generator, a document transcoder, a machine learning inference job, or a large-scale data export, the synchronous model breaks. The calling agent blocks, intermediate proxies time out, and the user waits. Amazon MQ solves this with a managed message broker that decouples tool dispatch from tool execution. This guide synthesises the full Amazon MQ arc for MCP server developers: the async dispatch pattern that works for any broker engine, the specific client patterns for ActiveMQ (STOMP with stompit, virtual topics, durable subscribers) and RabbitMQ (amqplib exchanges, publisher confirms, dead-letter exchanges, quorum queues), and the high-availability configurations that keep your message infrastructure alive through broker failover — along with the critical production gotchas that cause silent data loss if you miss them.

Why async tool dispatch belongs in production MCP server architectures

The standard MCP tool call model is synchronous. The client sends tools/call and waits for the server's response. For fast operations this is exactly the right model — it's simple, it has clear error semantics, and latency is predictable. The model breaks for three reasons when operations take more than a few seconds.

First, connection fragility. Cloud environments are full of intermediate infrastructure — load balancers, API gateways, reverse proxies — each with their own idle timeout. A 90-second report generation that holds an HTTP connection open will trigger timeouts in AWS ALB (60s default), nginx (60s default), and many API Gateway configurations. The agent sees a connection reset, not a clean error — and has no way to know if the work started, partially completed, or never ran.

Second, resource contention. Each long-held connection consumes a file descriptor, a worker thread or async context, and memory on the MCP server. For report generation that takes two minutes per request, ten concurrent tool calls will hold ten connections for two minutes each. The MCP server's ability to handle other, fast requests degrades.

Third, retry complexity. When a synchronous call fails at the network layer, neither the caller nor the server can easily distinguish between "work never started" and "work started but the server crashed before sending the response." Safe retry logic requires that the operation be idempotent, but long-running operations (database migrations, invoice generation, batch exports) are often inherently stateful. Message queues make retry state explicit: unacknowledged messages are automatically redelivered; completed work is marked acknowledged and never retried.

The async dispatch pattern for MCP tool handlers addresses all three. The tool handler publishes a task message to the broker queue, immediately returns a job ID to the calling agent, and returns. A separate worker process consumes the queue and executes the work. The calling agent polls a status-check tool at whatever cadence makes sense for the operation. The connection is never held open for the duration of the work. The queue provides the retry ledger.

Amazon MQ is the managed option for this pattern. It handles broker provisioning, storage management, TLS certificate rotation, CloudWatch metric publishing, and cross-AZ replication. The two supported engines — Apache ActiveMQ and RabbitMQ — cover different protocol and routing needs, but both support the same fundamental async dispatch pattern.

Choosing between ActiveMQ and RabbitMQ on Amazon MQ

The engine choice is permanent after broker creation. ActiveMQ and RabbitMQ on Amazon MQ are not interchangeable — they use different protocols, different client libraries, different routing models, and different HA configurations. Make this decision before provisioning, and understand what it commits you to.

Choose ActiveMQ if your stack already uses it, you need STOMP or MQTT protocols (for IoT device input alongside MCP tool messaging), you need JMS-style message selectors for routing tasks to specialized workers without application-level routing logic, or you need durable topic subscribers that survive restarts without the full exchange/binding declaration overhead of RabbitMQ.

Choose RabbitMQ if you are starting a new project with no existing broker technology. The AMQP 0-9-1 protocol is better-supported by Node.js tooling than ActiveMQ's STOMP. The exchange/binding routing model is more expressive for complex routing scenarios. The management HTTP API provides queue health metrics directly usable in MCP tool handlers without CloudWatch setup. The CLUSTER_MULTI_AZ deployment provides faster failover (10–30 seconds) than ActiveMQ's active/standby (30–60 seconds). And quorum queues provide native durability guarantees that classic queues in both engines cannot match.

The table below summarises the key decision points:

AttributeActiveMQ on Amazon MQRabbitMQ on Amazon MQ
Supported protocolsOpenWire, STOMP, AMQP 1.0, MQTT, WebSocketAMQP 0-9-1 (plus management HTTP API)
Node.js clientstompit for STOMP; OpenWire requires JVM bridgeamqplib + amqp-connection-manager
Routing modelQueues (point-to-point) + Topics (fan-out) + Virtual Topics (durable fan-out)Exchanges (direct/topic/fanout/headers) → bindings → queues
Message filteringJMS message selectors (SQL-92 against headers)Routing key matching or header exchanges
HA deploymentACTIVE_STANDBY_MULTI_AZ (2 nodes, shared EFS)CLUSTER_MULTI_AZ (3 nodes, quorum replication)
Failover time30–60 seconds10–30 seconds
Client failover handlingMust use failover URI or ConnectFailover — single endpoint won't reconnectCluster endpoint load-balances; amqp-connection-manager handles transparently
Queue durabilityShared EFS survives node failureQuorum queues survive any single-node failure
Admin interfaceWeb console + JMXManagement HTTP API (scriptable, embeddable in MCP tools)

The rest of this guide covers both engines in depth. Start with the Amazon MQ overview for broker creation, IAM permissions, VPC networking, and the security group rules that control broker access. Those setup steps are identical regardless of engine choice.

The async tool dispatch pattern: core mechanics

The pattern is the same regardless of whether you use ActiveMQ or RabbitMQ. What changes is the client library and the queue declaration API — the logical structure is identical.

On MCP server startup, establish a persistent broker connection and declare any queues or exchanges you need. This is the right time to assert topology: queues, exchanges, bindings. All of these operations are idempotent — running them again on reconnect is safe and expected behavior.

When a tool handler receives a call that will take more than a few seconds, it publishes a task message containing all the parameters needed to execute the work, plus a correlation ID. The correlation ID links the task to its result. The message must be published as persistent — set persistent: true on STOMP sends, set persistent: true in amqplib publish options. Without persistence, a broker restart between task publish and task consume silently drops the message. The calling tool handler also registers a listener on a reply queue for the result, then blocks waiting (up to a timeout).

A separate worker process (which may be a different Node.js process, a Lambda function, an ECS task) consumes the task queue. It processes the work, then publishes the result back to the reply queue specified in the task message's replyTo property, using the correlation ID so the waiting tool handler can match the result to its pending promise.

For operations that take more than a minute or two, the timeout-based reply pattern becomes fragile — holding a promise open for three minutes means holding the tool handler's async context for three minutes. For these cases, use a disconnected model: the tool handler returns the correlation ID immediately, the worker writes the result to a durable store (DynamoDB, Redis) keyed by correlation ID, and a separate get_task_status tool lets the agent poll for the result. This is the right model for any tool execution whose completion time is unbounded or highly variable.

The critical production rule: persistent messages sent without publisher confirms can be silently lost on broker failover. See the high-availability section for the full details. Use publisher confirms for every task message you cannot afford to lose.

The ActiveMQ path: STOMP clients, virtual topics, and durable subscribers

ActiveMQ on Amazon MQ communicates over STOMP on port 61614 (TLS required). The stompit npm package is the recommended Node.js STOMP client — it handles TLS, heartbeating, and reconnection natively. Never use the unencrypted STOMP port in production; Amazon MQ enforces TLS on all broker-protocol endpoints.

The full ActiveMQ destination and routing model is covered in the ActiveMQ on Amazon MQ guide. The key concepts for MCP tool architectures:

Queue destinations for task dispatch

Queues implement competing consumers: multiple worker processes subscribe to the same queue, and ActiveMQ distributes messages in round-robin order. Each message is delivered to exactly one consumer. This is correct for task dispatch — you want exactly one worker to handle each task.

Declare the queue with persistent: "true" on every send. The queue itself is durable by default on Amazon MQ, but messages must be marked persistent to survive a broker restart.

Always use ack: "client-individual" in STOMP subscriptions — never ack: "auto" for task queues. With auto-ack, the message is removed from the queue as soon as it is delivered to your process. If your process crashes during task execution, the message is gone. With client-individual, the message stays on the queue until your handler explicitly calls message.ack(). If the process crashes before acking, ActiveMQ redelivers the message to the next available consumer.

Virtual topics for durable fan-out to multiple services

When multiple independent services each need to process every tool result — an audit log service, a reporting service, a notification service — topics are the natural model. But non-durable topic subscribers miss messages that arrive while they are disconnected. And durable subscriptions have a constraint: a given client-id can only have one active connection, which makes horizontal scaling awkward.

Virtual topics solve this cleanly. Publish to /topic/VirtualTopic.tool.results. Each consuming service subscribes to its own queue-backed copy: /queue/Consumer.reporting.VirtualTopic.tool.results, /queue/Consumer.audit.VirtualTopic.tool.results. The broker automatically delivers a copy of every message to each consumer's queue. Each consumer's queue is independent — the reporting service's queue depth does not block the audit service. Each consumer can scale to multiple instances using competing consumers against its own named queue. Messages persist in the queue until acknowledged, so restarts don't lose messages.

Virtual topics require no broker-side configuration in Amazon MQ — the naming convention is handled automatically. The only requirement is that the ActiveMQ activemq.xml has virtual topic support enabled, which is the default.

Message selectors for routing to specialized workers

ActiveMQ supports JMS message selectors — SQL-92-like expressions evaluated against message headers at the broker. This lets you use a single task queue with multiple worker types that specialize in different tool types, without application-level routing logic. A document generation worker subscribes with selector: "toolType = 'document_generation'"; a data processing worker subscribes with selector: "toolType = 'data_processing'". Non-matching messages stay on the queue for the right consumer.

The critical failure mode: if no consumer has a selector matching a message, the message accumulates indefinitely. Monitor queue depth to detect unrouted messages. If a tool type is retired, explicitly consume and discard the orphaned messages — don't leave them piling up against a consumer selector that no longer exists.

Dead-letter queue configuration for failed tasks

When a consumer nacks a message (or the message exceeds its redelivery count), ActiveMQ moves it to a dead-letter destination. By default, all dead-lettered messages go to ActiveMQ.DLQ — a single global sink. For MCP architectures, configure per-destination DLQs using individualDeadLetterStrategy in the broker XML: queuePrefix="DLQ." creates DLQ.mcp.tasks.reports for the mcp.tasks.reports queue. This keeps failed report generation tasks separate from failed data processing tasks for diagnosis.

Redelivery with exponential backoff (3 retries, starting at 5 seconds, doubling each time) is the standard pattern. The first retry often succeeds if the failure was a transient upstream dependency outage. After maximum retries, the message goes to the DLQ where an operator (or an MCP tool) can inspect, replay, or discard it.

The RabbitMQ path: exchanges, amqplib confirms, dead-letter exchanges, quorum queues

RabbitMQ on Amazon MQ uses AMQP 0-9-1, a binary protocol with a richer routing model. All messaging flows through an exchange first; exchanges route to queues based on bindings. This indirection is the core of RabbitMQ's power — routing topology can change by updating bindings without redeploying producers or consumers. The full exchange and binding model is covered in the RabbitMQ on Amazon MQ guide.

amqp-connection-manager: the right reconnection wrapper

Bare amqplib does not reconnect automatically after network interruptions. Use amqp-connection-manager as a wrapper — it creates a persistent connection that reconnects automatically and replays the channel setup callback on every reconnect. The setup callback (channelWrapper.setup()) is where you assert exchanges, queues, and bindings. All assert* calls are idempotent, so running them on every reconnect is safe and expected.

Never put one-time operations in the setup callback. If you publish a startup notification or seed data there, it will re-execute on every reconnect — after failover events, maintenance reboots, and network blips. Keep setup callbacks to topology assertion only.

Exchange types for MCP tool architectures

Use a direct exchange for task dispatch. Publish to the exchange with a routing key equal to the task type ("generate_report"); bind the worker queue to the exchange with that routing key. Direct routing is predictable and fast. Use a topic exchange for event routing — the routing key becomes a dotted-word pattern ("tool.report.completed"), and consumers bind with wildcards ("tool.#" for all tool events, "tool.*.completed" for completion events across all tool types). Use a fanout exchange when you need to broadcast a message to all bound queues regardless of routing key — useful for system-wide notifications like "MCP server restarting in 60 seconds." Use a headers exchange for routing based on message properties beyond the routing key — useful when task routing depends on multiple dimensions simultaneously (e.g., priority and tool type).

Publisher confirms: the production requirement

This is the most important correctness property for task dispatch. Without publisher confirms, amqplib's channel.publish() returns true or false based on the in-memory write buffer — it does not indicate that the broker actually persisted the message. For MCP task dispatch, losing a task silently means the agent waits forever for a result that will never come.

Publisher confirms give you a broker-level acknowledgement for every published message. Enable them with channel.confirmSelect() in the channel setup callback. When using amqp-connection-manager, calling channelWrapper.publish() returns a promise that resolves on broker ack and rejects on broker nack. If the broker nacks (message rejected — typically because a queue is at capacity or the exchange does not exist), you can retry or return an error to the calling agent.

Publisher confirms have a performance cost: each message publish incurs a round-trip to the broker. For high-throughput scenarios, batch confirms — publish multiple messages then await all confirms together — amortise this cost. Use Promise.all() to await a batch of channelWrapper.publish() calls.

Always combine publisher confirms with persistent: true on published messages. Confirms tell you the broker received and queued the message; persistence tells the broker to write the message to durable storage before confirming. Without persistence, the broker may confirm a message that is only in memory — if the broker process restarts before the message is consumed, it is lost even though you received a confirm.

Dead-letter exchanges for failed MCP tasks

RabbitMQ dead-letter exchanges (DLX) route messages that are nacked-without-requeue, rejected, or expire from TTL to a designated dead-letter queue. Configure the DLX at queue declaration time with the x-dead-letter-exchange and x-dead-letter-routing-key arguments. This provides a safety net for tasks that fail processing — they are preserved for diagnosis and optional replay rather than silently lost.

For task queues, the recommended pattern is application-level retry with a DLX as the final destination: on task failure, increment an x-retry-count header; if below the retry limit, re-publish to the original exchange with the incremented header; if at the limit, nack with requeue: false, which routes the message to the DLX. The dead-lettered message preserves the original headers plus a broker-added x-death header array documenting the death reason, count, and original queue — invaluable for debugging why tasks failed in production.

Quorum queues (see below) support a simpler version of this via the x-delivery-limit argument: set it to 3 and the broker automatically tracks delivery count and routes to the DLX after the limit without any application-level retry logic.

Quorum queues for production durability

Classic RabbitMQ queues have known data-loss risks under node failure — messages that are only in memory on the failed node are gone. Quorum queues use a Raft-based replication protocol: a message is only confirmed to the producer after a quorum of nodes (at least 2 of 3 on a CLUSTER_MULTI_AZ deployment) have written it to persistent storage. A single node failure does not cause message loss.

Declare quorum queues with the x-queue-type: quorum argument. They require durable: true (non-durable quorum queues are not allowed). Quorum queues have restrictions compared to classic queues: per-message TTL via the expiration publish property is not supported — use queue-level x-message-ttl instead. Mirrored queue policies have no effect on quorum queues — quorum queues handle their own replication and ignore mirroring policies. You cannot change x-queue-type after creation; migrate existing classic queues by draining and recreating.

Use quorum queues for all production task queues on RabbitMQ CLUSTER_MULTI_AZ deployments. Use classic queues for DLQs and ephemeral queues (like per-request reply queues that use exclusive: true and auto-delete).

High availability: choosing and configuring your deployment mode

Amazon MQ offers HA deployment for both engines, but the architectures are fundamentally different. This section synthesises the full HA guide from the Amazon MQ active/standby and HA guide.

ActiveMQ ACTIVE_STANDBY_MULTI_AZ

Two broker nodes in different availability zones. The active node handles all connections and writes. The standby node stays synchronized via shared Amazon EFS filesystem. When the active node fails, Amazon MQ promotes the standby — failover typically completes in 30–60 seconds.

Both nodes are always present in the broker description. Use DescribeBrokerCommand to retrieve both endpoints at startup. The critical mistake: connecting using only the active node's endpoint. If you connect to a single hardcoded endpoint and that node fails, your MCP server loses its broker connection with no reconnection path. You must configure your client to know about both endpoints.

For STOMP clients, use stompit.ConnectFailover with both endpoint configurations in an array and randomize: false (try primary first, standby second). The ConnectFailover will cycle through the array on each reconnect attempt. Set maxReconnects: -1 to retry indefinitely — during maintenance events you may need to retry for a minute or more before the standby is fully ready.

const failover = new stompit.ConnectFailover([primaryConfig, standbyConfig], {
  randomize: false,
  initialReconnectDelay: 1000,
  maxReconnectDelay: 30000,
  useExponentialBackOff: true,
  maxReconnects: -1
});
const channel = stompit.createChannel(failover);
// Subscriptions are automatically re-established after reconnect

For OpenWire clients (less common in Node.js), use the failover transport URI syntax: failover://(ssl://primary:61617,ssl://standby:61617)?randomize=false. This URI encodes the failover logic in the connection string — the OpenWire client handles reconnection transparently without application-level retry logic.

RabbitMQ CLUSTER_MULTI_AZ

Three broker nodes across three availability zones. Unlike ActiveMQ active/standby, all three RabbitMQ nodes are active simultaneously — each accepts connections and handles message routing. Quorum queues replicate message state across all three nodes; the cluster tolerates one node failure without data loss or message delivery interruption.

The CLUSTER_MULTI_AZ deployment returns a single cluster endpoint from DescribeBrokerCommand — a load-balanced hostname that routes connections to healthy nodes. This endpoint remains available during single-node failures, which means amqp-connection-manager's automatic reconnection handles failover transparently for most scenarios. You do not need to configure multiple endpoint URLs unless you are explicitly testing node-level failure isolation.

RabbitMQ cluster failover is significantly faster than ActiveMQ active/standby (10–30 seconds vs 30–60 seconds) because there is no storage failover needed — quorum queues' replicated state is immediately available on surviving nodes.

Deployment mode comparison

AttributeActiveMQ ACTIVE_STANDBY_MULTI_AZRabbitMQ CLUSTER_MULTI_AZ
Node count2 (1 active, 1 standby)3 (all active)
StorageShared Amazon EFS filesystemQuorum replication (Raft protocol)
Client failoverMust explicitly configure ConnectFailover or failover URI — single endpoint fails to reconnectCluster endpoint load-balances; amqp-connection-manager handles transparently
Failover time30–60 seconds (EFS mount + broker start)10–30 seconds (no storage failover)
Message safety during failoverPersistent messages on shared EFS survive; non-persistent messages may be lostQuorum queue messages survive any single-node failure; classic queue messages on the failed node may be lost
Throughput during failoverBrief pause while standby becomes active; in-flight messages redeliveredNo pause — other nodes continue serving; in-flight messages on failed node requeued by quorum protocol

In-flight message safety: the production gotchas that cause silent data loss

This section covers the failure modes that are most dangerous in production because they are silent — no error is returned, no exception is thrown, messages simply vanish. Getting these right is the difference between a message broker that makes your MCP architecture more reliable and one that introduces a new category of hard-to-debug data loss.

Gotcha 1: persistent + confirms is required, not optional

During a broker failover, the following scenario causes silent message loss: your MCP tool handler publishes a task message, the broker accepts the message into memory, begins writing to durable storage, and then the broker process is killed before the write completes. If the message was not durable (persistent: false), it is gone — no error is returned to the publisher. If the message was durable but you did not use publisher confirms, your publisher has no way to know the write failed.

The correct pattern: always set persistent: true on task messages AND use publisher confirms. With confirms enabled, if the broker cannot persist a message (because it is nacking due to a failover in progress), your code receives a nack or a connection exception, and can retry the publish after reconnecting. Without confirms, you have no feedback mechanism for the failure.

On RabbitMQ with amqp-connection-manager, channelWrapper.publish() returns a promise that resolves on ack and rejects on nack. Await it and handle the rejection. On ActiveMQ with STOMP, persistent messages are fire-and-forget without a confirm mechanism — for critical task messages, check that the message count on the queue increased after publish (via management API for RabbitMQ, or via the web console for ActiveMQ) if you need confirmation.

Gotcha 2: redelivered messages require consumer idempotency

During broker failover, any message that was delivered to a consumer but not yet acknowledged will be redelivered after the failover completes. The consumer will see the same message again with the redelivered flag set to true (in AMQP: msg.fields.redelivered; in STOMP, the redelivered header on the message).

If your task handler is not idempotent — if running it twice causes duplicate side effects (two invoices sent, two rows inserted, two API calls made) — a failover event will cause exactly that. The correct pattern: for every task, record completion in a durable store before acknowledging. On processing a redelivered message, check the store first:

channel.consume("mcp.tasks.reports", async (msg) => {
  if (!msg) return;
  const task = JSON.parse(msg.content.toString());

  if (msg.fields.redelivered) {
    const alreadyCompleted = await checkTaskCompleted(task.jobId);
    if (alreadyCompleted) {
      channel.ack(msg);  // Safe: already done, just clear it
      return;
    }
  }

  await processReportTask(task);
  await markTaskCompleted(task.jobId);  // Record before ack
  channel.ack(msg);
}, { noAck: false });

The markTaskCompleted + checkTaskCompleted pattern needs a durable store: DynamoDB with a TTL-based cleanup, Redis with an expiry, or a PostgreSQL table with a unique constraint on jobId. The store TTL should be longer than your maximum task retry window — if the longest-running task type can take 30 minutes and may be retried up to 3 times over 2 hours, set the TTL to at least 24 hours.

Gotcha 3: ActiveMQ active/standby needs an explicit failover URI — a single endpoint silently disconnects

This is the most common ActiveMQ HA misconfiguration. If you connect your STOMP client to only the active node's endpoint, and that node fails, your client's connection drops with no reconnection path to the standby. The connection manager's retry logic will keep trying the same dead endpoint until it times out or reaches max retries. Your MCP tool handlers will all block until the timeout, then fail with connection errors. The standby has taken over and is accepting connections, but your client does not know the standby's address.

The fix: always use stompit.ConnectFailover with both endpoints, retrieved from DescribeBrokerCommand at startup. Never hardcode the active endpoint — broker endpoints can change after maintenance events, and the active/standby roles swap after every failover.

async function getActiveMQEndpoints(brokerId) {
  const broker = await mq.send(new DescribeBrokerCommand({ BrokerId: brokerId }));
  const stompEndpoints = broker.BrokerInstances
    .flatMap(i => i.Endpoints)
    .filter(e => e.includes(":61614"));
  // Returns both primary and standby STOMP endpoints
  return stompEndpoints;
}
// Use all returned endpoints in ConnectFailover

Gotcha 4: RabbitMQ management API requires URL-encoded vhost

When querying the RabbitMQ management API for queue metrics, the virtual host must be URL-encoded in the path. The default virtual host is /, which must be encoded as %2F in the URL: GET /api/queues/%2F. Without the encoding, the request resolves to /api/queues/ which may return a different vhost or a 404 depending on your broker configuration. This is a silent failure — no error, just empty or wrong results.

Gotcha 5: messages declared non-durable or queues declared non-durable cause silent loss on restart

Both ActiveMQ and RabbitMQ require two levels of durability to survive a broker restart: (1) the queue must be declared as durable, and (2) each message must be published as persistent. Missing either causes silent loss. A durable queue with non-persistent messages will lose all in-queue messages on restart. A non-durable queue with persistent messages will lose the queue definition itself on restart — the queue simply disappears.

For RabbitMQ, there is a third level: exchanges must also be declared as durable (durable: true in assertExchange). A non-durable exchange disappears on broker restart, and any messages published to it after restart go to a non-existent destination and are silently dropped.

Monitoring broker health from MCP tool handlers

An MCP server that relies on a broker for task dispatch is only as reliable as that broker. Build health visibility into your MCP server architecture from the start, not as an afterthought.

Startup health check

Before the MCP server accepts any tool calls, check that the broker is RUNNING via DescribeBrokerCommand. A tool server that starts up with a downed broker will silently fail every broker-dependent tool call with timeouts. Early detection surfaces the problem immediately:

async function assertBrokerHealthy(brokerId) {
  const broker = await mq.send(new DescribeBrokerCommand({ BrokerId: brokerId }));
  if (broker.BrokerState !== "RUNNING") {
    throw new Error(`Broker not ready: ${broker.BrokerState}`);
  }
  if (broker.PendingEngineVersion || broker.PendingSecurityGroups?.length) {
    console.warn("Broker has pending changes — expect maintenance window");
  }
  return broker.BrokerInstances.flatMap(i => i.Endpoints);
}

RabbitMQ management API for queue depth monitoring

Amazon MQ exposes the RabbitMQ management HTTP API at port 443 (HTTPS) on the broker endpoint. Query it from an MCP tool to surface queue health metrics — queue depth, consumer count, message rates — without requiring CloudWatch setup. The key endpoint: GET /api/queues/%2F (note %2F for the default vhost) with HTTP Basic Auth using broker credentials.

The two metrics that matter most for task queue health: messages (the depth of unprocessed messages) and consumers (the number of active consumers). A queue with consumers: 0 and growing messages means your worker processes have all crashed — tasks are accumulating with no one to process them. A queue with messages growing faster than the consume rate despite adequate consumers indicates a throughput problem. Build an MCP tool that surfaces this:

server.tool(
  "get_broker_queue_health",
  "Return current message counts and consumer status for all MCP task queues.",
  {},
  async () => {
    const queues = await getQueueMetrics(brokerHost, username, password);
    const mcpQueues = queues.filter(q => q.name.startsWith("mcp.") || q.name.startsWith("dlq."));
    const warnings = mcpQueues
      .filter(q => q.consumers === 0 && q.messages > 0)
      .map(q => `No consumers: ${q.name} has ${q.messages} queued messages`);
    return { content: [{ type: "text", text: JSON.stringify({ queues: mcpQueues, warnings }) }] };
  }
);

For ActiveMQ, queue depth metrics are available via CloudWatch (AmazonMQ/MessageCount and AmazonMQ/ConsumerCount dimensions). Set CloudWatch alarms on these metrics to get paged when queue depth exceeds a threshold or consumer count drops to zero.

AliveMCP for end-to-end tool availability monitoring

Queue depth and consumer counts tell you about broker-side health. But what the calling agent actually experiences is whether tool calls succeed and return results within an acceptable latency. AliveMCP monitors your MCP server endpoint's availability and tool response latency end-to-end, alerting via Slack and email when broker-dependent tools stop responding. This catches failure modes that neither CloudWatch metrics nor queue depth monitoring surfaces directly — like a situation where workers are consuming tasks but never posting results to the reply queue, leaving tool calls to timeout silently.

Planned maintenance and failover testing

Amazon MQ brokers receive periodic maintenance updates during configurable maintenance windows. For ACTIVE_STANDBY_MULTI_AZ ActiveMQ, the maintenance sequence is: standby receives update first; then active is failed over to standby (now updated) and the original active receives its update; then the original active becomes the new standby. Total downtime is under 60 seconds for most updates, but your client must handle the failover correctly during this window.

Inspect upcoming maintenance windows from your MCP server:

async function checkMaintenanceWindow(brokerId) {
  const broker = await mq.send(new DescribeBrokerCommand({ BrokerId: brokerId }));
  const { DayOfWeek, TimeOfDay, TimeZone } = broker.MaintenanceWindowStartTime;
  return {
    nextWindow: `${DayOfWeek} ${TimeOfDay} ${TimeZone}`,
    pendingEngineUpgrade: broker.PendingEngineVersion ?? null,
    brokerState: broker.BrokerState
  };
}

For planned failover testing without waiting for a maintenance event, use RebootBrokerCommand to reboot the active node. The standby takes over within the normal failover window, giving you a controlled test of your client's reconnection behavior. Run this test in staging before every broker configuration change that could affect failover behavior — adding security groups, updating engine versions, changing subnet configuration.

Consolidated failure patterns

Error / symptomCauseFix
Connection refused on port 5671 or 61614 Security group does not allow inbound from MCP server's security group, or broker is not yet RUNNING Check DescribeBrokerCommand for RUNNING state; add TCP inbound rule on the broker security group from the MCP server's security group
ACCESS_REFUSED / authentication failure Wrong username/password; for RabbitMQ, user lacks virtual host permission on / Use DescribeUserCommand to verify the user exists; for RabbitMQ, set vhost permissions via management API; rotate credential in Secrets Manager and redeploy
Messages lost after broker restart Queue not declared as durable: true, or messages sent without persistent: true Assert queues with durable: true; send messages with persistent: true (deliveryMode 2); for RabbitMQ, use quorum queues for maximum durability
Tasks lost silently during broker failover Publisher confirms not enabled — broker confirmed in memory but could not persist before failover Enable publisher confirms (channel.confirmSelect() for RabbitMQ); await confirms before returning to caller; re-publish on nack after reconnect
Duplicate task execution after failover Unacknowledged messages redelivered after failover; consumer not idempotent Check msg.fields.redelivered and look up job completion state in a durable store before processing; call markTaskCompleted before channel.ack()
ActiveMQ client does not reconnect after failover Client configured with single primary endpoint; standby address unknown Retrieve both endpoints from DescribeBrokerCommand; configure stompit.ConnectFailover with both; never hardcode a single ActiveMQ active/standby endpoint
Tasks accumulate with no consumers Worker processes crashed; consumer count dropped to zero Monitor consumers count via RabbitMQ management API or CloudWatch; alert when consumers === 0 && messages > 0 on any task queue
High memory alarm — broker stops accepting publishes Consumer lag — message accumulation exceeds broker memory threshold Scale consumer count; set channel.prefetch() to bound in-flight messages; monitor AmazonMQ/MessageCount CloudWatch metric
RabbitMQ management API returns wrong vhost data Default vhost / not URL-encoded as %2F in request URL Encode vhost as %2F: GET /api/queues/%2F
stompit ConnectFailover only tries primary host indefinitely maxReconnects set too low; standby not in server configs array Set maxReconnects: -1 for indefinite retry; populate both primary and standby STOMP endpoints in serverConfigs
RabbitMQ quorum queue declaration fails Attempting to change x-queue-type on existing classic queue Drain and delete the classic queue; recreate with x-queue-type: quorum; migrate existing messages via shovel if needed

Architecture decision summary

For a new MCP server deployment choosing Amazon MQ as its async dispatch layer, the recommended configuration is: RabbitMQ CLUSTER_MULTI_AZ, with amqp-connection-manager as the connection layer, quorum queues for all task queues, publisher confirms enabled on all task publishes, dead-letter exchanges on every task queue, and an MCP tool that queries the management API for real-time queue health metrics. This configuration is resilient to single AZ failure, provides durable message storage via quorum replication, gives you broker-level confirmation of every published task, and surfaces queue health in a form that agents can inspect without leaving the MCP tool surface.

For teams migrating from an existing ActiveMQ deployment, retain ActiveMQ on ACTIVE_STANDBY_MULTI_AZ and add stompit.ConnectFailover with both endpoint addresses. The virtual topic pattern provides durable fan-out to multiple downstream services without the exchange/binding overhead. Add per-destination DLQ configuration to the broker XML via Amazon MQ's custom broker configuration resource. The core invariants are the same as RabbitMQ: persistent messages, explicit acks, idempotent consumers.

Neither engine makes your MCP server automatically reliable. The reliability comes from the patterns: persistent messages, publisher confirms, explicit acknowledgements, idempotent consumers, failover-aware client configuration, and monitoring that surfaces queue depth and consumer count before they become user-visible failures.

Amazon MQ arc — full guide series

This blog post synthesises the complete Amazon MQ arc for MCP server developers. The individual guides go deeper on each engine and HA topic:

For end-to-end visibility into your MCP server's availability — including tool call latency measured through broker-dependent tools — AliveMCP provides uptime monitoring with Slack and email alerting when your tools stop responding.