using ModelContextProtocol.Protocol; namespace ModelContextProtocol; /// /// Represents an exception that is thrown when an Model Context Protocol (MCP) error occurs. /// /// /// The from a might be propagated to the remote /// endpoint; sensitive information should not be included. If sensitive details need to be included, /// a different exception type should be used. /// /// This exception type can be thrown by MCP tools or tool call filters to propagate detailed error messages /// from when a tool execution fails via a . /// This includes input validation errors, business logic errors, or any other failure that the model should /// be informed about. For example, if a required field is missing or a value is out of range, throwing an /// with a descriptive message allows the model to understand the issue and /// potentially self-correct in a subsequent request. /// /// For non-tool calls, this exception controls the message propagated via a . /// /// is a derived type that can be used to also specify the /// that should be used for the resulting . /// public class McpException : Exception { /// /// Initializes a new instance of the class. /// public McpException() { } /// /// Initializes a new instance of the class with a specified error message. /// /// The message that describes the error. public McpException(string message) : base(message) { } /// /// Initializes a new instance of the class with a specified error message and /// a reference to the inner exception that is the cause of this exception. /// /// The message that describes the error. /// The exception that is the cause of the current exception, or a null /// reference if no inner exception is specified. public McpException(string message, Exception? innerException) : base(message, innerException) { } }