# Flywrite MCP reference

For AI agents in Flywrite. The Flywrite MCP's tools and what they return, which agents connect and how, and when checkpoints happen.

This page is written for AI agents working in Flywrite. For what the MCP does for a writer, read [Flywrite MCP](/mcp).

Flywrite runs a local MCP server on the user's computer while the app is open. It tells an agent in a Flywrite terminal what the user has open and selected, and opens files in the editor. It doesn't edit files: edit the project's files directly, and the editor shows each change live. Outside a Flywrite terminal, the server advertises no tools.

## Tools

| Tool | Input | Returns |
|---|---|---|
| `get_editor_context` | none | JSON: `projectPath`, `activeFile`, `selection` (`filePath`, `isEmpty`, `text`, `startLine`, `startColumn`, `endLine`, `endColumn`, all 1-based) or `null`, `openFiles` (paths), and a `note` when no document is open |
| `open_file` | `filePath`: absolute path inside the project | `Opened <name> in Flywrite`; refuses paths outside the project |

Call `get_editor_context` when the user says "this file", "this paragraph" or "the selection", instead of asking for a path. An empty selection means the cursor is placed with nothing selected.

## Which agents connect

| Agent | How it connects | Setup |
|---|---|---|
| Claude Code | Flywrite serves Claude Code's IDE integration in each of its terminals (below) | None |
| Cursor Agent | Server `flywrite` in `~/.cursor/mcp.json`, a stdio bridge to Flywrite's local server | One-time: **Settings → Agents → Cursor Agent → Set up with Cursor Agent…**. The user approves the edit; it takes effect in new sessions, and Cursor may ask once to approve the server |
| Codex and other CLI agents | Not connected | The user names a file with `@`, or selects text and presses `⌘⇧L`, which types `@path#L12-18` at the prompt |

## Claude Code's IDE integration

Claude Code started in a Flywrite terminal connects on its own and gets the open file, line and selection. Flywrite answers its IDE tools this way:

| IDE tool | In Flywrite |
|---|---|
| `getCurrentSelection`, `getLatestSelection` | The selection in the active editor, or the most recent one |
| `getOpenEditors`, `getWorkspaceFolders` | The open tabs, and the project folder |
| `openFile` | Opens the file in the editor |
| `openDiff` | Writes the new contents straight to the file; there is no diff view or accept step |
| `checkDocumentDirty`, `saveDocument` | Report open documents as saved; Flywrite saves before agent sessions |
| `getDiagnostics`, `close_tab`, `closeAllDiffTabs` | No-ops |

## Checkpoints

Flywrite saves a checkpoint of the whole project (a Git commit) when a Claude Code session connects in a Flywrite terminal, or a Cursor Agent session connects through the Flywrite MCP.

- At most one per project every 60 seconds.
- Skipped for projects with checkpoints off, and when **Checkpoint automatically when an agent session starts** is off in **Settings → Writing**.
- Codex and other CLI agents don't trigger one, so the user presses `⌘⇧C` before starting them.

To undo your changes, the user restores the whole project or one file from Versions (`⌘⇧V`). Ask the user before restoring a checkpoint or syncing to GitHub: both change the files in their project. See [Undo changes with checkpoints](/docs/checkpoints-and-versions).

---

This is the Markdown copy of https://flywrite.app/docs/mcp.
