# MCP item writes (/reference/mcp-item-writes)

How the Marfa MCP tools save an item's edges, which way an edge named by a reverse name runs, and when a change to an item is refused.



`marfa_create`, `marfa_update` and `marfa_bulk_save` are three of the [tools](/reference/marfa-mcp-server#tools) an instance serves over MCP. Each write is an API call made with the client's credential. The rules are in the contract's MCP chapter, under [Saving edges with items](https://github.com/withmarfa/marfa/blob/main/conformance/spec/mcp.md#saving-edges-with-items) and [Changing an item](https://github.com/withmarfa/marfa/blob/main/conformance/spec/mcp.md#changing-an-item).

## Edges saved with an item [#edges-saved-with-an-item]

`marfa_create` and each `marfa_bulk_save` entry take `edges`, an object that gives each name a list of item IDs. `marfa_update` takes `add_edges` and `remove_edges`, where each entry holds an `edge_type` and a `to_id`. **A name is an [edge type's](/build/edges#edge-types) ID or its reverse name:**

| Name | The edge runs |
| - | - |
| An edge type's ID, such as `parent-of` | From the item written to each item named |
| Its reverse name, such as `child-of` | From each item named to the item written |

So one `marfa_create` call saves a task under its parent:

```json
{
  "type": "core.task",
  "properties": { "title": "Book the van" },
  "edges": { "child-of": ["01a2394e-d555-71ba-bffb-a280969fb025"] }
}
```

* **A reverse name needs what the same edge needs by its ID:** write on the from item's type, and write on the edge type's ID in the credential's edge map. Every rule of the edge type holds, with the refusal [Create an edge](/reference/api/edges/createEdge) gives.
* **An item named by a reverse name that the credential can't read** is refused `item_not_found`, as an ID that no item holds is.
* **A refused edge saves nothing of its item.**
* **Only these tools read a reverse name.** [Create an item](/reference/api/items/createItem), [Update an item](/reference/api/items/updateItem) and [Upsert items in bulk](/reference/api/items/bulkUpsertItems) take an edge type's ID, and answer a reverse name `edge_type_not_found`.

`marfa_overview` lists each edge type's `reverse_name`, and the [Catalog](/catalog/edges) gives those of the edge types Marfa ships.

## Edges in a bulk save [#edges-in-a-bulk-save]

| When | What `marfa_bulk_save` does |
| - | - |
| An entry's edge is refused, and `atomic` is `false` | Reports the entry `errored` with the refusal's code, and saves the others |
| An entry's edge is refused, and `atomic` is `true` or left out | Saves nothing, and answers `bulk_atomic_rollback` with the entry's place in `details.index` |
| `mode` is `upsert`, and an entry that lands on a saved item names an edge type's ID | Replaces the item's edges of that type with edges to the items listed, as [Upsert items in bulk](/reference/api/items/bulkUpsertItems) does |
| An entry that lands on a saved item names a reverse name | Adds the edges that don't stand yet, and removes none, even for an empty list |
| `mode` is `create_only`, and the entry is skipped | Writes none of the entry's edges |

An entry that changes nothing on its saved item, and whose reverse-name edges all stand, is `skipped` with the `reason` `unchanged`. An entry that only adds edges by a reverse name announces `edge.created` for each, and no `item.updated` for its item ([Events](/build/events)).

## Changing an item [#changing-an-item]

`marfa_update` takes the `version` the agent read, and with a `state`, and only then, `from`: the state it read the item in. **Unlike [Update an item](/reference/api/items/updateItem), it never merges a stale change**: if the item changed since, nothing is written. `version_conflict` holds the item as it is now in `current`, and names in `conflicting_fields` each field of the call that changed since. An item no longer in `from` answers `state_conflict`, with both states in `details`, so **a restore from the bin needs `from: trashed`**. If the item changes partway through, `failed_step` names the refused step and `applied` those written.

* **An item in the bin takes no edge.** `marfa_update` adds and removes none there, and answers `item_not_found`. Restore the item first.
* **Edges are added before any is removed.** Moving a task to another parent takes two calls: one that removes its `child-of` edge, then one that adds the other. In one call, the second parent is refused `edge_constraint_violation`.
* **An edge step is named as the call sent it,** so `failed_step` and `applied` show a reverse name where the call used one.
