Skip to content

SANDBOX-1813: add openspec for bash MCP tool handler - #17

Merged
fbm3307 merged 1 commit into
codeready-toolchain:masterfrom
fbm3307:SANDBOX-1813-bash-mcp-tool-openspec
Jul 16, 2026
Merged

SANDBOX-1813: add openspec for bash MCP tool handler #17
fbm3307 merged 1 commit into
codeready-toolchain:masterfrom
fbm3307:SANDBOX-1813-bash-mcp-tool-openspec

Conversation

@fbm3307

@fbm3307 fbm3307 commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator
  • Add OpenSpec for SANDBOX-1813 (bash MCP tool handler): proposal, design, spec, and tasks
  • Covers X-Session-ID routing, timeout clamping (default 60 / max 300), BashInput/BashOutput, and CommandExecutor for testability
  • Locks error model to non-zero exit → IsError + structured BashOutput; infra/validation → tool IsError without BashOutput (not JSON-RPC protocol errors)

Assisted By: Cursor

Summary by CodeRabbit

  • New Features
    • Added an MCP bash tool for executing commands within active sessions.
    • Supports configurable timeouts from 60 to 300 seconds.
    • Returns structured output including standard output, standard error, exit code, and execution duration.
    • Preserves command output when commands finish with non-zero exit codes.
  • Tests
    • Added coverage for validation, timeout handling, command results, execution failures, and tool registration.

- Define bash tool registration, X-Session-ID routing, and timeout clamping
- Lock error model to tool IsError (option A), not JSON-RPC protocol errors
- Include CommandExecutor interface and unit-test task plan

Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: Feny Mehta <fbm3307@gmail.com>
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Walkthrough

The OpenSpec change documents a typed MCP bash tool that routes commands through X-Session-ID, normalizes timeouts, returns structured execution output, distinguishes exit failures from infrastructure errors, and defines implementation and test requirements.

Changes

Bash MCP tool specification

Layer / File(s) Summary
Scope and architecture
openspec/changes/.../.openspec.yaml, openspec/changes/.../proposal.md, openspec/changes/.../design.md
Initializes the OpenSpec change and documents the proposed pkg/tools bash tool, its scope, architecture, and deferred server wiring.
Behavioral contract
openspec/changes/.../specs/bash-tool/spec.md, openspec/changes/.../design.md
Defines typed registration, session-header extraction, timeout clamping, command validation, structured output, error mapping, executor abstraction, annotations, and SDK version requirements.
Implementation and validation checklist
openspec/changes/.../tasks.md
Lists the planned exported types, constructor, registration and handler behavior, mock-based tests, and acceptance verification steps.

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

Possibly related PRs

Suggested labels: documentation

Suggested reviewers: alexeykazakov

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the PR’s main change: adding an OpenSpec for the bash MCP tool handler.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai coderabbitai Bot added the documentation Improvements or additions to documentation label Jul 13, 2026

@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)
openspec/changes/2026-07-13-bash-mcp-tool-handler/design.md (1)

148-155: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Pin an exact SDK version.

Resolving an unspecified patch at implementation time makes this OpenSpec non-reproducible and can change typed-handler behavior between implementations. Record the exact module version in go.mod/go.sum and validate the selected version’s schema and error-mapping behavior. The SDK documents these transformations as responsibilities of typed AddTool. (pkg.go.dev)

As per path instructions, this is a material maintainability and integration concern, not a version-style nitpick.

🤖 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 `@openspec/changes/2026-07-13-bash-mcp-tool-handler/design.md` around lines 148
- 155, Update Decision 8 to specify the exact
github.com/modelcontextprotocol/go-sdk patch version rather than the v1.4.x
range, and require recording that version in go.mod and go.sum. Validate the
selected SDK version’s schema and error-mapping behavior through the typed
AddTool integration before finalizing the change.

Source: Path instructions

openspec/changes/2026-07-13-bash-mcp-tool-handler/tasks.md (1)

33-45: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add an end-to-end typed-SDK registration test.

Listing the tool does not verify generated input/output schemas, ReadOnlyHint, StructuredContent, or typed error packing. Add an in-memory MCP server/client call covering exit 0, exit 1, and executor errors; otherwise direct handler tests can pass while the actual tools/call wire behavior is broken. The SDK documents these AddTool transformations explicitly. (pkg.go.dev)

As per path instructions, this targets a high-value integration gap rather than test-style cleanup.

🤖 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 `@openspec/changes/2026-07-13-bash-mcp-tool-handler/tasks.md` around lines 33 -
45, Add an end-to-end typed-SDK MCP registration test alongside the existing
bash tests, using an in-memory server/client and an injected mock
CommandExecutor to invoke the registered bash tool through tools/call. Cover
exit 0, exit 1, and executor-error cases, asserting generated input/output
schemas, ReadOnlyHint, StructuredContent, and typed error packing on the wire
rather than only testing the handler or tool listing.

Source: 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 `@openspec/changes/2026-07-13-bash-mcp-tool-handler/design.md`:
- Around line 148-155: Update Decision 8 to specify the exact
github.com/modelcontextprotocol/go-sdk patch version rather than the v1.4.x
range, and require recording that version in go.mod and go.sum. Validate the
selected SDK version’s schema and error-mapping behavior through the typed
AddTool integration before finalizing the change.

In `@openspec/changes/2026-07-13-bash-mcp-tool-handler/tasks.md`:
- Around line 33-45: Add an end-to-end typed-SDK MCP registration test alongside
the existing bash tests, using an in-memory server/client and an injected mock
CommandExecutor to invoke the registered bash tool through tools/call. Cover
exit 0, exit 1, and executor-error cases, asserting generated input/output
schemas, ReadOnlyHint, StructuredContent, and typed error packing on the wire
rather than only testing the handler or tool listing.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 7cabe1fc-8958-49d0-b124-4e4fd80f7bac

📥 Commits

Reviewing files that changed from the base of the PR and between 2d316cf and 3c5f804.

📒 Files selected for processing (5)
  • openspec/changes/2026-07-13-bash-mcp-tool-handler/.openspec.yaml
  • openspec/changes/2026-07-13-bash-mcp-tool-handler/design.md
  • openspec/changes/2026-07-13-bash-mcp-tool-handler/proposal.md
  • openspec/changes/2026-07-13-bash-mcp-tool-handler/specs/bash-tool/spec.md
  • openspec/changes/2026-07-13-bash-mcp-tool-handler/tasks.md
🔗 Linked repositories identified

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

  • codeready-toolchain/mcp-common (manual)
  • codeready-toolchain/mcp-server-devsandbox (manual)
  • codeready-toolchain/api (manual)
  • codeready-toolchain/toolchain-common (manual)
  • codeready-toolchain/host-operator (manual)
  • codeready-toolchain/toolchain-e2e (manual)
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
  • GitHub Check: build-test-coverage
  • GitHub Check: govulncheck
🧰 Additional context used
📓 Path-based instructions (1)
**

⚙️ CodeRabbit configuration file

-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.

Files:

  • openspec/changes/2026-07-13-bash-mcp-tool-handler/proposal.md
  • openspec/changes/2026-07-13-bash-mcp-tool-handler/design.md
  • openspec/changes/2026-07-13-bash-mcp-tool-handler/specs/bash-tool/spec.md
  • openspec/changes/2026-07-13-bash-mcp-tool-handler/tasks.md
🔇 Additional comments (8)
openspec/changes/2026-07-13-bash-mcp-tool-handler/.openspec.yaml (1)

1-2: LGTM!

openspec/changes/2026-07-13-bash-mcp-tool-handler/proposal.md (1)

1-20: LGTM!

Also applies to: 23-35, 39-41

openspec/changes/2026-07-13-bash-mcp-tool-handler/design.md (2)

1-20: LGTM!

Also applies to: 28-147, 156-193


25-25: 🚀 Performance & Scalability

Remove the output-limit concern. The /exec client already caps successful responses at 10 MB before the tool handles them, so this handler is not exposed to unbounded stdout/stderr.

			> Likely an incorrect or invalid review comment.
openspec/changes/2026-07-13-bash-mcp-tool-handler/specs/bash-tool/spec.md (3)

1-6: LGTM!

Also applies to: 19-26, 45-120


7-18: 🩺 Stability & Availability

No change needed here. Persistence and same-session serialization are defined in the sandbox agent/session-manager specs, so this tool spec doesn’t need to restate them.

			> Likely an incorrect or invalid review comment.

27-44: 🔒 Security & Privacy

No server-side session binding needed here. X-Session-ID is trusted routing metadata injected by TARSy; access to the MCP endpoint is already gated by kube-rbac-proxy/bearer auth, and this handler does not own a separate session-authorization check.

			> Likely an incorrect or invalid review comment.
openspec/changes/2026-07-13-bash-mcp-tool-handler/tasks.md (1)

1-13: LGTM!

Also applies to: 16-32, 46-54

@fbm3307
fbm3307 merged commit 22e0202 into codeready-toolchain:master Jul 16, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant