# `Excessibility.MCP.Resource`
[🔗](https://github.com/lessthanseventy/excessibility/blob/v0.18.1/lib/excessibility/mcp/resource.ex#L1)

Behaviour for MCP resources.

Resources provide read-only data that can be accessed via URIs.

## Example

    defmodule MyApp.MCP.Resources.Config do
      @behaviour Excessibility.MCP.Resource

      @impl true
      def uri_pattern, do: "config://{name}"

      @impl true
      def name, do: "config"

      @impl true
      def description, do: "Application configuration"

      @impl true
      def mime_type, do: "application/json"

      @impl true
      def list do
        [
          %{
            "uri" => "config://app",
            "name" => "app",
            "description" => "App config",
            "mimeType" => "application/json"
          }
        ]
      end

      @impl true
      def read("config://app") do
        {:ok, Jason.encode!(%{setting: "value"})}
      end

      def read(_uri), do: {:error, "Resource not found"}
    end

## Callbacks

- `uri_pattern/0` - URI template pattern (e.g., "timeline://latest")
- `name/0` - Human-readable name for this resource type
- `description/0` - Description of what this resource provides
- `mime_type/0` - MIME type of the resource content
- `list/0` - Returns list of available resource instances
- `read/1` - Reads a specific resource by URI

# `description`

```elixir
@callback description() :: String.t()
```

# `list`

```elixir
@callback list() :: [map()]
```

# `mime_type`

```elixir
@callback mime_type() :: String.t()
```

# `name`

```elixir
@callback name() :: String.t()
```

# `read`

```elixir
@callback read(uri :: String.t()) :: {:ok, String.t()} | {:error, String.t()}
```

# `uri_pattern`

```elixir
@callback uri_pattern() :: String.t()
```

# `format_result`

Formats a resource read result for MCP response.

# `matches_uri?`

Checks if a URI matches a resource module's pattern.

Supports simple patterns like:
- "timeline://latest" (exact match)
- "snapshot://{name}" (matches any snapshot://...)
- "config://{type}" (matches any config://...)

# `to_mcp_definition`

Returns MCP resource definition for a resource module.

---

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