# `Beamlet.MCP.Patch`
[🔗](https://github.com/aaronrussell/beamlet/blob/v0.1.0/lib/beamlet/mcp/patch.ex#L1)

The `patch` tool, which edits the source of modules agents defined.

An agent names a module and an anchor in its source, then replaces
the anchor or inserts text before or after it. The anchor is a
piece of text that occurs exactly once, or a function given as
`name/arity`, together with its `@doc` and `@spec`.

The patches apply in order. The modules they touch then go through
everything `define` does, as one change: checked against the
token's policy, compiled and committed. Either all of it lands or
none of it does.

A token has the tool whenever it has `define`
(`Beamlet.MCP.Define`).

## Input

```json
{
  "patches": [
    {"module": "Shopping.List", "find": "@limit 10", "replace": "@limit 50"},
    {"module": "Shopping.List", "select": "add/2", "after": "def remove(list, item) do..."}
  ]
}
```

* `patches` - Required. The patches to apply, in order, each with:
  * `module` - Required. The module to edit, such as `Shopping.List`.
  * `find` - Text that occurs exactly once in the module's source.
  * `select` - A function as `name/arity`, with its `@doc` and
    `@spec`.
  * `replace` - Text to put in place of the anchor. Empty removes it.
  * `before` - Text to insert before the anchor.
  * `after` - Text to insert after the anchor.

Each patch takes one anchor, `find` or `select`, and one of
`replace`, `before` or `after`.

## Configuration

Nothing of its own. A patch uses define's `:timeout`
(`Beamlet.MCP.Define`).

# `description`

The description a client lists for the tool, written for the model.

Built when it is read, from define's `timeout`, so it always states
the one in force.

# `get_schema`

# `mcp_schema`

# `mcp_schema!`

# `mcp_schema_changeset`

---

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