DevOps
A resilience pattern that wraps MCP calls with health-aware gates using three states: Closed (normal), Open (failures detected, fast-fail), and Half-Open (testing recovery). Prevents cascading failures when tools become unresponsive. Essential for production-grade reliability.
Full FlowZap Code
Host { # Host Application
n1: circle label="User sends prompt"
n2: rectangle label="Agent prepares MCP call"
n3: rectangle label="Pass call to circuit breaker"
n4: rectangle label="Receive result or error"
n5: rectangle label="Agent responds to user"
n1.handle(right) -> n2.handle(left)
n2.handle(right) -> n3.handle(left)
n3.handle(bottom) -> CB.n6.handle(top) [label="MCP tool call"]
n4.handle(right) -> n5.handle(left)
}
CB { # Circuit Breaker
n6: rectangle label="Check circuit state"
n7: diamond label="Circuit open?"
n8: rectangle label="Forward to MCP server"
n9: rectangle label="Fast-fail with error"
n10: diamond label="Call succeeded?"
n11: rectangle label="Record success"
n12: rectangle label="Record failure and check threshold"
n6.handle(right) -> n7.handle(left)
n7.handle(right) -> n8.handle(left) [label="Closed"]
n7.handle(bottom) -> n9.handle(top) [label="Open"]
n8.handle(bottom) -> MCPServer.n13.handle(top) [label="Forward request"]
n9.handle(top) -> Host.n4.handle(bottom) [label="CircuitOpenError"]
n10.handle(right) -> n11.handle(left) [label="Yes"]
n10.handle(bottom) -> n12.handle(top) [label="No"]
n11.handle(top) -> Host.n4.handle(left) [label="Return result"]
n12.handle(top) -> Host.n4.handle(right) [label="Return error"]
}
MCPServer { # MCP Server
n13: rectangle label="Attempt tool execution"
n14: rectangle label="Return result or error"
n13.handle(right) -> n14.handle(left)
n14.handle(top) -> CB.n10.handle(bottom) [label="Execution outcome"]
}
Related templates
DevOps
The simplest MCP pattern — direct connection between host application and MCP server over stdio or HTTP. No extra hops, lowest latency, easiest debugging. Perfect for MVPs, hackathons, and single-team setups where security governance is not yet a concern.
DevOps
An API gateway pattern that sits between agents and MCP servers to handle authentication, rate limits, and auditing. The gateway enforces OAuth 2.0, SAML, SSO, tool-level rate limiting, and team-based quotas. Essential for multi-team or multi-tenant MCP deployments.
DevOps
A routing pattern that puts a semantic router in front of MCP tools so the LLM only sees the subset it needs. Uses vector embeddings and cosine similarity to match user intent to tools dynamically. Achieves up to 96% reduction in input tokens when dealing with large tool catalogs.
DevOps
A multi-agent mesh pattern where agents communicate through a shared context broker backed by MCP. Enables coordinated tool access and state synchronization across multiple specialized agents (planner, coder, reviewer, operator). Supports both orchestrated and choreographed interaction patterns.
DevOps
A caching and compression layer that sits between agents and MCP servers, intercepting redundant context requests before they hit the wire. Uses TTL-based cache invalidation, Brotli compression, and semantic caching. Can achieve up to 95%+ token reduction and significantly lower LLM bills.
Architecture
A circuit breaker resilience architecture diagram showing the complete state machine with closed, open, and half-open states, failure threshold tracking, recovery timer, and fallback response strategies for protecting services from cascading failures. This template visualizes the circuit breaker pattern in detail, including how the breaker transitions between states based on success and failure counts. Essential for building fault-tolerant microservices that degrade gracefully under load.