René's URL Explorer Experiment


Title: refactor: MCP 新增状态管理增强与 UI 可视化 by hqwlkj · Pull Request #72 · lessweb/deepcode-cli · GitHub

Open Graph Title: refactor: MCP 新增状态管理增强与 UI 可视化 by hqwlkj · Pull Request #72 · lessweb/deepcode-cli

X Title: refactor: MCP 新增状态管理增强与 UI 可视化 by hqwlkj · Pull Request #72 · lessweb/deepcode-cli

Description: 📋 概述 本 PR 为 Deep Code CLI 增加了完整的 MCP (Model Context Protocol) 服务器状态管理和可视化功能,包括实时状态监控、工具/提示/资源发现、错误处理以及优化的用户交互体验。 🎯 变更类型 ✨ 新功能 🎨 UI 改进 🐛 Bug 修复 ♻️ 代码重构 ✅ 测试更新 📝 主要变更 1. MCP 客户端增强 (src/mcp/mcp-client.ts) 协议版本校验 在初始化时验证服务器返回的 MCP 协议版本 拒绝不支持的协议版本,提升兼容性控制 JSON-RPC 批处理支持 支持处理 JSON-RPC 批量消息 逐条分发消息,提高处理效率 抽离单条消息处理逻辑,统一处理通知和响应 通知机制 支持 JSON-RPC 通知的处理(无 id 字段的服务器主动消息) 防止通知处理器异常导致读取循环崩溃 完善请求超时控制 2. MCP 管理器扩展 (src/mcp/mcp-manager.ts) 状态管理 新增 MCP 状态变更回调机制 (onStatusChanged) 支持 UI 实时刷新显示服务器状态 添加 promptCount、prompts、resourceCount、resources 字段 资源发现 扩展支持发现和 prompts(提示) 扩展支持发现和 resources(资源) 支持工具列表变化的事件通知 (onToolsListChanged) 实现分页列表查询(tools/prompts/resources) 错误处理 移除 MCP 初始化失败的控制台错误输出,避免敏感信息泄露 优化错误信息收集和展示 3. MCP 状态列表 UI (src/ui/McpStatusList.tsx) 全新组件 实现 MCP 服务器状态、工具、提示和资源的可视化展示 支持服务器列表和服务器详情两种视图模式 提供完整的键盘操作支持(上下翻页、快速导航) 交互体验 为启动状态服务器添加动态加载动画 错误信息使用带红色边框的样式包裹,更加醒目 支持通过方向键分页和滚动,确保选中项始终可见 服务器详情视图新增工具、提示和资源的详细列表展示 视觉优化 统一界面中选中项前缀符号由 "› " 改为 "> " 优化行宽计算逻辑,提升标签列自适应能力 改善布局间距和边框样式,增强视觉层次感 为工具项添加左侧缩进优化排版布局 4. 应用集成 (src/ui/App.tsx, src/session.ts) 视图切换 修改 App 组件,支持切换视图显示 MCP 状态列表 在 session 中添加 MCP 工具列表变化监听 实时更新工具定义数据 状态计数高亮 调整 UI 组件以支持状态计数的高亮显示 优化退出命令行提示颜色为灰色,提升可读性 5. 键盘交互优化 冲突解决 移除 Esc 键作为取消操作,避免与 Ctrl+C 冲突 更新底部提示,明确 Ctrl+C 为关闭操作,Esc 为返回操作 调整 MessageView 内容左边距,使间距更合理 6. 测试更新 (src/tests/session.test.ts) 断言字段同步 在 getMcpStatus 的断言中添加 promptCount、prompts、resourceCount 和 resources 字段 确保各状态对象包含完整的提示和资源数组信息 扩展现有测试覆盖,支持提示和资源相关的状态字段验证 🧪 测试验证 所有测试通过(204/204): npm test # tests 204 # pass 204 # fail 0 关键测试用例: ✅ SessionManager dispose disconnects MCP servers ✅ SessionManager reports configured MCP servers as starting before initialization ✅ SessionManager reports MCP startup stderr on failure ✅ SessionManager adds -y when launching MCP servers through npx 状态流转 配置服务器 → starting → ready/failed ↓ 实时更新(工具列表变化等) 键盘导航 上下方向键: 在服务器列表中导航 回车键: 查看服务器详情/返回列表 q/Esc: 返回上一级 Ctrl+C: 退出应用 💡 设计决策 敏感信息保护: 移除 MCP 初始化失败的控制台错误输出,避免泄露配置信息 协议版本校验: 在连接时验证 MCP 协议版本,提前发现兼容性问题 批处理支持: 支持 JSON-RPC 批量消息,提高通信效率 事件驱动: 使用回调机制实现状态实时更新,避免轮询 分页查询: tools/prompts/resources 都支持分页,应对大量数据场景 🔗 相关文档 MCP 配置文档 MCP 使用指南 ⚠️ 注意事项 本 PR 引入了新的 UI 组件 McpStatusList,需要确保终端支持相应的渲染特性 MCP 服务器的 prompts 和 resources 功能是可选的,服务器不支持时会优雅降级 协议版本校验基于 MCP 规范,当前支持 2025-03-26 版本 📸 截图

Open Graph Description: 📋 概述 本 PR 为 Deep Code CLI 增加了完整的 MCP (Model Context Protocol) 服务器状态管理和可视化功能,包括实时状态监控、工具/提示/资源发现、错误处理以及优化的用户交互体验。 🎯 变更类型 ✨ 新功能 🎨 UI 改进 🐛 Bug 修复 ♻️ 代码重构 ✅ 测试更新 📝 主要变更 1. MCP 客户端增强 (src/mcp/mcp...

X Description: 📋 概述 本 PR 为 Deep Code CLI 增加了完整的 MCP (Model Context Protocol) 服务器状态管理和可视化功能,包括实时状态监控、工具/提示/资源发现、错误处理以及优化的用户交互体验。 🎯 变更类型 ✨ 新功能 🎨 UI 改进 🐛 Bug 修复 ♻️ 代码重构 ✅ 测试更新 📝 主要变更 1. MCP 客户端增强 (src/mcp/mcp...

Opengraph URL: https://github.com/lessweb/deepcode-cli/pull/72

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:2ca58e49-a799-9f92-23b4-c5fb82a4c95b
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idD7C2:358B3C:47A551D:65AAEEC:6A5006D4
html-safe-noncea48d87aca60660935d2abc54671870b85c34f29f7dec6f90e048ac87f47b0087
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEN0MyOjM1OEIzQzo0N0E1NTFEOjY1QUFFRUM6NkE1MDA2RDQiLCJ2aXNpdG9yX2lkIjoiNzA0Mzg5NjYyNjY1NDQ4MDA4NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac517763cd669e52429f2cb21bdc2deb1639b09f920ff16f157e1e52514dbd7afb
hovercard-subject-tagpull_request:3687751529
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/lessweb/deepcode-cli/pull/72/files
twitter:imagehttps://avatars.githubusercontent.com/u/12181423?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/12181423?s=400&v=4
og:image:alt📋 概述 本 PR 为 Deep Code CLI 增加了完整的 MCP (Model Context Protocol) 服务器状态管理和可视化功能,包括实时状态监控、工具/提示/资源发现、错误处理以及优化的用户交互体验。 🎯 变更类型 ✨ 新功能 🎨 UI 改进 🐛 Bug 修复 ♻️ 代码重构 ✅ 测试更新 📝 主要变更 1. MCP 客户端增强 (src/mcp/mcp...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None56eec25a3430492dd6ec2a480eb33256a0da5192d5714b0db4f5ab5f33203d94
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/lessweb/deepcode-cli git https://github.com/lessweb/deepcode-cli.git
octolytics-dimension-user_id118287711
octolytics-dimension-user_loginlessweb
octolytics-dimension-repository_id1223512305
octolytics-dimension-repository_nwolessweb/deepcode-cli
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1223512305
octolytics-dimension-repository_network_root_nwolessweb/deepcode-cli
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release93a615b89b7dcbdb6b678f4772931ecc28ada82a
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/lessweb/deepcode-cli/pull/72/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Flessweb%2Fdeepcode-cli%2Fpull%2F72%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Flessweb%2Fdeepcode-cli%2Fpull%2F72%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=lessweb%2Fdeepcode-cli
Reloadhttps://github.com/lessweb/deepcode-cli/pull/72/files
Reloadhttps://github.com/lessweb/deepcode-cli/pull/72/files
Reloadhttps://github.com/lessweb/deepcode-cli/pull/72/files
Please reload this pagehttps://github.com/lessweb/deepcode-cli/pull/72/files
lessweb https://github.com/lessweb
deepcode-clihttps://github.com/lessweb/deepcode-cli
Notifications https://github.com/login?return_to=%2Flessweb%2Fdeepcode-cli
Fork 159 https://github.com/login?return_to=%2Flessweb%2Fdeepcode-cli
Star 1.8k https://github.com/login?return_to=%2Flessweb%2Fdeepcode-cli
Code https://github.com/lessweb/deepcode-cli
Issues 47 https://github.com/lessweb/deepcode-cli/issues
Pull requests 22 https://github.com/lessweb/deepcode-cli/pulls
Actions https://github.com/lessweb/deepcode-cli/actions
Projects https://github.com/lessweb/deepcode-cli/projects
Security and quality 0 https://github.com/lessweb/deepcode-cli/security
Insights https://github.com/lessweb/deepcode-cli/pulse
Code https://github.com/lessweb/deepcode-cli
Issues https://github.com/lessweb/deepcode-cli/issues
Pull requests https://github.com/lessweb/deepcode-cli/pulls
Actions https://github.com/lessweb/deepcode-cli/actions
Projects https://github.com/lessweb/deepcode-cli/projects
Security and quality https://github.com/lessweb/deepcode-cli/security
Insights https://github.com/lessweb/deepcode-cli/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Flessweb%2Fdeepcode-cli%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Flessweb%2Fdeepcode-cli%2Fissues%2Fnew%2Fchoose
qorzjhttps://github.com/qorzj
lessweb:mainhttps://github.com/lessweb/deepcode-cli/tree/main
hqwlkj:feature/mcp-refactorhttps://github.com/hqwlkj/deepcode-cli/tree/feature/mcp-refactor
Conversation 0 https://github.com/lessweb/deepcode-cli/pull/72
Commits 13 https://github.com/lessweb/deepcode-cli/pull/72/commits
Checks 0 https://github.com/lessweb/deepcode-cli/pull/72/checks
Files changed https://github.com/lessweb/deepcode-cli/pull/72/files
Please reload this pagehttps://github.com/lessweb/deepcode-cli/pull/72/files
refactor: MCP 新增状态管理增强与 UI 可视化 https://github.com/lessweb/deepcode-cli/pull/72/files#top
Show all changes 13 commits https://github.com/lessweb/deepcode-cli/pull/72/files
fb38560 feat(mcp): 集成并展示MCP服务器状态和资源列表 hqwlkj May 14, 2026 https://github.com/lessweb/deepcode-cli/pull/72/commits/fb38560830a55c217122ebff5ee42836523d7c3b
91e5240 feat(ui): 添加服务器错误信息显示功能 hqwlkj May 14, 2026 https://github.com/lessweb/deepcode-cli/pull/72/commits/91e52406293ff1e8683e15ec00eac98bed175f7d
40025e4 feat(mcp): 实时更新和展示 MCP 服务器状态 hqwlkj May 14, 2026 https://github.com/lessweb/deepcode-cli/pull/72/commits/40025e495a6c19aa34939be78a4ace696a966ed7
d68baf7 refactor(ui): 优化 MCP 状态列表视图及界面细节调整 hqwlkj May 14, 2026 https://github.com/lessweb/deepcode-cli/pull/72/commits/d68baf776ff6f92d112a15df4f8c6a079005308c
b858c87 chore: update McpStatusList hqwlkj May 14, 2026 https://github.com/lessweb/deepcode-cli/pull/72/commits/b858c8755978480321f79dd8068376c7c45408d4
d9a3e15 Merge branch 'main' into feature/mcp-refactor hqwlkj May 14, 2026 https://github.com/lessweb/deepcode-cli/pull/72/commits/d9a3e152a09be7019c13babc46426c98e7577665
587a602 Merge branch 'main' into feature/mcp-refactor hqwlkj May 15, 2026 https://github.com/lessweb/deepcode-cli/pull/72/commits/587a6023295235adb67e2d96aea817baf30c4ade
35b686d test(session): 更新测试以包括提示和资源计数信息 hqwlkj May 15, 2026 https://github.com/lessweb/deepcode-cli/pull/72/commits/35b686d55fa1a6fcd91f3845d49b17d5975fcd61
5a99628 refactor(ui): 移除McpStatusList中不必要的React导入和文本显示 hqwlkj May 15, 2026 https://github.com/lessweb/deepcode-cli/pull/72/commits/5a996281dce9cb2ef6371374669aea304bdbec7c
bee349b fix(mcp-client): 增强协议版本校验和JSON-RPC批处理支持 hqwlkj May 15, 2026 https://github.com/lessweb/deepcode-cli/pull/72/commits/bee349bb8ca700eefe96615cba4b51352bdc907b
c819374 feat(ui): 添加无服务器时按Esc键退出的功能 hqwlkj May 15, 2026 https://github.com/lessweb/deepcode-cli/pull/72/commits/c81937434575bee3eb734fcf28d9bec01bad4667
a094524 fix(ui): update string hqwlkj May 15, 2026 https://github.com/lessweb/deepcode-cli/pull/72/commits/a094524e8fd4e939b93e71d56743b0fd1a50806d
9a21884 fix(ui): update string hqwlkj May 15, 2026 https://github.com/lessweb/deepcode-cli/pull/72/commits/9a2188407e71a66a46b1937a6798c094ae2a486f
Clear filters https://github.com/lessweb/deepcode-cli/pull/72/files
Please reload this pagehttps://github.com/lessweb/deepcode-cli/pull/72/files
Please reload this pagehttps://github.com/lessweb/deepcode-cli/pull/72/files
mcp-client.ts https://github.com/lessweb/deepcode-cli/pull/72/files#diff-629980a013434764d29c6eb5dc269c55468056f2e134ac78c04ac0b24fd0989d
mcp-manager.ts https://github.com/lessweb/deepcode-cli/pull/72/files#diff-710cf8658728525aefdd27c7d7ac3fce8d5aacd831b755ebce29ddbc1304ac96
session.ts https://github.com/lessweb/deepcode-cli/pull/72/files#diff-96998a2148aa3d52ad3e80303d0ad88fc43a4afd08966b5330a5657021ae52bb
session.test.ts https://github.com/lessweb/deepcode-cli/pull/72/files#diff-de8fd838e685eb171fd68dd90115fa8a20cf6d0b1aa1756278c53d2825eae713
App.tsx https://github.com/lessweb/deepcode-cli/pull/72/files#diff-0022b32944774e72bcbec1b0520e753925073bfbeff256269d0f668f5f515b0e
AskUserQuestionPrompt.tsx https://github.com/lessweb/deepcode-cli/pull/72/files#diff-8e937d1d46eb20e3ae5c50696ed9d5f883c1c40530c543e0ce88b3574877fe19
DropdownMenu.tsx https://github.com/lessweb/deepcode-cli/pull/72/files#diff-a2b9c0f15201e52cbb3cd5e55aed1c3c20ac5b988582ccc57d7ac5db39140c51
McpStatusList.tsx https://github.com/lessweb/deepcode-cli/pull/72/files#diff-42dda36a29773e24bfbeb630c276cce38b3e2d636f5658f32772137d6f0f8ffb
MessageView.tsx https://github.com/lessweb/deepcode-cli/pull/72/files#diff-98529297184603c06e7504c8597d26336d6df669c6a57940ce4ad1e60b4b011b
PromptInput.tsx https://github.com/lessweb/deepcode-cli/pull/72/files#diff-82045eb6c45c8c094739d89e1eb59b5ca893247cff1a12ef81af2ed6231b6be2
SessionList.tsx https://github.com/lessweb/deepcode-cli/pull/72/files#diff-9ac820054d226d3a46ec8e52320b29693146818c6d3358e14467eba5e54dbdb7
SlashCommandMenu.tsx https://github.com/lessweb/deepcode-cli/pull/72/files#diff-1b2c26b7a2b23c928b8397db12456ad0504e21ec7312ac5b06f0645228bcf0b4
src/mcp/mcp-client.tshttps://github.com/lessweb/deepcode-cli/pull/72/files#diff-629980a013434764d29c6eb5dc269c55468056f2e134ac78c04ac0b24fd0989d
View file https://github.com/hqwlkj/deepcode-cli/blob/9a2188407e71a66a46b1937a6798c094ae2a486f/src/mcp/mcp-client.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/lessweb/deepcode-cli/pull/72/{{ revealButtonHref }}
https://github.com/lessweb/deepcode-cli/pull/72/files#diff-629980a013434764d29c6eb5dc269c55468056f2e134ac78c04ac0b24fd0989d
https://github.com/lessweb/deepcode-cli/pull/72/files#diff-629980a013434764d29c6eb5dc269c55468056f2e134ac78c04ac0b24fd0989d
https://github.com/lessweb/deepcode-cli/pull/72/files#diff-629980a013434764d29c6eb5dc269c55468056f2e134ac78c04ac0b24fd0989d
https://github.com/lessweb/deepcode-cli/pull/72/files#diff-629980a013434764d29c6eb5dc269c55468056f2e134ac78c04ac0b24fd0989d
https://github.com/lessweb/deepcode-cli/pull/72/files#diff-629980a013434764d29c6eb5dc269c55468056f2e134ac78c04ac0b24fd0989d
https://github.com/lessweb/deepcode-cli/pull/72/files#diff-629980a013434764d29c6eb5dc269c55468056f2e134ac78c04ac0b24fd0989d
https://github.com/lessweb/deepcode-cli/pull/72/files#diff-629980a013434764d29c6eb5dc269c55468056f2e134ac78c04ac0b24fd0989d
https://github.com/lessweb/deepcode-cli/pull/72/files#diff-629980a013434764d29c6eb5dc269c55468056f2e134ac78c04ac0b24fd0989d
https://github.com/lessweb/deepcode-cli/pull/72/files#diff-629980a013434764d29c6eb5dc269c55468056f2e134ac78c04ac0b24fd0989d
Please reload this pagehttps://github.com/lessweb/deepcode-cli/pull/72/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.