Problem
MCP tool calls currently expose structured output primarily for paged Repl results.
For non-paged command handlers that return typed objects, Repl renders the result through the output pipeline and returns it as CallToolResult.Content text. Even when that text is JSON, the MCP tool does not generally advertise an outputSchema, and the call result does not generally populate StructuredContent.
That makes it harder for MCP clients and agents to distinguish:
- human text fallback;
- JSON-looking text;
- actual structured tool result data with a declared schema.
Current behavior
McpSchemaGenerator.BuildOutputSchema(...) returns an output schema for paged results only.
McpToolAdapter.BuildToolResult(...) populates StructuredContent for paged result envelopes only.
- Normal typed handler return values are exposed through text content.
Why this matters
Agents and MCP clients that understand outputSchema / StructuredContent should be able to consume typed Repl command results without parsing text fallbacks.
This is separate from MCP resources: resources now advertise the MIME type of the actual resource body. Tool calls need their own contract for typed return values.
Things to investigate
- How Repl should infer or declare output schemas for non-paged handler return types.
- Whether normal JSON-rendered command results should populate
StructuredContent.
- How to preserve a useful
Content text fallback for clients that ignore structured content.
- How
Results.Success(...), Results.Error(...), void/no-output handlers, paged results, and custom output transformers should map to MCP tool result fields.
- Whether this needs an explicit API, conventions, or documentation-only guidance first.
Related
Follow-up from #38, which fixed MCP resource MIME consistency but intentionally did not solve MCP tool return typing.
Problem
MCP tool calls currently expose structured output primarily for paged Repl results.
For non-paged command handlers that return typed objects, Repl renders the result through the output pipeline and returns it as
CallToolResult.Contenttext. Even when that text is JSON, the MCP tool does not generally advertise anoutputSchema, and the call result does not generally populateStructuredContent.That makes it harder for MCP clients and agents to distinguish:
Current behavior
McpSchemaGenerator.BuildOutputSchema(...)returns an output schema for paged results only.McpToolAdapter.BuildToolResult(...)populatesStructuredContentfor paged result envelopes only.Why this matters
Agents and MCP clients that understand
outputSchema/StructuredContentshould be able to consume typed Repl command results without parsing text fallbacks.This is separate from MCP resources: resources now advertise the MIME type of the actual resource body. Tool calls need their own contract for typed return values.
Things to investigate
StructuredContent.Contenttext fallback for clients that ignore structured content.Results.Success(...),Results.Error(...), void/no-output handlers, paged results, and custom output transformers should map to MCP tool result fields.Related
Follow-up from #38, which fixed MCP resource MIME consistency but intentionally did not solve MCP tool return typing.