# MCP Server Library (Elixir)

`mcp42` is a transport-agnostic [Model Context Protocol](https://modelcontextprotocol.io) server library with a ready-made Phoenix (Plug) integration.

**Design boundary:** mcp42 knows the MCP protocol and transports — nothing else. All application logic (tools, auth, side effects) lives in the host application, plugged in via a single `Server` behaviour. rproxy/davver/search logic never ends up in this library.

## Transport

Target spec: **MCP Streamable HTTP (2025-06-18)** — one endpoint, `POST` for JSON-RPC (with optional SSE response streaming), `GET` for server-initiated SSE, `DELETE` for session termination.

## Server behaviour (the only integration surface)

```elixir
defmodule MyApp.MCP do
  use Mcp42.Server,
    name: "myapp",
    version: "1.0.0"

  @impl true
  def tools, do: [my_tool()]

  @impl true
  def handle_tool("my_tool", args, _ctx) do
    {:ok, "Hello #{args["name"]}"}
  end
end
```

```elixir
# router.ex — auth happens in YOUR pipeline before the plug
plug Mcp42.Plug, server: MyApp.MCP
```

## Development

    mix test

Test-driven throughout: every module has its failing test written first.

## License

MIT — see [LICENSE](LICENSE).
