# `ExMCP.Error`
[🔗](https://github.com/azmaveth/ex_mcp/blob/v1.0.0/lib/ex_mcp/error.ex#L1)

Error types and utilities for ExMCP.

This module provides structured error handling with proper error types
that can be pattern matched and provide useful debugging information.

# `t`

```elixir
@type t() :: %ExMCP.Error{
  __exception__: true,
  code: integer(),
  data: any(),
  message: String.t(),
  request_id: String.t() | nil
}
```

# `application_error?`

# `authentication_error`

# `authorization_error`

# `category`

# `connection_error`

Creates a connection error.

# `connection_error`

# `connection_error_struct`

# `connection_error_struct`

# `exception`

# `from_json_rpc_error`

Creates an error struct from a JSON-RPC error response.

# `internal_error`

Creates a JSON-RPC internal error.

# `invalid_params`

Creates a JSON-RPC invalid params error.

# `invalid_request`

Creates a JSON-RPC invalid request error.

# `json_rpc_error?`

# `mcp_error?`

# `message`

# `method_not_found`

Creates a JSON-RPC method not found error.

# `missing_required_client_capability`

```elixir
@spec missing_required_client_capability(map()) :: ExMCP.Error.ProtocolError.t()
```

Creates the MCP 2026-07-28 error returned when a server operation requires
client capabilities that were not declared on the request.

Handlers may return this value as their normal error reason; every ExMCP
server dispatcher preserves its code and `requiredCapabilities` data.

# `parse_error`

Creates a JSON-RPC parse error.

# `prompt_error`

Creates an MCP prompt error.

# `protocol_error`

Creates a protocol error exception with the given JSON-RPC error code.

## Standard JSON-RPC Error Codes

* `-32700` - Parse error
* `-32600` - Invalid Request
* `-32601` - Method not found
* `-32602` - Invalid params
* `-32603` - Internal error
* `-32000` to `-32099` - Server error

# `resource_error`

# `resource_error`

# `to_json_rpc`

# `tool_error`

# `tool_error`

# `tool_error`

# `transport_error`

Creates a transport error exception.

# `transport_error`

# `transport_error`

# `validation_error`

Creates a validation error.

# `wrap`

Wraps a function call and converts exceptions to proper error tuples.

## Examples

    ExMCP.Error.wrap(fn ->
      do_something_dangerous()
    end)
    # => {:ok, result} or {:error, %ExMCP.Error.SomeError{}}

# `wrap_with`

Wraps a function call with a custom error transformer.

## Examples

    ExMCP.Error.wrap_with(fn ->
      read_file(path)
    end, fn
      {:error, :enoent} -> ExMCP.Error.resource_error(path, :read, :not_found)
      error -> error
    end)

---

*Consult [api-reference.md](api-reference.md) for complete listing*
