Skip to main content

Org-roam MCP Server

org-roam-ai > MCP Server

An MCP (Model Context Protocol) server that provides clean, typed tool interfaces for AI agents to interact with an org-roam knowledge management system running in Emacs.

Overview

This server wraps existing org-roam elisp functions via emacsclient, providing structured MCP tools that can be used by AI agents (particularly designed for n8n AI Agent nodes) instead of complex shell command workflows.

Features

Core MCP Tools

  • contextual_search - Enhanced search with full content, backlinks, and relevance scores for RAG applications
  • create_note - Create new org-roam notes with proper structure and metadata
  • add_daily_entry - Add structured entries to daily notes (journal or TODO types)
  • get_daily_content - Retrieve daily note content
  • search_notes - Basic search across note titles and content
  • sync_database - Sync org-roam database

Requirements

  • Python 3.8+
  • Emacs with org-roam running
  • Emacs server accessible via emacsclient
  • The org-roam-api.el functions available in your Emacs instance

Installation

For Users

One-shot installation (Recommended):

# Download and run the installation script
curl -fsSL https://raw.githubusercontent.com/dcruver/org-roam-ai/main/install.sh | bash

Install from PyPI:

pip install org-roam-mcp

Install from GitHub (Development):

pip install git+https://github.com/dcruver/org-roam-ai.git#subdirectory=mcp

For Developers

# Clone repository
git clone gitea@gitea-backend.cruver.network:dcruver/org-roam-mcp.git
cd org-roam-mcp

# Create and activate virtual environment
python -m venv .venv
source .venv/bin/activate  # On Linux/Mac
# OR: .venv\Scripts\activate  # On Windows

# Install in development mode
pip install -e .

# Or install with dev dependencies for testing
pip install -e ".[dev]"

For complete distribution guide (publishing to package registries, CI/CD, etc.), see DISTRIBUTION.md.

Configuration

The server expects an Emacs server running with the org-roam API functions loaded (org-roam-api.el must be loaded).

By default, it looks for the server file at ~/emacs-server/server. You can override this with the EMACS_SERVER_FILE environment variable:

export EMACS_SERVER_FILE=/path/to/your/emacs-server/server
org-roam-mcp

Usage

Running the MCP Server

# Run the server
python -m org_roam_mcp.server

# Or use the installed script
org-roam-mcp

The server communicates via stdio and implements the MCP protocol for tool discovery and execution.

Tool Examples

Contextual Search

{
  "name": "contextual_search",
  "arguments": {
    "query": "docker networking concepts",
    "limit": 5
  }
}

Create Note

{
  "name": "create_note", 
  "arguments": {
    "title": "Docker Networking Overview",
    "content": "Docker networks enable communication between containers...",
    "type": "reference",
    "confidence": "high"
  }
}

Add Daily Entry

{
  "name": "add_daily_entry",
  "arguments": {
    "timestamp": "14:30",
    "title": "Fixed SSL configuration issue", 
    "points": [
      "Updated nginx configuration",
      "Renewed SSL certificates",
      "Tested HTTPS connections"
    ],
    "next_steps": [
      "Monitor for 24 hours", 
      "Update documentation"
    ],
    "tags": ["ssl", "nginx", "troubleshooting"],
    "type": "journal"
  }
}

Integration with n8n

This server is designed to replace complex Execute Command nodes in n8n workflows with clean MCP tool calls:

Before:

Webhook → Intent Classification → Execute Command (complex elisp escaping) → Response Formatter → Respond

After:

Webhook → Intent Classification → AI Agent (with MCP tools) → Respond

The MCP tools handle all the complexity of:

  • Parameter escaping for elisp
  • JSON response parsing
  • Error handling
  • Database synchronization

Architecture

org-roam-mcp/
├── src/org_roam_mcp/
│   ├── __init__.py
│   ├── server.py          # Main MCP server
│   ├── emacs_client.py    # Emacsclient wrapper
│   └── tools/             # Tool implementations
├── tests/                 # Test files
└── pyproject.toml        # Project configuration

Key Components

  • EmacsClient: Handles communication with Emacs via emacsclient, including parameter escaping and JSON response parsing
  • MCP Server: Implements the MCP protocol and exposes org-roam functionality as structured tools
  • Tool Handlers: Individual functions that map MCP tool calls to elisp functions

Error Handling

The server includes comprehensive error handling for:

  • Emacs connection failures
  • Elisp execution errors
  • JSON parsing issues
  • Parameter validation
  • Timeout conditions

Development

# Install development dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Format code
black src/ tests/
ruff check src/ tests/

# Type checking
mypy src/

Logging

The server logs important operations and errors. Configure logging level as needed:

import logging
logging.basicConfig(level=logging.DEBUG)  # For verbose output

Contributing

  1. Ensure all tests pass
  2. Follow code formatting standards (black, ruff)
  3. Add type hints for new functions
  4. Update documentation for new features

License

MIT License

Metadata

Release files for org-roam-mcp 0.1.15

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for org-roam-mcp 0.1.15
File Size Uploaded Provenance
org_roam_mcp-0.1.15.tar.gz 21.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for org-roam-mcp 0.1.15
File Interpreter ABI Platform
org_roam_mcp-0.1.15-py3-none-any.whl Python 3 none any Details

Total release size: 38.7 kB

Release files / org_roam_mcp-0.1.15.tar.gz

Download URL org_roam_mcp-0.1.15.tar.gz
Size 21.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b893c35d7dc02f46adb7dd990e37928dfd12bc58830a76be5a85d1dad7b1ae57
BLAKE2b-256 checksum
How to use checksums
3c9fcb0a212d335f33245c0a3c8507e3b5cb4d492f147e8844c0f31173669acf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release files / org_roam_mcp-0.1.15-py3-none-any.whl

Download URL org_roam_mcp-0.1.15-py3-none-any.whl
Size 17.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ce4f310dcd9a807f72f01a674108e426625a9b0b8a163146192e4abdcad97619
BLAKE2b-256 checksum
How to use checksums
b6e2e82e193ff1d938050a34281718e6bc819c4f16aebde24b3aecdf2d38f4fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Security for org-roam-mcp 0.1.15

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.15 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page