Skip to content

MCPClientError

Namespace: Vercel.AI.Mcp

public class MCPClientError : AiSdkException, ISerializable

An MCP call failed. Carries the JSON-RPC and HTTP details when the transport has them.

Inheritance: object → Exception → AiSdkException

Implements: ISerializable

View source

MCPClientError(string, int?, int?, string?, string?, JsonElement?, Exception?)

Section titled “MCPClientError(string, int?, int?, string?, string?, JsonElement?, Exception?)”
public MCPClientError(string message, int? code = null, int? statusCode = null, string? url = null, string? responseBody = null, JsonElement? data = null, Exception? cause = null)

Creates the error with optional MCP error metadata.

Parameters

Name Type Description
message string
code int?
statusCode int?
url string
responseBody string
data JsonElement?
cause Exception

View source

public int? Code { get; }

JSON-RPC error.code. This is not the HTTP status.

Value: int?

View source

public JsonElement? Data { get; }

JSON-RPC error.data, when the server sent it.

Value: JsonElement?

View source

public string? ResponseBody { get; }

Raw response text.

Value: string

View source

public int? StatusCode { get; }

HTTP status, when the failure came from an HTTP transport.

Value: int?

View source

public string? Url { get; }

MCP endpoint URL.

Value: string

View source

public static bool IsInstance(Exception? error)

Returns whether <code class=“paramref”>error</code> is an MCPClientError.

Parameters

Name Type Description
error Exception

Returns: bool

View source

Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product