Documentation Index
Fetch the complete documentation index at: https://easyaf.dev/llms.txt
Use this file to discover all available pages before exploring further.
Definition
Assembly: Microsoft.OData.Mcp.Core.dll
Namespace: Microsoft.OData.Mcp.Core.Tools
Inheritance: System.Object
Syntax
Microsoft.OData.Mcp.Core.Tools.McpToolResult
Summary
Represents the result of an MCP tool execution.
This class standardizes the format of tool execution results, providing
consistent error handling, data formatting, and metadata across all tools.
Constructors
.ctor
Initializes a new instance of the McpToolResult class.
Syntax
.ctor
Initializes a new instance of the McpToolResult class with success status.
Syntax
public McpToolResult(System.Text.Json.JsonDocument data, string correlationId = null)
Parameters
| Name | Type | Description |
|---|
data | System.Text.Json.JsonDocument? | The result data. |
correlationId | string? | The correlation ID. |
.ctor
Initializes a new instance of the McpToolResult class with error status.
Syntax
public McpToolResult(string errorMessage, string errorCode = null, string correlationId = null)
Parameters
| Name | Type | Description |
|---|
errorMessage | string | The error message. |
errorCode | string? | The error code. |
correlationId | string? | The correlation ID. |
.ctor Inherited
Syntax
Properties
CompletedAt
Gets or sets the timestamp when the execution completed.
Syntax
public System.DateTime CompletedAt { get; set; }
Property Value
Type: System.DateTime?
The UTC timestamp when the tool finished executing.
This timestamp can be used for auditing and troubleshooting purposes.
CorrelationId
Gets or sets the correlation ID for this execution.
Syntax
public string CorrelationId { get; set; }
Property Value
Type: string?
The correlation ID that can be used to trace this execution across systems.
This should match the correlation ID from the tool context for end-to-end tracing.
Data
Gets or sets the result data as a JSON document.
Syntax
public System.Text.Json.JsonDocument Data { get; set; }
Property Value
Type: System.Text.Json.JsonDocument?
The structured result data, or null if no data is available.
The data format depends on the specific tool but should always be
valid JSON that can be consumed by MCP clients.
ErrorCode
Gets or sets the error code for failed executions.
Syntax
public string ErrorCode { get; set; }
Property Value
Type: string?
A machine-readable error code, or null if execution was successful.
Error codes provide a standardized way for clients to handle specific
error conditions programmatically.
ErrorMessage
Gets or sets the error message for failed executions.
Syntax
public string ErrorMessage { get; set; }
Property Value
Type: string?
A human-readable error message, or null if execution was successful.
Error messages should be clear and actionable, helping users understand
what went wrong and how to fix it.
ExecutionDuration
Gets or sets the execution duration.
Syntax
public System.TimeSpan ExecutionDuration { get; set; }
Property Value
Type: System.TimeSpan?
The time taken to execute the tool.
This information is useful for performance monitoring and optimization.
IsSuccess
Gets or sets a value indicating whether the tool execution was successful.
Syntax
public bool IsSuccess { get; set; }
Property Value
Type: bool
true if the execution was successful; otherwise, false.
Success indicates that the tool executed without errors and completed
its intended operation, regardless of whether data was found or modified.
Gets or sets additional metadata about the execution.
Syntax
public System.Collections.Generic.Dictionary<string, object> Metadata { get; set; }
Property Value
Type: System.Collections.Generic.Dictionary<string, object>
A dictionary of metadata key-value pairs.
Metadata can include information such as execution time, record counts,
caching status, or other operational details.
StatusCode
Gets or sets the HTTP status code equivalent for this result.
Syntax
public int StatusCode { get; set; }
Property Value
Type: int
The HTTP status code that best represents this result.
This helps clients understand the result in terms of standard HTTP semantics,
even when the tool isn’t directly related to HTTP operations.
Warnings
Gets or sets warnings that occurred during execution.
Syntax
public System.Collections.Generic.List<string> Warnings { get; set; }
Property Value
Type: System.Collections.Generic.List<string>
A collection of warning messages.
Warnings indicate potential issues or notable conditions that didn’t
prevent successful execution but may be of interest to users.
Methods
Adds metadata to the result.
Syntax
public void AddMetadata(string key, object value)
Parameters
| Name | Type | Description |
|---|
key | string | The metadata key. |
value | object | The metadata value. |
Exceptions
| Exception | Description |
|---|
ArgumentException | Thrown when key is null or whitespace. |
AddWarning
Adds a warning to the result.
Syntax
public void AddWarning(string warning)
Parameters
| Name | Type | Description |
|---|
warning | string | The warning message. |
Exceptions
| Exception | Description |
|---|
ArgumentException | Thrown when warning is null or whitespace. |
Equals Inherited Virtual
Syntax
public virtual bool Equals(object obj)
Parameters
| Name | Type | Description |
|---|
obj | object? | - |
Returns
Type: bool
Equals Inherited
Syntax
public static bool Equals(object objA, object objB)
Parameters
| Name | Type | Description |
|---|
objA | object? | - |
objB | object? | - |
Returns
Type: bool
Error
Creates an error result with the specified message and code.
Syntax
public static Microsoft.OData.Mcp.Core.Tools.McpToolResult Error(string errorMessage, string errorCode = null, string correlationId = null)
Parameters
| Name | Type | Description |
|---|
errorMessage | string | The error message. |
errorCode | string? | The error code. |
correlationId | string? | The correlation ID. |
Returns
Type: Microsoft.OData.Mcp.Core.Tools.McpToolResult
An error MCP tool result.
Exceptions
| Exception | Description |
|---|
ArgumentException | Thrown when errorMessage is null or whitespace. |
Error
Creates an error result from an exception.
Syntax
public static Microsoft.OData.Mcp.Core.Tools.McpToolResult Error(System.Exception exception, string correlationId = null)
Parameters
| Name | Type | Description |
|---|
exception | System.Exception | The exception that occurred. |
correlationId | string? | The correlation ID. |
Returns
Type: Microsoft.OData.Mcp.Core.Tools.McpToolResult
An error MCP tool result.
Exceptions
| Exception | Description |
|---|
ArgumentNullException | Thrown when exception is null. |
GetHashCode Inherited Virtual
Syntax
public virtual int GetHashCode()
Returns
Type: int
Gets metadata value by key.
Syntax
public T GetMetadata<T>(string key)
Parameters
| Name | Type | Description |
|---|
key | string | The metadata key. |
Returns
Type: T?
The metadata value if found and of the correct type; otherwise, the default value.
Type Parameters
T - The type of the metadata value.
GetType Inherited
Syntax
public System.Type GetType()
Returns
Type: System.Type
MemberwiseClone Inherited
Syntax
protected internal object MemberwiseClone()
Returns
Type: object
NotFound
Creates a not found result.
Syntax
public static Microsoft.OData.Mcp.Core.Tools.McpToolResult NotFound(string message = null, string correlationId = null)
Parameters
| Name | Type | Description |
|---|
message | string? | The not found message. |
correlationId | string? | The correlation ID. |
Returns
Type: Microsoft.OData.Mcp.Core.Tools.McpToolResult
A not found MCP tool result.
ReferenceEquals Inherited
Syntax
public static bool ReferenceEquals(object objA, object objB)
Parameters
| Name | Type | Description |
|---|
objA | object? | - |
objB | object? | - |
Returns
Type: bool
SetExecutionDuration
Sets the execution duration based on a start time.
Syntax
public void SetExecutionDuration(System.DateTime startTime)
Parameters
| Name | Type | Description |
|---|
startTime | System.DateTime? | The execution start time. |
Success
Creates a successful result with the specified data.
Syntax
public static Microsoft.OData.Mcp.Core.Tools.McpToolResult Success(System.Text.Json.JsonDocument data = null, string correlationId = null)
Parameters
| Name | Type | Description |
|---|
data | System.Text.Json.JsonDocument? | The result data. |
correlationId | string? | The correlation ID. |
Returns
Type: Microsoft.OData.Mcp.Core.Tools.McpToolResult
A successful MCP tool result.
Success
Creates a successful result with the specified object data.
Syntax
public static Microsoft.OData.Mcp.Core.Tools.McpToolResult Success(object data, string correlationId = null)
Parameters
| Name | Type | Description |
|---|
data | object | The data object to serialize to JSON. |
correlationId | string? | The correlation ID. |
Returns
Type: Microsoft.OData.Mcp.Core.Tools.McpToolResult
A successful MCP tool result.
Exceptions
| Exception | Description |
|---|
ArgumentNullException | Thrown when data is null. |
ToDictionary
Converts the result to a dictionary for JSON serialization.
Syntax
public System.Collections.Generic.Dictionary<string, object> ToDictionary()
Returns
Type: System.Collections.Generic.Dictionary<string, object?>
A dictionary representation of the result.
ToString Override
Returns a JSON string representation of the result.
Syntax
public override string ToString()
Returns
Type: string
A JSON string representation of the result.
ToString Inherited Virtual
Syntax
public virtual string ToString()
Returns
Type: string?
Unauthorized
Creates an unauthorized result.
Syntax
public static Microsoft.OData.Mcp.Core.Tools.McpToolResult Unauthorized(string message = null, string correlationId = null)
Parameters
| Name | Type | Description |
|---|
message | string? | The unauthorized message. |
correlationId | string? | The correlation ID. |
Returns
Type: Microsoft.OData.Mcp.Core.Tools.McpToolResult
An unauthorized MCP tool result.
ValidationError
Creates a validation error result.
Syntax
public static Microsoft.OData.Mcp.Core.Tools.McpToolResult ValidationError(string message, string correlationId = null)
Parameters
| Name | Type | Description |
|---|
message | string | The validation error message. |
correlationId | string? | The correlation ID. |
Returns
Type: Microsoft.OData.Mcp.Core.Tools.McpToolResult
A validation error MCP tool result.