Skip to content

CNV-83516: Enable kubevirt toolset in default MCP server config - #1833

Open
lyarwood wants to merge 1 commit into
openshift:mainfrom
lyarwood:cnv-83516-enable-kubevirt-toolset
Open

CNV-83516: Enable kubevirt toolset in default MCP server config#1833
lyarwood wants to merge 1 commit into
openshift:mainfrom
lyarwood:cnv-83516-enable-kubevirt-toolset

Conversation

@lyarwood

@lyarwood lyarwood commented Jul 15, 2026

Copy link
Copy Markdown

Description

Enable the kubevirt toolset in the default MCP server config deployed by the operator. The kubevirt toolset is safe to enable unconditionally thanks to two layers of protection:

  1. TargetCompatibilityFilters (kubernetes-mcp-server#1298) — kubevirt tools now declare GVK-based filters that check for kubevirt.io/v1 VirtualMachine on connected clusters. When KubeVirt is not installed, the tools are completely hidden from the MCP client — they never appear in the tool list.

  2. Graceful error handling — as a fallback, if a kubevirt tool is somehow invoked on a cluster without CNV, it returns a tool-level error (IsError: true) to the LLM rather than crashing the MCP server.

This replaces the previous justification that relied solely on error handling. With target compatibility filtering, there is zero cost to enabling the toolset on clusters without KubeVirt — the tools simply don't appear.

Type of change

  • Configuration Update

Related Tickets & Documents

Checklist before requesting a review

  • I have performed a self-review of my code.
  • PR has passed all pre-merge test jobs.
  • If it is a core feature, I have added thorough tests.

Testing

  • Existing Ginkgo spec in internal/controller/ocpmcp/assets_test.go updated to validate the kubevirt toolset and experimental_enable_target_compatibility_tool_filters in the generated TOML ConfigMap.
  • The kubevirt toolset uses the Kubernetes dynamic client to interact with KubeVirt CRDs. When CNV is not installed, tools are hidden via TargetCompatibilityFilters. If somehow invoked directly, tool invocations return a tool-level error result (IsError: true) to the LLM — the MCP server process continues running normally.

Summary by CodeRabbit

  • New Features
    • Added KubeVirt tools to the standalone OpenShift MCP server.
    • Enabled compatibility-based filtering for experimental tools.

@openshift-ci-robot

openshift-ci-robot commented Jul 15, 2026

Copy link
Copy Markdown

@lyarwood: This pull request references CNV-83516 which is a valid jira issue.

Details

In response to this:

Description

Enable the kubevirt toolset in the default MCP server config deployed by the operator. The kubevirt toolset handles the absence of CNV gracefully by returning tool-level errors (IsError: true) rather than crashing the MCP server, making it safe to enable by default alongside the existing core, config, helm, and metrics toolsets.

Type of change

  • Configuration Update

Related Tickets & Documents

Checklist before requesting a review

  • I have performed a self-review of my code.
  • PR has passed all pre-merge test jobs.
  • If it is a core feature, I have added thorough tests.

Testing

  • Existing unit test TestOpenShiftMCPServerConfigTOML updated and passing.
  • The kubevirt toolset uses the Kubernetes dynamic client to interact with KubeVirt CRDs. When CNV is not installed, tool invocations return a tool-level error result (IsError: true) to the LLM — the MCP server process continues running normally.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 15, 2026
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The standalone OpenShift MCP server configuration now enables the kubevirt toolset and experimental target compatibility tool filters. The assets controller test updates its expected TOML content accordingly.

Changes

OpenShift MCP configuration

Layer / File(s) Summary
Update MCP toolsets and validation
internal/controller/ocpmcp/assets.go, internal/controller/ocpmcp/assets_test.go
The embedded TOML enables kubevirt and target compatibility tool filters, and the ConfigMap generation test asserts both settings.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related issues

Suggested reviewers: xrajesh, blublinsky

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: enabling the kubevirt toolset in the default MCP server config.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands.

@openshift-ci
openshift-ci Bot requested review from blublinsky and xrajesh July 15, 2026 09:25
@openshift-ci

openshift-ci Bot commented Jul 15, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign xrajesh for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/controller/utils/mcp_server_config_test.go`:
- Around line 27-28: Convert the test around the TOML toolsets assertion from
testing.T and strings.Contains to the repository’s Ginkgo v2/Gomega style, using
the established suite and matcher patterns. Preserve the assertion that the
config explicitly contains the toolsets list ending with kubevirt, and remove
the direct testing and strings-based assertion usage.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: c48462c1-7fa3-4426-84ac-fddabc79387f

📥 Commits

Reviewing files that changed from the base of the PR and between 3d2f911 and edef312.

📒 Files selected for processing (2)
  • internal/controller/utils/mcp_server_config.go
  • internal/controller/utils/mcp_server_config_test.go

Comment on lines +27 to +28
if !strings.Contains(config, `toolsets = ["core", "config", "helm", "metrics", "kubevirt"]`) {
t.Error("TOML config should pin toolsets explicitly")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Use the required Ginkgo v2/Gomega test style.

This updated test still uses testing.T and strings.Contains. Convert it to the repository’s Ginkgo/Gomega pattern while preserving the kubevirt assertion.

As per coding guidelines and path instructions, *_test.go files must use Ginkgo v2/Gomega and shared repository test patterns.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/controller/utils/mcp_server_config_test.go` around lines 27 - 28,
Convert the test around the TOML toolsets assertion from testing.T and
strings.Contains to the repository’s Ginkgo v2/Gomega style, using the
established suite and matcher patterns. Preserve the assertion that the config
explicitly contains the toolsets list ending with kubevirt, and remove the
direct testing and strings-based assertion usage.

Sources: Coding guidelines, Path instructions

@lyarwood

Copy link
Copy Markdown
Author

/retest-required

@lyarwood
lyarwood force-pushed the cnv-83516-enable-kubevirt-toolset branch from edef312 to 5e0a3b6 Compare July 17, 2026 09:39
The kubevirt toolset handles the absence of CNV gracefully by
returning tool-level errors rather than crashing the MCP server,
making it safe to enable by default.

Signed-off-by: Lee Yarwood <lyarwood@redhat.com>
Assisted-By: Claude <noreply@anthropic.com>
@lyarwood
lyarwood force-pushed the cnv-83516-enable-kubevirt-toolset branch from 5e0a3b6 to 2feb36a Compare July 27, 2026 10:43
@lyarwood

Copy link
Copy Markdown
Author

@Cali0707 @manusa any objections to enabling the toolset by default now?

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
internal/controller/ocpmcp/assets.go (2)

47-55: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use utils.DefaultLabels() for asset labels.

selectorLabels() is the shared label source for every generated asset, but it hand-rolls the map. Base it on utils.DefaultLabels() and layer only component-specific selector labels on top.

As per coding guidelines: “Use utils.DefaultLabels() for consistent labeling in asset generation functions.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/controller/ocpmcp/assets.go` around lines 47 - 55, Update
selectorLabels() to initialize its label map from utils.DefaultLabels(), then
overlay only the component-specific selector labels required by the assets.
Remove the duplicated hand-rolled default labels while preserving the existing
selector values and shared-label consistency.

Source: Coding guidelines


57-64: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use the required unexported asset-generator names.

These assets.go helpers should be named generate<Resource> rather than exported Generate<Resource> functions. Rename the five helpers and update their call sites in internal/controller/ocpmcp/assets_test.go.

As per coding guidelines: “Use naming conventions: functions reconcile<Resource> and generate<Resource>...”
As per path instructions: “Use naming conventions: functions reconcile<Resource> and generate<Resource>...”

Also applies to: 67-83, 85-102, 104-133, 135-174

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/controller/ocpmcp/assets.go` around lines 57 - 64, Rename the five
asset helpers in assets.go from exported Generate<Resource> to unexported
generate<Resource>, following the required naming convention. Update every
corresponding call in internal/controller/ocpmcp/assets_test.go and preserve
each helper’s behavior and signatures otherwise.

Sources: Coding guidelines, Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@internal/controller/ocpmcp/assets.go`:
- Around line 47-55: Update selectorLabels() to initialize its label map from
utils.DefaultLabels(), then overlay only the component-specific selector labels
required by the assets. Remove the duplicated hand-rolled default labels while
preserving the existing selector values and shared-label consistency.
- Around line 57-64: Rename the five asset helpers in assets.go from exported
Generate<Resource> to unexported generate<Resource>, following the required
naming convention. Update every corresponding call in
internal/controller/ocpmcp/assets_test.go and preserve each helper’s behavior
and signatures otherwise.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: de7f0450-0705-49ee-ba87-8cc10237e7de

📥 Commits

Reviewing files that changed from the base of the PR and between 5e0a3b6 and 2feb36a.

📒 Files selected for processing (2)
  • internal/controller/ocpmcp/assets.go
  • internal/controller/ocpmcp/assets_test.go

@openshift-ci

openshift-ci Bot commented Jul 27, 2026

Copy link
Copy Markdown

@lyarwood: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants