# Class LittleGhost::MCP::Toolset

Documentation version: Edge

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

Connects one MCP server to an Agent as a reusable Tool provider. Each Agent
run gets its own connection. `map_tool` chooses and configures the generated
Tool classes; `map_result` converts results that need application-specific
handling.

    class HelpCenterTools < LittleGhost::MCP::Toolset
      connection url: "https://mcp.example/rpc", timeout: 20
    end

    class CustomerSupportAgent < LittleGhost::Agent
      tools HelpCenterTools
    end

## Inheritance

`LittleGhost::MCP::Toolset < Object`

## Class methods

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

```ruby
connection() -> Hash, Proc, nil
connection(values) -> Hash
connection { |binding| ... } -> Proc
```

Declares a static connection Hash or a block called with the current
Tool::Binding. The Hash requires `url` and may include `headers`, `timeout`,
`signer`, `allow_insecure_http`, and `max_response_bytes`.

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

```ruby
map_result() -> Proc, nil
map_result { |result, call:, binding:| ... } -> Proc
```

Maps each immutable MCP::Result. The block receives `call:` and
`binding:` keywords and returns any Ruby value or Tool::Result.

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

```ruby
map_tool() -> Proc, nil
map_tool { |tool_class, definition:, binding:| ... } -> Proc
```

Maps each generated Tool class. The block receives `definition:`
and `binding:` keywords. Return the configured Tool class, or nil
to omit it. Changing Tool#tool_name does not change the operation name sent to
the MCP server.

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

```ruby
on_error() -> Proc, nil
on_error { |error, binding:| ... } -> Proc
```

Observes an expected discovery failure caught by `optional true`. Exceptions
raised by this callback propagate.

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

```ruby
optional() -> true or false
optional(value) -> true or false
```

Makes expected provider and protocol discovery failures produce no tools.
Configuration, cancellation, deadline, and callback failures still propagate.

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

```ruby
.tools(binding)
```

Generates Tool classes for an Agent's current binding.
