Table of Contents

Class CallToolResult

Namespace
ModelContextProtocol.Protocol
Assembly
ModelContextProtocol.Core.dll

Represents the result of a ToolsCall request from a client to invoke a tool provided by the server.

public sealed class CallToolResult : Result
Inheritance
CallToolResult
Inherited Members
Extension Methods

Remarks

Tool execution errors (including input validation errors, API failures, and business logic errors) should be reported inside the result object with IsError set to true, rather than as a JsonRpcError. This allows language models to see error details and potentially self-correct in subsequent requests.

To return a validation or business-logic error from a tool method, either throw an McpException (whose Message will be included in the error result), or declare the tool's return type as CallToolResult so it can be returned directly with IsError set to true and details in Content. Using CallToolResult as the return type gives the tool full control over both success and error responses.

Protocol-level errors (such as unknown tool names, malformed requests that fail schema validation, or server errors) should be reported as MCP protocol error responses using McpErrorCode.

See the schema for details.

Properties

Content

Gets or sets the response content from the tool call.

[JsonPropertyName("content")]
public IList<ContentBlock> Content { get; set; }

Property Value

IList<ContentBlock>

IsError

Gets or sets a value that indicates whether the tool call was unsuccessful.

[JsonPropertyName("isError")]
public bool? IsError { get; set; }

Property Value

bool?

true to signify that the tool execution failed; false if it was successful.

Remarks

Tool execution errors (including input validation errors, API failures, and business logic errors) are reported with this property set to true and details in the Content property, rather than as protocol-level errors.

This design allows language models to receive detailed error feedback and potentially self-correct in subsequent requests. For example, if a date parameter is in the wrong format or out of range, the error message in Content can explain the issue, enabling the model to retry with corrected parameters.

StructuredContent

Gets or sets an optional JSON object representing the structured result of the tool call.

[JsonPropertyName("structuredContent")]
public JsonElement? StructuredContent { get; set; }

Property Value

JsonElement?

Task

Gets or sets the task data for the newly created task.

[Experimental("MCPEXP001", UrlFormat = "https://github.com/modelcontextprotocol/csharp-sdk/blob/main/docs/list-of-diagnostics.md#mcpexp001")]
[JsonIgnore]
public McpTask? Task { get; set; }

Property Value

McpTask

Remarks

This property is populated only for task-augmented tool calls. When present, the other properties (Content, StructuredContent, IsError) may not be populated. The actual tool result can be retrieved later via tasks/result.