使用官方 MCP SDK 重构客户端 - #1643
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist / 检查清单
未关联自动关闭的 issue;人工审查尚未完成。
Description / 描述
背景
现有 MCP client 手写了 JSON-RPC over HTTP 的 POST-only 子集,固定按 JSON 解析响应,无法处理标准 Streamable HTTP 的 SSE 响应、协议 header、session 与 transport 生命周期。此改动响应 PR #1573 的讨论。
本次改动
@modelcontextprotocol/sdk的Client与StreamableHTTPClientTransport直接替换手写协议实现。1.29.0;1.30.0未满足仓库minimumReleaseAge约束,因此没有绕过供应链保护。实现考虑
只导入 HTTP client 入口,没有引入 stdio transport。生产 service worker 产物扫描未发现
node:child_process、node:stream、node:process、cross-spawn或StdioClientTransport。已知限制
本次没有扩展 OAuth、sampling、elicitation 或 tasks 等产品能力;仍只迁移现有工具、资源和提示词能力。
Screenshots / 截图
N/A — 非视觉改动。
验证
pnpm exec vitest run --no-coverage --reporter=verbose src/app/service/agent/core/mcp_client.test.ts src/app/service/agent/service_worker/mcp.test.ts:17/17 通过。pnpm run typecheck:通过。pnpm run lint:ci:通过。pnpm run build:通过;仅有既有 bundle size 与 Monaco dynamic require 警告。dist/ext,经serviceWorker/agent/mcpApi完成添加 server、testConnection、工具/资源/提示词发现及删除,1/1 通过。pnpm run test:ci:3490/3491 通过;唯一失败是未修改的MigrationSection.test.tsx在全套并发下超过 850ms(约 931ms)。原测试随后单独复跑 48ms 通过,未修改该测试或其实现。git diff --check:通过。参考