Skip to content
Oleaflyv0.4.1

Connections

Connect Claude Desktop, Claude Code, Cursor, Codex, or another MCP client to Oleafly's local project tools.

Oleafly can act as an MCP (Model Context Protocol) server. MCP clients such as Claude Desktop, Claude Code, Cursor, Codex, and Grok CLI can read, edit, search, and compile an Oleafly project. You do not need an AI provider key in Oleafly because the client supplies the model.

This is the option when you already have a Claude (or similar) subscription and want that chat app to drive Oleafly, without pasting an API key into Settings.

  1. Open Settings → Integrations → Oleafly MCP.
  2. Toggle Enable MCP server on.

The server runs only while the Oleafly process is open. It listens on 127.0.0.1 only, never on your local network. Closing the project window does not stop the server. Turning MCP off or quitting Oleafly does.

Oleafly prefers port 5323 (http://127.0.0.1:5323/mcp). If it is unavailable, the server automatically binds another free local port and saves it for the next launch. Settings shows the active URL. Its restart button reuses the current port when possible or selects another free one.

Settings shows copy-paste snippets for common clients. Copy the live URL because the selected port may differ from 5323, then replace <token> with the bearer token from Settings (Reveal / Copy).

Terminal window
claude mcp add --transport http oleafly http://127.0.0.1:5323/mcp --header "Authorization: Bearer <token>"

Add to claude_desktop_config.json (stdio bridge via mcp-remote, because Desktop prefers stdio):

{
"mcpServers": {
"oleafly": {
"command": "npx",
"args": [
"-y",
"mcp-remote@latest",
"http://127.0.0.1:5323/mcp",
"--header",
"Authorization: Bearer <token>",
"--transport",
"http-only"
]
}
}
}

In .cursor/mcp.json (or your client’s MCP config):

{
"mcpServers": {
"oleafly": {
"url": "http://127.0.0.1:5323/mcp",
"headers": {
"Authorization": "Bearer <token>"
}
}
}
}

In ~/.grok/config.toml:

[mcp_servers.oleafly]
url = "http://127.0.0.1:5323/mcp"
headers = { Authorization = "Bearer <token>" }

Use the Codex CLI snippet in Oleafly settings, which provides a stdio bridge to the running server. Add the entry to your Codex configuration and use the live URL and token shown by Oleafly:

~/.codex/config.toml
[mcp_servers.oleafly]
command = "npx"
args = [
"-y",
"mcp-remote@latest",
"http://127.0.0.1:5323/mcp",
"--header",
"Authorization: Bearer <token>",
"--transport",
"http-only"
]

The bridge requires Node.js and npx. Restart or reconnect the client after changing its configuration.

The mcp.json file next to your Oleafly data (shown in Settings) holds the same URL and token if you prefer to script setup. It is written only while the server is running (mode 0600 on Unix) and deleted when the server stops. Treat it like any other local secret.

Most MCP tools share their names and schemas with the in-app assistant. Project discovery and routing tools are provided by the desktop backend.

Tools target the project open in the app when one is available. With a connected window, use list_projects and open_project to select another project.

After the last window closes, the backend keeps read_file, list_files, and search_project available. Native writes, replacements, creates, and renames also remain available when the approval policy permits them. These tools use only the last project reported by the app, and refuse the call if that project is no longer valid. They never guess from other projects in the library. Status, project selection, deletion, compilation, logs, PDF inspection, theme changes, and figure tools require a connected window.

ToolWhat it does
get_statusOleafly version, open project, main document, last compile status
list_projectsProjects with IDs, names, engines, kinds, main documents, timestamps, colors, preview state, and export history
open_projectOpen a project by id so other tools target it
list_filesProject file tree
project_mapOutline, labels, citations, macros, input graph, unresolved refs
search_projectSearch text in the current project
ToolWhat it does
read_fileRead a project file
get_logLast compile log
get_pdf_textText extracted from the compiled PDF
ToolWhat it does
write_fileWrite or overwrite a file
replace_in_fileFind and replace within a file
create_fileCreate a file or folder
rename_fileRename or move a path
delete_fileDelete a file or folder
set_main_docSet the compile entry document
ToolWhat it does
compileCompile the project to PDF
preview_figureCompile a figure in isolation and return a PNG image
insert_figureInsert the last previewed figure into the document
load_imageLoad an image from the project for figure work
ToolWhat it does
toggle_themeToggle light / dark mode

Many MCP clients ask before calling a tool. Oleafly also applies the policy selected in Settings → Integrations → Oleafly MCP:

  • Confirm every change is the default. Writes, renames, and deletes show an approval card while an app window is connected. Without a window, those operations are refused because there is nowhere to show the card.
  • Auto-approve edits, confirm deletes lets writes and renames run in the backend. Deletes still need a connected window for confirmation.
  • Trust this connection lets backend writes and renames run without an Oleafly prompt. Deletion still requires a connected window. Use this policy only when you trust the client and its own approval controls.

Two more switches back this up:

  • Read-only mode (separate toggle) removes the mutating tools from tools/list entirely, so an external app can read and compile but never modify files, whatever the policy above.
  • Bearer token: a 256-bit random value stored in authenticated encrypted local storage under ~/.oleafly/. Regenerate it to invalidate old clients. General config reads never expose the token. Only the running server’s connection controls can reveal it in Settings.

And two invariants you do not configure:

  • Localhost only: the bind address is 127.0.0.1. Requests carrying a browser Origin header are rejected, and Host must be loopback.
  • Project confinement: backend file tools accept project-relative paths and confine canonical paths to the project reported by the app. A tool call cannot supply another project ID or make the backend choose a different library project.

While a window is connected, an MCP activity tab logs incoming calls. Backend calls can continue after the last window closes, but there is no activity panel or approval card until a window reconnects.

Why claude.ai in the browser cannot connect

Section titled “Why claude.ai in the browser cannot connect”

A cloud chat service cannot reach 127.0.0.1 on your machine. Use Claude Desktop (or Claude Code, Cursor, etc.) instead. Do not tunnel the MCP port to the public internet: that would let anyone with the URL edit and delete your local project files.

SymptomWhat to try
Some tools are unavailableFigure previews and other UI-only tools need an Oleafly window. Open the app and project, then retry tools/list.
Port changed from 5323The preferred port was unavailable, so Oleafly selected a free one. Copy the live URL from Settings.
HTTP 401Token mismatch (for example after Regenerate). Copy the new token into the client.
HTTP 403Client sent an Origin header or a non-loopback Host. Use a native MCP client, not a browser tab.
Call timed outEach tool call waits up to 5 minutes (300 s) for compiles or for you to click Approve. Approve or reject pending cards, or retry.
Cannot connectOleafly must be running with MCP enabled. The server does not run in the background after quit.
Settings → AI Assistant → MCP. Add a server, browse the registry, or import configurations from another tool.
Settings → AI Assistant → MCP. Add a server, browse the registry, or import configurations from another tool. Open full screenshot

To give the built-in assistant more tools, open Settings → AI Assistant → MCP.

  • Browse registry to find a server and review its setup.
  • Import from other tools to select existing server configurations. Review the selected entries before importing.
  • Add server to enter a server yourself, then validate the connection.

Connected servers expose their tools to the assistant. You can inspect connection status and enable or disable servers from the same page. Credentials and commands belong to each server configuration; review them before connecting a new server.

Add server → Form. Choose Local command or Remote URL, fill in the connection fields, then use Add and validate.
Add server → Form. Choose Local command or Remote URL, fill in the connection fields, then use Add and validate. Open full screenshot

Under Settings → AI Assistant → MCP, choose Add server. A local server runs a command over stdio; a remote server connects to a URL. The JSON form uses Oleafly’s server format:

Local server configuration
{
"name": "Research tools",
"enabled": true,
"transport": "stdio",
"command": "your-mcp-server",
"args": ["--stdio"],
"env": {}
}

Replace the command and arguments with those documented by the server you installed. Environment values belong in the env object.

Remote server configuration
{
"name": "Research service",
"enabled": true,
"transport": "remote",
"url": "https://your-server.example/mcp",
"headers": {
"Authorization": "Bearer YOUR_TOKEN"
}
}

Replace the example URL and token with the service’s connection details. Use Validate to check the connection, then review the tools the server exposes. Enable or disable the server from its row. Use its edit action to change configuration and its remove action to disconnect it.

Choose Import from other tools, inspect the discovered configurations, and select the servers you want. Review executable paths, environment variables, URLs, and credentials before importing. This imports connection settings; it does not install the server executable for you.

  1. Open a small practice project in Oleafly.
  2. Connect the external client using the snippet copied from the app.
  3. Ask the client to call get_status and list the project files.
  4. Ask it to read the main document and suggest a title change.
  5. Review the action in Oleafly before approving a write.
  6. Compile and inspect the PDF.

For a connected external tool inside Oleafly, start with a simple read-only request supported by that server and inspect the resulting tool card in chat.

Image preview

AI answers couldn’t load

Try again, or search the documentation.