Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: showing all mcp server in the list #4478

Merged
merged 3 commits into from
Mar 14, 2025
Merged

Conversation

erha19
Copy link
Member

@erha19 erha19 commented Mar 14, 2025

Types

  • 🐛 Bug Fixes

Background or solution

原有实现会导致用户存储的非启动配置丢失

Changelog

showing all mcp server in the list

Summary by CodeRabbit

  • 新功能
    • 优化了服务器信息加载逻辑,现在整合了用户自定义设置与实时运行状态,展示更精准的服务器状态。
    • 扩充了服务器数据内容,新增服务器类型信息,让用户获取更全面的服务详情。

@erha19 erha19 requested review from life2015, ensorrow and Aaaaash March 14, 2025 08:21
@erha19
Copy link
Member Author

erha19 commented Mar 14, 2025

/next

@opensumi opensumi bot added the 🐞 bug Something isn't working label Mar 14, 2025
Copy link
Contributor

coderabbitai bot commented Mar 14, 2025

Walkthrough

该 PR 引入了增强的服务器数据加载逻辑和接口调整。在 MCPConfigView 组件中,现在通过先获取用户偏好设置中的服务器,再获取当前正在运行的服务器,并将二者合并,形成包含 isStartedtools 属性的服务器数组。同时,ISumiMCPServerBackend 接口中 getServers 方法的返回类型更新,新增了 type 属性,从而提供更详细的服务器信息。

Changes

File(s) Change Summary
packages/ai-native/.../mcp-config.view.tsx 更新了 loadServers 函数逻辑:先从 preferenceService 获取用户服务器配置,再调用 $getServers 获取运行中的服务器,并合并成包含 isStartedtools 属性的数组。
packages/ai-native/.../index.ts 修改了 ISumiMCPServerBackend.getServers() 方法返回类型,新增 type 属性,使返回对象结构从三个属性扩展为四个属性。

Sequence Diagram(s)

sequenceDiagram
    participant View as MCPConfigView
    participant Pref as preferenceService
    participant Server as mcpServerProxyService

    View->>Pref: 调用 get() 获取用户服务器配置
    Pref-->>View: 返回用户服务器列表
    View->>Server: 调用 $getServers() 获取运行中服务器
    Server-->>View: 返回运行中服务器列表
    View->>View: 合并用户配置与运行状态,设置 isStarted 与 tools 属性
Loading

Possibly related PRs

  • feat: improve MCP Server edit UX and i18n #4455: 该 PR 修改了 MCPConfigView 组件中的 loadServers 函数,而检索到的 PR 则改变了同一组件中的 handleServerControl 函数,表明它们在功能上存在直接关系。
  • feat: support mcp server management #4387: 该 PR 修改了 ISumiMCPServerBackend 接口中的 getServers 方法,与本次 PR 中 loadServers 函数的修改直接相关,均涉及服务器数据的结构和检索。

Suggested labels

🎨 feature

Suggested reviewers

  • life2015
  • Aaaaash
  • ensorrow

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

yarn install v1.22.22
[1/4] Resolving packages...
warning [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning eslint > @humanwhocodes/[email protected]: Use @eslint/config-array instead
warning eslint > @humanwhocodes/config-array > @humanwhocodes/[email protected]: Use @eslint/object-schema instead
warning eslint > file-entry-cache > flat-cache > [email protected]: Rimraf versions prior to v4 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > [email protected]: Glob versions prior to v9 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > glob > [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning eslint-import-resolver-typescript > [email protected]: Glob versions prior to v9 are no longer supported
error Couldn't find any versions for "@opensumi/ide-dev-tool" that matches "workspace:*"
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a17ff03 and 2ed73f5.

📒 Files selected for processing (1)
  • packages/ai-native/src/browser/mcp/config/components/mcp-config.view.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/ai-native/src/browser/mcp/config/components/mcp-config.view.tsx
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: 🚀🚀🚀 Next Version for pull request
  • GitHub Check: unittest (ubuntu-latest, 18.x, jsdom)
  • GitHub Check: unittest (ubuntu-latest, 18.x, node)
  • GitHub Check: build (ubuntu-latest, 20.x)
  • GitHub Check: build (macos-latest, 20.x)
  • GitHub Check: unittest (macos-latest, 18.x, jsdom)
  • GitHub Check: ubuntu-latest, Node.js 20.x
  • GitHub Check: unittest (macos-latest, 18.x, node)
  • GitHub Check: build-windows

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/ai-native/src/browser/mcp/config/components/mcp-config.view.tsx (1)

29-40: 修复服务器列表显示逻辑,确保显示所有 MCP 服务器

这个更改解决了 PR 中描述的问题,通过合并用户配置的服务器和运行中的服务器,确保所有 MCP 服务器都显示在列表中,即使它们没有启动。这样可以防止用户丢失非启动配置设置。

代码逻辑清晰,先获取用户配置的服务器,再获取运行中的服务器,然后将它们合并,保留用户配置的所有信息,同时添加运行时状态。

但有一个小的优化点:在 return 语句中,...server 已经包含了 name 属性,因此 name: server.name 是多余的。

可以简化为:

return {
  ...server,
- name: server.name,
  isStarted: !!runningServer,
  tools: runningServer?.tools,
};
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 031625b and a17ff03.

📒 Files selected for processing (2)
  • packages/ai-native/src/browser/mcp/config/components/mcp-config.view.tsx (1 hunks)
  • packages/ai-native/src/common/index.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: 🚀🚀🚀 Next Version for pull request
  • GitHub Check: build (ubuntu-latest, 20.x)
  • GitHub Check: build-windows
  • GitHub Check: ubuntu-latest, Node.js 20.x
  • GitHub Check: build (macos-latest, 20.x)
🔇 Additional comments (1)
packages/ai-native/src/common/index.ts (1)

137-144:

❓ Verification inconclusive

接口更新以支持服务器类型显示

此更改在 ISumiMCPServerBackend 接口的 getServers 方法返回类型中添加了 type 属性。这是一个良好的更新,因为它允许 UI 显示服务器的类型,与 MCPConfigView 组件的 getReadableServerType 函数对齐。

确保所有实现此接口的类都更新了它们的返回值以包含 type 属性。


🏁 Script executed:

#!/bin/bash
# 描述:检查 ISumiMCPServerBackend 接口的实现,确保它们包含新的 type 属性

# 查找 ISumiMCPServerBackend 接口的所有实现
echo "查找 ISumiMCPServerBackend 接口的所有实现..."
rg -l "class.*implements.*ISumiMCPServerBackend" --type ts

# 检查 getServers 方法实现
echo "检查 getServers 方法的实现..."
rg "getServers\(\).*\{" -A 15 --type ts

Length of output: 5125


请确保所有实现 getServers 的类返回包含 type 属性的数据

  • packages/ai-native/src/common/index.ts 中,getServers 接口现在要求返回的对象包含 nameisStartedtype(字符串类型)以及 tools
  • 验证结果显示唯一实现 ISumiMCPServerBackend 接口的文件为 packages/ai-native/src/node/mcp/sumi-mcp-server.ts,但其 getServers 实现中未明显看到对 type 属性的处理。请检查该方法,确保最终返回结果包含服务器的 type 字段。
  • 此外,请核对其他相关定义(例如 packages/ai-native/src/common/types.ts$getServers 方法及 MCPServer 接口)与新接口保持一致,以确保 UI 中 MCPConfigView 组件的 getReadableServerType 能正确显示服务器类型。

@opensumi
Copy link
Contributor

opensumi bot commented Mar 14, 2025

🎉 PR Next publish successful!

3.8.3-next-1741940731.0

@erha19
Copy link
Member Author

erha19 commented Mar 14, 2025

/next

@opensumi
Copy link
Contributor

opensumi bot commented Mar 14, 2025

🎉 PR Next publish successful!

3.8.3-next-1741943877.0

Copy link

codecov bot commented Mar 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 53.14%. Comparing base (031625b) to head (2ed73f5).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4478      +/-   ##
==========================================
- Coverage   53.14%   53.14%   -0.01%     
==========================================
  Files        1665     1665              
  Lines      102615   102615              
  Branches    22371    22215     -156     
==========================================
- Hits        54537    54536       -1     
- Misses      39995    39996       +1     
  Partials     8083     8083              
Flag Coverage Δ
jsdom 48.63% <ø> (-0.01%) ⬇️
node 12.13% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@life2015 life2015 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@life2015 life2015 merged commit 69cb47b into main Mar 14, 2025
13 checks passed
@life2015 life2015 deleted the fix/mcp-server-configuration branch March 14, 2025 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants