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

Core message processing abstraction for ExMCP.

The MessageProcessor provides a simple, composable interface for processing MCP messages.
It follows the Plug specification pattern used throughout the Elixir ecosystem.

# `conn`

```elixir
@type conn() :: %ExMCP.MessageProcessor.Conn{
  assigns: term(),
  halted: term(),
  progress_token: term(),
  request: term(),
  response: term(),
  session_id: term(),
  state: term(),
  transport: term()
}
```

# `opts`

```elixir
@type opts() :: term()
```

# `t`

```elixir
@type t() :: module()
```

# `call`

```elixir
@callback call(conn(), opts()) :: conn()
```

Callback for processing the connection.

# `init`

```elixir
@callback init(opts()) :: opts()
```

Callback for initializing the plug with options.

# `assign`

```elixir
@spec assign(ExMCP.MessageProcessor.Conn.t(), atom(), term()) ::
  ExMCP.MessageProcessor.Conn.t()
```

Assigns a value to the connection.

# `complete_progress`

```elixir
@spec complete_progress(ExMCP.MessageProcessor.Conn.t()) ::
  ExMCP.MessageProcessor.Conn.t()
```

Completes progress tracking for a connection.

This should be called when a long-running operation finishes,
either successfully or with an error.

# `halt`

```elixir
@spec halt(ExMCP.MessageProcessor.Conn.t()) :: ExMCP.MessageProcessor.Conn.t()
```

Halts the plug pipeline.

# `new`

```elixir
@spec new(
  map(),
  keyword()
) :: ExMCP.MessageProcessor.Conn.t()
```

Creates a new connection.

# `process`

```elixir
@spec process(ExMCP.MessageProcessor.Conn.t(), map()) ::
  ExMCP.MessageProcessor.Conn.t()
```

Process an MCP request using a handler module.

This is a convenience function that creates a connection, processes it
through a handler, and returns the response.

# `put_response`

```elixir
@spec put_response(ExMCP.MessageProcessor.Conn.t(), map()) ::
  ExMCP.MessageProcessor.Conn.t()
```

Sets the response on the connection.

# `run`

```elixir
@spec run([{module(), opts()}], ExMCP.MessageProcessor.Conn.t()) ::
  ExMCP.MessageProcessor.Conn.t()
```

Runs a list of plugs on the connection.

# `start_progress_tracking`

```elixir
@spec start_progress_tracking(ExMCP.MessageProcessor.Conn.t()) ::
  ExMCP.MessageProcessor.Conn.t()
```

Starts progress tracking for a connection if it has a progress token.

This should be called at the beginning of long-running operations.

# `update_progress`

```elixir
@spec update_progress(
  ExMCP.MessageProcessor.Conn.t(),
  number(),
  number() | nil,
  String.t() | nil
) ::
  ExMCP.MessageProcessor.Conn.t()
```

Updates progress for a connection.

This is a helper function to send progress notifications during
long-running operations.

---

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