Skip to content

config mcp server in config file - #761

Merged
mainred merged 3 commits into
masterfrom
mcp-server-config
Jul 31, 2025
Merged

mainred merged 3 commits into
masterfrom
mcp-server-config

Conversation

@mainred

@mainred mainred commented Jul 30, 2025 •

Copy link
Copy Markdown
Collaborator

For the example, after setting up the mcp server configuration as follows

mcp_servers:
  aks-mcp:
    description: "The AKS-MCP is a Model Context Protocol (MCP) server that enables AI assistants to interact with Azure Kubernetes Service (AKS) clusters"
    url: "http://localhost:8000/sse"

holmes gives

Connecting to SSE endpoint: http://localhost:8000/sse
Received endpoint URL: http://localhost:8000/message?sessionId=990d179d-bd59-4d73-81ef-1ef762ae72ae
Starting post writer with endpoint URL: http://localhost:8000/message?sessionId=990d179d-bd59-4d73-81ef-1ef762ae72ae
✅ Toolset aks-mcp

@coderabbitai

coderabbitai Bot commented Jul 30, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

The changes introduce support for configuring MCP servers directly in the global Holmes configuration file, update the Config and ToolsetManager classes to handle an mcp_servers attribute, standardize MCP toolset type handling as strings, reorganize imports, and add targeted tests for MCP server configuration loading.

Changes

Cohort / File(s) Change Summary
Documentation Update
docs/data-sources/remote-mcp-servers.md
Added instructions for configuring MCP servers in the global Holmes config file and updated CLI usage examples.
Config Class Extension
holmes/config.py
Added mcp_servers attribute to Config and updated toolset_manager property to pass it to ToolsetManager.
ToolsetManager Enhancements
holmes/core/toolset_manager.py
Extended ToolsetManager to accept and integrate mcp_servers, standardized toolset type handling as strings, and updated toolset loading logic.
Toolset Loader Import Cleanup
holmes/plugins/toolsets/__init__.py
Reorganized imports and updated type comparison for MCP toolsets to use string equality.
MCP Server Tests
tests/core/test_toolset_manager.py
Added tests for loading MCP servers from both custom YAML files and direct config dictionary input.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant HolmesConfig
    participant ToolsetManager

    User->>HolmesConfig: Load config (may include mcp_servers)
    HolmesConfig->>ToolsetManager: Instantiate with mcp_servers, toolsets, etc.
    ToolsetManager->>ToolsetManager: Merge mcp_servers into toolsets (type="MCP")
    User->>ToolsetManager: Request toolsets
    ToolsetManager-->>User: Return toolsets including MCP servers
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers

  • moshemorad
  • arikalon1

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch mcp-server-config

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 (2)
holmes/core/toolset_manager.py (2)

35-39: Fix redundant assignment and approve MCP server integration logic.

The MCP server processing logic correctly sets the type to string values and merges them into the toolsets dictionary. However, there's a redundant assignment to self.toolsets on line 35.

-        self.toolsets = toolsets
         self.toolsets = toolsets or {}

444-444: Remove duplicate assignment.

There's a duplicate assignment on line 444 that should be removed.

                 existing_toolsets_by_name[new_toolset.name] = new_toolset
-                existing_toolsets_by_name[new_toolset.name] = new_toolset
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c8805b9 and 6af8b88.

📒 Files selected for processing (5)
  • docs/data-sources/remote-mcp-servers.md (1 hunks)
  • holmes/config.py (2 hunks)
  • holmes/core/toolset_manager.py (3 hunks)
  • holmes/plugins/toolsets/__init__.py (2 hunks)
  • tests/core/test_toolset_manager.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py

📄 CodeRabbit Inference Engine (CLAUDE.md)

**/*.py: Use Ruff for formatting and linting (configured in pyproject.toml)
Type hints required (mypy configuration in pyproject.toml)

Files:

  • holmes/config.py
  • tests/core/test_toolset_manager.py
  • holmes/core/toolset_manager.py
  • holmes/plugins/toolsets/__init__.py
tests/**/*.py

📄 CodeRabbit Inference Engine (CLAUDE.md)

tests/**/*.py: All new features require unit tests
New toolsets require integration tests with mocks
Tests: Match source structure under tests/

Files:

  • tests/core/test_toolset_manager.py
🧠 Learnings (5)
📓 Common learnings
Learnt from: CR
PR: robusta-dev/holmesgpt#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-27T14:10:31.590Z
Learning: Applies to holmes/plugins/toolsets/**/*.yaml : Toolsets: holmes/plugins/toolsets/{name}.yaml or {name}/
docs/data-sources/remote-mcp-servers.md (2)

Learnt from: CR
PR: robusta-dev/holmesgpt#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-27T14:10:31.590Z
Learning: Applies to holmes/plugins/toolsets/**/*.yaml : Toolsets: holmes/plugins/toolsets/{name}.yaml or {name}/

Learnt from: CR
PR: robusta-dev/holmesgpt#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-27T14:10:31.590Z
Learning: Applies to holmes/plugins/toolsets/**/*.yaml : Bash toolset validates commands for safety

tests/core/test_toolset_manager.py (2)

Learnt from: CR
PR: robusta-dev/holmesgpt#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-27T14:10:31.590Z
Learning: Applies to tests/**/*.py : New toolsets require integration tests with mocks

Learnt from: CR
PR: robusta-dev/holmesgpt#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-27T14:10:31.590Z
Learning: Applies to tests/**/*.py : All new features require unit tests

holmes/core/toolset_manager.py (1)

Learnt from: nherment
PR: #535
File: holmes/plugins/toolsets/bash/bash_toolset.py:207-209
Timestamp: 2025-06-24T05:51:04.543Z
Learning: The init_config method in toolsets should be idempotent - safely callable multiple times without errors. self.config should maintain consistent typing (not alternate between dict and config object types) throughout the object lifecycle.

holmes/plugins/toolsets/__init__.py (5)

Learnt from: CR
PR: robusta-dev/holmesgpt#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-27T14:10:31.590Z
Learning: Applies to holmes/plugins/toolsets/**/*.yaml : Toolsets: holmes/plugins/toolsets/{name}.yaml or {name}/

Learnt from: CR
PR: robusta-dev/holmesgpt#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-27T14:10:31.590Z
Learning: Applies to holmes/plugins/toolsets/**/*.yaml : Bash toolset validates commands for safety

Learnt from: nherment
PR: #610
File: .github/workflows/llm-evaluation.yaml:39-42
Timestamp: 2025-07-08T08:45:41.069Z
Learning: The robusta-dev/holmesgpt codebase has comprehensive existing validation for Azure environment variables (AZURE_API_BASE, AZURE_API_KEY, AZURE_API_VERSION) and MODEL in tests/llm/utils/classifiers.py, tests/llm/conftest.py, and holmes/core/llm.py. Don't suggest adding redundant validation logic.

Learnt from: CR
PR: robusta-dev/holmesgpt#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-27T14:10:31.590Z
Learning: Applies to holmes/plugins/prompts/**/*.jinja2 : Prompts: holmes/plugins/prompts/{name}.jinja2

Learnt from: nherment
PR: #535
File: holmes/plugins/toolsets/bash/bash_toolset.py:207-209
Timestamp: 2025-06-24T05:51:04.543Z
Learning: The init_config method in toolsets should be idempotent - safely callable multiple times without errors. self.config should maintain consistent typing (not alternate between dict and config object types) throughout the object lifecycle.

🧬 Code Graph Analysis (1)
holmes/core/toolset_manager.py (1)
holmes/core/tools.py (1)
  • ToolsetType (114-117)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Pre-commit checks
  • GitHub Check: llm_evals
  • GitHub Check: Pre-commit checks
🔇 Additional comments (10)
docs/data-sources/remote-mcp-servers.md (1)

170-174: LGTM! Clear documentation of the new MCP server configuration option.

The addition effectively demonstrates the new capability to configure MCP servers directly in the global Holmes configuration file, which simplifies the user experience by eliminating the need for custom toolset files in CLI commands.

holmes/config.py (2)

118-118: LGTM! Proper integration of MCP server configuration.

The new mcp_servers attribute follows the established pattern with appropriate typing and default initialization.


129-129: LGTM! Correct parameter passing to ToolsetManager.

The mcp_servers attribute is properly passed to the ToolsetManager constructor, enabling the integration of MCP servers as toolsets.

holmes/plugins/toolsets/__init__.py (2)

10-31: LGTM! Import reorganization improves code structure.

The imports are now better organized and grouped logically, making the code more readable and maintainable.


157-157: LGTM! Critical fix for MCP toolset type comparison.

The change from identity (is) to equality (==) comparison is essential for correct MCP toolset recognition, as the system now uses string values (ToolsetType.MCP.value) rather than enum instances for type checking.

tests/core/test_toolset_manager.py (2)

307-324: LGTM! Comprehensive test for MCP servers from custom toolset files.

The test properly validates MCP server loading from YAML configuration files, including correct toolset creation, naming, and type assignment. The use of temporary files and proper test data structure follows established testing patterns.


327-344: LGTM! Proper test coverage for direct MCP server configuration.

The test effectively validates MCP server loading from direct configuration dictionaries, ensuring the ToolsetManager correctly processes MCP servers passed via the constructor. The assertions verify both toolset presence and correct type assignment.

holmes/core/toolset_manager.py (3)

29-29: LGTM! Proper constructor extension for MCP server support.

The new mcp_servers parameter is correctly typed and integrated into the constructor signature, enabling MCP server configuration support.


264-264: LGTM! Correct enum instantiation from cached status.

The use of .value ensures proper enum instantiation from string values stored in the cache, maintaining consistency with the string-based type representation.


364-364: LGTM! Consistent MCP server type assignment in YAML loading.

The assignment of ToolsetType.MCP.value maintains consistency with the string-based type representation used throughout the system for MCP servers.

@mainred mainred changed the title Mcp server config config mcp server in config file Jul 30, 2025
@mainred
mainred enabled auto-merge (squash) July 31, 2025 11:35
@github-actions

Copy link
Copy Markdown
Contributor

Results of HolmesGPT evals

  • ask_holmes: 23/37 test cases were successful, 0 regressions, 1 skipped, 13 mock failures
Test suite Test case Status
ask 01_how_many_pods ✅
ask 02_what_is_wrong_with_pod 🔧
ask 03_what_is_the_command_to_port_forward 🔧
ask 04_related_k8s_events ↪️
ask 05_image_version 🔧
ask 09_crashpod ✅
ask 10_image_pull_backoff 🔧
ask 11_init_containers ✅
ask 14_pending_resources ✅
ask 15_failed_readiness_probe ✅
ask 17_oom_kill ✅
ask 18_crash_looping_v2 ✅
ask 19_detect_missing_app_details 🔧
ask 24_misconfigured_pvc 🔧
ask 28_permissions_error ✅
ask 29_events_from_alert_manager ✅
ask 39_failed_toolset 🔧
ask 41_setup_argo0 ✅
ask 41_setup_argo1 ✅
ask 42_dns_issues_steps_new_tools 🔧
ask 43_current_datetime_from_prompt ✅
ask 45_fetch_deployment_logs_simple ✅
ask 51_logs_summarize_errors 🔧
ask 53_logs_find_term ✅
ask 54_not_truncated_when_getting_pods 🔧
ask 59_label_based_counting ✅
ask 60_count_less_than 🔧
ask 61_exact_match_counting ✅
ask 63_fetch_error_logs_no_errors ✅
ask 77_liveness_probe_misconfiguration 🔧
ask 79_configmap_mount_issue 🔧
ask 83_secret_not_found 🔧
ask 86_configmap_like_but_secret 🔧
ask 89_runbook_missing_cloudwatch 🔧
ask 90_runbook_basic_selection 🔧
ask 24a_misconfigured_pvc_basic 🔧
ask 13a_pending_node_selector_basic 🔧

Legend

  • ✅ the test was successful
  • ↪️ the test was skipped
  • ⚠️ the test failed but is known to be flaky or known to fail
  • 🔧 the test failed due to mock data issues (not a code regression)
  • ❌ the test failed and should be fixed before merging the PR

@mainred
mainred merged commit 82a2f92 into master Jul 31, 2025
@mainred
mainred deleted the mcp-server-config branch July 31, 2025 11:41
@coderabbitai coderabbitai Bot mentioned this pull request Oct 21, 2025
This was referenced Jan 2, 2026
@coderabbitai coderabbitai Bot mentioned this pull request Apr 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants