Skip to content

test: validate complete MCP CLI invocations - #362

Open
YoungJinJung wants to merge 3 commits into
mainfrom
fix/issue-360-validate-mcp-cli-invocation
Open

YoungJinJung wants to merge 3 commits into
mainfrom
fix/issue-360-validate-mcp-cli-invocation

Conversation

@YoungJinJung

@YoungJinJung YoungJinJung commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • resolve each mapped MCP invocation against a fresh CLI command tree
  • validate flags, positional arguments, required flags, and flag groups without executing AWS loaders
  • require every mapped resource tool to invoke JSON output

Related Issues

Part of #360
Follow-up to #361

Validation

  • go test ./internal/mcp -run TestCatalogFeaturesHaveAgentSurfaceDecision -count=1
  • make test
  • make build

Checklist

  • Scope is focused
  • Branch name follows docs/branch-naming-harness.md
  • Documentation harness reviewed
  • README reviewed; no user-facing behavior changed
  • Relevant docs reviewed; no architecture, auth, config, or workflow change
  • Tests/validation included
  • No breaking changes

Summary by CodeRabbit

  • Tests
    • Expanded validation coverage for mapped resource MCP tools.
    • Added checks for command discovery, flag parsing, argument validation, required flags, and flag groups.
    • Confirmed that resource commands receive the expected --json=true setting.

- Parse mapped tool arguments against a fresh command tree.
- Enforce positional, required flag, group, and JSON constraints.
@coderabbitai

coderabbitai Bot commented Sep 14, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

Warning

Review limit reached

Next included review available in 5 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 54077e75-7237-4b21-b2b8-15a4c7559296

📥 Commits

Reviewing files that changed from the base of the PR and between 4f35c33 and 120737f.

📒 Files selected for processing (1)
  • internal/mcp/agent_surface_test.go

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: d7465350-6d26-41ff-8e68-8735cb690174

📥 Commits

Reviewing files that changed from the base of the PR and between 8deced7 and ade86dc.

📒 Files selected for processing (1)
  • internal/mcp/agent_surface_test.go

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

📜 Recent review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: test
🧰 Additional context used
📓 Path-based instructions (4)
Check that tests cover API errors, mapping edge cases, and navigation state transitions, not only happy paths.

⚙️ CodeRabbit configuration file

Files:

  • internal/mcp/agent_surface_test.go
For Go reviews, look beyond compilation and prioritize nil pointer risks, context propagation, AWS SDK pagination, error wrapping, deterministic sorting, and stable table/detail rendering.

⚙️ CodeRabbit configuration file

Files:

  • internal/mcp/agent_surface_test.go
Tests use mock client interfaces (see `rds_test.go` pattern) in Go test files

📄 CodeRabbit inference engine (CLAUDE.md)

Files:

  • internal/mcp/agent_surface_test.go
Use lipgloss for styled TUI output — column-aligned tables with dimmed labels in Go implementation files Implement scroll windowing with formula: `visibleLines := max(m.height-N, 5)` in Go TUI implementation

📄 CodeRabbit inference engine (CLAUDE.md)

Files:

  • internal/mcp/agent_surface_test.go
🔇 Additional comments (1)
internal/mcp/agent_surface_test.go (1)

160-175: LGTM!


Walkthrough

The MCP surface test now performs full CLI validation for each mapped resource tool. It checks command resolution, flag parsing, argument validation, required flags, flag groups, and the enabled --json flag.

Changes

MCP CLI validation

Layer / File(s) Summary
Mapped command dispatch validation
internal/mcp/agent_surface_test.go
The test creates a fresh root command, resolves the mapped command, validates its arguments and flags, and checks that --json is changed and set to "true".

Priority: ⬇️ Low

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

Change: Other

Merge Risk: ⚪ Minimal · up to 4f35c

The change strengthens MCP dispatch validation without introducing a merge-blocking risk.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description includes all required sections. It explains the MCP CLI validation changes, lists related issues, documents targeted and full validation commands, and completes the checklist.
Title check ✅ Passed The title uses the required conventional prefix test: and clearly describes the MCP CLI validation change.
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 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-360-validate-mcp-cli-invocation

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.

@YoungJinJung

Copy link
Copy Markdown
Contributor Author

/q review

@amazon-q-developer amazon-q-developer 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.

The validation logic correctly implements complete MCP CLI invocation testing. The added validation chain properly verifies command resolution, flag parsing, argument validation, required flags, flag groups, and JSON output requirements without executing AWS loaders. No blocking issues identified.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

@amazon-q-developer amazon-q-developer 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.

The validation logic correctly implements the requirements to resolve each mapped MCP invocation against a fresh CLI command tree and validate flags, positional arguments, required flags, and flag groups without executing AWS loaders. The code is well-structured with proper error handling and comprehensive validation checks. No blocking issues identified.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

@YoungJinJung YoungJinJung left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Findings

  1. Medium — reject resolved commands that Cobra cannot execute (internal/mcp/agent_surface_test.go:162)

    After Find, the new chain validates flags, positional arguments, required flags, flag groups, and JSON mode, but it never checks command.Runnable(). Cobra returns flag.ErrHelp before those validations when a command has neither Run nor RunE, so a mapped resources child could keep the expected annotations and --json flag, pass this guard, and still fail every MCP call instead of returning JSON. Reject !command.Runnable() immediately after the successful Find.

Reviewed head: 4f35c33

- Ensure mapped resource tools resolve to executable Cobra commands.
@YoungJinJung

Copy link
Copy Markdown
Contributor Author

Addressed in 120737f: the parity guard now rejects a resolved Cobra command when command.Runnable() is false, immediately after Find and before flag validation. Validation passed: go test ./internal/mcp -run TestCatalogFeaturesHaveAgentSurfaceDecision -count=1, make test, and make build.

@YoungJinJung

Copy link
Copy Markdown
Contributor Author

/q review

@amazon-q-developer amazon-q-developer 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.

The changes add comprehensive validation for MCP CLI invocations, including command discovery, flag parsing, argument validation, required flags, flag groups, and JSON output verification. The implementation is correct with proper error handling throughout the validation chain.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

@YoungJinJung YoungJinJung left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Re-reviewed head 120737f after the prior finding on 4f35c33. The new command.Runnable() guard closes the non-executable-command gap before flag validation. I reviewed the complete one-file diff and found no further actionable concerns. Local validation passed: make test and make build.

@youngjinjung-linq youngjinjung-linq 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.

Reviewed head 120737f after the runnable-command follow-up. I read the complete current diff, issue context, tests, CI, prior reviews, and discussion; no actionable concerns remain. Local validation passed: the targeted parity test, make test, and make build.

@YoungJinJung
YoungJinJung dismissed youngjinjung-linq’s stale review September 15, 2026 00:32

Redundant review submitted under the wrong authenticated identity; YoungJinJung had already reviewed this unchanged head.

@youngjinjung-linq youngjinjung-linq 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.

Re-reviewed head 120737f after the prior approval was dismissed. I read the complete current diff, issue context, tests, CI, prior reviews, comments, and thread state. The validation follows Cobra’s real command path without adding production complexity, and no actionable concerns remain. Local validation passed: the uncached parity test, make test, make build, and git diff --check.

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