MCP server for org-roam knowledge management system
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.elfunctions available in your Emacs instance
Installation
For Users
Install from Git (Recommended):
pip install git+ssh://gitea@gitea-backend.cruver.network/dcruver/org-roam-mcp.git
Install from GitHub Packages:
pip install --index-url https://pypi.pkg.github.com/dcruver org-roam-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
- Ensure all tests pass
- Follow code formatting standards (black, ruff)
- Add type hints for new functions
- Update documentation for new features
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file org_roam_mcp-0.1.14.tar.gz.
File metadata
- Download URL: org_roam_mcp-0.1.14.tar.gz
- Upload date:
- Size: 21.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
930fba765a4b232d56ddb0e67156d782b1569090ce4ca0cff5df8a2d379cc80e
|
|
| MD5 |
d7935e1b03b267591cd66637907afcb3
|
|
| BLAKE2b-256 |
09311de220a4198db97db4f5d1d9304c2f9b5c053c02328a0b1bf8d2b2a956cd
|
File details
Details for the file org_roam_mcp-0.1.14-py3-none-any.whl.
File metadata
- Download URL: org_roam_mcp-0.1.14-py3-none-any.whl
- Upload date:
- Size: 17.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f06bcc97fa220ee0d3134dcad0213b17c32ae835e112190ae197f14b9a72a77
|
|
| MD5 |
614e7f9616aed8ef2d38ae8f2f329232
|
|
| BLAKE2b-256 |
89d2358d2763121fc66f41391b92bfe7f969e41f37573894fd9a02ca591e86af
|