McpException
Base exception for MCP Client errors. All MCP-related exceptions extend this class, allowing for easy catch-all error handling while also enabling granular exception handling when needed.
McpException::__construct()
public function __construct(string $message, ?string $serverName = null, int $code = 0, ?Throwable $previous = null):Parameters
| Name | Type | Description |
|---|---|---|
| $message | string | Exception message |
| $serverName | (string | null) | Name of the MCP server (for context in error messages) |
| $code | int | Exception code |
| $previous | (\Throwable | null) | Previous exception for chaining |
McpException::getServerName()
public function getServerName(): ?stringGet the server name associated with this exception.