Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
R

roam-research-mcp

> 编程语言
Open source

MCP Server and CLI tool for Roam Research Graph Integration

100 stars0 likes2 views
WebsiteGitHub

About

MCP Server and CLI tool for Roam Research Graph Integration

Roam Research MCP + CLI

Introduction

I created this project to solve a personal problem: I wanted to manage my Roam Research graph directly from Claude Code (and other LLMs). As I built the Model Context Protocol (MCP) server to give AI agents access to my notes, I realized the underlying tools were powerful enough to stand on their own.

What started as an backend for AI agents evolved into a full-featured Standalone CLI. Now, you can use the same powerful API capabilities directly from your terminal—piping content into Roam, searching your graph, and managing tasks—without needing an LLM at all.

Whether you want to give Claude superpowers over your knowledge base or just want a robust CLI for your own scripts, this project has you covered.

What's New in v4.0

In one line: a block containing a soft line break (Shift+Enter) now survives a page rewrite. Read a page, write it back, and nothing moves.

Until now, a multi-line block rendered as two physical lines, the second at column 0. That reset the parser's indentation baseline, so every block after it collapsed toward the root and roam_update_page_markdown dutifully generated the moves to make your real page match. Reading a page and writing back a revision, the documented purpose of the tool, was enough to trigger it. Callout bodies and fenced code blocks are exactly the blocks that carry soft breaks.

  • Soft breaks render as ⏎. A page containing one gains a leading `` marker line; keep it if you write the markdown back. Pages with no multi-line block render byte-identical to 3.x, with no marker and no encoding.
  • Backslashes are never special. The earlier design escaped newlines as \n, which is also a common prefix in authored text: \nabla, \neq, C:\newdir. The sentinel needs no such rule, so all of those are written exactly as typed, everywhere.
  • Verbatim round-trips are no-ops. Renderer output submitted back unchanged, title header included, produces zero actions. The CLI shares the fix: roam get piped into roam save --update leaves the page as it was.
  • Two more guards on page rewrites. Non-empty markdown that parses to zero blocks is now refused rather than deleting every block on the page (genuinely empty markdown still clears a page, as documented). And a hand-authored first block that happens to be an H1 echoing the page title is no longer stripped on an ordinary update.
  • Linked references are encoded too. roam_fetch_page_full_view escapes soft breaks in referring blocks and breadcrumbs, not just the page's own content.
  • Browser clients pass CORS preflight. The HTTP transport now allows MCP-Protocol-Version and Last-Event-ID, both of which a client must send after initialization. Non-browser clients were never affected.
  • The MCP SDK is pinned to the version the test suite runs against, so a fresh install gets the protocol surface that was tested rather than whatever npm serves that day.

Why a major. Four read surfaces return different bytes for any page containing a multi-line block: roam_fetch_page_by_title (format: "markdown"), roam_fetch_page_full_view, roam_get_subpages, and roam get. If you use the server through an AI assistant, nothing is required of you. A script that parses markdown output of multi-line pages sees the new encoding. If you pinned roam-research-mcp@3, you keep 3.2.0's fixes and its documented multi-line limitation until you re-pin.

Full detail, including the corner cases and how each fix was verified against the prior state, is in the changelog.

How this differs from Roam's official MCP server

Roam Research ships its own MCP server and CLI (@roam-research/roam-mcp). It is a good tool, and this project is not trying to replace it. They talk to two different Roam APIs, which is the difference everything else follows from.

This project Official @roam-research/roam-mcp
Talks to Roam's backend REST API (graph token + graph name) Roam Desktop's local HTTP API
Needs Roam running No — works headless Yes, the desktop app must be open (it deep-links to launch it)
Where it can run Anywhere: laptop, server, container, CI The machine running Roam Desktop
Shared daemon Yes — roam server runs one HTTP daemon for every client Per-client stdio
Multi-graph ROAM_GRAPHS env var, with write_key protection for chosen graphs ~/.roam-tools.json, one token per graph
Web-only graphs Works Desktop only

Reach for the official server when you want Roam's own supported path, or you need things only the running app can do: controlling the Desktop UI (open a page, read the current selection, drive the sidebar), semantic/embeddings search, link suggestions, file upload, comments, or invoking tools that Roam extensions register.

Reach for this one when Roam isn't running or isn't installed — a server, a container, a cron job, a CI step. Or when you want the extras this project has grown: a full standalone CLI with stdin piping, a shared HTTP daemon with optional bearer auth, smart page diffing that preserves block UIDs (and therefore your block references), batch operations with UID placeholders for building nested structures in one call, and agent memory tools.

One deliberate omission: there is no page-delete tool here. Roam has no undo that can reverse a bulk API deletion. The official server does offer delete_page; this project takes the more conservative line.

They interoperate

The two servers share conventions on purpose, so running both costs you nothing:

  • [[roam/agent guidelines]] — both read the same page for your conventions. Write them once; both honour them. See Agent guidelines.
  • #.rm-hide / #.rm-private — both withhold tagged blocks from AI-facing content. Tag once, hidden from both. See Hiding content from the AI.

Standalone CLI: roam

The roam CLI lets you interact with your graph directly from the terminal. It supports standard input (stdin) piping for all content creation and retrieval commands, making it perfect for automation workflows.

Quick Examples

…

Available Commands: get, search, save, refs, update, batch, rename, status, server. Run roam --help for details on any command.

Installation

bash
npm install -g roam-research-mcp
# The 'roam' command is now available globally

MCP Server Tools

The MCP server exposes these tools to AI assistants (like Claude), enabling them to read, write, and organize your Roam graph intelligently.

Multi-Graph Support: All tools accept optional graph and write_key parameters. Use graph to target a specific graph from your ROAM_GRAPHS config, and write_key for write operations on protected graphs.

Tool Name Description
roam_fetch_page_by_title Fetch page content by title.
roam_fetch_page_full_view Fetch a page's content plus all linked references with breadcrumb context and children.
roam_fetch_block Fetch a block by UID with optional children (depth) and/or ancestors (up to page root).
roam_create_page Create new pages, optionally with mixed text and table content.
roam_update_page_markdown Update a page using smart diff (preserves block UIDs).
roam_get_subpages List sub-pages under a namespace prefix (e.g. "Project/") with optional tag filter.
roam_search_by_text Full-text search across the graph or within specific pages. Supports namespace prefix search for page titles.
roam_search_block_refs Find blocks that reference a page, tag, or block UID.
roam_search_by_status Find TODO or DONE items.
roam_search_for_tag Find blocks containing specific tags (supports exclusion).
roam_search_by_date Find blocks/pages by creation or modification date.
roam_find_pages_modified_today List pages modified since midnight.
roam_add_todo Add TODO items to today's daily page.
roam_create_table Create properly formatted Roam tables.
roam_create_outline Create hierarchical outlines.
roam_process_batch_actions Execute multiple low-level actions (create, move, update, delete) in one batch.
roam_move_block Move a block to a new parent or position.
roam_remember / roam_recall specialized tools for AI memory management within Roam.
roam_datomic_query Execute raw Datalog queries for advanced filtering.
roam_markdown_cheatsheet Retrieve the Roam-flavored markdown reference.
roam_get_guidelines Retrieve this graph's user-defined agent conventions.

Structured results from write tools (v3.0.0+)

The ten write tools declare an outputSchema and return structuredContent — a validated object — alongside the usual text. A client can read page_uid, uid_map or success directly instead of hunting for JSON inside a string, which makes chaining calls more reliable:

jsonc
// roam_process_batch_actions
{ "success": true, "uid_map": { "parent1": "Xk7mN2pQ9" },
  "validation_passed": true, "actions_attempted": 4 }

Three things worth knowing:

  • Nothing was taken away. The text channel is unchanged, so a client that ignores structuredContent behaves exactly as before.
  • Read tools deliberately have neither. They already serialise their whole result into the text channel, so a schema would just double the payload.
  • These fields are additive-only. Some clients validate live responses against a cached tool list, so a field will be added or deprecated — never renamed or removed outside a major version.

Upgrading to 4.0.0: markdown reads of a page containing a soft line break (Shift+Enter) now render that break as ⏎ and carry a leading `` marker, so the page survives a write-back intact. Pages without multi-line blocks are byte-identical to 3.x. AI-assistant users need do nothing; scripts parsing markdown output of multi-line pages see the new encoding. See the changelog.

Upgrading from 2.x: three write-result fields were renamed — uid → page_uid (roam_create_page), created_uids → created_blocks (roam_create_outline, roam_import_markdown) and preservedUids → preserved_uids (roam_update_page_markdown). This only affects code that reads those names; if you use the server through an AI assistant, nothing changes. See the changelog for why.


Agent guidelines (per-graph)

roam_get_guidelines reads a page inside the graph — [[roam/agent guidelines]] by default — holding your own conventions: how you tag, how you namespace pages, what an agent should never do. Roam's official MCP server reads the same page title, so one page serves both.

This is distinct from CUSTOM_INSTRUCTIONS_PATH, and the two compose:

CUSTOM_INSTRUCTIONS_PATH [[roam/agent guidelines]]
Lives in a file on disk a page in the graph
Scope server-wide, all graphs per-graph
To change it edit the file, restart the server edit the page
Answers how to write Roam markdown how *thi

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScript

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言