Class McpProtocolException | MCP C# SDK

Namespace
ModelContextProtocol
Assembly
ModelContextProtocol.Core.dll

Represents an exception that is thrown when a Model Context Protocol (MCP) protocol-level error occurs.

public class McpProtocolException : McpException, ISerializable
Inheritance

McpProtocolException

Implements
Derived
Inherited Members

Constructors

McpProtocolException()

public McpProtocolException()

McpProtocolException(string)

Initializes a new instance of the McpProtocolException class with a specified error message.

public McpProtocolException(string message)

Parameters

message string

The message that describes the error.

McpProtocolException(string, McpErrorCode)

Initializes a new instance of the McpProtocolException class with a specified error message and JSON-RPC error code.

public McpProtocolException(string message, McpErrorCode errorCode)

Parameters

message string

The message that describes the error.

errorCode McpErrorCode

An McpErrorCode.

McpProtocolException(string, Exception?)

Initializes a new instance of the McpProtocolException class with a specified error message and a reference to the inner exception that is the cause of this exception.

public McpProtocolException(string message, Exception? innerException)

Parameters

message string

The message that describes the error.

innerException Exception

The exception that is the cause of the current exception, or a null reference if no inner exception is specified.

McpProtocolException(string, Exception?, McpErrorCode)

Initializes a new instance of the McpProtocolException class with a specified error message, inner exception, and JSON-RPC error code.

public McpProtocolException(string message, Exception? innerException, McpErrorCode errorCode)

Parameters

message string

The message that describes the error.

innerException Exception

The exception that is the cause of the current exception, or a null reference if no inner exception is specified.

errorCode McpErrorCode

An McpErrorCode.

Properties

ErrorCode

Gets the error code associated with this exception.

public McpErrorCode ErrorCode { get; }

Property Value

McpErrorCode