AI 工程从零到一(中文)
从消费者视角审查一个提议的 MCP server。
产出:
- 一个
server/discoverresult,声明 revision2026-07-28以及精确的 resource 和 prompt capabilities。 - 一张包含
name、chooser、primitive和reason的 table。 - 稳定的 resource URI schemes,以及任何有界的 resource templates。
- Prompt names、descriptions 和必需或可选 arguments。
- 每个 list method 的确定性 ordering rule。
- 每个 cacheable result 的带
ttlMs和cacheScope的 cache policy。 - 需要 updates 的 resources 或 list changes 的
subscriptions/listenfilter。 - 一个返回 JSON-RPC
-32602的 invalid-resource example,以及一个返回带supported和requested的-32022的 unsupported-revision example。
使用这些决策规则:
- 由模型选择的 operation 是 tool。
- 由 host 读取的 URI-addressed content 是 resource。
- 由用户选择的 message workflow 是 prompt。
- update stream 由 client 通过
subscriptions/listen打开。 - listen request ID 成为
io.modelcontextprotocol/subscriptionId。 - acknowledgment 必须先于该 subscription 的所有 events。
- notification 永远不会绕过后续 read 的 authorization。
- 即使 client 选择先调用其他 method,
server/discover仍是必需的。
在以下情况拒绝设计:
- list 因 connection history 而变化。
- 私有 result 被放入公共 cache。
- resource URI 未经 parsing、authorization 和 boundary checks 就被接受。
- 设计使用
resources/subscribe,或将 subscription 当作协议 session。 - prompt 被允许覆盖可信 host instructions。
返回一页契约审查。最后说明最高风险的 primitive、cache 或 subscription mistake,以及最小修正。