The Roam Research MCP server enables AI assistants to programmatically interact with Roam Research graphs through a standardized interface, providing comprehensive read and write operations:
Content retrieval: Fetch pages by title, search for specific text, dates, block references, or pages modified today
Content creation: Create new pages, blocks, hierarchical outlines, or import markdown
Content management: Add todos, update blocks (individually or in batch), store and recall memories
Advanced search: Search by tags, status (TODO/DONE), hierarchy, or execute custom Datomic/Datalog queries
Automation: Perform batch operations and efficiently handle nested content structures
This allows AI assistants to fully leverage Roam's database capabilities for both retrieving and manipulating graph content.
Supports loading configuration from .env files for managing environment variables like API tokens and graph names.
Enables parsing and conversion of markdown content, with support for importing nested markdown structures into Roam Research with proper hierarchy preservation.
Provides comprehensive access to Roam Research's API functionality, allowing AI assistants to interact with Roam Research graphs through tools for fetching, creating, and updating pages and blocks, importing markdown, searching content, and executing Datalog queries.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Roam Researchsearch for notes about project planning from last month"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.

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.
Related MCP server: Shared Knowledge MCP Server
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.
Run roam <command> --help for details on any command.
Installation
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
graphandwrite_keyparameters. Usegraphto target a specific graph from yourROAM_GRAPHSconfig, andwrite_keyfor write operations on protected graphs.
Tool Name | Description |
| Fetch page content by title. |
| Fetch a block and its nested children by UID (resolves refs). |
| Create new pages, optionally with mixed text and table content. |
| Update a page using smart diff (preserves block UIDs). |
| Full-text search across the graph or within specific pages. Supports namespace prefix search for page titles. |
| Find blocks that reference a page, tag, or block UID. |
| Find TODO or DONE items. |
| Find blocks containing specific tags (supports exclusion). |
| Find blocks/pages by creation or modification date. |
| List pages modified since midnight. |
| Add TODO items to today's daily page. |
| Create properly formatted Roam tables. |
| Create hierarchical outlines. |
| Execute multiple low-level actions (create, move, update, delete) in one batch. |
| Move a block to a new parent or position. |
| specialized tools for AI memory management within Roam. |
| Execute raw Datalog queries for advanced filtering. |
| Retrieve the Roam-flavored markdown reference. |
Configuration
Environment Variables
Single Graph Mode
For a single Roam graph, set these in your environment or a .env file:
Multi-Graph Mode (v2.0+)
Connect to multiple Roam graphs from a single server instance:
Graph Configuration Options:
Property | Required | Description |
| Yes | Roam API token for this graph |
| Yes | Graph name/database identifier |
| No | If |
| No | Tag for |
Write Protection:
Protected graphs require the write_key parameter matching ROAM_SYSTEM_WRITE_KEY for any write operation. This prevents accidental writes to sensitive graphs.
Optional:
ROAM_MEMORIES_TAG: Default tag forroam_remember/roam_recall(fallback when per-graphmemoriesTagnot set).HTTP_STREAM_PORT: To enable HTTP Stream (defaults to 8088).
Running the Server
1. Stdio Mode (Default) Best for local integration (e.g., Claude Desktop, IDE extensions).
2. HTTP Stream Mode Best for remote access or web clients.
3. Docker
Configuring in LLMs
Claude Desktop / Cline:
Add to your MCP settings file (e.g., ~/Library/Application Support/Claude/claude_desktop_config.json):
Single Graph:
Multi-Graph:
Query Block Parser (v2.11.0+)
A utility for parsing and executing Roam query blocks programmatically. Converts {{[[query]]: ...}} syntax into Datalog queries.
Supported Clauses
Clause | Syntax | Description |
Page ref |
| Blocks referencing a page |
Block ref |
| Blocks referencing a block |
|
| All conditions must match |
|
| Any condition matches |
|
| Exclude matches |
|
| Date range filter |
|
| Full-text search |
|
| Daily notes pages only |
|
| Created or edited by user |
|
| Created by user |
|
| Edited by user |
Relative Dates
The between clause supports relative dates: today, yesterday, last week, last month, this year, 7 days ago, 2 months ago, etc.
Usage
Utility Functions
Support
If this project helps you manage your knowledge base or build cool agents, consider buying me a coffee! It helps keep the updates coming.
License
MIT License - Created by Ian Shen.
This server cannot be installed