Skip to content

fix(mcp): return typed error JSON for unsupported actions (info/describe/list-filter)#2989

Merged
code-yeongyu merged 1 commit intomainfrom
fix/mcp-error-contract
May 4, 2026
Merged

fix(mcp): return typed error JSON for unsupported actions (info/describe/list-filter)#2989
code-yeongyu merged 1 commit intomainfrom
fix/mcp-error-contract

Conversation

@code-yeongyu
Copy link
Copy Markdown
Collaborator

Problem

claw mcp info nonexistent --output-format json, claw mcp list nonexistent --output-format json, claw mcp describe myserver --output-format json all fell through to the generic help renderer, returning an opaque envelope with only unexpected set — no machine-readable error_kind.

// before: info nonexistent → generic help, not an error
{ "kind": "mcp", "action": "help", "unexpected": "info nonexistent" }

// after
{ "kind": "mcp", "action": "error", "ok": false, "error_kind": "unsupported_action",
  "requested_action": "info nonexistent", "hint": "use `claw mcp show <server>` to inspect a server" }

mcp show nonexistent --output-format json already returns a proper found:false envelope — that path is unchanged.

Fix

  • Add typed list <filter> / info / describe guards in render_mcp_report_for and render_mcp_report_json_for
  • New render_mcp_unsupported_action_text/json helpers emit ok:false, error_kind:"unsupported_action", hint, requested_action

Test

mcp_unsupported_actions_return_typed_error_not_generic_help asserts kind=="mcp", ok==false, error_kind=="unsupported_action" for info, list <filter>, and describe paths.

Pinpoint: ROADMAP #504

@code-yeongyu
Copy link
Copy Markdown
Collaborator Author

QA: Two test failures on this branch. (1) resumed_status_command_emits_structured_json_when_requested — pre-existing main failure, not introduced by this PR. (2) init::tests::artifacts_with_status_partitions_fresh_and_idempotent_runs.gitignore and CLAUDE.md missing from created[] in fresh init. This second failure appears specific to this PR's changes.

…ibe/list-filter)

`claw mcp info nonexistent --output-format json` and
`claw mcp list nonexistent --output-format json` fell through to
the generic help renderer, returning an opaque envelope with only
`unexpected` set — no machine-readable error_kind.

Fix:
- Add typed guards in render_mcp_report_for/_json_for for:
  - `list <filter>`: list accepts no filter argument
  - `info <name>` / `describe <name>`: suggest `mcp show`
- New render_mcp_unsupported_action_text/json helpers emit
  `ok:false`, `error_kind:"unsupported_action"`, `hint`, `requested_action`
- `mcp show`, `mcp list`, `mcp help` existing paths unchanged

Test: mcp_unsupported_actions_return_typed_error_not_generic_help
asserts kind=="mcp", ok==false, error_kind=="unsupported_action"
for info/list-filter/describe paths.

Pinpoint: ROADMAP #504
@code-yeongyu code-yeongyu force-pushed the fix/mcp-error-contract branch from a10d547 to 061e1e9 Compare May 4, 2026 20:09
@code-yeongyu code-yeongyu merged commit 5eb4b8a into main May 4, 2026
4 checks passed
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.

1 participant