From cc88a7e90ae663446be4f8e656970e533c5ef76b Mon Sep 17 00:00:00 2001 From: xfy Date: Tue, 28 Jul 2026 16:39:43 +0800 Subject: [PATCH] =?UTF-8?q?fix(mcp):=20=E4=BF=AE=E6=AD=A3=20Oh-My-Pi=20?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=A0=BC=E5=BC=8F=E4=B8=8E=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 三处错误(据 omp 客户端实际报错): 1. 字段名 transport→type,值 streamable-http→http:omp 不识别 transport, 遇未知字段退化为 stdio 因缺 command 报错丢弃 2. 路径 ~/.pi/agent/mcp.json→.mcp.json / ~/.omp/agent/mcp.json / ~/.mcp.json 3. omp 与 Claude Code 的 JSON 体现完全相同,差异仅在配置文件路径 --- src/api/mcp_tokens.rs | 2 +- src/mcp/config.rs | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/api/mcp_tokens.rs b/src/api/mcp_tokens.rs index 3392d22..e765f86 100644 --- a/src/api/mcp_tokens.rs +++ b/src/api/mcp_tokens.rs @@ -306,7 +306,7 @@ pub async fn get_mcp_client_configs(token: String) -> Result ClientConfigs { } } }); - - // --- Oh-My-Pi:字段名是 transport(非 type),值仍为 streamable-http --- + // --- Oh-My-Pi:type = "http"(与 Claude Code 同形)。omp 不识别 transport/streamable-http, + // 遇未知字段会退化为 stdio 并因缺 command 报错丢弃。与 Claude Code 的 JSON 体相同, + // 差异仅在配置文件路径(见上方字段文档)。 let omp_json = serde_json::json!({ "mcpServers": { SERVER_NAME: { - "transport": "streamable-http", + "type": "http", "url": mcp_url, "headers": { "Authorization": auth_header } } @@ -215,13 +217,14 @@ mod tests { } #[test] - fn omp_json_uses_transport_field_not_type() { + fn omp_json_uses_type_http_not_transport() { let cfg = generate_client_configs(BASE, TOKEN); let v: serde_json::Value = serde_json::from_str(&cfg.omp_json).unwrap(); let entry = &v["mcpServers"]["yggdrasil"]; - // 关键差异:字段名是 transport(非 type)。 - assert_eq!(entry["transport"], "streamable-http"); - assert!(entry.get("type").is_none(), "omp 配置不应含 type 字段"); + // omp 协议字段是 type: "http"(与 Claude Code 同形)。 + assert_eq!(entry["type"], "http"); + // 不应含 transport 字段——会让 omp 退化为 stdio 报错。 + assert!(entry.get("transport").is_none(), "omp 配置不应含 transport 字段"); assert_eq!(entry["url"], "https://rua.plus/mcp"); assert_eq!(entry["headers"]["Authorization"], format!("Bearer {TOKEN}")); }