# Class LittleGhost::MCP::Client

Documentation version: Edge

Canonical HTML: https://littleghostai.org/docs/LittleGhost/MCP/Client.html

Client is the lower-level interface for loading tools from an MCP server. Most
Agents can declare a reusable Toolset instead. Use Client directly when an
application needs a custom transport.

    transport = LittleGhost::MCP::HTTPTransport.new(url: "https://mcp.example/rpc")
    client = LittleGhost::MCP::Client.new(transport:)
    client.tools.map(&:tool_name) # => ["search", "fetch"]

Tool names are normalized and checked for collisions. LittleGhost limits
catalog size, schema complexity, and returned media before creating Tool
classes. `tool_mapper` and `result_mapper` use the same Definition, Result,
and Call values as Toolset.

The server chooses its definitions and results. LittleGhost checks their
structure before creating Tools, but the application still chooses which
servers and operations an Agent may use.

A client and its transport represent one authenticated server session. Create
a separate pair for each authenticated user or service identity. Protocol
initialization and subsequent requests through one client are serialized; do
not share its transport with another client.

## Inheritance

`LittleGhost::MCP::Client < Object`

## Class methods

<a id="method-c-new"></a>
### `.new`

```ruby
.new(transport:,
        name: "mcp",
        tool_mapper: nil,
        result_mapper: nil)
```

Uses a transport that responds to `send`. `tool_mapper` receives each
generated Tool class and may return a configured class or nil. `result_mapper`
receives Result and Call values. Catalog, schema, and media limits use fixed
framework defaults.

## Instance methods

<a id="method-i-call"></a>
### `#call`

```ruby
#call(name, arguments, context: nil, binding: Tool::Binding.new)
```

Calls a generated or named Tool and returns the common Tool execution result.
Names discovered through #tools resolve to their stored Definition; an
undiscovered name is treated as a source name.

<a id="method-i-tools"></a>
### `#tools`

```ruby
#tools(context: nil, binding: Tool::Binding.new)
```

Negotiates the protocol when needed, then provides Tool classes for the
server's current definitions.
