roam-research-mcp 0.25.7 → 0.30.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -5,16 +5,25 @@
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
6
  [![GitHub](https://img.shields.io/github/license/2b3pro/roam-research-mcp)](https://github.com/2b3pro/roam-research-mcp/blob/main/LICENSE)
7
7
 
8
- A Model Context Protocol (MCP) server that provides comprehensive access to Roam Research's API functionality. This server enables AI assistants like Claude to interact with your Roam Research graph through a standardized interface. (A WORK-IN-PROGRESS, personal project not officially endorsed by Roam Research)
8
+ A Model Context Protocol (MCP) server that provides comprehensive access to Roam Research's API functionality. This server enables AI assistants like Claude to interact with your Roam Research graph through a standardized interface. It supports standard input/output (stdio), HTTP Stream, and Server-Sent Events (SSE) communication. (A WORK-IN-PROGRESS, personal project not officially endorsed by Roam Research)
9
9
 
10
10
  <a href="https://glama.ai/mcp/servers/fzfznyaflu"><img width="380" height="200" src="https://glama.ai/mcp/servers/fzfznyaflu/badge" alt="Roam Research MCP server" /></a>
11
11
 
12
- ## Installation
12
+ ## Installation and Usage
13
13
 
14
- You can install the package globally:
14
+ This MCP server supports three primary communication methods:
15
+
16
+ 1. **Stdio (Standard Input/Output):** Ideal for local inter-process communication, command-line tools, and direct integration with applications running on the same machine. This is the default communication method when running the server directly.
17
+ 2. **HTTP Stream:** Provides network-based communication, suitable for web-based clients, remote applications, or scenarios requiring real-time updates over HTTP. The HTTP Stream endpoint runs on port `8088` by default.
18
+ 3. **SSE (Server-Sent Events):** A transport for legacy clients that require SSE. The SSE endpoint runs on port `8087` by default. (NOTE: ⚠️ DEPRECATED: The SSE Transport has been deprecated as of MCP specification version 2025-03-26. HTTP Stream Transport preferred.)
19
+
20
+ ### Running with Stdio
21
+
22
+ You can install the package globally and run it:
15
23
 
16
24
  ```bash
17
25
  npm install -g roam-research-mcp
26
+ roam-research-mcp
18
27
  ```
19
28
 
20
29
  Or clone the repository and build from source:
@@ -24,8 +33,22 @@ git clone https://github.com/2b3pro/roam-research-mcp.git
24
33
  cd roam-research-mcp
25
34
  npm install
26
35
  npm run build
36
+ npm start
27
37
  ```
28
38
 
39
+ ### Running with HTTP Stream
40
+
41
+ To run the server with HTTP Stream or SSE support, you can either:
42
+
43
+ 1. **Use the default ports:** Run `npm start` after building (as shown above). The server will automatically listen on port `8088` for HTTP Stream and `8087` for SSE.
44
+ 2. **Specify custom ports:** Set the `HTTP_STREAM_PORT` and/or `SSE_PORT` environment variables before starting the server.
45
+
46
+ ```bash
47
+ HTTP_STREAM_PORT=9000 SSE_PORT=9001 npm start
48
+ ```
49
+
50
+ Or, if using a `.env` file, add `HTTP_STREAM_PORT=9000` and/or `SSE_PORT=9001` to it.
51
+
29
52
  ## Docker
30
53
 
31
54
  This project can be easily containerized using Docker. A `Dockerfile` is provided at the root of the repository.
@@ -40,20 +63,22 @@ docker build -t roam-research-mcp .
40
63
 
41
64
  ### Run the Docker Container
42
65
 
43
- To run the Docker container and map port 3000 (if your application uses it), you must also provide the necessary environment variables. Use the `-e` flag to pass `ROAM_API_TOKEN`, `ROAM_GRAPH_NAME`, and optionally `MEMORIES_TAG`:
66
+ To run the Docker container and map the necessary ports, you must also provide the required environment variables. Use the `-e` flag to pass `ROAM_API_TOKEN`, `ROAM_GRAPH_NAME`, and optionally `MEMORIES_TAG`, `HTTP_STREAM_PORT`, and `SSE_PORT`:
44
67
 
45
68
  ```bash
46
- docker run -p 3000:3000 \
69
+ docker run -p 3000:3000 -p 8088:8088 -p 8087:8087 \
47
70
  -e ROAM_API_TOKEN="your-api-token" \
48
71
  -e ROAM_GRAPH_NAME="your-graph-name" \
49
72
  -e MEMORIES_TAG="#[[LLM/Memories]]" \
73
+ -e HTTP_STREAM_PORT="8088" \
74
+ -e SSE_PORT="8087" \
50
75
  roam-research-mcp
51
76
  ```
52
77
 
53
78
  Alternatively, if you have a `.env` file in the project root (which is copied into the Docker image during build), you can use the `--env-file` flag:
54
79
 
55
80
  ```bash
56
- docker run -p 3000:3000 --env-file .env roam-research-mcp
81
+ docker run -p 3000:3000 -p 8088:8088 --env-file .env roam-research-mcp
57
82
  ```
58
83
 
59
84
  ## To Test
@@ -80,20 +105,154 @@ The server provides powerful tools for interacting with Roam Research:
80
105
 
81
106
  1. `roam_fetch_page_by_title`: Fetch page content by title.
82
107
  2. `roam_create_page`: Create new pages with optional content and headings.
83
- 3. `roam_create_block`: Add new blocks to an existing page or today's daily note.
84
- 4. `roam_import_markdown`: Import nested markdown content under a specific block.
85
- 5. `roam_add_todo`: Add a list of todo items to today's daily page.
86
- 6. `roam_create_outline`: Add a structured outline to an existing page or block.
87
- 7. `roam_search_block_refs`: Search for block references within a page or across the entire graph.
88
- 8. `roam_search_hierarchy`: Search for parent or child blocks in the block hierarchy.
89
- 9. `roam_find_pages_modified_today`: Find pages that have been modified today (since midnight).
90
- 10. `roam_search_by_text`: Search for blocks containing specific text.
91
- 11. `roam_update_block`: Update a single block identified by its UID.
92
- 12. `roam_search_by_date`: Search for blocks or pages based on creation or modification dates.
93
- 13. `roam_search_for_tag`: Search for blocks containing a specific tag and optionally filter by blocks that also contain another tag nearby.
94
- 14. `roam_remember`: Add a memory or piece of information to remember.
95
- 15. `roam_recall`: Retrieve all stored memories.
96
- 16. `roam_datomic_query`: Execute a custom Datomic query on the Roam graph beyond the available search tools.
108
+ 3. `roam_import_markdown`: Import nested markdown content under a specific block. (Internally uses `roam_process_batch_actions`.)
109
+ 4. `roam_add_todo`: Add a list of todo items to today's daily page. (Internally uses `roam_process_batch_actions`.)
110
+ 5. `roam_create_outline`: Add a structured outline to an existing page or block, with support for `children_view_type`. (Internally uses `roam_process_batch_actions`.)
111
+ 6. `roam_search_block_refs`: Search for block references within a page or across the entire graph.
112
+ 7. `roam_search_hierarchy`: Search for parent or child blocks in the block hierarchy.
113
+ 8. `roam_find_pages_modified_today`: Find pages that have been modified today (since midnight).
114
+ 9. `roam_search_by_text`: Search for blocks containing specific text.
115
+ 10. `roam_search_by_status`: Search for blocks with a specific status (TODO/DONE) across all pages or within a specific page.
116
+ 11. `roam_search_by_date`: Search for blocks or pages based on creation or modification dates.
117
+ 12. `roam_search_for_tag`: Search for blocks containing a specific tag and optionally filter by blocks that also contain another tag nearby.
118
+ 13. `roam_remember`: Add a memory or piece of information to remember. (Internally uses `roam_process_batch_actions`.)
119
+ 14. `roam_recall`: Retrieve all stored memories.
120
+ 15. `roam_datomic_query`: Execute a custom Datomic query on the Roam graph beyond the available search tools.
121
+ 16. `roam_process_batch_actions`: Execute a sequence of low-level block actions (create, update, move, delete) in a single, non-transactional batch.
122
+
123
+ **Deprecated Tools**:
124
+ The following tools have been deprecated as of `v.0.30.0` in favor of the more powerful and flexible `roam_process_batch_actions`:
125
+
126
+ - `roam_create_block`: Use `roam_process_batch_actions` with the `create-block` action.
127
+ - `roam_update_block`: Use `roam_process_batch_actions` with the `update-block` action.
128
+ - `roam_update_multiple_blocks`: Use `roam_process_batch_actions` with multiple `update-block` actions.
129
+
130
+ ### Important Considerations for Tool Usage
131
+
132
+ When making changes to your Roam graph, precision in your requests is crucial for achieving desired outcomes.
133
+
134
+ **Specificity in Requests:**
135
+ Some tools allow for identifying blocks or pages by their text content (e.g., `parent_string`, `title`). While convenient, using **Unique Identifiers (UIDs)** is always preferred for accuracy and reliability. Text-based matching can be prone to errors if there are multiple blocks with similar content or if the content changes. Tools are designed to work best when provided with explicit UIDs where available.
136
+
137
+ **Example of Specificity:**
138
+ Instead of:
139
+ `"parent_string": "My project notes"`
140
+
141
+ Prefer:
142
+ `"parent_uid": "((some-unique-uid))"`
143
+
144
+ **Migrating from Deprecated Tools:**
145
+ The following examples demonstrate how to achieve the functionality of the deprecated tools using `roam_process_batch_actions`.
146
+
147
+ **1. Replacing `roam_create_block`:**
148
+
149
+ - **Old (Deprecated):**
150
+ ```json
151
+ {
152
+ "tool_name": "roam_create_block",
153
+ "arguments": {
154
+ "content": "New block content",
155
+ "page_uid": "((page-uid))"
156
+ }
157
+ }
158
+ ```
159
+ - **New (Recommended):**
160
+ ```json
161
+ {
162
+ "tool_name": "roam_process_batch_actions",
163
+ "arguments": {
164
+ "actions": [
165
+ {
166
+ "action": "create-block",
167
+ "location": {
168
+ "parent-uid": "((page-uid))",
169
+ "order": "last"
170
+ },
171
+ "block": {
172
+ "string": "New block content"
173
+ }
174
+ }
175
+ ]
176
+ }
177
+ }
178
+ ```
179
+
180
+ **2. Replacing `roam_update_block`:**
181
+
182
+ - **Old (Deprecated):**
183
+ ```json
184
+ {
185
+ "tool_name": "roam_update_block",
186
+ "arguments": {
187
+ "block_uid": "((block-uid))",
188
+ "content": "Updated block content"
189
+ }
190
+ }
191
+ ```
192
+ - **New (Recommended):**
193
+ ```json
194
+ {
195
+ "tool_name": "roam_process_batch_actions",
196
+ "arguments": {
197
+ "actions": [
198
+ {
199
+ "action": "update-block",
200
+ "uid": "((block-uid))",
201
+ "string": "Updated block content"
202
+ }
203
+ ]
204
+ }
205
+ }
206
+ ```
207
+
208
+ **3. Replacing `roam_update_multiple_blocks`:**
209
+
210
+ - **Old (Deprecated):**
211
+ ```json
212
+ {
213
+ "tool_name": "roam_update_multiple_blocks",
214
+ "arguments": {
215
+ "updates": [
216
+ {
217
+ "block_uid": "((block-uid-1))",
218
+ "content": "Content for block 1"
219
+ },
220
+ {
221
+ "block_uid": "((block-uid-2))",
222
+ "transform": {
223
+ "find": "old text",
224
+ "replace": "new text"
225
+ }
226
+ }
227
+ ]
228
+ }
229
+ }
230
+ ```
231
+ - **New (Recommended):**
232
+ ```json
233
+ {
234
+ "tool_name": "roam_process_batch_actions",
235
+ "arguments": {
236
+ "actions": [
237
+ {
238
+ "action": "update-block",
239
+ "uid": "((block-uid-1))",
240
+ "string": "Content for block 1"
241
+ },
242
+ {
243
+ "action": "update-block",
244
+ "uid": "((block-uid-2))",
245
+ "string": "((block-content-with-new-text))"
246
+ // Note: Transformations (find/replace) must be handled by the client
247
+ // before sending the 'string' to roam_process_batch_actions.
248
+ }
249
+ ]
250
+ }
251
+ }
252
+ ```
253
+
254
+ **Caveat Regarding Heading Formatting:**
255
+ Please note that while the `roam_process_batch_actions` tool can set block headings (H1, H2, H3), directly **removing** an existing heading (i.e., reverting a heading block to a plain text block) through this tool is not currently supported by the Roam API. The `heading` attribute persists its value once set, and attempting to remove it by setting `heading` to `0`, `null`, or omitting the property will not unset the heading.
97
256
 
98
257
  ## Setup
99
258
 
@@ -113,10 +272,12 @@ The server provides powerful tools for interacting with Roam Research:
113
272
  ROAM_API_TOKEN=your-api-token
114
273
  ROAM_GRAPH_NAME=your-graph-name
115
274
  MEMORIES_TAG='#[[LLM/Memories]]'
275
+ HTTP_STREAM_PORT=8088 # Or your desired port for HTTP Stream communication
276
+ SSE_PORT=8087 # Or your desired port for SSE communication
116
277
  ```
117
278
 
118
279
  Option 2: Using MCP settings (Alternative method)
119
- Add the configuration to your MCP settings file:
280
+ Add the configuration to your MCP settings file. Note that you may need to update the `args` to `["/path/to/roam-research-mcp/build/index.js"]` if you are running the server directly.
120
281
 
121
282
  - For Cline (`~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json`):
122
283
  - For Claude desktop app (`~/Library/Application Support/Claude/claude_desktop_config.json`):
@@ -130,7 +291,9 @@ The server provides powerful tools for interacting with Roam Research:
130
291
  "env": {
131
292
  "ROAM_API_TOKEN": "your-api-token",
132
293
  "ROAM_GRAPH_NAME": "your-graph-name",
133
- "MEMORIES_TAG": "#[[LLM/Memories]]"
294
+ "MEMORIES_TAG": "#[[LLM/Memories]]",
295
+ "HTTP_STREAM_PORT": "8088",
296
+ "SSE_PORT": "8087"
134
297
  }
135
298
  }
136
299
  }
@@ -146,599 +309,6 @@ The server provides powerful tools for interacting with Roam Research:
146
309
  npm run build
147
310
  ```
148
311
 
149
- ## Usage
150
-
151
- ### Fetch Page By Title
152
-
153
- Fetch and read a page's content with resolved block references:
154
-
155
- ```typescript
156
- use_mcp_tool roam-research roam_fetch_page_by_title {
157
- "title": "Example Page"
158
- }
159
- ```
160
-
161
- Returns the page content as markdown with:
162
-
163
- - Complete hierarchical structure
164
- - Block references recursively resolved (up to 4 levels deep)
165
- - Proper indentation for nesting levels
166
- - Full markdown formatting
167
-
168
- ### Create Page
169
-
170
- Create a new page with optional content:
171
-
172
- ```typescript
173
- use_mcp_tool roam-research roam_create_page {
174
- "title": "New Page",
175
- "content": "Initial content for the page"
176
- }
177
- ```
178
-
179
- Returns the created page's UID on success.
180
-
181
- ### Create Block
182
-
183
- Add a new block to a page (defaults to today's daily page if neither page_uid nor title provided):
184
-
185
- ```typescript
186
- use_mcp_tool roam-research roam_create_block {
187
- "content": "Block content",
188
- "page_uid": "optional-target-page-uid",
189
- "title": "optional-target-page-title"
190
- }
191
- ```
192
-
193
- You can specify either:
194
-
195
- - `page_uid`: Direct reference to target page
196
- - `title`: Name of target page (will be created if it doesn't exist)
197
- - Neither: Block will be added to today's daily page
198
-
199
- Returns:
200
-
201
- ```json
202
- {
203
- "success": true,
204
- "block_uid": "created-block-uid",
205
- "parent_uid": "parent-page-uid"
206
- }
207
- ```
208
-
209
- ### Create Outline
210
-
211
- Create a hierarchical outline with proper nesting and structure:
212
-
213
- ```typescript
214
- use_mcp_tool roam-research roam_create_outline {
215
- "outline": [
216
- {
217
- "text": "I. Top Level",
218
- "level": 1
219
- },
220
- {
221
- "text": "A. Second Level",
222
- "level": 2
223
- },
224
- {
225
- "text": "1. Third Level",
226
- "level": 3
227
- }
228
- ],
229
- "page_title_uid": "optional-target-page",
230
- "block_text_uid": "optional-header-text"
231
- }
232
- ```
233
-
234
- Features:
235
-
236
- - Create complex outlines with up to 10 levels of nesting
237
- - Validate outline structure and content
238
- - Maintain proper parent-child relationships
239
- - Optional header block for the outline
240
- - Defaults to today's daily page if no page specified
241
- - Efficient batch operations for creating blocks
242
-
243
- Parameters:
244
-
245
- - `outline`: Array of outline items, each with:
246
- - `text`: Content of the outline item (required)
247
- - `level`: Nesting level (1-10, required)
248
- - `page_title_uid`: Target page title or UID (optional, defaults to today's page)
249
- - `block_text_uid`: Header text for the outline (optional)
250
-
251
- Returns:
252
-
253
- ```json
254
- {
255
- "success": true,
256
- "page_uid": "target-page-uid",
257
- "parent_uid": "header-block-uid",
258
- "created_uids": ["uid1", "uid2", ...]
259
- }
260
- ```
261
-
262
- ### Add Todo Items
263
-
264
- Add one or more todo items to today's daily page:
265
-
266
- ```typescript
267
- use_mcp_tool roam-research roam_add_todo {
268
- "todos": [
269
- "First todo item",
270
- "Second todo item",
271
- "Third todo item"
272
- ]
273
- }
274
- ```
275
-
276
- Features:
277
-
278
- - Adds todos with Roam checkbox syntax (`{{TODO}} todo text`)
279
- - Supports adding multiple todos in a single operation
280
- - Uses batch actions for efficiency when adding >10 todos
281
- - Automatically creates today's page if it doesn't exist
282
- - Adds todos as top-level blocks in sequential order
283
-
284
- ### Import Nested Markdown
285
-
286
- Import nested markdown content under a specific block:
287
-
288
- ```typescript
289
- use_mcp_tool roam-research roam_import_markdown {
290
- "content": "- Item 1\n - Subitem A\n - Subitem B\n- Item 2",
291
- "page_uid": "optional-page-uid",
292
- "page_title": "optional-page-title",
293
- "parent_uid": "optional-parent-block-uid",
294
- "parent_string": "optional-exact-block-content",
295
- "order": "first"
296
- }
297
- ```
298
-
299
- Features:
300
-
301
- - Import content under specific blocks:
302
- - Find parent block by UID or exact string match
303
- - Locate blocks within specific pages by title or UID
304
- - Defaults to today's page if no page specified
305
- - Control content placement:
306
- - Add as first or last child of parent block
307
- - Preserve hierarchical structure
308
- - Efficient batch operations for nested content
309
- - Comprehensive return value:
310
- ```json
311
- {
312
- "success": true,
313
- "page_uid": "target-page-uid",
314
- "parent_uid": "parent-block-uid",
315
- "created_uids": ["uid1", "uid2", ...]
316
- }
317
- ```
318
-
319
- Parameters:
320
-
321
- - `content`: Nested markdown content to import
322
- - `page_uid`: UID of the page containing the parent block
323
- - `page_title`: Title of the page containing the parent block (ignored if page_uid provided)
324
- - `parent_uid`: UID of the parent block to add content under
325
- - `parent_string`: Exact string content of the parent block (must provide either page_uid or page_title)
326
- - `order`: Where to add the content ("first" or "last", defaults to "first")
327
-
328
- ### Search Block References
329
-
330
- Search for block references within pages or across the entire graph:
331
-
332
- ```typescript
333
- use_mcp_tool roam-research roam_search_block_refs {
334
- "block_uid": "optional-block-uid",
335
- "page_title_uid": "optional-page-title-or-uid"
336
- }
337
- ```
338
-
339
- Features:
340
-
341
- - Find all references to a specific block
342
- - Search for any block references within a page
343
- - Search across the entire graph
344
- - Supports both direct and indirect references
345
- - Includes block content and location context
346
-
347
- Parameters:
348
-
349
- - `block_uid`: UID of the block to find references to (optional)
350
- - `page_title_uid`: Title or UID of the page to search in (optional)
351
-
352
- Returns:
353
-
354
- ```json
355
- {
356
- "success": true,
357
- "matches": [
358
- {
359
- "block_uid": "referenced-block-uid",
360
- "content": "Block content with ((reference))",
361
- "page_title": "Page containing reference"
362
- }
363
- ],
364
- "message": "Found N block(s) referencing..."
365
- }
366
- ```
367
-
368
- ### Search By Text
369
-
370
- Search for blocks containing specific text across all pages or within a specific page:
371
-
372
- ```typescript
373
- use_mcp_tool roam-research roam_search_by_text {
374
- "text": "search text",
375
- "page_title_uid": "optional-page-title-or-uid",
376
- "case_sensitive": true
377
- }
378
- ```
379
-
380
- Features:
381
-
382
- - Search for any text across all blocks in the graph
383
- - Optional page-scoped search
384
- - Case-sensitive or case-insensitive search
385
- - Returns block content with page context
386
- - Efficient text matching using Datalog queries
387
-
388
- Parameters:
389
-
390
- - `text`: The text to search for (required)
391
- - `page_title_uid`: Title or UID of the page to search in (optional)
392
- - `case_sensitive`: Whether to perform a case-sensitive search (optional, default: true to match Roam's native behavior)
393
-
394
- Returns:
395
-
396
- ```json
397
- {
398
- "success": true,
399
- "matches": [
400
- {
401
- "block_uid": "matching-block-uid",
402
- "content": "Block content containing search text",
403
- "page_title": "Page containing block"
404
- }
405
- ],
406
- "message": "Found N block(s) containing \"search text\""
407
- }
408
- ```
409
-
410
- ### Update Block Content
411
-
412
- Update a block's content using either direct text replacement or pattern-based transformations:
413
-
414
- ```typescript
415
- use_mcp_tool roam-research roam_update_block {
416
- "block_uid": "target-block-uid",
417
- "content": "New block content"
418
- }
419
- ```
420
-
421
- Or use pattern-based transformation:
422
-
423
- ```typescript
424
- use_mcp_tool roam-research roam_update_block {
425
- "block_uid": "target-block-uid",
426
- "transform_pattern": {
427
- "find": "\\bPython\\b",
428
- "replace": "[[Python]]",
429
- "global": true
430
- }
431
- }
432
- ```
433
-
434
- Features:
435
-
436
- - Two update modes:
437
- - Direct content replacement
438
- - Pattern-based transformation using regex
439
- - Verify block existence before updating
440
- - Return updated content in response
441
- - Support for global or single-match replacements
442
- - Preserve block relationships and metadata
443
-
444
- Parameters:
445
-
446
- - `block_uid`: UID of the block to update (required)
447
- - `content`: New content for the block (if using direct replacement)
448
- - `transform_pattern`: Pattern for transforming existing content:
449
- - `find`: Text or regex pattern to find
450
- - `replace`: Text to replace with
451
- - `global`: Whether to replace all occurrences (default: true)
452
-
453
- Returns:
454
-
455
- ```json
456
- {
457
- "success": true,
458
- "content": "Updated block content"
459
- }
460
- ```
461
-
462
- ### Search For Tags
463
-
464
- Search for blocks containing specific tags with optional filtering by nearby tags:
465
-
466
- ```typescript
467
- use_mcp_tool roam-research roam_search_for_tag {
468
- "primary_tag": "Project/Tasks",
469
- "page_title_uid": "optional-page-title-or-uid",
470
- "near_tag": "optional-secondary-tag",
471
- "case_sensitive": true
472
- }
473
- ```
474
-
475
- Features:
476
-
477
- - Search for blocks containing specific tags
478
- - Optional filtering by presence of another tag
479
- - Page-scoped or graph-wide search
480
- - Case-sensitive or case-insensitive search
481
- - Returns block content with page context
482
- - Efficient tag matching using Datalog queries
483
-
484
- Parameters:
485
-
486
- - `primary_tag`: The main tag to search for (required)
487
- - `page_title_uid`: Title or UID of the page to search in (optional)
488
- - `near_tag`: Another tag to filter results by (optional)
489
- - `case_sensitive`: Whether to perform case-sensitive search (optional, default: true to match Roam's native behavior)
490
-
491
- Returns:
492
-
493
- ```json
494
- {
495
- "success": true,
496
- "matches": [
497
- {
498
- "block_uid": "matching-block-uid",
499
- "content": "Block content containing #[[primary_tag]]",
500
- "page_title": "Page containing block"
501
- }
502
- ],
503
- "message": "Found N block(s) referencing \"primary_tag\""
504
- }
505
- ```
506
-
507
- ### Remember Information
508
-
509
- Store memories or important information with automatic tagging and categorization:
510
-
511
- ```typescript
512
- use_mcp_tool roam-research roam_remember {
513
- "memory": "Important information to remember",
514
- "categories": ["Work", "Project/Alpha"]
515
- }
516
- ```
517
-
518
- Features:
519
-
520
- - Store information with #[[LLM/Memories]] tag
521
- - Add optional category tags for organization
522
- - Automatically adds to today's daily page
523
- - Supports multiple categories per memory
524
- - Easy retrieval using roam_search_for_tag
525
- - Maintains chronological order of memories
526
-
527
- Parameters:
528
-
529
- - `memory`: The information to remember (required)
530
- - `categories`: Optional array of categories to tag the memory with
531
-
532
- Returns:
533
-
534
- ```json
535
- {
536
- "success": true,
537
- "block_uid": "created-block-uid",
538
- "content": "Memory content with tags"
539
- }
540
- ```
541
-
542
- ### Search By Date
543
-
544
- Search for blocks and pages based on creation or modification dates:
545
-
546
- ```typescript
547
- use_mcp_tool roam-research roam_search_by_date {
548
- "start_date": "2025-01-01",
549
- "end_date": "2025-01-31",
550
- "type": "modified",
551
- "scope": "blocks",
552
- "include_content": true
553
- }
554
- ```
555
-
556
- Features:
557
-
558
- - Search by creation date, modification date, or both
559
- - Filter blocks, pages, or both
560
- - Optional date range with start and end dates
561
- - Include or exclude block/page content in results
562
- - Sort results by timestamp
563
- - Efficient date-based filtering using Datalog queries
564
-
565
- Parameters:
566
-
567
- - `start_date`: Start date in ISO format (YYYY-MM-DD) (required)
568
- - `end_date`: End date in ISO format (YYYY-MM-DD) (optional)
569
- - `type`: Whether to search by 'created', 'modified', or 'both' (required)
570
- - `scope`: Whether to search 'blocks', 'pages', or 'both' (required)
571
- - `include_content`: Whether to include the content of matching blocks/pages (optional, default: true)
572
-
573
- Returns:
574
-
575
- ```json
576
- {
577
- "success": true,
578
- "matches": [
579
- {
580
- "uid": "block-or-page-uid",
581
- "type": "block",
582
- "time": 1704067200000,
583
- "content": "Block or page content",
584
- "page_title": "Page title (for blocks)"
585
- }
586
- ],
587
- "message": "Found N matches for the given date range and criteria"
588
- }
589
- ```
590
-
591
- ### Find Pages Modified Today
592
-
593
- Find all pages that have been modified since midnight today:
594
-
595
- ```typescript
596
- use_mcp_tool roam-research roam_find_pages_modified_today {}
597
- ```
598
-
599
- Features:
600
-
601
- - Tracks all modifications made to pages since midnight
602
- - Detects changes at any level in the block hierarchy
603
- - Returns unique list of modified page titles
604
- - Includes count of modified pages
605
- - No parameters required
606
-
607
- Returns:
608
-
609
- ```json
610
- {
611
- "success": true,
612
- "pages": ["Page 1", "Page 2"],
613
- "message": "Found 2 page(s) modified today"
614
- }
615
- ```
616
-
617
- ### Execute Datomic Queries
618
-
619
- Execute custom Datalog queries on your Roam graph for advanced data retrieval and analysis:
620
-
621
- ```typescript
622
- use_mcp_tool roam-research roam_datomic_query {
623
- "query": "[:find (count ?p)\n :where [?p :node/title]]",
624
- "inputs": []
625
- }
626
- ```
627
-
628
- Features:
629
-
630
- - Direct access to Roam's query engine
631
- - Support for all Datalog query features:
632
- - Complex pattern matching
633
- - Aggregation functions (count, sum, max, min, avg, distinct)
634
- - String operations (includes?, starts-with?, ends-with?)
635
- - Logical operations (<, >, <=, >=, =, not=)
636
- - Rules for recursive queries
637
- - Case-sensitive and case-insensitive search capabilities
638
- - Efficient querying across the entire graph
639
-
640
- Parameters:
641
-
642
- - `query`: The Datalog query to execute (required)
643
- - `inputs`: Optional array of input parameters for the query
644
-
645
- Returns:
646
-
647
- ```json
648
- {
649
- "success": true,
650
- "matches": [
651
- {
652
- "content": "[result data]",
653
- "block_uid": "",
654
- "page_title": ""
655
- }
656
- ],
657
- "message": "Query executed successfully. Found N results."
658
- }
659
- ```
660
-
661
- Example Queries:
662
-
663
- 1. Count all pages:
664
-
665
- ```clojure
666
- [:find (count ?p)
667
- :where [?p :node/title]]
668
- ```
669
-
670
- 2. Case-insensitive text search:
671
-
672
- ```clojure
673
- [:find ?string ?title
674
- :where
675
- [?b :block/string ?string]
676
- [(clojure.string/lower-case ?string) ?lower]
677
- [(clojure.string/includes? ?lower "search term")]
678
- [?b :block/page ?p]
679
- [?p :node/title ?title]]
680
- ```
681
-
682
- 3. Find blocks modified after a date:
683
-
684
- ```clojure
685
- [:find ?block_ref ?string
686
- :in $ ?start_of_day
687
- :where
688
- [?b :edit/time ?time]
689
- [(> ?time ?start_of_day)]
690
- [?b :block/uid ?block_ref]
691
- [?b :block/string ?string]]
692
- ```
693
-
694
- See Roam_Research_Datalog_Cheatsheet.md for more query examples and syntax documentation.
695
-
696
- ### Search Block Hierarchy
697
-
698
- Navigate and search through block parent-child relationships:
699
-
700
- ```typescript
701
- use_mcp_tool roam-research roam_search_hierarchy {
702
- "parent_uid": "optional-parent-block-uid",
703
- "child_uid": "optional-child-block-uid",
704
- "page_title_uid": "optional-page-title-or-uid",
705
- "max_depth": 3
706
- }
707
- ```
708
-
709
- Features:
710
-
711
- - Search up or down the block hierarchy
712
- - Find children of a specific block
713
- - Find parents of a specific block
714
- - Configure search depth (1-10 levels)
715
- - Optional page scope filtering
716
- - Includes depth information for each result
717
-
718
- Parameters:
719
-
720
- - `parent_uid`: UID of the block to find children of (required if searching down)
721
- - `child_uid`: UID of the block to find parents of (required if searching up)
722
- - `page_title_uid`: Title or UID of the page to search in (optional)
723
- - `max_depth`: How many levels deep to search (optional, default: 1, max: 10)
724
-
725
- Returns:
726
-
727
- ```json
728
- {
729
- "success": true,
730
- "matches": [
731
- {
732
- "block_uid": "related-block-uid",
733
- "content": "Block content",
734
- "depth": 2,
735
- "page_title": "Page containing block"
736
- }
737
- ],
738
- "message": "Found N block(s) as children/parents..."
739
- }
740
- ```
741
-
742
312
  ## Error Handling
743
313
 
744
314
  The server provides comprehensive error handling for common scenarios: