MCP server

The Model Context Protocol server bundled with Clearly. Run it as clearly mcp from any MCP client — Claude Desktop, Claude Code, Cursor, Codex CLI — and your AI gets vault-aware search, link graph traversal, and file edit tools. Your notes never leave the device.

Setup

Install the CLI from Clearly → Settings → Command Line. Then add the server to your MCP client. For Claude Desktop, edit claude_desktop_config.json:

{
  "mcpServers": {
    "clearly": {
      "command": "/usr/local/bin/clearly",
      "args": ["mcp"]
    }
  }
}

For an opt-in read-only profile, append "--read-only" to the args. The server discovers vaults the same way the CLI does — auto-detected, or pass "--vault", "<path>".

Design

  • Local stdio only. No HTTP, no relay, no OAuth. Notes never leave the device.
  • Reads from the same SQLite index the app uses, in WAL mode — safe to query while the app is open.
  • Reads use the link graph, BM25 ranking, on-device embeddings — not just substring matching.
  • --read-only hides every write tool at registration time. The client genuinely cannot call them.
  • Use clearly mcp tools to dump every registered tool and its JSON Schema for debugging or generating client manifests.

search_notes

read

Full-text search with BM25 ranking and stemming. Supports quoted phrases for exact match. Use this for keyword targets and proper nouns; use semantic_search when the question is conceptual.

Operators inside the query string narrow without a schema change:

  • tag:foo — file must carry tag foo (case-insensitive). Repeat for AND.
  • path:notes/sub — file's vault-relative path must start with this prefix.

Input

{ query: string, limit?: integer (default 20, max 100) }

Output

{ query, total_count, returned_count, results: [...] }

get_tags

read

Without tag: list every tag with file count (mode all). With tag: list every note carrying it (mode by_tag). Tags come from inline #hashtags and YAML frontmatter tags:.

Input

{ tag?: string }

read_note

read

Full content of a note plus metadata: content hash, byte size, modified timestamp, parsed frontmatter, headings, and tags. Optional 1-based line range.

Input

{ relative_path: string, start_line?: integer, end_line?: integer, vault?: string }

list_notes

read

Walks the filesystem fresh every call — results always reflect current on-disk state. Optional subpath prefix.

Input

{ under?: string, vault?: string }

get_headings

read

Heading outline (H1–H6) with level, text, and 1-based line number.

get_frontmatter

read

Parsed YAML frontmatter as a flat key-value map, plus a has_frontmatter boolean.

create_note

write

Create a new note. Parent folders are created automatically. Returns a note_exists error if the path is already taken.

Input

{ relative_path: string, content: string, vault?: string }

move_note

write

Rename or move a note within a vault, rewriting every inbound [[wiki-link]] to point at the new path. Preserves heading anchors and aliases. Index id is preserved across the move — existing backlink relationships survive without re-resolution.

Input

{ from_path: string, to_path: string, vault?: string }

Output

{ vault, from, to,
  links_rewritten: [{ relative_path, count }] }

update_note

write

Update an existing note. replace overwrites the whole file. append adds to the end. prepend inserts after the YAML frontmatter block (or at the top if there is none).

Pass expected_content_hash (the value read_note returned) to opt into optimistic concurrency — the call is rejected with stale_content if the file changed since you last read it. The editor's save path goes through the same coordinated I/O, so a user typing in the editor and an MCP write to the same note can no longer drop each other's edits.

Input

{ relative_path: string, content: string, mode: "replace"|"append"|"prepend",
  vault?: string, expected_content_hash?: string }

Errors

Tool calls that fail return MCP error responses with a stable error code: note_not_found, note_exists, path_outside_vault, ambiguous_vault, no_vault_match, invalid_argument. Inspect the full schema with clearly mcp tools.