MCPAI AgentAPI EngineeringNbility

Validate an MCP tool result beyond its JSON

Distinguish content, structuredContent, outputSchema and isError before treating an MCP tool response as a successful business result.

Validate an MCP tool result beyond its JSON

A JSON tool response is not proof of business success. An MCP host needs to distinguish JSON-RPC errors, completion state, isError, structured-data validity and the meaning of the returned fields. HTTP 200 alone does not establish any of those outcomes.

This article checks MCP 2026-07-28 Tools on November 25, 2026. Its stock lookup uses application-defined public fixtures, not a connected inventory system or model.

Should a host consume content or structuredContent?

content carries text, images, audio and resources; structuredContent carries JSON data for programmatic use. A result can contain both.

For backward compatibility, the specification recommends also serializing structured data into a text content block. Keep both representations derived from one business result so they cannot drift into conflicting answers.

One business result produces consistent text and structured-data representations

MCP structuredContent is produced by the tool server. Model API Structured Outputs constrain model-generated output. They operate at different points in the chain. A tool outputSchema therefore does not validate a model's final answer; see the separate JSON Schema and structured-output guide.

Can outputSchema prove the stock answer is correct?

An output Schema constrains data shape, but it does not prove freshness or that the correct product was queried.

This is one tool definition, not a complete listing response:

{
  "name": "lookup_demo_stock",
  "description": "Read stock for a public demo SKU",
  "inputSchema": {
    "type": "object",
    "properties": {"sku": {"type": "string"}},
    "required": ["sku"],
    "additionalProperties": false
  },
  "outputSchema": {
    "type": "object",
    "properties": {
      "sku": {"type": "string"},
      "available": {"type": "integer", "minimum": 0},
      "checked_at": {"type": "string"}
    },
    "required": ["sku", "available", "checked_at"],
    "additionalProperties": false
  }
}

An illustrative successful result member:

{
  "resultType": "complete",
  "isError": false,
  "content": [{
    "type": "text",
    "text": "{\"sku\":\"DEMO-A\",\"available\":0,\"checked_at\":\"2026-11-25T10:00:00Z\"}"
  }],
  "structuredContent": {
    "sku": "DEMO-A",
    "available": 0,
    "checked_at": "2026-11-25T10:00:00Z"
  }
}

Zero available stock is a valid result, not a missing value or failed execution. The application must still match sku to the request and enforce its freshness rules. Here checked_at is only declared as a string; that declaration does not validate timestamps.

Servers declaring outputSchema must provide conforming structured results, and clients should validate them. Do not silently coerce "0" into 0 and claim the original result passed strict validation. Any permitted conversion needs an explicit application contract.

How does isError differ from a JSON-RPC error?

A JSON-RPC error reports a protocol-level request failure; isError: true reports tool execution failure inside a result.

OutcomeInterpretationNext action
JSON-RPC errorThe tool request did not complete normallyCheck method, tool name, request or server failure
resultType: "input_required"More input is neededContinue through the protocol's input flow
Complete result with isError: trueThe tool returned execution feedbackInspect whether corrected arguments can help
Complete result without an error markerData was returnedValidate structure and business meaning

Protocol failure, required input, execution failure and returned data are distinct branches

The specification includes invalid business input, such as a departure date, among tool execution errors that a model may correct. Do not classify every parameter problem as a disconnection. isError is optional; absence does not itself indicate failure or prove a correct business result.

If an output Schema only describes successful stock records, putting {"error":"timeout"} in structuredContent violates it. Follow the applicable protocol, SDK and error contract, and explicitly model business outcomes where needed. Removing validation only conceals the mismatch.

Are structured results interchangeable across protocol versions?

Matching field names do not guarantee that every protocol version accepts the same shape.

The 2026-07-28 specification allows any JSON value in structuredContent, including arrays and scalars conforming to the output Schema. The older 2025-11-25 Tools specification describes structured content as a JSON object. An object envelope is convenient for cross-version examples, but implementations still need checking.

Current results require resultType. The change log says clients reading earlier-protocol results without that field must treat them as complete; this is a compatibility rule for older responses, not permission to omit required fields in new messages.

Files and images also need correct content-block conversion. The Gemini multimodal tool-result guide explains another host-to-model boundary, using Gemini fields rather than MCP wire fields.

What should result-consumption checks cover?

Use public fixtures for zero stock, an invalid field type, execution failure and required input, then inspect the application's decision for each.

Validate structure, match request identity, preserve zero and interpret the business outcome

Zero should remain a valid no-stock answer. A string quantity should fail strict validation. Execution failure should not become zero inventory, and required input should not become completion. Add a structurally valid response for the wrong SKU to demonstrate why business checks are separate.

The JSON and Schema fixtures were checked offline. No model tool call, order write or inventory accuracy measurement was performed. For troubleshooting evidence, use the redacted support-log checklist; the model connection is documented in Chat Completions. A successful Nbility model response does not validate an MCP business result.

Related posts

Missing MCP tools may be on the next page
MCPAI AgentAPI Engineering

Missing MCP tools may be on the next page

Follow opaque nextCursor values, including empty strings, to discover the complete MCP catalog. Test pagination and failure handling offline.

Run your Agent workflow through Nbility

Get an API key and connect OpenAI-compatible models and developer tools from one place.

Get an API key