roam-research-mcp 1.0.0 → 1.4.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
@@ -83,6 +83,59 @@ Alternatively, if you have a `.env` file in the project root (which is copied in
83
83
  docker run -p 3000:3000 -p 8088:8088 --env-file .env roam-research-mcp
84
84
  ```
85
85
 
86
+ ## Standalone CLI: roam-import
87
+
88
+ A standalone command-line tool for importing markdown content directly into Roam Research, without running the MCP server.
89
+
90
+ ### Usage
91
+
92
+ ```bash
93
+ # From a file
94
+ cat document.md | roam-import "Meeting Notes"
95
+
96
+ # From clipboard (macOS)
97
+ pbpaste | roam-import "Ideas"
98
+
99
+ # From here-doc
100
+ roam-import "Quick Note" << EOF
101
+ # Heading
102
+ - Item 1
103
+ - Item 2
104
+ - Nested item
105
+ EOF
106
+ ```
107
+
108
+ ### Features
109
+
110
+ - Reads markdown from stdin
111
+ - Creates a new page with the specified title (or appends to existing page)
112
+ - Automatically links the new page from today's daily page
113
+ - Converts standard markdown to Roam-flavored markdown (bold, italic, highlights, tasks, code blocks)
114
+
115
+ ### Installation
116
+
117
+ After building the project, make the command globally available:
118
+
119
+ ```bash
120
+ npm link
121
+ ```
122
+
123
+ Or run directly without linking:
124
+
125
+ ```bash
126
+ cat document.md | node build/cli/import-markdown.js "Page Title"
127
+ ```
128
+
129
+ ### Requirements
130
+
131
+ Same environment variables as the MCP server:
132
+ - `ROAM_API_TOKEN`: Your Roam Research API token
133
+ - `ROAM_GRAPH_NAME`: Your Roam graph name
134
+
135
+ Configure via `.env` file in the project root or set as environment variables.
136
+
137
+ ---
138
+
86
139
  ## To Test
87
140
 
88
141
  Run [MCP Inspector](https://github.com/modelcontextprotocol/inspector) after build using the provided npm script:
@@ -109,22 +162,24 @@ The server provides powerful tools for interacting with Roam Research:
109
162
 
110
163
  1. `roam_fetch_page_by_title`: Fetch page content by title. Returns content in the specified format.
111
164
  2. `roam_fetch_block_with_children`: Fetch a block by its UID along with its hierarchical children down to a specified depth. Automatically handles `((UID))` formatting.
112
- 3. `roam_create_page`: Create new pages with optional content and headings. Now creates a block on the daily page linking to the newly created page.
113
- 4. `roam_import_markdown`: Import nested markdown content under a specific block. (Internally uses `roam_process_batch_actions`.)
114
- 5. `roam_add_todo`: Add a list of todo items to today's daily page. (Internally uses `roam_process_batch_actions`.)
115
- 6. `roam_create_outline`: Add a structured outline to an existing page or block, with support for `children_view_type`. Best for simpler, sequential outlines. For complex nesting (e.g., tables), consider `roam_process_batch_actions`. If `page_title_uid` and `block_text_uid` are both blank, content defaults to the daily page. (Internally uses `roam_process_batch_actions`.)
116
- 7. `roam_search_block_refs`: Search for block references within a page or across the entire graph.
117
- 8. `roam_search_hierarchy`: Search for parent or child blocks in the block hierarchy.
118
- 9. `roam_find_pages_modified_today`: Find pages that have been modified today (since midnight), with pagination and sorting options.
119
- 10. `roam_search_by_text`: Search for blocks containing specific text across all pages or within a specific page. This tool supports pagination via the `limit` and `offset` parameters.
120
- 11. `roam_search_by_status`: Search for blocks with a specific status (TODO/DONE) across all pages or within a specific page.
121
- 12. `roam_search_by_date`: Search for blocks or pages based on creation or modification dates.
122
- 13. `roam_search_for_tag`: Search for blocks containing a specific tag and optionally filter by blocks that also contain another tag nearby or exclude blocks with a specific tag. This tool supports pagination via the `limit` and `offset` parameters.
123
- 14. `roam_remember`: Add a memory or piece of information to remember. (Internally uses `roam_process_batch_actions`.)
124
- 15. `roam_recall`: Retrieve all stored memories.
125
- 16. `roam_datomic_query`: Execute a custom Datomic query on the Roam graph for advanced data retrieval beyond the available search tools. Now supports client-side regex filtering for enhanced post-query processing. Optimal for complex filtering (including regex), highly complex boolean logic, arbitrary sorting criteria, and proximity search.
126
- 17. `roam_markdown_cheatsheet`: Provides the content of the Roam Markdown Cheatsheet resource, optionally concatenated with custom instructions if `CUSTOM_INSTRUCTIONS_PATH` environment variable is set.
127
- 18. `roam_process_batch_actions`: Execute a sequence of low-level block actions (create, update, move, delete) in a single, non-transactional batch. Provides granular control for complex nesting like tables. (Note: For actions on existing blocks or within a specific page context, it is often necessary to first obtain valid page or block UIDs using tools like `roam_fetch_page_by_title`.)
165
+ 3. `roam_create_page`: Create new pages with optional content and headings. **Now supports mixed content types** - content array can include both text blocks and tables in a single call using `{type: "table", headers, rows}` format. Creates a block on the daily page linking to the newly created page.
166
+ 4. `roam_create_table`: Create a properly formatted Roam table with specified headers and rows. Abstracts Roam's complex nested table structure, validates row/column consistency, and handles empty cells automatically.
167
+ 5. `roam_import_markdown`: Import nested markdown content under a specific block. (Internally uses `roam_process_batch_actions`.)
168
+ 6. `roam_add_todo`: Add a list of todo items to today's daily page. (Internally uses `roam_process_batch_actions`.)
169
+ 7. `roam_create_outline`: Add a structured outline to an existing page or block, with support for `children_view_type`. Best for simpler, sequential outlines. For complex nesting (e.g., tables), consider `roam_process_batch_actions`. If `page_title_uid` and `block_text_uid` are both blank, content defaults to the daily page. (Internally uses `roam_process_batch_actions`.)
170
+ 8. `roam_search_block_refs`: Search for block references within a page or across the entire graph.
171
+ 9. `roam_search_hierarchy`: Search for parent or child blocks in the block hierarchy.
172
+ 10. `roam_find_pages_modified_today`: Find pages that have been modified today (since midnight), with pagination and sorting options.
173
+ 11. `roam_search_by_text`: Search for blocks containing specific text across all pages or within a specific page. This tool supports pagination via the `limit` and `offset` parameters.
174
+ 12. `roam_search_by_status`: Search for blocks with a specific status (TODO/DONE) across all pages or within a specific page.
175
+ 13. `roam_search_by_date`: Search for blocks or pages based on creation or modification dates.
176
+ 14. `roam_search_for_tag`: Search for blocks containing a specific tag and optionally filter by blocks that also contain another tag nearby or exclude blocks with a specific tag. This tool supports pagination via the `limit` and `offset` parameters.
177
+ 15. `roam_remember`: Add a memory or piece of information to remember. (Internally uses `roam_process_batch_actions`.)
178
+ 16. `roam_recall`: Retrieve all stored memories.
179
+ 17. `roam_datomic_query`: Execute a custom Datomic query on the Roam graph for advanced data retrieval beyond the available search tools. Now supports client-side regex filtering for enhanced post-query processing. Optimal for complex filtering (including regex), highly complex boolean logic, arbitrary sorting criteria, and proximity search.
180
+ 18. `roam_markdown_cheatsheet`: Provides the content of the Roam Markdown Cheatsheet resource, optionally concatenated with custom instructions if `CUSTOM_INSTRUCTIONS_PATH` environment variable is set.
181
+ 19. `roam_process_batch_actions`: Execute a sequence of low-level block actions (create, update, move, delete) in a single, non-transactional batch. Provides granular control for complex nesting like tables. **Now includes pre-validation** that catches errors before API execution, with structured error responses and automatic rate limit retry with exponential backoff. (Note: For actions on existing blocks or within a specific page context, it is often necessary to first obtain valid page or block UIDs using tools like `roam_fetch_page_by_title`.)
182
+ 20. `roam_update_page_markdown`: Update an existing page with new markdown content using smart diff. **Preserves block UIDs** where possible, keeping references intact across the graph. Uses three-phase matching (exact text → normalized → position fallback) to generate minimal operations. Supports `dry_run` mode to preview changes. Ideal for syncing external markdown files, AI-assisted content updates, and batch modifications without losing block references.
128
183
 
129
184
  **Deprecated Tools**:
130
185
  The following tools have been deprecated as of `v0.36.2` in favor of the more powerful and flexible `roam_process_batch_actions`:
@@ -216,12 +271,44 @@ This demonstrates moving a block from one location to another and simultaneously
216
271
 
217
272
  ### Example 4: Making a Table
218
273
 
219
- This demonstrates moving a block from one location to another and simultaneously updating its content.
274
+ This demonstrates creating a standalone table on a page.
220
275
 
221
276
  ```
222
277
  "In Roam, add a new table on the page "Fruity Tables" that compares four types of fruits: apples, oranges, grapes, and dates. Choose randomly four areas to compare."
223
278
  ```
224
279
 
280
+ ### Example 5: Creating a Page with Mixed Content (Text + Table)
281
+
282
+ This demonstrates creating a new page with both text blocks and a table in a single call using `roam_create_page`.
283
+
284
+ ```
285
+ "Create a new Roam page titled 'Product Comparison' with:
286
+ - A heading 'Overview'
287
+ - An introduction paragraph explaining the comparison
288
+ - A comparison table with columns: Feature, Plan A, Plan B
289
+ - Rows: Price ($10, $20), Storage (10GB, 50GB), Support (Email, 24/7)
290
+ - A conclusion section"
291
+ ```
292
+
293
+ ### Example 6: Updating a Page with Smart Diff
294
+
295
+ This demonstrates updating an existing page while preserving block UIDs (and therefore block references across the graph).
296
+
297
+ ```
298
+ "Update the 'Project Alpha Planning' page with this revised content, preserving block references:
299
+ - Overview (keep existing UID)
300
+ - Updated Goals section
301
+ - Revised Scope with new details
302
+ - Team Members
303
+ - John Doe (Senior Dev)
304
+ - Jane Smith (PM)
305
+ - New hire: Bob Wilson
306
+ - Updated Timeline
307
+ - Remove the old 'Deadlines' section"
308
+ ```
309
+
310
+ The tool will match existing blocks by content, update changed text, add new blocks, and remove deleted ones - all while keeping UIDs stable for blocks that still exist.
311
+
225
312
  ---
226
313
 
227
314
  ## Setup