Skip to main content

MCP server for org-roam knowledge management. Provides AI agent tools for semantic search, note creation, and daily entries. Install with: pip install org-roam-mcp or curl -fsSL https://raw.githubusercontent.com/dcruver/org-roam-ai/main/install.sh | bash

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

org_roam_mcp-0.1.15.tar.gz (21.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

org_roam_mcp-0.1.15-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file org_roam_mcp-0.1.15.tar.gz.

File metadata

  • Download URL: org_roam_mcp-0.1.15.tar.gz
  • Upload date:
  • Size: 21.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for org_roam_mcp-0.1.15.tar.gz
Algorithm Hash digest
SHA256 b893c35d7dc02f46adb7dd990e37928dfd12bc58830a76be5a85d1dad7b1ae57
MD5 d2c1dd8c1cbd1af17c69829b0b07438d
BLAKE2b-256 3c9fcb0a212d335f33245c0a3c8507e3b5cb4d492f147e8844c0f31173669acf

See more details on using hashes here.

File details

Details for the file org_roam_mcp-0.1.15-py3-none-any.whl.

File metadata

  • Download URL: org_roam_mcp-0.1.15-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for org_roam_mcp-0.1.15-py3-none-any.whl
Algorithm Hash digest
SHA256 ce4f310dcd9a807f72f01a674108e426625a9b0b8a163146192e4abdcad97619
MD5 5b624e1abc2dfefc788e5f7efb3b0d59
BLAKE2b-256 b6e2e82e193ff1d938050a34281718e6bc819c4f16aebde24b3aecdf2d38f4fb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page