---
title: Agents and MCP
description: Let AI coding agents read and edit Octarine notes through the CLI or its built-in MCP server.
---

The Octarine CLI is designed to be driven by AI agents such as Claude Code, Codex, or Cursor as well as by people. Agents can call the CLI from a shell, or connect to it as a Model Context Protocol (MCP) server. Both run the same commands, so behavior is identical either way.

Everything runs locally against your Markdown files. The desktop app does not need to be open.

## `agent-guide`

Print a short guide that tells an agent how to find notes, read them before editing, make small revision-checked edits, recover from conflicts, and work with tasks and projects.

```bash
octarine agent-guide
```

Paste the output into your agent's instructions, such as a project `CLAUDE.md` or `AGENTS.md`, or ask the agent to run the command itself before working with your notes:

```bash
octarine agent-guide >> AGENTS.md
```

## `help --json`

Describe commands in machine-readable form: every argument with its type, default, and allowed values, plus the global options, response envelopes, and [error codes](/cli/automation-and-maintenance#errors).

```bash
octarine help --json
octarine help note edit --json
```

```text
{"schemaVersion":1,"ok":true,"data":{"name":"octarine","version":"0.1.0","commands":[{"command":"note edit","about":"Replace exact text in a note (one match unless --all)","arguments":[{"name":"path","positional":true,"required":true,"schema":{"type":"string"}},{"name":"find","flag":"--find","required":true,"schema":{"type":"string","description":"Exact text to find"}},…]}],"globalOptions":[…],"output":{…},"errors":[…]},"meta":{"truncated":false}}
```

Without `--json`, `octarine help <command>` prints the same help as `octarine <command> --help`.

## `octarine mcp`

Serve the CLI as MCP tools over standard input and output, or over HTTP for clients that connect to a server by URL.

```text
octarine mcp [--workspace <name, uuid, or path>] [--all-tools | --tools <names>] [--read-only]
             [--allow-folder <folder>]... [--transport stdio|http] [--host <address>] [--port <port>]
             [--token-file <path>]
```

### Connect An MCP Client

Add Octarine to Claude Code:

```bash
claude mcp add octarine -- octarine mcp --workspace "Work Notes"
```

For clients configured with JSON, such as Claude Desktop or Cursor, add a server entry:

```json
{
  "mcpServers": {
    "octarine": {
      "command": "octarine",
      "args": ["mcp", "--workspace", "Work Notes"]
    }
  }
}
```

If the client cannot find `octarine`, use the full path printed by `which octarine` (or `where octarine` on Windows).

`--workspace` fixes the workspace for the server. Without it, the server uses the [default workspace](/cli/getting-started#select-a-workspace). Every tool also accepts an optional `workspace` argument to target a different workspace for one call, except over HTTP or with `--allow-folder` (see [Serve Over HTTP](#serve-over-http)).

### Available Tools

Tool names follow the command path, with spaces and hyphens replaced by underscores: `note replace-section` becomes `note_replace_section`. Each tool's input schema matches the command's arguments, and each result is the command's JSON response.

By default, the server exposes a curated set of everyday tools:

| Area | Tools |
| --- | --- |
| Workspaces | `workspace_list`, `workspace_show`, `workspace_info`, `capabilities` |
| Reading | `note_list`, `note_read`, `note_context`, `note_info`, `note_outline`, `note_properties`, `search` |
| Editing | `note_create`, `note_edit`, `note_replace_section`, `note_insert`, `note_patch`, `note_append`, `note_prepend`, `note_update` |
| Organizing | `note_move`, `note_rename`, `note_duplicate`, `note_trash`, `folder_list`, `folder_create`, `folder_move` |
| Links | `link_list`, `link_backlinks`, `link_unresolved`, `link_orphans`, `link_deadends`, `link_mentions` |
| Checkboxes, tags, and properties | `note_task_list`, `note_task_set`, `checkbox_list`, `tag_list`, `property_list`, `property_get`, `property_set`, `property_unset` |
| Tasks and projects | `task_list`, `task_show`, `task_create`, `task_update`, `task_comment`, `task_statuses`, `task_labels`, `task_resource_list`, `task_resource_add`, `project_list`, `project_show`, `cycle_list`, `cycle_show` |
| Inbox | `inbox_capture`, `inbox_list` |

Add `--all-tools` to expose every other command as well, including folder rename, duplicate, and trash, `link_replace`, views, note types, themes, property definitions, metadata, folder configuration, the rest of the Inbox commands, task and project settings (statuses, labels, buckets, templates, filters, cycle settings), spaces, archiving, `schema`, `export`, and `doctor`.

`update`, `completion`, `config`, `workspace use`, `help`, `agent-guide`, and `mcp` are never exposed as tools.

Read-only tools, such as `note_read`, `search`, and `task_statuses`, are marked as read-only. Tools that trash, delete, unset, or replace content, such as `note_trash` and `note_update`, are marked as destructive, so clients that ask before risky actions can prompt you.

### Limit The Tools

Add `--read-only` to expose only tools that don't change the workspace:

```bash
octarine mcp --workspace "Work Notes" --read-only
```

Add `--tools` with a comma-separated list to expose exactly those tools. You can name any tool, including ones only available with `--all-tools`:

```bash
octarine mcp --workspace "Work Notes" --tools note_read,search,note_create,inbox_capture
```

The server refuses to start if a name is not a tool, or if you combine `--read-only` with a tool that changes the workspace.

### Limit The Folders

Add `--allow-folder` to limit notes and folders to part of the workspace:

```bash
octarine mcp --workspace "Work Notes" --allow-folder Claude
```

To allow more than one folder, repeat `--allow-folder` once per folder. Comma-separated lists are not supported. Folders are workspace-relative paths, so you can allow a subfolder without its parent. For example, this allows everything in `Claude` and in `Projects/Launch`, but not other notes in `Projects`:

```bash
octarine mcp --workspace "Work Notes" --allow-folder Claude --allow-folder "Projects/Launch"
```

Quote folder names that contain spaces, such as `--allow-folder "Reading List"`. In a JSON client configuration, each flag and folder is its own entry in `args`:

```json
{
  "mcpServers": {
    "octarine": {
      "command": "octarine",
      "args": [
        "mcp", "--workspace", "Work Notes",
        "--allow-folder", "Claude",
        "--allow-folder", "Projects/Launch"
      ]
    }
  }
}
```

With allowed folders:

- Reading, creating, editing, moving, or trashing a note or folder outside them fails with `OUT_OF_SCOPE`.
- Note and folder lists, search, tags, checkboxes, and backlinks only include notes inside them.
- The allowed folders themselves can't be moved or trashed.
- Moving a note that notes outside the folders link to fails, because the server can't update those links. Move it with `no_update_links`, or move it in Octarine.
- Links from inside the folders still resolve to notes elsewhere, so those notes' paths can appear in link results.

Tasks, projects, and the Inbox are not stored in folders, so `--allow-folder` does not limit them. Leave their tools out with `--tools` if the client shouldn't use them.

Each folder must already exist. The server refuses to start otherwise.

### Serve Over HTTP

Some MCP clients connect to servers by URL instead of starting them. For those, serve the [Streamable HTTP](https://modelcontextprotocol.io/specification/2025-06-18/basic/transports#streamable-http) transport:

```bash
octarine mcp --workspace "Work Notes" --transport http --port 8765 --token-file ~/.octarine-mcp-token
```

The server listens on `127.0.0.1:8765` by default and answers at `/mcp`, so the URL to give your client is `http://127.0.0.1:8765/mcp`. Change the address with `--host` and the port with `--port`.

With `--token-file`, every request must include `Authorization: Bearer <token>`, where the token is the file's contents. Create a token with:

```bash
openssl rand -hex 32 > ~/.octarine-mcp-token
```

Add the server to Claude Code:

```bash
claude mcp add --transport http octarine http://127.0.0.1:8765/mcp --header "Authorization: Bearer <token>"
```

Anyone who can reach the server can use the tools it exposes. To use it from another machine, keep the server on `127.0.0.1`, put an HTTPS reverse proxy in front of it, and set `--token-file`. Combine it with `--read-only` or `--tools` to expose only what the client needs.

Without a token, the server rejects requests that browsers send from other websites, so a web page cannot reach a server running on your computer.

Over HTTP, and whenever you use `--allow-folder`, the server only works on the workspace it started with. Tools don't take a `workspace` argument, arguments that read or write files on the server's computer (`file` and `output`) are removed, and of the workspace tools only `workspace_info`, `workspace_show`, and `workspace_doctor` remain. Pass content inline instead of as a file.

## Recommended Agent Workflow

The CLI is built so agents can edit notes precisely without overwriting your changes:

1. **Find notes** with `search` or `note list --sort modified --limit 20`. Follow `meta.nextCursor` with `--cursor` to page through long searches.
2. **Read before editing** with `note context`. It returns the content, its `revision`, the outline with line numbers, properties, links, and backlinks in one call.
3. **Edit as little as possible** with [`note edit`](/cli/notes#note-edit), [`note replace-section`](/cli/notes#note-replace-section), [`note insert`](/cli/notes#note-insert), or [`note patch`](/cli/notes#note-patch), always passing `--revision`. Use `note update` only to rewrite a whole note.
4. **Chain edits** using the `revision` each edit returns.
5. **Handle conflicts.** On `REVISION_CONFLICT`, the note changed since it was read. Re-read it, re-apply the change, and retry with `error.currentRevision`. On `AMBIGUOUS_MATCH`, include more surrounding text.

To track work, agents can use the [task commands](/cli/tasks-and-projects#use-tasks-from-an-agent): read a task with `task show --activity`, move it with `task update --state`, and record progress with `task comment`. Task IDs such as `WEB-24` are stable and safe to mention in commit messages.

Task changes and comments an agent makes are labelled in the app's [task activity](/tasks/working-with-tasks#activity-and-comments) with who made them, such as **via Claude Code** or **via CLI**. Octarine works out the name, most specific first, from:

1. `--via <name>` or `OCTARINE_VIA`
2. The MCP client's name, when the change comes through `octarine mcp`
3. The environment variable a known agent sets, such as Claude Code, Gemini CLI, Cursor, or opencode, or the generic `AI_AGENT`
4. Otherwise, **CLI**

The label is what the caller says about itself, so treat it as a hint rather than proof.

To link notes, write workspace-relative paths without `.md`, such as `[[Projects/Launch]]` or `[[Projects/Launch#Goals|goals]]`. Moving or renaming a note with the CLI updates links to it automatically.

Set JSON output once so the agent does not need `--json` on every call:

```bash
octarine config set format json
```

#### Quick Answers

### Can AI agents use Octarine without the desktop app running?

Yes. The CLI and its MCP server work directly on the Markdown workspace. They are safe to run while the desktop app is open because writes are atomic and take a workspace lock.

### Does the Octarine MCP server send my notes anywhere?

No. By default, the server only talks to the MCP client that started it, over standard input and output. With `--transport http`, it answers whoever can reach its address and port, so keep it on `127.0.0.1` or protect it with `--token-file`. What the client does with the results depends on the client and the AI provider it uses.

### How do I expose every CLI command over MCP?

Start the server with `octarine mcp --all-tools`.

### How do I stop an agent from changing my notes?

Start the server with `octarine mcp --read-only`, or list only the tools the agent needs with `--tools`.

### Can I limit an agent to some folders?

Yes. Start the server with `--allow-folder <folder>`, once for each folder. Notes elsewhere are hidden from lists and search, and reading or writing them fails with `OUT_OF_SCOPE`.

### Can I connect Octarine to an MCP client that runs on another machine?

Yes. Run `octarine mcp --transport http --token-file <path>` on a machine with a copy of your workspace, put an HTTPS reverse proxy in front of it, and add its `/mcp` URL to the client.

### How does an agent avoid overwriting my edits?

It passes the `revision` from its last read to every edit. If you changed the note in the meantime, the edit fails with `REVISION_CONFLICT` instead of overwriting your work.
