Skip to content

feat: add MCPServer resource - #2796

Open
jonburdo wants to merge 1 commit into
RedHatQE:mainfrom
jonburdo:mcp-server-resource
Open

feat: add MCPServer resource#2796
jonburdo wants to merge 1 commit into
RedHatQE:mainfrom
jonburdo:mcp-server-resource

Conversation

@jonburdo

@jonburdo jonburdo commented Aug 24, 2026

Copy link
Copy Markdown
Short description:

Add MCPServer resource to ocp_resources for shared use and integration tests in opendatahub-tests.

More details:
What this PR does / why we need it:
Which issue(s) this PR fixes:

opendatahub-io/opendatahub-tests#2240

Special notes for reviewer:
Bug:

Summary by CodeRabbit

  • New Features
    • Added support for creating and managing namespaced MCP Server resources.
    • Added configuration for MCP server sources, runtimes, metadata, and related settings.
    • Added validation to ensure required configuration and source details are provided.

Signed-off-by: Jon Burdo <jon@jonburdo.com>
@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: e8e85dbd-ef3c-4837-b4e7-809bf390a27b

📥 Commits

Reviewing files that changed from the base of the PR and between 7bbbdf6 and c1d0847.

⛔ Files ignored due to path filters (1)
  • class_generator/schema/__resources-mappings.json.gz is excluded by !**/*.gz, !class_generator/schema/**
📒 Files selected for processing (2)
  • ocp_resources/mcp_server.py
  • ocp_resources/resource.py

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


Walkthrough

Adds the MCPServer namespaced resource for the mcp.x-k8s.io/v1alpha1 API. The resource validates required config and source values and serializes optional annotations, labels, MCP, and runtime fields.

Changes

MCPServer resource

Layer / File(s) Summary
MCPServer registration and serialization
ocp_resources/resource.py, ocp_resources/mcp_server.py
Registers the mcp.x-k8s.io API group. Adds MCPServer with required config and source fields and conditional optional fields in to_dict.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to c1d08

This localized resource addition has no actionable merge-blocking risk identified at the current head and is merge-ready after normal checks and review.

Suggested reviewers: dalia-frank

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description includes a short summary and issue link, but most template sections are empty. Complete the More details, What this PR does / why we need it, Special notes for reviewer, and Bug sections.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the main change: adding the MCPServer resource.
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.
✨ 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.

@redhat-qe-bot

Copy link
Copy Markdown
Contributor

Report bugs in Issues

Welcome! 🎉

This pull request will be automatically processed with the following features:

🔄 Automatic Actions

  • Reviewer Assignment: Reviewers are automatically assigned based on the OWNERS file in the repository root
  • Size Labeling: PR size labels (XS, S, M, L, XL, XXL) are automatically applied based on changes
  • Issue Creation: Disabled for this repository
  • Branch Labeling: Branch-specific labels are applied to track the target branch
  • Auto-verification: Auto-verified users have their PRs automatically marked as verified
  • Labels: All label categories are enabled (default configuration)

📋 Available Commands

PR Status Management

  • /wip - Mark PR as work in progress (adds WIP: prefix to title)
  • /wip cancel - Remove work in progress status
  • /hold - Block PR merging (PR author or approvers)
  • /hold cancel - Unblock PR merging (PR author or approvers)
  • /verified - Mark PR as verified
  • /verified cancel - Remove verification status
  • /reprocess - Trigger complete PR workflow reprocessing (useful if webhook failed or configuration changed)
  • /regenerate-welcome - Regenerate this welcome message
  • /security-override - Set security check runs to pass (maintainers only)
  • /security-override cancel - Re-run security checks

Review & Approval

  • /lgtm - Approve changes (looks good to me)
  • /approve - Approve PR (approvers only)
  • /automerge - Enable automatic merging when all requirements are met (maintainers and approvers only)
  • /assign-reviewers - Assign reviewers based on OWNERS file
  • /assign-reviewer @username - Assign specific reviewer
  • /check-can-merge - Check if PR meets merge requirements

Testing & Validation

  • /retest tox - Run Python test suite with tox
  • /retest python-module-install - Test Python package installation
  • /retest conventional-title - Validate commit message format
  • /retest all - Run all available tests

Cherry-pick Operations

  • /cherry-pick <branch> - Schedule cherry-pick to target branch when PR is merged
    • Multiple branches: /cherry-pick branch1 branch2 branch3
  • /cherry-pick-retry <branch> - Retry a failed cherry-pick (merged PRs only)

Branch Management

  • /rebase - Rebase this PR branch onto its base branch

Label Management

  • /<label-name> - Add a label to the PR
  • /<label-name> cancel - Remove a label from the PR

✅ Merge Requirements

This PR will be automatically approved when the following conditions are met:

  1. Approval: /approve from at least one approver
  2. Status Checks: All required status checks must pass
  3. No Blockers: No wip, hold, has-conflicts labels and PR must be mergeable (no conflicts)
  4. Verified: PR must be marked as verified

📊 Review Process

Approvers and Reviewers

Approvers:

  • myakove
  • rnetser

Reviewers:

  • myakove
  • rnetser
Available Labels
  • hold
  • verified
  • wip
  • lgtm
  • approve
  • automerge
AI Features
  • Conventional Title: Mode: fix (cursor/cursor-grok-4.6-high)
  • Cherry-Pick Conflict Resolution: Enabled (cursor/cursor-grok-4.6-high)
Security Checks
  • Suspicious Path Detection: Monitors paths: .claude/, .vscode/, .cursor/, .devcontainer/, .pi/, .github/workflows/, .github/actions/
  • Committer Identity Check: Verifies last committer matches PR author
  • Mandatory: Security checks block merge (use /security-override to bypass — maintainers only)

💡 Tips

  • WIP Status: Use /wip when your PR is not ready for review
  • Verification: The verified label is removed on new commits unless the push is detected as a clean rebase
  • Cherry-picking: Cherry-pick labels are processed when the PR is merged
  • Permission Levels: Some commands require approver permissions
  • Auto-verified Users: Certain users have automatic verification and merge privileges

For more information, please refer to the project documentation or contact the maintainers.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Add MCPServer custom resource wrapper to ocp_resources

✨ Enhancement 🕐 20-40 Minutes

Grey Divider

AI Description

• Add a typed MCPServer NamespacedResource for managing MCP server CRs in tests.
• Enforce required spec fields (config, source) when generating manifests.
• Register the MCP API group constant (mcp.x-k8s.io) for consistent resource definitions.
Diagram

graph TD
  T["Integration tests"] --> R["MCPServer resource"] --> B["NamespacedResource base"] --> K[("Kubernetes API")]
  R --> G["ApiGroup.MCP_X_K8S_IO"]
  G --> K

  subgraph Legend
    direction LR
    _t["Test code"] ~~~ _r["Resource wrapper"] ~~~ _b["Base class"] ~~~ _k[("Cluster API")]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Use a generic/dynamic custom resource wrapper
  • ➕ No need to add/maintain per-CRD Python classes
  • ➕ Works immediately for any new CRD group/version/kind
  • ➖ Less type/field guidance for callers
  • ➖ Harder to enforce required fields like config/source consistently
  • ➖ Call sites become more verbose and error-prone (manual group/version/kind/spec construction)
2. Import MCPServer from an upstream SDK/client package
  • ➕ Avoids generated code in this repo
  • ➕ Potentially better alignment with upstream CRD evolution
  • ➖ Introduces a new dependency and versioning surface area
  • ➖ May not exist or may not match ocp_resources conventions (NamespacedResource, to_dict validation patterns)

Recommendation: Keep the dedicated MCPServer NamespacedResource approach. It matches existing ocp_resources patterns, centralizes spec construction/validation (required config/source), and minimizes boilerplate in consuming test suites while avoiding new runtime dependencies.

Files changed (2) +118 / -0

Enhancement (2) +118 / -0
mcp_server.pyAdd MCPServer NamespacedResource wrapper (generated) +117/-0

Add MCPServer NamespacedResource wrapper (generated)

• Introduces a new MCPServer resource class targeting the mcp.x-k8s.io API group. The wrapper builds the CR spec (config/source plus optional extraAnnotations/extraLabels/mcp/runtime) and raises MissingRequiredArgumentError when required fields are omitted.

ocp_resources/mcp_server.py

resource.pyRegister MCP API group constant +1/-0

Register MCP API group constant

• Adds NamespacedResource.ApiGroup.MCP_X_K8S_IO = "mcp.x-k8s.io" so the new MCPServer resource can reference the group consistently.

ocp_resources/resource.py

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (3) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Missing generated start marker 📘 Rule violation ⚙ Maintainability
Description
The generated MCPServer class includes # End of generated code but lacks a corresponding start
boundary marker to clearly delimit the generated region. Without explicit boundaries, manual edits
can be mixed into generated code unintentionally.
Code

ocp_resources/mcp_server.py[R39-41]

+    api_group: str = NamespacedResource.ApiGroup.MCP_X_K8S_IO
+
+    def __init__(
Evidence
PR Compliance ID 1835157 requires generated regions to be wrapped by explicit start and end boundary
comments. The added class shows an end marker (# End of generated code) but there is no
corresponding start marker near the beginning of the generated section (e.g., before api_group /
generated members).

Rule 1835157: Protect generated code regions with explicit boundary markers
ocp_resources/mcp_server.py[39-41]
ocp_resources/mcp_server.py[117-117]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The generated region is not protected by explicit boundary markers; only `# End of generated code` is present.

## Issue Context
Compliance requires both a start marker and an end marker to clearly wrap generated code regions.

## Fix Focus Areas
- ocp_resources/mcp_server.py[39-41]
- ocp_resources/mcp_server.py[117-117]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. to_dict() performs validation 📘 Rule violation ≡ Correctness
Description
MCPServer.to_dict() raises MissingRequiredArgumentError when config or source is unset,
which is validation logic inside a serializer. This violates the requirement that to_dict() only
serialize fields without enforcing resource validity.
Code

ocp_resources/mcp_server.py[R92-97]

+        if not self.kind_dict and not self.yaml_file:
+            if self.config is None:
+                raise MissingRequiredArgumentError(argument="self.config")
+
+            if self.source is None:
+                raise MissingRequiredArgumentError(argument="self.source")
Relevance

●● Moderate

Related serializer correctness findings were accepted, but no close precedent addresses validation
inside to_dict().

PR-#2480

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 1835318 forbids client-side validation (required-field checks and raising
exceptions to block invalid resource shapes) inside to_dict(). The new to_dict() explicitly
checks self.config/self.source and raises MissingRequiredArgumentError, which is validation
rather than pure serialization.

Rule 1835318: to_dict() must only serialize fields and must not perform resource validation
ocp_resources/mcp_server.py[88-97]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`MCPServer.to_dict()` raises exceptions to enforce required fields (`config`, `source`), which is resource validation inside the serialization method.

## Issue Context
Compliance requires `to_dict()` to only serialize/normalize fields and not reject or validate resource shapes.

## Fix Focus Areas
- ocp_resources/mcp_server.py[88-97]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational

3. Non-Google __init__ docstring 📘 Rule violation ⚙ Maintainability
Description
The new MCPServer.__init__ docstring uses a non–Google-style Args: format (e.g., `name (type):
...`) and inconsistent indentation. This violates the docstring style requirement and reduces
consistency across the codebase.
Code

ocp_resources/mcp_server.py[R51-56]

+        r"""
+        Args:
+            config (dict[str, Any]): Config is a required field that defines how the MCP server should be
+              configured when it runs. This includes runtime settings such as
+              the server port, command-line arguments, environment variables,
+              and storage mounts.
Relevance

● Weak

Exact recent precedent rejected the same Google-style docstring-format finding in generated code.

PR-#2765

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 1834792 requires Google-style triple-quoted docstrings with Args: entries
formatted as name: description (no :param/other styles). The added __init__ docstring uses
config (dict[str, Any]): ... and non-standard indentation, which does not match the required
Google style format.

Rule 1834792: Inline docstrings must use Google-style triple-quoted blocks
ocp_resources/mcp_server.py[51-78]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`MCPServer.__init__` uses a non–Google-style docstring format (e.g., `param (type): ...`) and inconsistent indentation.

## Issue Context
Compliance requires Google-style docstrings for added/modified Python definitions.

## Fix Focus Areas
- ocp_resources/mcp_server.py[51-78]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context sources
✅ Compliance rules (platform): 18 rules
Review mode: ⚖️ Balanced: This adds new runtime resource logic and API-group behavior with required-field serialization, so it carries real correctness risk beyond a purely localized trivial change.

Grey Divider

Tip of the day
💡 Did you know, you can switch off images and animations for a plain-text comment

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment on lines +39 to +41
api_group: str = NamespacedResource.ApiGroup.MCP_X_K8S_IO

def __init__(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

2. Missing generated start marker 📘 Rule violation ⚙ Maintainability

The generated MCPServer class includes # End of generated code but lacks a corresponding start
boundary marker to clearly delimit the generated region. Without explicit boundaries, manual edits
can be mixed into generated code unintentionally.
Agent Prompt
## Issue description
The generated region is not protected by explicit boundary markers; only `# End of generated code` is present.

## Issue Context
Compliance requires both a start marker and an end marker to clearly wrap generated code regions.

## Fix Focus Areas
- ocp_resources/mcp_server.py[39-41]
- ocp_resources/mcp_server.py[117-117]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +92 to +97
if not self.kind_dict and not self.yaml_file:
if self.config is None:
raise MissingRequiredArgumentError(argument="self.config")

if self.source is None:
raise MissingRequiredArgumentError(argument="self.source")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

3. to_dict() performs validation 📘 Rule violation ≡ Correctness

MCPServer.to_dict() raises MissingRequiredArgumentError when config or source is unset,
which is validation logic inside a serializer. This violates the requirement that to_dict() only
serialize fields without enforcing resource validity.
Agent Prompt
## Issue description
`MCPServer.to_dict()` raises exceptions to enforce required fields (`config`, `source`), which is resource validation inside the serialization method.

## Issue Context
Compliance requires `to_dict()` to only serialize/normalize fields and not reject or validate resource shapes.

## Fix Focus Areas
- ocp_resources/mcp_server.py[88-97]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants