Roam Research MCP server

Integrates with Roam Research to enable searching, creating, and manipulating graph content for automated note-taking and intelligent information retrieval.
Back to servers
Setup instructions
Provider
Ian Shen
Release date
Dec 20, 2024
Language
TypeScript
Stats
63 stars

The Roam Research MCP server provides an interface for AI assistants like Claude to interact with your Roam Research graph. It acts as a bridge between AI systems and your Roam database, allowing for searching, reading, and writing operations through a standardized protocol.

Installation Options

Standard Installation

You can install the package globally using npm:

npm install -g roam-research-mcp
roam-research-mcp

Alternatively, clone and build from source:

git clone https://github.com/2b3pro/roam-research-mcp.git
cd roam-research-mcp
npm install
npm run build
npm start

Docker Installation

For containerized deployment:

# Build the image
docker build -t roam-research-mcp .

# Run with environment variables
docker run -p 3000:3000 -p 8088:8088 -p 8087:8087 \
  -e ROAM_API_TOKEN="your-api-token" \
  -e ROAM_GRAPH_NAME="your-graph-name" \
  -e MEMORIES_TAG="#[[LLM/Memories]]" \
  -e CUSTOM_INSTRUCTIONS_PATH="/path/to/your/custom_instructions_file.md" \
  -e HTTP_STREAM_PORT="8088" \
  -e SSE_PORT="8087" \
  roam-research-mcp

Configuration

Required Environment Variables

Create a .env file in the root directory with:

ROAM_API_TOKEN=your-api-token
ROAM_GRAPH_NAME=your-graph-name
MEMORIES_TAG='#[[LLM/Memories]]'
CUSTOM_INSTRUCTIONS_PATH='/path/to/your/custom_instructions_file.md'
HTTP_STREAM_PORT=8088
SSE_PORT=8087

Getting a Roam API Token

  1. Go to your Roam Research graph settings
  2. Navigate to the "API tokens" section (Settings > "Graph" tab > "API Tokens")
  3. Click on the "+ New API Token" button to create a token

Using the MCP Server

The server supports three communication methods:

  • Stdio: Default for local communication (automatically used when running directly)
  • HTTP Stream: Network-based communication on port 8088 (default)
  • SSE: Legacy Server-Sent Events transport on port 8087 (deprecated)

Testing the Installation

Run the MCP Inspector to test your installation:

npm run inspector

Available Functionality

Core Features

  • Page Operations: Create, fetch, and modify Roam pages
  • Block Operations: Work with individual blocks and hierarchies
  • Search Capabilities: Find content by text, tags, dates, or status
  • Markdown Support: Import and process Roam-flavored markdown
  • Memory System: Store and recall information for the AI assistant
  • Advanced Queries: Execute custom Datomic queries for complex operations

Key Tools

The server provides numerous tools for interacting with Roam, including:

  • roam_fetch_page_by_title: Get page content by title
  • roam_search_by_text: Find blocks containing specific text
  • roam_create_page: Create new pages with optional content
  • roam_import_markdown: Import nested markdown content
  • roam_process_batch_actions: Execute multiple block operations in a single batch
  • roam_create_outline: Add structured outlines to pages
  • roam_remember and roam_recall: Store and retrieve memories

Example Usage: Creating a Project Outline

"Create a new Roam page titled 'Project Alpha Planning' and add the following outline:
- Overview
  - Goals
  - Scope
- Team Members
  - John Doe
  - Jane Smith
- Tasks
  - Task 1
    - Subtask 1.1
    - Subtask 1.2
  - Task 2
- Deadlines"

Example Usage: Creating a Table

"In Roam, add a new table on the page "Fruity Tables" that compares four types of fruits: apples, oranges, grapes, and dates. Choose randomly four areas to compare."

Best Practices

  • Load the Roam Markdown Cheatsheet before operations to understand syntax
  • Use UIDs rather than text matches when possible for greater reliability
  • Break complex operations into smaller, verifiable steps
  • Verify changes after significant operations
  • Be aware of case-sensitivity in text searches and page titles

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "roam-research" '{"command":"node","args":["/path/to/roam-research-mcp/build/index.js"],"env":{"ROAM_API_TOKEN":"your-api-token","ROAM_GRAPH_NAME":"your-graph-name","MEMORIES_TAG":"#[[LLM/Memories]]"}}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "roam-research": {
            "command": "node",
            "args": [
                "/path/to/roam-research-mcp/build/index.js"
            ],
            "env": {
                "ROAM_API_TOKEN": "your-api-token",
                "ROAM_GRAPH_NAME": "your-graph-name",
                "MEMORIES_TAG": "#[[LLM/Memories]]"
            }
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "roam-research": {
            "command": "node",
            "args": [
                "/path/to/roam-research-mcp/build/index.js"
            ],
            "env": {
                "ROAM_API_TOKEN": "your-api-token",
                "ROAM_GRAPH_NAME": "your-graph-name",
                "MEMORIES_TAG": "#[[LLM/Memories]]"
            }
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later