MCP网关代理架构
DevOps
位于智能体和MCP服务器之间的API网关模式,用于处理认证、速率限制和审计。网关强制执行OAuth 2.0、SAML、SSO、工具级速率限制和基于团队的配额。对于多团队或多租户MCP部署至关重要。
完整 FlowZap 代码
Host { # Host Application
n1: circle label="User sends prompt"
n2: rectangle label="Agent builds tool call"
n3: rectangle label="Send request to gateway"
n4: rectangle label="Receive gateway response"
n5: rectangle label="Agent responds to user"
n1.handle(right) -> n2.handle(left)
n2.handle(right) -> n3.handle(left)
n3.handle(bottom) -> Gateway.n6.handle(top) [label="Tool request"]
n4.handle(right) -> n5.handle(left)
}
Gateway { # MCP Gateway
n6: rectangle label="Receive and log request"
n7: diamond label="Authorized?"
n8: rectangle label="Forward to MCP server"
n9: rectangle label="Receive MCP response"
n10: rectangle label="Log response and return"
n6.handle(right) -> n7.handle(left)
n7.handle(right) -> n8.handle(left) [label="Yes"]
n7.handle(top) -> Host.n4.handle(left) [label="401 Unauthorized"]
n8.handle(bottom) -> MCPServer.n11.handle(top) [label="Forwarded request"]
n9.handle(right) -> n10.handle(left)
n10.handle(top) -> Host.n4.handle(bottom) [label="Authorized response"]
}
MCPServer { # MCP Server
n11: rectangle label="Execute tool"
n12: rectangle label="Return result"
n11.handle(right) -> n12.handle(left)
n12.handle(top) -> Gateway.n9.handle(bottom) [label="Tool result"]
}
相关模板
MCP智能体网格架构
DevOps
多智能体网格模式,其中智能体通过MCP支持的共享上下文代理进行通信。实现多个专业智能体(规划者、编码者、审查者、操作者)之间的协调工具访问和状态同步。支持编排和编排的交互模式。
MCP上下文代理架构
DevOps
位于智能体和MCP服务器之间的缓存和压缩层,在冗余上下文请求到达网络之前拦截它们。使用基于TTL的缓存失效、Brotli压缩和语义缓存。可实现高达95%以上的token减少,并显著降低LLM账单。
微服务 API 网关架构
Architecture
微服务 API 网关架构图,展示请求路由、JWT 身份验证、速率限制、服务发现以及跨分布式后端服务的响应聚合。该模板模拟微服务生态系统中所有客户端流量的入口点,在请求到达内部服务之前执行安全策略。适合设计具有集中式横切关注点的可扩展 API 基础设施的平台工程师。