Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
fix(mcp): handle HTTP acknowledgements without requiring OAuth
zszz3c1ba4f37cddf
diff --git a/apps/desktop/electron/main/plugin-mcp.ts b/apps/desktop/electron/main/plugin-mcp.tsindex c622190ed..aa5fbfd4d 100644--- a/apps/desktop/electron/main/plugin-mcp.ts+++ b/apps/desktop/electron/main/plugin-mcp.ts@@ -360,6 +360,16 @@ function createHttpTransport(}const nextSession = response.headers.get("mcp-session-id");if (nextSession && new URL(url).origin === initialOrigin) sessionId = nextSession;+ // Notifications and client responses have no JSON-RPC reply. Some+ // servers include a plain-text "Accepted" body with their HTTP 202.+ if (response.status === 202 && (message.method === undefined || message.id === undefined)) {+ try {+ await response.body?.cancel();+ } catch {+ // The acknowledgement body is not part of the MCP response.+ }+ return;+ }const contentType = response.headers.get("content-type") ?? "";const body = await readBoundedHttpBody(response);if (!body.trim()) return;diff --git a/apps/desktop/src/components/settings/AgentMcpPage.tsx b/apps/desktop/src/components/settings/AgentMcpPage.tsxindex 725e5f584..719dd9ac9 100644--- a/apps/desktop/src/components/settings/AgentMcpPage.tsx+++ b/apps/desktop/src/components/settings/AgentMcpPage.tsx@@ -433,8 +433,7 @@ export function AgentMcpPage() {const needsAuth =isHttp &&!hasAuthHeader &&- !status?.hasOauth &&- (Boolean(status?.authRequired) || status?.state !== "ready");+ Boolean(status?.authRequired);const items: CapabilityMenuItem[] = [{key: "test",diff --git a/apps/desktop/test/plugin-mcp.test.mjs b/apps/desktop/test/plugin-mcp.test.mjsindex 35ae130ec..2d5560880 100644--- a/apps/desktop/test/plugin-mcp.test.mjs+++ b/apps/desktop/test/plugin-mcp.test.mjs@@ -282,7 +282,7 @@ async function startHttpServer(t) {return;}if (message.method === "notifications/initialized") {- res.writeHead(202).end();+ res.writeHead(202, { "content-type": "text/plain" }).end("Accepted");return;}if (message.method === "tools/list") {diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex bb5ad75e3..b6a2bac64 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -13882,3 +13882,21 @@ the latest destination. These assertions measure work counts, not device FPS.- **Limits:** OS-root inclusion is checked without installing a root. The TLSsuccess fixture uses a child-only extra CA; it does not reproduce a specificantivirus installation or claim native macOS/Linux verification.++### E2E-MCP-HTTP-ACK — HTTP acknowledgement and authorization status++- **Preconditions**: A local mock Streamable HTTP server returns JSON for+ initialize, `202` with plain-text `Accepted` for notifications/initialized,+ SSE for tools/list, and JSON for tools/call. No provider credentials needed.+- **Steps**: Connect, discover a tool, and call it. Render the MCP settings row+ with idle, connecting, ready, non-authentication failure, and authentication+ failure statuses, including an expired stored OAuth credential.+- **Expected**: The acknowledgement does not enter the JSON parser; discovery,+ calls, and session headers remain functional. Only explicit authRequired+ status shows the authorization-required badge. Non-authentication failures+ retain their original error. Authentication failures remain actionable.+- **Specs**: 07-plugins/01-plugin-system §12.2; ADR 0038; ADR 0283.+- **Acceptance**: HTTP client integration and settings component rendering.+- **Milestone**: Maintenance.+- **Status**: Covered by the existing HTTP client integration fixture and a+ focused component-render validation; no live IDA process required.diff --git a/docs/spec/07-plugins/01-plugin-system.md b/docs/spec/07-plugins/01-plugin-system.mdindex f4f3b90e3..652d80606 100644--- a/docs/spec/07-plugins/01-plugin-system.md+++ b/docs/spec/07-plugins/01-plugin-system.md@@ -518,6 +518,16 @@ Rules the control encodes:on each call. Removed tools return `TOOL_NOT_FOUND`. Recovery never replays afailed `tools/call`, which may already have performed a mutation.+- Streamable HTTP `202 Accepted` acknowledgements for notifications and client+ responses are not JSON-RPC replies. Any acknowledgement body is discarded,+ including plain-text `Accepted`; ordinary request replies still follow the+ JSON/SSE parsing and response-size limits.+- The MCP row shows “Authorization required” only when runtime status explicitly+ reports `authRequired`. Missing credentials, an untested connection, and+ non-authentication failures do not imply OAuth is required. A stored OAuth+ credential does not hide a subsequent authentication failure. Manual OAuth+ authorization remains available from the HTTP server menu.+### 12.3 Skills management in Settings > Agent- The Skills page has independent global and selected-project columns rooted atdiff --git a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.mdindex f2260c45e..83c41cf43 100644--- a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md@@ -8186,3 +8186,21 @@ the latest destination. These assertions measure work counts, not device FPS.- **Limits:** OS-root inclusion is checked without installing a root. The TLSsuccess fixture uses a child-only extra CA; it does not reproduce a specificantivirus installation or claim native macOS/Linux verification.++### E2E-MCP-HTTP-ACK — HTTP acknowledgement and authorization status++- **Preconditions**: A local mock Streamable HTTP server returns JSON for+ initialize, `202` with plain-text `Accepted` for notifications/initialized,+ SSE for tools/list, and JSON for tools/call. No provider credentials needed.+- **Steps**: Connect, discover a tool, and call it. Render the MCP settings row+ with idle, connecting, ready, non-authentication failure, and authentication+ failure statuses, including an expired stored OAuth credential.+- **Expected**: The acknowledgement does not enter the JSON parser; discovery,+ calls, and session headers remain functional. Only explicit authRequired+ status shows the authorization-required badge. Non-authentication failures+ retain their original error. Authentication failures remain actionable.+- **Specs**: 07-plugins/01-plugin-system §12.2; ADR 0038; ADR 0283.+- **Acceptance**: HTTP client integration and settings component rendering.+- **Milestone**: Maintenance.+- **Status**: Covered by the existing HTTP client integration fixture and a+ focused component-render validation; no live IDA process required.diff --git a/docs/zh-CN/spec/07-plugins/01-plugin-system.md b/docs/zh-CN/spec/07-plugins/01-plugin-system.mdindex 7e4094d4b..a98a17d27 100644--- a/docs/zh-CN/spec/07-plugins/01-plugin-system.md+++ b/docs/zh-CN/spec/07-plugins/01-plugin-system.md@@ -499,6 +499,16 @@ MCP、技能和子代理由设置 > 智能体下的三个独立页面管理,而不是每次调用都反复连接。已移除的工具返回 `TOOL_NOT_FOUND`。恢复从不重放失败的 `tools/call`,因为那次调用可能已经产生过副作用。+- Streamable HTTP `202 Accepted` acknowledgements for notifications and client+ responses are not JSON-RPC replies. Any acknowledgement body is discarded,+ including plain-text `Accepted`; ordinary request replies still follow the+ JSON/SSE parsing and response-size limits.+- The MCP row shows “Authorization required” only when runtime status explicitly+ reports `authRequired`. Missing credentials, an untested connection, and+ non-authentication failures do not imply OAuth is required. A stored OAuth+ credential does not hide a subsequent authentication failure. Manual OAuth+ authorization remains available from the HTTP server menu.+### 12. 3 设置 > 智能体中的技能管理- 技能页面使用 `~/.agents/skills` 和 `<project>/.agents/skills` 下的全局/项目栏。