Roam Research Python client with built-in CLI and MCP server support.
Project description
roamresearch-client-py
This is another Roam Research Python Client with opinionated design.
Hightlight:
- Built-in CLI & MCP supports which should be LLM & Agent friendly.
- Pythonic coding API for building templates.
Installation
# Install from PyPI
pip install roamresearch-client-py
# Or with uv as a CLI tool
uv tool install roamresearch-client-py
Configuration
Environment Variables
export ROAM_API_TOKEN="your-api-token"
export ROAM_API_GRAPH="your-graph-name"
Configuration File
Run rr init to create a config file at ~/.config/roamresearch-client-py/config.toml:
[roam]
api_token = "your-api-token"
api_graph = "your-graph-name"
[logging]
level = "WARNING" # DEBUG, INFO, WARNING, ERROR, CRITICAL
httpx_level = "WARNING" # Control httpx library logging
CLI Usage
# Initialize config file
rr init
# Get a page by title
rr get "Page Title"
# Get a block by uid
rr get "((block-uid))"
# Search blocks
rr search "keyword"
rr search "term1" "term2" --ignore-case --limit 50
# Save markdown to Roam as a new page
rr save --title "New Page" --file content.md
echo "# Hello" | rr save --title "New Page"
# Execute raw datalog query
rr q '[:find ?title :where [?e :node/title ?title]]'
# Start MCP server
rr mcp
rr mcp --port 9100
Python API
Create Blocks
from roamresearch_client_py import RoamClient
async with RoamClient() as client:
async with client.create_block("This is title") as blk:
blk.write("Line 1")
blk.write("Line 2")
with blk:
blk.write("Indented Line 3")
blk.write("Back to normal")
# Everything saves in batch when exiting
Query and Search
async with RoamClient() as client:
# Get page by title
page = await client.get_page_by_title("My Page")
# Get block by uid
block = await client.get_block_by_uid("block-uid")
# Search blocks
results = await client.search_blocks(["keyword"], limit=20)
# Raw datalog query
result = await client.q('[:find ?title :where [?e :node/title ?title]]')
MCP Server
The built-in MCP server exposes Roam Research tools for AI assistants.
# Start SSE MCP server (default port 9000)
rr mcp
# With custom settings
rr mcp --port 9100 --token <TOKEN> --graph <GRAPH>
License
MIT
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 roamresearch_client_py-0.2.0.tar.gz.
File metadata
- Download URL: roamresearch_client_py-0.2.0.tar.gz
- Upload date:
- Size: 21.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.24.2 CPython/3.12.1 Darwin/25.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b0ac5e1a26d789b32b214b19cb9e2b610c7b90887a9b2b93dc8b639c915a81f5
|
|
| MD5 |
bdef4a23379d1d217dde78c70161bd2c
|
|
| BLAKE2b-256 |
cbdaad516674365297715eccbc08ef07c70deda78dcc7600d3f11de8c24aacc9
|
File details
Details for the file roamresearch_client_py-0.2.0-py3-none-any.whl.
File metadata
- Download URL: roamresearch_client_py-0.2.0-py3-none-any.whl
- Upload date:
- Size: 23.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.24.2 CPython/3.12.1 Darwin/25.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
887af9e5581d4c7907585b950a5a7d8e9b3310f9c9db403d7257b99088d075c7
|
|
| MD5 |
415cd5ace7ec26c442c00f18e636defc
|
|
| BLAKE2b-256 |
bd8bb8b09b6bb010a447c74751b7345143f9a3d723ed1db3fb5554b11d83b5c7
|