Skip to content

Commit f05101b

Browse files
cameroncookecodex
andauthored
docs: Clarify structured output artifacts (#11)
Document that streamed fragments are transient and final responses are driven from structured results. Clarify xcode-ide bridge payload handling and the structured-output union consumers should parse. Refs GH-360 Co-authored-by: Codex <noreply@openai.com>
1 parent e538cb6 commit f05101b

4 files changed

Lines changed: 44 additions & 10 deletions

File tree

app/docs/_content/architecture-rendering-output.mdx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ stateDiagram-v2
3737
Collecting --> Collecting: attach(image)
3838
Collecting --> StructuredReady: setStructuredOutput(output)
3939
StructuredReady --> StructuredReady: setNextSteps(steps, runtime)
40-
Collecting --> ErrorTracked: error fragment emitted
4140
StructuredReady --> ErrorTracked: structured result didError=true
4241
4342
ErrorTracked --> Finalizing: finalize()
@@ -60,7 +59,7 @@ stateDiagram-v2
6059
RuntimeBoundary --> [*]
6160
```
6261

63-
The render session is the collection point for the tool invocation. It receives fragments as work happens, stores attachments, stores the final structured output, stores next steps, tracks error state, and finalizes the transcript for the selected render strategy.
62+
The render session is the collection point for the tool invocation. It receives fragments as work happens, stores attachments, stores the final structured output, stores next steps, derives error state from the structured result, and finalizes the transcript for the selected render strategy.
6463

6564
## Render strategy vs CLI output mode
6665

app/docs/_content/architecture-tool-lifecycle.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ interface ToolHandlerContext {
6060
| `nextSteps` | Provide explicit dynamic follow-ups when templates cannot express the result. |
6161
| `structuredOutput` | Set the final canonical result, schema ID, and schema version. |
6262

63-
The omitted progress flags are internal boundary controls. They exist in source today, but the public docs intentionally do not teach tool authors to branch on them.
64-
6563
## Fragments versus structured output
6664

6765
A handler produces two different things, and they serve different readers. Fragments are live progress and transcript material — log lines, build output, attachments — that callers and pipelines consume while the work is running. Structured output is the one final canonical result the handler sets at the end of the call. Fragments are never the final result; the structured output is what powers CLI `--output json`, MCP `structuredContent`, schema validation, fixtures, and stable integrations.

app/docs/_content/mcp-protocol-support.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ The envelope wraps every tool's structured payload in the same shape, so consume
5151
}
5252
```
5353

54-
The envelope fields are documented in [Output Formats](/docs/output-formats). Canonical JSON schemas live in [`schemas/structured-output/`](https://github.com/getsentry/XcodeBuildMCP/tree/main/schemas/structured-output). Tools advertise their output schema in `tools/list`.
54+
The envelope fields are documented in [Output Formats](/docs/output-formats). Canonical JSON schemas live in [`schemas/structured-output/`](https://github.com/getsentry/XcodeBuildMCP/tree/main/schemas/structured-output). Tools advertise their output schema in `tools/list` as an object-shaped union of the domain schema OR `xcodebuildmcp.output.error`, so clients can always branch on `schema` to determine whether a structured result is a normal domain payload or a generic error.
5555

5656
The one exception is the [Xcode IDE bridge](/docs/xcode-ide): bridge tools forward calls to Xcode's own MCP service, so their output shape comes from Xcode and does not use the XcodeBuildMCP envelope.
5757

app/docs/_content/output-formats.mdx

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,31 @@ The response has these fields:
7070
|-------|------|---------|
7171
| `schema` | `string` | Schema identifier, for example `xcodebuildmcp.output.build-result`. |
7272
| `schemaVersion` | `string` | Version of that schema contract. |
73-
| `didError` | `boolean` | Whether the tool reported a domain error. |
73+
| `didError` | `boolean` | Whether the final result is an error. |
7474
| `error` | `string \| null` | Human-readable error text when `didError` is true. |
75-
| `data` | `object \| null` | Tool-specific data. |
75+
| `data` | `object \| null` | Schema-specific payload. Domain schemas use tool-specific data; `xcodebuildmcp.output.error` uses generic error metadata. |
76+
77+
Structured output is a tagged union. Consumers should branch on `schema`, then parse `data` according to that schema:
78+
79+
```typescript
80+
type XcodeBuildMCPOutput =
81+
| {
82+
schema: "xcodebuildmcp.output.simulator-list"
83+
schemaVersion: "1"
84+
didError: boolean
85+
error: string | null
86+
data: { simulators: Simulator[] }
87+
}
88+
| {
89+
schema: "xcodebuildmcp.output.error"
90+
schemaVersion: "1"
91+
didError: true
92+
error: string
93+
data: { category: "runtime" | "validation" | "schema"; code: string }
94+
}
95+
```
96+
97+
For example, `list_sims` normally returns `xcodebuildmcp.output.simulator-list`, but a validation or runtime failure before simulator listing begins returns `xcodebuildmcp.output.error`. Do not assume a tool always returns only its domain schema; always check `schema` first.
7698
7799
```json
78100
{
@@ -101,7 +123,22 @@ The response has these fields:
101123
}
102124
```
103125
104-
`data` can be `null` when a tool succeeds but has no structured payload. If a tool does not produce structured output for `--output json`, the CLI emits an error response with `schema: "xcodebuildmcp.output.error"`, `didError: true`, and exits with a non-zero status.
126+
`data` can be `null` when a tool succeeds but has no structured payload. If a tool produces no structured output, or if a pre-domain failure occurs (validation, schema, or runtime error before the tool executes), the response uses the generic error branch and the CLI exits with a non-zero status:
127+
128+
```json
129+
{
130+
"schema": "xcodebuildmcp.output.error",
131+
"schemaVersion": "1",
132+
"didError": true,
133+
"error": "Parameter validation failed: Invalid parameters...",
134+
"data": {
135+
"category": "validation",
136+
"code": "PARAMETER_VALIDATION_FAILED"
137+
}
138+
}
139+
```
140+
141+
Domain failures still use their domain schema. For example, an attempted build that fails returns `xcodebuildmcp.output.build-result` with `didError: true` and build diagnostics in `data`.
105142
106143
## `--output jsonl`
107144
@@ -143,7 +180,7 @@ Do not script against `raw`. The transcript is intentionally close to the underl
143180
144181
## Structured content for MCP clients
145182
146-
MCP mode always returns the normal `content` array. When a tool sets structured output, XcodeBuildMCP also attaches [`structuredContent`](https://modelcontextprotocol.io/specification/2025-11-25/server/tools#structured-content) with the same shape as `--output json`.
183+
MCP mode always returns the normal `content` array. When a tool sets structured output, XcodeBuildMCP also attaches [`structuredContent`](https://modelcontextprotocol.io/specification/2025-11-25/server/tools#structured-content) with the same shape as `--output json`. Pre-domain failures — validation errors, schema mismatches, or runtime errors before the tool executes — also produce `structuredContent` using `schema: "xcodebuildmcp.output.error"`.
147184
148185
```json
149186
{
@@ -188,7 +225,7 @@ MCP mode always returns the normal `content` array. When a tool sets structured
188225
}
189226
```
190227
191-
Tools that declare an [output schema](https://modelcontextprotocol.io/specification/2025-11-25/server/tools#output-schema) also advertise it during MCP registration. Clients can use that schema to validate `structuredContent` or render typed UI.
228+
Tools that declare an [output schema](https://modelcontextprotocol.io/specification/2025-11-25/server/tools#output-schema) also advertise it during MCP registration. For tools with structured output, the advertised schema is a union of the tool's domain envelope and the generic `xcodebuildmcp.output.error` envelope. Clients can use that schema to validate `structuredContent` or render typed UI, but should still branch on the returned `schema` value at runtime.
192229
193230
## Response schema reference
194231

0 commit comments

Comments
 (0)