# `SuperPi.MCP.Client`
[🔗](https://github.com/oleksandr/super-pi-beam/blob/v0.1.0/lib/super_pi/mcp/client.ex#L1)

Client for one Model Context Protocol server, over stdio or Streamable HTTP.

The client runs the `initialize` handshake, lists the server's tools (following
`nextCursor`), and then forwards `tools/call` requests. It owns the protocol: request ids,
timeouts and the handshake. A `SuperPi.MCP.Transport` moves the messages:

  * `command` starts the server as an OS process (`SuperPi.MCP.Transport.Stdio`).
  * `url` talks to a hosted server (`SuperPi.MCP.Transport.StreamableHTTP`).

Use `SuperPi.MCP.Manager` to start every configured server and expose its tools to the
agent. This module only speaks the protocol. It declares no client capabilities, so a server
cannot ask for sampling, roots or elicitation; it may still send `ping`.

# `await_ready`

Waits until the handshake and the tool listing finish. Returns `:ok` or `{:error, reason}`.

# `call_tool`

Calls a tool. Returns `{:ok, result}` with the server's `tools/call` result map,
or `{:error, reason}` for a protocol error, a timeout, or a server that exited.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `start_link`

Starts a client. Options: `:name` (server name) and either `:command`, `:args`, `:env` (map), `:cwd`
(stdio) or `:url`, `:headers` (map, `${ENV_VAR}` is expanded) for Streamable HTTP. `:transport`
names a `SuperPi.MCP.Transport` module explicitly.

Returns `{:error, {:command_not_found, command}}` when the executable does not exist, and
`{:error, {:invalid_url, url}}` or `{:error, {:missing_env, names}}` for a bad `url` entry.

# `tools`

Tool definitions as the server returned them (`name`, `description`, `inputSchema`).

---

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