mcptools icon indicating copy to clipboard operation
mcptools copied to clipboard

No support for tool outputSchema (MCP spec 2025-06-18)

Open mrcanofcatfood opened this issue 6 months ago • 0 comments

Problem

The MCP spec (2025-06-18) defines an outputSchema field on tool definitions — a JSON Schema describing the expected structure of tool results. This enables clients to validate outputs and provides type information for better integration.

Neither tool_as_json() nor ellmer::tool() currently support declaring an output schema.

Expected

ellmer::tool(
  fun = function() list(auc = 0.92, tss = 0.81),
  name = "evaluate_model",
  description = "Evaluate model performance",
  arguments = list(),
  outputSchema = list(
    type = "object",
    properties = list(
      auc = list(type = "number"),
      tss = list(type = "number")
    ),
    required = c("auc", "tss")
  )
)

Should produce in tools/list:

{
  "name": "evaluate_model",
  "description": "Evaluate model performance",
  "inputSchema": {...},
  "outputSchema": {
    "type": "object",
    "properties": {
      "auc": {"type": "number"},
      "tss": {"type": "number"}
    },
    "required": ["auc", "tss"]
  }
}

Use Case

Building an SDM MCP server with ~70 tools. Each tool returns structured data (metrics, file paths, statistics). outputSchema would let clients validate every tool response automatically instead of parsing free-form text.

Fix

  1. Add outputSchema parameter to ellmer::tool() (stores on ToolDef)
  2. Include in tool_as_json() output in mcptools

Depends on ellmer changes first, then mcptools serialization.

mrcanofcatfood avatar May 20 '26 12:05 mrcanofcatfood