Skip to content

OLS-3185: spec changes for operator MCP auto-injection#271

Open
onmete wants to merge 1 commit into
openshift:mainfrom
onmete:OLS-3185-spec-mcp-operator
Open

OLS-3185: spec changes for operator MCP auto-injection#271
onmete wants to merge 1 commit into
openshift:mainfrom
onmete:OLS-3185-spec-mcp-operator

Conversation

@onmete

@onmete onmete commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add disableDefaultMCP bool field to ToolsSpec in crd-api.md (rule 36a)
  • Add default MCP server auto-injection rule in sandbox-execution.md (rule 19a): when OLSConfig.introspectionEnabled is true and disableDefaultMCP is not set, prepend ocp-mcp server entry to LIGHTSPEED_MCP_SERVERS
  • Add cross-operator RBAC rule (rule 19b): agentic operator needs get/watch on OLSConfig (ols.openshift.io/v1alpha1)

Design decisions

From OLS-3185 design interview:

  • Reuse existing ocp-mcp sidecar deployed by classic lightspeed-operator
  • Classic operator creates the Service exposing the sidecar (separate work)
  • Agentic operator auto-injects Service URL into sandbox pods
  • disableDefaultMCP on ToolsSpec provides per-Proposal opt-out
  • Auth via ServiceAccountToken (sandbox SA token sent as Bearer header)

Test plan

  • Spec review — rules are consistent with existing sandbox-execution patterns
  • No code changes — spec only

Made with Cursor

Add disableDefaultMCP field to ToolsSpec CRD spec. Add rules for
auto-injecting the default OpenShift MCP server into sandbox pods
when OLSConfig.introspectionEnabled is true, and cross-operator
RBAC to read OLSConfig.

Co-authored-by: Cursor <cursoragent@cursor.com>
@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 2, 2026
@openshift-ci-robot

openshift-ci-robot commented Jul 2, 2026

Copy link
Copy Markdown

@onmete: This pull request references OLS-3185 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the feature request to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Summary

  • Add disableDefaultMCP bool field to ToolsSpec in crd-api.md (rule 36a)
  • Add default MCP server auto-injection rule in sandbox-execution.md (rule 19a): when OLSConfig.introspectionEnabled is true and disableDefaultMCP is not set, prepend ocp-mcp server entry to LIGHTSPEED_MCP_SERVERS
  • Add cross-operator RBAC rule (rule 19b): agentic operator needs get/watch on OLSConfig (ols.openshift.io/v1alpha1)

Design decisions

From OLS-3185 design interview:

  • Reuse existing ocp-mcp sidecar deployed by classic lightspeed-operator
  • Classic operator creates the Service exposing the sidecar (separate work)
  • Agentic operator auto-injects Service URL into sandbox pods
  • disableDefaultMCP on ToolsSpec provides per-Proposal opt-out
  • Auth via ServiceAccountToken (sandbox SA token sent as Bearer header)

Test plan

  • Spec review — rules are consistent with existing sandbox-execution patterns
  • No code changes — spec only

Made with Cursor

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 openshift-ci Bot requested review from harche and joshuawilson July 2, 2026 19:22
@openshift-ci

openshift-ci Bot commented Jul 2, 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 raptorsun 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 commented Jul 2, 2026

Copy link
Copy Markdown
📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added an option to disable automatic injection of the default MCP server for sandbox pods.
    • Clarified that user-defined MCP servers are still used as configured.
  • Bug Fixes

    • Updated behavior so default MCP server injection follows the platform’s introspection setting, with a safe default when no configuration is present.

Walkthrough

Documentation-only changes describing a new optional disableDefaultMCP field on ToolsSpec, its effect on default MCP server auto-injection, and the corresponding operator RBAC requirement to read/watch OLSConfig for introspection status.

Changes

disableDefaultMCP Documentation

Layer / File(s) Summary
CRD API field documentation
.ai/spec/what/crd-api.md
Documents disableDefaultMCP (default false) behavior preventing default MCP server injection, and adds it to the shared ToolsSpec field list.
Sandbox execution behavioral rules
.ai/spec/what/sandbox-execution.md
Documents default MCP server auto-injection tied to OLSConfig.spec.olsConfig.introspectionEnabled (default enabled, treated as enabled if no CR exists) unless overridden by disableDefaultMCP, plus required RBAC to get/watch OLSConfig.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: spec updates for MCP auto-injection.
Description check ✅ Passed The description accurately summarizes the spec-only changes and design intent in this PR.
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.

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

@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 @.ai/spec/what/sandbox-execution.md:
- Around line 47-48: The default OpenShift MCP injection behavior in the sandbox
execution spec needs an explicit collision rule for the reserved name openshift.
Update the MCP server handling described here so the logic in the ToolsSpec
serialization path clearly defines whether an injected default entry is
rejected, overrides a user entry, or is skipped when MCPServerConfig.Name
already equals openshift. Reference the default injection flow and
LIGHTSPEED_MCP_SERVERS assembly so the precedence is unambiguous.
🪄 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: 0846a326-8411-4afe-a5fa-fbf75f8fac29

📥 Commits

Reviewing files that changed from the base of the PR and between 133da41 and 4b1cec5.

📒 Files selected for processing (2)
  • .ai/spec/what/crd-api.md
  • .ai/spec/what/sandbox-execution.md
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • openshift/lightspeed-agentic-sandbox (manual)

Comment on lines +47 to +48
19a. **Default MCP server auto-injection**: When the classic `OLSConfig` CR has `spec.olsConfig.introspectionEnabled` set to `true` (or absent, since it defaults to `true`) AND the effective `ToolsSpec` for the step does NOT have `disableDefaultMCP: true`, the operator MUST prepend the default OpenShift MCP server entry to the MCP server list before serializing to `LIGHTSPEED_MCP_SERVERS`. The default entry MUST use: name `openshift`, URL pointing to the `Service` created by the classic `lightspeed-operator` for the ocp-mcp sidecar (e.g., `http://openshift-mcp-server.<namespace>.svc:8080/mcp`), and an `Authorization` header with source `ServiceAccountToken`. When `introspectionEnabled` is `false` or `disableDefaultMCP` is `true`, the default entry MUST NOT be injected. User-defined `mcpServers` from the `ToolsSpec` are always included regardless of this flag.
19b. **OLSConfig cross-operator read**: The agentic operator MUST have RBAC to `get` and `watch` `OLSConfig` resources (API group `ols.openshift.io`, version `v1alpha1`) to read `introspectionEnabled`. When no `OLSConfig` CR exists, the operator MUST behave as if `introspectionEnabled` is `true` (matching the classic operator's default).

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -n --glob '.ai/spec/**' --glob 'api/**' --glob '*.md' 'openshift'

Repository: openshift/lightspeed-agentic-operator

Length of output: 175


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- matches for relevant terms ---'
rg -n --glob '.ai/spec/**' --glob 'api/**' --glob '*.md' \
  'LIGHTSPEED_MCP_SERVERS|disableDefaultMCP|mcpServers|introspectionEnabled|openshift-mcp-server|ServiceAccountToken|OLSConfig' \
  .

echo
echo '--- spec files mentioning openshift ---'
rg -n --glob '.ai/spec/**' 'openshift' .ai/spec || true

echo
echo '--- outline of the target spec file ---'
ast-grep outline .ai/spec/what/sandbox-execution.md --view expanded || true

Repository: openshift/lightspeed-agentic-operator

Length of output: 11546


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- targeted lines around the injected MCP entry ---'
sed -n '35,70p' .ai/spec/what/sandbox-execution.md

Repository: openshift/lightspeed-agentic-operator

Length of output: 9701


🏁 Script executed:

#!/bin/bash
set -euo pipefail

sed -n '1,180p' api/v1alpha1/shared_types.go
echo
sed -n '110,170p' api/v1alpha1/tools_types.go

Repository: openshift/lightspeed-agentic-operator

Length of output: 11094


Define the openshift MCP server collision rule. MCPServerConfig.Name allows openshift, and ToolsSpec.mcpServers only enforces uniqueness within the user list, so this needs an explicit precedence rule here: reject, override, or skip the injected entry. Otherwise LIGHTSPEED_MCP_SERVERS is ambiguous.

🤖 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 @.ai/spec/what/sandbox-execution.md around lines 47 - 48, The default
OpenShift MCP injection behavior in the sandbox execution spec needs an explicit
collision rule for the reserved name openshift. Update the MCP server handling
described here so the logic in the ToolsSpec serialization path clearly defines
whether an injected default entry is rejected, overrides a user entry, or is
skipped when MCPServerConfig.Name already equals openshift. Reference the
default injection flow and LIGHTSPEED_MCP_SERVERS assembly so the precedence is
unambiguous.

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