MCP生产宿主与Tool-Schema治理

MCP 生产宿主与 Tool Schema 治理

🏠 返回 07-README | ⬅️ 14-A2A协议与Agent互操作-Task生命周期 | ➡️ 16-Voice与实时对话Agent-生产架构


§0 面试前 Checklist

金句(90s):见各 L1。

L1 · MCP 在生产栈中的位置

#mermaid-svg-RUwlwX2ygrl7tuHQ{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-RUwlwX2ygrl7tuHQ .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-RUwlwX2ygrl7tuHQ .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-RUwlwX2ygrl7tuHQ .error-icon{fill:#552222;}#mermaid-svg-RUwlwX2ygrl7tuHQ .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-RUwlwX2ygrl7tuHQ .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-RUwlwX2ygrl7tuHQ .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-RUwlwX2ygrl7tuHQ .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-RUwlwX2ygrl7tuHQ .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-RUwlwX2ygrl7tuHQ .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-RUwlwX2ygrl7tuHQ .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-RUwlwX2ygrl7tuHQ .marker{fill:#333333;stroke:#333333;}#mermaid-svg-RUwlwX2ygrl7tuHQ .marker.cross{stroke:#333333;}#mermaid-svg-RUwlwX2ygrl7tuHQ svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-RUwlwX2ygrl7tuHQ p{margin:0;}#mermaid-svg-RUwlwX2ygrl7tuHQ .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-RUwlwX2ygrl7tuHQ .cluster-label text{fill:#333;}#mermaid-svg-RUwlwX2ygrl7tuHQ .cluster-label span{color:#333;}#mermaid-svg-RUwlwX2ygrl7tuHQ .cluster-label span p{background-color:transparent;}#mermaid-svg-RUwlwX2ygrl7tuHQ .label text,#mermaid-svg-RUwlwX2ygrl7tuHQ span{fill:#333;color:#333;}#mermaid-svg-RUwlwX2ygrl7tuHQ .node rect,#mermaid-svg-RUwlwX2ygrl7tuHQ .node circle,#mermaid-svg-RUwlwX2ygrl7tuHQ .node ellipse,#mermaid-svg-RUwlwX2ygrl7tuHQ .node polygon,#mermaid-svg-RUwlwX2ygrl7tuHQ .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-RUwlwX2ygrl7tuHQ .rough-node .label text,#mermaid-svg-RUwlwX2ygrl7tuHQ .node .label text,#mermaid-svg-RUwlwX2ygrl7tuHQ .image-shape .label,#mermaid-svg-RUwlwX2ygrl7tuHQ .icon-shape .label{text-anchor:middle;}#mermaid-svg-RUwlwX2ygrl7tuHQ .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-RUwlwX2ygrl7tuHQ .rough-node .label,#mermaid-svg-RUwlwX2ygrl7tuHQ .node .label,#mermaid-svg-RUwlwX2ygrl7tuHQ .image-shape .label,#mermaid-svg-RUwlwX2ygrl7tuHQ .icon-shape .label{text-align:center;}#mermaid-svg-RUwlwX2ygrl7tuHQ .node.clickable{cursor:pointer;}#mermaid-svg-RUwlwX2ygrl7tuHQ .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-RUwlwX2ygrl7tuHQ .arrowheadPath{fill:#333333;}#mermaid-svg-RUwlwX2ygrl7tuHQ .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-RUwlwX2ygrl7tuHQ .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-RUwlwX2ygrl7tuHQ .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-RUwlwX2ygrl7tuHQ .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-RUwlwX2ygrl7tuHQ .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-RUwlwX2ygrl7tuHQ .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-RUwlwX2ygrl7tuHQ .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-RUwlwX2ygrl7tuHQ .cluster text{fill:#333;}#mermaid-svg-RUwlwX2ygrl7tuHQ .cluster span{color:#333;}#mermaid-svg-RUwlwX2ygrl7tuHQ div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-RUwlwX2ygrl7tuHQ .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-RUwlwX2ygrl7tuHQ rect.text{fill:none;stroke-width:0;}#mermaid-svg-RUwlwX2ygrl7tuHQ .icon-shape,#mermaid-svg-RUwlwX2ygrl7tuHQ .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-RUwlwX2ygrl7tuHQ .icon-shape p,#mermaid-svg-RUwlwX2ygrl7tuHQ .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-RUwlwX2ygrl7tuHQ .icon-shape .label rect,#mermaid-svg-RUwlwX2ygrl7tuHQ .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-RUwlwX2ygrl7tuHQ .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-RUwlwX2ygrl7tuHQ .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-RUwlwX2ygrl7tuHQ :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} SSE
Agent Runtime
MCP Server Java
Domain API
Registry

角色 职责
MCP Client LangGraph / Spring AI
MCP Server 鉴权、schema、执行、审计
Registry tool_schema_ref pin

L2 · 宿主设计(深展)

2.1 部署形态

形态 适用 风险
Sidecar 强隔离 资源多
共享服务 推荐 需 bulkhead
stdio dev only 无鉴权

2.2 Tool 设计十诫

# 规则
1 窄 Tool,禁万能 SQL
2 写 Tool 必 HITL
3 幂等键写操作必备
4 tenant 服务端强制
5 schema 版本进 Registry
6 错误码可机器读
7 超时 < Agent deadline
8 审计 log 脱敏
9 只读默认
10 红队非法 Tool 名 Golden

L3 · Schema 治理

阶段 动作
设计 JSON Schema 入 Git
PR breaking change 检测
发布 tool_schema_ref 写入 Release
回滚 先 schema 维

L4 · 与 A2A / gRPC

场景 选型
查订单 MCP get_order
调 Python 推理 gRPC 13
外包伙伴 A2A 14

L11 · STAR

STAR:schema 未 pin 全红

要素 内容
S 发版未绑 tool_schema_ref
A Release Record 四维绑定;CI 契约测
M illegal_tool_rate 飙升
P 回滚 schema;Canary

Q1 · 大厂题 #1

标准答案:结合本章 L2--L3 机制回答;强调 release_id、审计、Golden 门禁。

追问:如何回滚?→ Registry 先回滚 schema/prompt 维。

Q2 · 大厂题 #2

标准答案:结合本章 L2--L3 机制回答;强调 release_id、审计、Golden 门禁。

追问:如何回滚?→ Registry 先回滚 schema/prompt 维。

Q3 · 大厂题 #3

标准答案:结合本章 L2--L3 机制回答;强调 release_id、审计、Golden 门禁。

追问:如何回滚?→ Registry 先回滚 schema/prompt 维。

Q4 · 大厂题 #4

标准答案:结合本章 L2--L3 机制回答;强调 release_id、审计、Golden 门禁。

追问:如何回滚?→ Registry 先回滚 schema/prompt 维。

Q5 · 大厂题 #5

标准答案:结合本章 L2--L3 机制回答;强调 release_id、审计、Golden 门禁。

追问:如何回滚?→ Registry 先回滚 schema/prompt 维。

Q6 · 大厂题 #6

标准答案:结合本章 L2--L3 机制回答;强调 release_id、审计、Golden 门禁。

追问:如何回滚?→ Registry 先回滚 schema/prompt 维。

Q7 · 大厂题 #7

标准答案:结合本章 L2--L3 机制回答;强调 release_id、审计、Golden 门禁。

追问:如何回滚?→ Registry 先回滚 schema/prompt 维。

Q8 · 大厂题 #8

标准答案:结合本章 L2--L3 机制回答;强调 release_id、审计、Golden 门禁。

追问:如何回滚?→ Registry 先回滚 schema/prompt 维。

Q9 · 大厂题 #9

标准答案:结合本章 L2--L3 机制回答;强调 release_id、审计、Golden 门禁。

追问:如何回滚?→ Registry 先回滚 schema/prompt 维。

Q10 · 大厂题 #10

标准答案:结合本章 L2--L3 机制回答;强调 release_id、审计、Golden 门禁。

追问:如何回滚?→ Registry 先回滚 schema/prompt 维。

§15 Checklist

  • 机制与边界
  • 生产宿主/观测
  • Registry 绑定
  • STAR 各一条
  • Golden 负例

L6 · MCP 参数矩阵(扩展)

6.1 配置组 1

说明
slot_1_timeout_ms 320 超时
slot_1_max_tokens 4224 上下文
slot_1_retry 1 重试

6.2 配置组 2

说明
slot_2_timeout_ms 340 超时
slot_2_max_tokens 4352 上下文
slot_2_retry 2 重试

6.3 配置组 3

说明
slot_3_timeout_ms 360 超时
slot_3_max_tokens 4480 上下文
slot_3_retry 3 重试

6.4 配置组 4

说明
slot_4_timeout_ms 380 超时
slot_4_max_tokens 4608 上下文
slot_4_retry 3 重试

6.5 配置组 5

说明
slot_5_timeout_ms 400 超时
slot_5_max_tokens 4736 上下文
slot_5_retry 3 重试

6.6 配置组 6

说明
slot_6_timeout_ms 420 超时
slot_6_max_tokens 4864 上下文
slot_6_retry 3 重试

6.7 配置组 7

说明
slot_7_timeout_ms 440 超时
slot_7_max_tokens 4992 上下文
slot_7_retry 3 重试

6.8 配置组 8

说明
slot_8_timeout_ms 460 超时
slot_8_max_tokens 5120 上下文
slot_8_retry 3 重试

6.9 配置组 9

说明
slot_9_timeout_ms 480 超时
slot_9_max_tokens 5248 上下文
slot_9_retry 3 重试

6.10 配置组 10

说明
slot_10_timeout_ms 500 超时
slot_10_max_tokens 5376 上下文
slot_10_retry 3 重试

6.11 配置组 11

说明
slot_11_timeout_ms 520 超时
slot_11_max_tokens 5504 上下文
slot_11_retry 3 重试

6.12 配置组 12

说明
slot_12_timeout_ms 540 超时
slot_12_max_tokens 5632 上下文
slot_12_retry 3 重试

6.13 配置组 13

说明
slot_13_timeout_ms 560 超时
slot_13_max_tokens 5760 上下文
slot_13_retry 3 重试

6.14 配置组 14

说明
slot_14_timeout_ms 580 超时
slot_14_max_tokens 5888 上下文
slot_14_retry 3 重试

6.15 配置组 15

说明
slot_15_timeout_ms 600 超时
slot_15_max_tokens 6016 上下文
slot_15_retry 3 重试

6.16 配置组 16

说明
slot_16_timeout_ms 620 超时
slot_16_max_tokens 6144 上下文
slot_16_retry 3 重试

6.17 配置组 17

说明
slot_17_timeout_ms 640 超时
slot_17_max_tokens 6272 上下文
slot_17_retry 3 重试

6.18 配置组 18

说明
slot_18_timeout_ms 660 超时
slot_18_max_tokens 6400 上下文
slot_18_retry 3 重试

6.19 配置组 19

说明
slot_19_timeout_ms 680 超时
slot_19_max_tokens 6528 上下文
slot_19_retry 3 重试

6.20 配置组 20

说明
slot_20_timeout_ms 700 超时
slot_20_max_tokens 6656 上下文
slot_20_retry 3 重试

6.21 配置组 21

说明
slot_21_timeout_ms 720 超时
slot_21_max_tokens 6784 上下文
slot_21_retry 3 重试

6.22 配置组 22

说明
slot_22_timeout_ms 740 超时
slot_22_max_tokens 6912 上下文
slot_22_retry 3 重试

6.23 配置组 23

说明
slot_23_timeout_ms 760 超时
slot_23_max_tokens 7040 上下文
slot_23_retry 3 重试

6.24 配置组 24

说明
slot_24_timeout_ms 780 超时
slot_24_max_tokens 7168 上下文
slot_24_retry 3 重试

6.25 配置组 25

说明
slot_25_timeout_ms 800 超时
slot_25_max_tokens 7296 上下文
slot_25_retry 3 重试

2.20 Tool 模板 #0

field type required
tenant_id string yes
idempotency_key string write only

2.21 Tool 模板 #1

field type required
tenant_id string yes
idempotency_key string write only

2.22 Tool 模板 #2

field type required
tenant_id string yes
idempotency_key string write only

2.23 Tool 模板 #3

field type required
tenant_id string yes
idempotency_key string write only

2.24 Tool 模板 #4

field type required
tenant_id string yes
idempotency_key string write only

2.25 Tool 模板 #5

field type required
tenant_id string yes
idempotency_key string write only

2.26 Tool 模板 #6

field type required
tenant_id string yes
idempotency_key string write only

2.27 Tool 模板 #7

field type required
tenant_id string yes
idempotency_key string write only

2.28 Tool 模板 #8

field type required
tenant_id string yes
idempotency_key string write only

2.29 Tool 模板 #9

field type required
tenant_id string yes
idempotency_key string write only

2.30 Tool 模板 #10

field type required
tenant_id string yes
idempotency_key string write only

2.31 Tool 模板 #11

field type required
tenant_id string yes
idempotency_key string write only

2.32 Tool 模板 #12

field type required
tenant_id string yes
idempotency_key string write only

2.33 Tool 模板 #13

field type required
tenant_id string yes
idempotency_key string write only

2.34 Tool 模板 #14

field type required
tenant_id string yes
idempotency_key string write only

2.35 Tool 模板 #15

field type required
tenant_id string yes
idempotency_key string write only

2.36 Tool 模板 #16

field type required
tenant_id string yes
idempotency_key string write only

2.37 Tool 模板 #17

field type required
tenant_id string yes
idempotency_key string write only

2.38 Tool 模板 #18

field type required
tenant_id string yes
idempotency_key string write only

2.39 Tool 模板 #19

field type required
tenant_id string yes
idempotency_key string write only
相关推荐
bdy_y91 天前
PROMPT设计中的“边界感”:从一句规则说到三层对齐
ai·大模型·prompt
头茬韭菜1 天前
22个架构模式速查 + System Prompt全链路拆解
架构·prompt
旋律翼22 天前
AI Prompt 工程化设计最佳实践(Harness Engineering)
人工智能·prompt
人道领域2 天前
【0-1的agent进阶篇】Prompt 与上下文工程
java·开发语言·prompt·mcp
haluhalu.2 天前
prompts.chat:03-core-prompting-principles
prompt·github
承受失3 天前
Cloud Agent 开发笔记(4):Skill 与 MCP 集成、项目后记
人工智能·prompt
haluhalu.3 天前
prompts.chat:02-anatomy-of-effective-prompt
jvm·prompt
城事漫游Molly4 天前
用AI提炼研究问题与假设的完整提示词——从模糊想法到精准RQ/Hypothesis,AI辅助精化全流程
人工智能·机器学习·prompt·ai for science·博士生必读·应用语言学·研究问题