Opt-in structured output schema: {stdout, stderr, exitCode} #8

Closed
opened 2026-05-23 20:53:53 +00:00 by coilysiren · 0 comments
Owner

Originally filed by @coilysiren on 2026-05-13T14:19:53Z - https://github.com/coilysiren/cli-mcp/issues/34

Today cli-mcp captures tool stdout/stderr as MCP text content and signals failure via CallToolResult.IsError. Narrative, easy to read in a chat transcript.

njayp/ophis standardizes on a structured output schema for every tool:

{ "stdout": "...", "stderr": "...", "exitCode": 0 }

Easier for agents to parse programmatically. The exit code in particular is useful: ophis's docs note "Non-zero exit codes indicate command errors (not execution failures)" which lets an agent distinguish between "the tool ran and reported failure" and "the tool itself broke."

Proposal: add an opt-in Options.StructuredOutput bool (or similar). When set, the tool's MCP output schema becomes the three-field object, and CallToolResult.StructuredContent carries it. Keep text-content the default so existing consumers don't break.

Open question: does anything in cli-mcp's in-process model make exit-code capture awkward? root.Run returns an error, not an int; mapping that to a meaningful exitCode cleanly is part of the design.

_Originally filed by @coilysiren on 2026-05-13T14:19:53Z - [https://github.com/coilysiren/cli-mcp/issues/34](https://github.com/coilysiren/cli-mcp/issues/34)_ Today cli-mcp captures tool stdout/stderr as MCP text content and signals failure via `CallToolResult.IsError`. Narrative, easy to read in a chat transcript. [njayp/ophis](https://github.com/njayp/ophis) standardizes on a structured output schema for every tool: ```json { "stdout": "...", "stderr": "...", "exitCode": 0 } ``` Easier for agents to parse programmatically. The exit code in particular is useful: ophis's docs note "Non-zero exit codes indicate command errors (not execution failures)" which lets an agent distinguish between "the tool ran and reported failure" and "the tool itself broke." Proposal: add an opt-in `Options.StructuredOutput bool` (or similar). When set, the tool's MCP output schema becomes the three-field object, and `CallToolResult.StructuredContent` carries it. Keep text-content the default so existing consumers don't break. Open question: does anything in cli-mcp's in-process model make exit-code capture awkward? `root.Run` returns an `error`, not an int; mapping that to a meaningful `exitCode` cleanly is part of the design.
coilysiren 2026-05-30 05:44:17 +00:00
  • closed this issue
  • added the
    icebox
    label
Commenting is not possible because the repository is archived.
No milestone
No project
No assignees
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
coilysiren/cli-mcp#8
No description provided.