欢迎使用 FlowZap,快速、清晰、掌控的绘图应用。

MCP工具路由架构

DevOps

在MCP工具前放置语义路由器的路由模式,使LLM只看到你需要的子集。使用向量嵌入和余弦相似度动态匹配用户意图到工具。在处理大型工具目录时可减少高达96%的输入token。

完整 FlowZap 代码

Host {
  n1: circle label="User sends prompt"
  n2: rectangle label="Agent extracts intent"
  n3: rectangle label="Send intent to router"
  n4: rectangle label="Receive routed result"
  n5: rectangle label="Agent responds to user"
  n1.handle(right) -> n2.handle(left)
  n2.handle(right) -> n3.handle(left)
  n3.handle(bottom) -> Router.n6.handle(top) [label="Intent + tool request"]
  n4.handle(right) -> n5.handle(left)
}

Router {
  n6: rectangle label="Receive intent"
  n7: rectangle label="Semantic match via embeddings"
  n8: diamond label="Which MCP server?"
  n9: rectangle label="Forward to Server A"
  n10: rectangle label="Forward to Server B"
  n11: rectangle label="Normalize and return result"
  n6.handle(right) -> n7.handle(left)
  n7.handle(right) -> n8.handle(left)
  n8.handle(bottom) -> n9.handle(top) [label="Route A"]
  n8.handle(right) -> n10.handle(left) [label="Route B"]
  n9.handle(bottom) -> ServerA.n12.handle(top) [label="Call Server A"]
  n10.handle(bottom) -> ServerB.n14.handle(top) [label="Call Server B"]
  n11.handle(top) -> Host.n4.handle(bottom) [label="Final result"]
}

ServerA {
  n12: rectangle label="Execute tool A"
  n13: rectangle label="Return A result"
  n12.handle(right) -> n13.handle(left)
  n13.handle(top) -> Router.n11.handle(bottom) [label="Result A"]
}

ServerB {
  n14: rectangle label="Execute tool B"
  n15: rectangle label="Return B result"
  n14.handle(right) -> n15.handle(left)
  n15.handle(top) -> Router.n11.handle(left) [label="Result B"]
}

相关模板

MCP上下文代理架构

DevOps

位于智能体和MCP服务器之间的缓存和压缩层,在冗余上下文请求到达网络之前拦截它们。使用基于TTL的缓存失效、Brotli压缩和语义缓存。可实现高达95%以上的token减少,并显著降低LLM账单。

MCP直连架构

DevOps

最简单的MCP模式——通过stdio或HTTP在主机应用程序和MCP服务器之间直接连接。没有额外跳转,延迟最低,调试最容易。非常适合MVP、黑客马拉松和单团队设置,其中安全治理还不是关注点。

MCP网关代理架构

DevOps

位于智能体和MCP服务器之间的API网关模式,用于处理认证、速率限制和审计。网关强制执行OAuth 2.0、SAML、SSO、工具级速率限制和基于团队的配额。对于多团队或多租户MCP部署至关重要。

MCP智能体网格架构

DevOps

多智能体网格模式,其中智能体通过MCP支持的共享上下文代理进行通信。实现多个专业智能体(规划者、编码者、审查者、操作者)之间的协调工具访问和状态同步。支持编排和编排的交互模式。

MCP断路器架构

DevOps

弹性模式,使用三种状态包装MCP调用:关闭(正常)、打开(检测到故障,快速失败)和半开(测试恢复)。防止工具无响应时的级联故障。对于生产级可靠性至关重要。

AI原生单智能体架构

Architecture

单智能体AI架构,其中一个智能体处理所有事务:解析请求、推理、通过MCP调用工具、生成响应。这是原型和简单自动化的默认架构——易于调试,但很快达到上下文窗口限制且难以并行化。适合快速交付的MVP和独立开发者。

返回所有模板