构建 MCP 服务器的经验总结
本文总结了作者在构建 MCP (Model Chain Provider) 服务器过程中获得的经验,MCP 服务器的设计目标是让模型能够按照预定流程完成任务,而不是让模型自主规划。
作者强调,为了实现这一目标,服务器需要提供清晰的下一步操作指导,具体体现在:使用少量核心动词集合,输出建议的下一步调用指令,以及使用稳定的地址方案(如锚点、ID、路径)在调用之间保持上下文。
此外,文章还提到了命名规范的重要性,利用前缀匹配引导模型选择合适的工具,并提供诊断工具和标准化的数据包以确保稳定性和可恢复性。
作者最终提供了一份 MCP 设计检查清单,涵盖了核心动词选择、命名规范、数据结构标准化等方面。
查看原文开头(英文 · 仅前 3 段)
I’ve been building MCP servers for a while now–I wrote about the general approach last year, started out by creating umcp, and I’ve recently opened up an Office server that’s been battered by enough models against enough real documents that the patterns have settled.
I’m still not a fan of MCP, but what follows is what I’ve learned about making tool chains actually work, condensed from swearing at logs rather than reading papers.
Disclaimer:This is a condensed version of CHAINING.md, which was itself stapled together from a bunch of notes in my Obsidian vault. The full version has more code examples and a techniques inventory table that Opus just _had to add, and I’ve since beaten that out of it and restored most of the original text (minus typos).
※ 出于版权考虑,仅引用前 3 段。完整内容请阅读原文。