arXiv:2606.30317cs.SEcs.AI2026-06

总结LLM应用中MCP服务器的五种架构模式与实践问题。

MCP Server Architecture Patterns for LLM-Integrated Applications

  • 提炼出五类MCP服务器架构模式,解决工具集成与上下文管理问题。
  • 发现每10~15个工具时,Claude Haiku 4.5的选工具准确率跌破90%。
  • 适合构建智能系统、开发人员和平台架构师参考。

Anthropic于2024年11月推出的模型上下文协议(MCP)定义了大语言模型(LLMs)连接外部工具、数据源和服务的标准接口。发布数月内,GitHub上涌现出数百个社区构建的MCP服务器,但尚未有文献描述其在生产中的实际架构形态。本文通过分析十五个独立开发的服务器(包括五个来自ANSYR语音AI平台的生产级服务器及十个官方MCP注册表中的公开服务器),归纳出五种常见架构模式:资源网关、工具编排器、有状态会话服务器、代理聚合器和领域专用适配器。每种模式均按Gamma等人的结构化框架(上下文、问题、解决方案、后果)进行阐述。同时记录了四种反模式,并梳理了认证、版本控制和可观测性等共性挑战。定量评估包含三项指标:两名独立LLM评审者对54个未见服务器的分类一致性(Cohen's kappa = 0.76),定位出三处模式边界模糊点;环回路径下的传输开销测量;以及工具数量研究显示,对于Claude Haiku 4.5,每上下文工具数超过10~15个时选型准确率低于90%;对Sonnet 4则在20~30个工具时出现类似下降。代码、语料库和提示词已作为可复现包发布。

原文摘要 · Abstract (English)

The Model Context Protocol (MCP), introduced by Anthropic in November 2024, defines a standardized interface for connecting large language models (LLMs) to external tools, data sources, and services. Within months of release, hundreds of community-built MCP servers appeared on GitHub, but no software-maintenance literature has yet described how the ecosystem is being structured in production. This industry experience paper catalogues five recurring MCP server architectural patterns observed across an enumerated corpus of fifteen independently developed servers (five production servers from the ANSYR voice AI platform plus ten public servers from the official MCP registry): Resource Gateway, Tool Orchestrator, Stateful Session Server, Proxy Aggregator, and Domain-Specific Adapter. Each pattern is described in the structured form of Gamma et al.: context, problem, solution, and consequences. We also document four anti-patterns and a set of cross-cutting concerns around authentication, versioning, and observability. The quantitative evaluation contributes three measurements: inter-rater reliability of the taxonomy across two independent LLM raters on 54 held-out servers (Cohen's kappa = 0.76), which also localizes three pattern-boundary ambiguities; transport overhead measured end-to-end on loopback and modeled for cross-host paths; and a tool-count study showing tool-selection accuracy drops below 90% between 10 and 15 tools per context for Claude Haiku 4.5 and between 20 and 30 tools for Sonnet 4. Code, corpus, and prompts are released as a replication package.

LLM架构MCP协议系统设计工具集成

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。