# fetch

> Release: 0.11.0 · Last changed: 2026-10-22 · Source: https://github.com/KeiaiLab/SwarmOps/blob/stable/docs/reference/mcp-tools/fetch.md

Fetches a git remote, by its name, into the store's mirror, and its followed branch's commits into the store as changesets; main never moves. Run again with nothing new, it imports nothing.

```yaml
title: "fetch"
description: "Fetch a git remote."
since: "0.2.0"
mutates: true
identity_required: false
cli_command: "swarmops fetch"
envelope_op: "fetch"
request_type: "FetchReq"
annotations: {"destructiveHint":false,"idempotentHint":true,"openWorldHint":true,"readOnlyHint":false}
max_result_chars: null
```

## Input schema

`arguments` is a `FetchReq`: `swarmops schema FetchReq` prints the type. A field the type does not know is ignored.

| Field | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `remote` | string | yes |  | The remote, by its name. |

### JSON Schema

As `tools/list` gives it: each `$ref` replaced by its definition, so that it stands alone.

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "description": "`fetch`: bring a remote's branches and tags into the store's mirror, and its followed\nbranch's commits into the store as changesets. No ref of the store moves, so it needs no\nidentity.",
  "properties": {
    "remote": {
      "description": "The remote, by its name.",
      "type": "string"
    }
  },
  "required": [
    "remote"
  ],
  "title": "FetchReq",
  "type": "object"
}
```

## Annotations

It moves history between the store and a git remote, and moves no ref of the store: a push moves the remote's branch only from what the last fetch saw, to a descendant of it. Run again, it fetches or sends nothing new. It reaches the remote, beyond the store.

| Annotation | Value | Meaning |
| --- | --- | --- |
| `destructiveHint` | `false` | True: a tool that changes the store may overwrite or delete what is there, not only add to it. |
| `idempotentHint` | `true` | True: calling it again with the same arguments changes nothing more. |
| `openWorldHint` | `true` | True: it reaches beyond a closed set of things. Every tool here stays inside the store. |
| `readOnlyHint` | `false` | True: the tool does not change its environment, the store. |

Its entry in `tools/list` carries no `_meta`.

## CLI command

[`swarmops fetch`](../commands/fetch.md) runs the same operation and prints the same envelope.

## Examples

### MCP

No recorded example yet.

## Return information

A tool result: the envelope, whose `op` is `fetch`, as `structuredContent` and again as the text of its one `content` block. `isError` is true exactly when the envelope's `ok` is false. On success the envelope's `result` is what [`swarmops fetch`](../commands/fetch.md#return-information) returns.

## Errors

A failed call is a tool result with `isError: true`; the envelope's `error.code` is one of the [error codes](../errors.md).

- [`E_INVALID_ARG`](../errors.md#e_invalid_arg): arguments that do not fit `FetchReq`, a field named twice among them included, or that break one of the server's own rules.
- [`E_NOT_A_REPO`](../errors.md#e_not_a_repo): the server's store is not there; the server serves on.
- [`E_INTERNAL`](../errors.md#e_internal): the operation panicked, a bug.

Then the errors of the operation, as [`swarmops fetch`](../commands/fetch.md#errors) lists them.

## See also

- [`swarmops fetch`](../commands/fetch.md)
- [MCP tools](README.md)
- [MCP integration](../../develop/mcp.md)
- [Error codes](../errors.md)
