roam-research-mcp 0.12.3 → 0.14.0

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
@@ -6,6 +6,8 @@
6
6
 
7
7
  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.
8
8
 
9
+ <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>
10
+
9
11
  ## Installation
10
12
 
11
13
  You can install the package globally:
@@ -25,13 +27,16 @@ npm run build
25
27
 
26
28
  ## Features
27
29
 
28
- The server provides five powerful tools for interacting with Roam Research:
30
+ The server provides eight powerful tools for interacting with Roam Research:
29
31
 
30
32
  1. `roam_fetch_page_by_title`: Fetch and read a page's content by title, recursively resolving block references up to 4 levels deep
31
33
  2. `roam_create_page`: Create new pages with optional content
32
34
  3. `roam_create_block`: Create new blocks in a page (defaults to today's daily page)
33
35
  4. `roam_import_markdown`: Import nested markdown content under specific blocks
34
36
  5. `roam_add_todo`: Add multiple todo items to today's daily page with checkbox syntax
37
+ 6. `roam_create_outline`: Create hierarchical outlines with proper nesting and structure
38
+ 7. `roam_search_block_refs`: Search for block references within pages or across the graph
39
+ 8. `roam_search_hierarchy`: Navigate and search through block parent-child relationships
35
40
 
36
41
  ## Setup
37
42
 
@@ -158,6 +163,59 @@ Returns:
158
163
  }
159
164
  ```
160
165
 
166
+ ### Create Outline
167
+
168
+ Create a hierarchical outline with proper nesting and structure:
169
+
170
+ ```typescript
171
+ use_mcp_tool roam-research roam_create_outline {
172
+ "outline": [
173
+ {
174
+ "text": "I. Top Level",
175
+ "level": 1
176
+ },
177
+ {
178
+ "text": "A. Second Level",
179
+ "level": 2
180
+ },
181
+ {
182
+ "text": "1. Third Level",
183
+ "level": 3
184
+ }
185
+ ],
186
+ "page_title_uid": "optional-target-page",
187
+ "block_text_uid": "optional-header-text"
188
+ }
189
+ ```
190
+
191
+ Features:
192
+
193
+ - Create complex outlines with up to 10 levels of nesting
194
+ - Validate outline structure and content
195
+ - Maintain proper parent-child relationships
196
+ - Optional header block for the outline
197
+ - Defaults to today's daily page if no page specified
198
+ - Efficient batch operations for creating blocks
199
+
200
+ Parameters:
201
+
202
+ - `outline`: Array of outline items, each with:
203
+ - `text`: Content of the outline item (required)
204
+ - `level`: Nesting level (1-10, required)
205
+ - `page_title_uid`: Target page title or UID (optional, defaults to today's page)
206
+ - `block_text_uid`: Header text for the outline (optional)
207
+
208
+ Returns:
209
+
210
+ ```json
211
+ {
212
+ "success": true,
213
+ "page_uid": "target-page-uid",
214
+ "parent_uid": "header-block-uid",
215
+ "created_uids": ["uid1", "uid2", ...]
216
+ }
217
+ ```
218
+
161
219
  ### Add Todo Items
162
220
 
163
221
  Add one or more todo items to today's daily page:
@@ -224,6 +282,92 @@ Parameters:
224
282
  - `parent_string`: Exact string content of the parent block (must provide either page_uid or page_title)
225
283
  - `order`: Where to add the content ("first" or "last", defaults to "first")
226
284
 
285
+ ### Search Block References
286
+
287
+ Search for block references within pages or across the entire graph:
288
+
289
+ ```typescript
290
+ use_mcp_tool roam-research roam_search_block_refs {
291
+ "block_uid": "optional-block-uid",
292
+ "page_title_uid": "optional-page-title-or-uid"
293
+ }
294
+ ```
295
+
296
+ Features:
297
+
298
+ - Find all references to a specific block
299
+ - Search for any block references within a page
300
+ - Search across the entire graph
301
+ - Supports both direct and indirect references
302
+ - Includes block content and location context
303
+
304
+ Parameters:
305
+
306
+ - `block_uid`: UID of the block to find references to (optional)
307
+ - `page_title_uid`: Title or UID of the page to search in (optional)
308
+
309
+ Returns:
310
+
311
+ ```json
312
+ {
313
+ "success": true,
314
+ "matches": [
315
+ {
316
+ "block_uid": "referenced-block-uid",
317
+ "content": "Block content with ((reference))",
318
+ "page_title": "Page containing reference"
319
+ }
320
+ ],
321
+ "message": "Found N block(s) referencing..."
322
+ }
323
+ ```
324
+
325
+ ### Search Block Hierarchy
326
+
327
+ Navigate and search through block parent-child relationships:
328
+
329
+ ```typescript
330
+ use_mcp_tool roam-research roam_search_hierarchy {
331
+ "parent_uid": "optional-parent-block-uid",
332
+ "child_uid": "optional-child-block-uid",
333
+ "page_title_uid": "optional-page-title-or-uid",
334
+ "max_depth": 3
335
+ }
336
+ ```
337
+
338
+ Features:
339
+
340
+ - Search up or down the block hierarchy
341
+ - Find children of a specific block
342
+ - Find parents of a specific block
343
+ - Configure search depth (1-10 levels)
344
+ - Optional page scope filtering
345
+ - Includes depth information for each result
346
+
347
+ Parameters:
348
+
349
+ - `parent_uid`: UID of the block to find children of (required if searching down)
350
+ - `child_uid`: UID of the block to find parents of (required if searching up)
351
+ - `page_title_uid`: Title or UID of the page to search in (optional)
352
+ - `max_depth`: How many levels deep to search (optional, default: 1, max: 10)
353
+
354
+ Returns:
355
+
356
+ ```json
357
+ {
358
+ "success": true,
359
+ "matches": [
360
+ {
361
+ "block_uid": "related-block-uid",
362
+ "content": "Block content",
363
+ "depth": 2,
364
+ "page_title": "Page containing block"
365
+ }
366
+ ],
367
+ "message": "Found N block(s) as children/parents..."
368
+ }
369
+ ```
370
+
227
371
  ## Error Handling
228
372
 
229
373
  The server provides comprehensive error handling for common scenarios:
@@ -240,6 +384,7 @@ The server provides comprehensive error handling for common scenarios:
240
384
  - Block not found by string match
241
385
  - Invalid markdown format
242
386
  - Missing required parameters
387
+ - Invalid outline structure or content
243
388
 
244
389
  Each error response includes:
245
390
 
@@ -259,6 +404,7 @@ The server is built with TypeScript and includes:
259
404
  - Daily page integration
260
405
  - Detailed debug logging
261
406
  - Efficient batch operations
407
+ - Hierarchical outline creation
262
408
 
263
409
  To modify or extend the server:
264
410
 
@@ -0,0 +1,44 @@
1
+ import * as dotenv from 'dotenv';
2
+ import { dirname, join } from 'path';
3
+ import { existsSync } from 'fs';
4
+ // Get the project root from the script path
5
+ const scriptPath = process.argv[1]; // Full path to the running script
6
+ const projectRoot = dirname(dirname(scriptPath)); // Go up two levels from build/index.js
7
+ // Try to load .env from project root
8
+ const envPath = join(projectRoot, '.env');
9
+ if (existsSync(envPath)) {
10
+ dotenv.config({ path: envPath });
11
+ }
12
+ // Required environment variables
13
+ const API_TOKEN = process.env.ROAM_API_TOKEN;
14
+ const GRAPH_NAME = process.env.ROAM_GRAPH_NAME;
15
+ // Validate environment variables
16
+ if (!API_TOKEN || !GRAPH_NAME) {
17
+ const missingVars = [];
18
+ if (!API_TOKEN)
19
+ missingVars.push('ROAM_API_TOKEN');
20
+ if (!GRAPH_NAME)
21
+ missingVars.push('ROAM_GRAPH_NAME');
22
+ throw new Error(`Missing required environment variables: ${missingVars.join(', ')}\n\n` +
23
+ 'Please configure these variables either:\n' +
24
+ '1. In your MCP settings file:\n' +
25
+ ' - For Cline: ~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json\n' +
26
+ ' - For Claude: ~/Library/Application Support/Claude/claude_desktop_config.json\n\n' +
27
+ ' Example configuration:\n' +
28
+ ' {\n' +
29
+ ' "mcpServers": {\n' +
30
+ ' "roam-research": {\n' +
31
+ ' "command": "node",\n' +
32
+ ' "args": ["/path/to/roam-research/build/index.js"],\n' +
33
+ ' "env": {\n' +
34
+ ' "ROAM_API_TOKEN": "your-api-token",\n' +
35
+ ' "ROAM_GRAPH_NAME": "your-graph-name"\n' +
36
+ ' }\n' +
37
+ ' }\n' +
38
+ ' }\n' +
39
+ ' }\n\n' +
40
+ '2. Or in a .env file in the roam-research directory:\n' +
41
+ ' ROAM_API_TOKEN=your-api-token\n' +
42
+ ' ROAM_GRAPH_NAME=your-graph-name');
43
+ }
44
+ export { API_TOKEN, GRAPH_NAME };