roam-research-mcp 0.12.3

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Ian Shen / 2B3 PRODUCTIONS LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,273 @@
1
+ # Roam Research MCP Server
2
+
3
+ [![npm version](https://badge.fury.io/js/roam-research-mcp.svg)](https://badge.fury.io/js/roam-research-mcp)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+ [![GitHub](https://img.shields.io/github/license/2b3pro/roam-research-mcp)](https://github.com/2b3pro/roam-research-mcp/blob/main/LICENSE)
6
+
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
+
9
+ ## Installation
10
+
11
+ You can install the package globally:
12
+
13
+ ```bash
14
+ npm install -g roam-research-mcp
15
+ ```
16
+
17
+ Or clone the repository and build from source:
18
+
19
+ ```bash
20
+ git clone https://github.com/2b3pro/roam-research-mcp.git
21
+ cd roam-research-mcp
22
+ npm install
23
+ npm run build
24
+ ```
25
+
26
+ ## Features
27
+
28
+ The server provides five powerful tools for interacting with Roam Research:
29
+
30
+ 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
+ 2. `roam_create_page`: Create new pages with optional content
32
+ 3. `roam_create_block`: Create new blocks in a page (defaults to today's daily page)
33
+ 4. `roam_import_markdown`: Import nested markdown content under specific blocks
34
+ 5. `roam_add_todo`: Add multiple todo items to today's daily page with checkbox syntax
35
+
36
+ ## Setup
37
+
38
+ 1. Create a Roam Research API token:
39
+
40
+ - Go to your graph settings
41
+ - Navigate to the "API tokens" section
42
+ - Create a new token
43
+
44
+ 2. Configure the environment variables:
45
+ You have two options for configuring the required environment variables:
46
+
47
+ Option 1: Using a .env file (Recommended for development)
48
+ Create a `.env` file in the roam-research directory:
49
+
50
+ ```
51
+ ROAM_API_TOKEN=your-api-token
52
+ ROAM_GRAPH_NAME=your-graph-name
53
+ ```
54
+
55
+ Option 2: Using MCP settings (Alternative method)
56
+ Add the configuration to your MCP settings file:
57
+
58
+ - For Cline (`~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json`):
59
+
60
+ ```json
61
+ {
62
+ "mcpServers": {
63
+ "roam-research": {
64
+ "command": "node",
65
+ "args": ["/path/to/roam-research/build/index.js"],
66
+ "env": {
67
+ "ROAM_API_TOKEN": "your-api-token",
68
+ "ROAM_GRAPH_NAME": "your-graph-name"
69
+ }
70
+ }
71
+ }
72
+ }
73
+ ```
74
+
75
+ - For Claude desktop app (`~/Library/Application Support/Claude/claude_desktop_config.json`):
76
+
77
+ ```json
78
+ {
79
+ "mcpServers": {
80
+ "roam-research": {
81
+ "command": "node",
82
+ "args": ["/path/to/roam-research/build/index.js"],
83
+ "env": {
84
+ "ROAM_API_TOKEN": "your-api-token",
85
+ "ROAM_GRAPH_NAME": "your-graph-name"
86
+ }
87
+ }
88
+ }
89
+ }
90
+ ```
91
+
92
+ Note: The server will first try to load from .env file, then fall back to environment variables from MCP settings.
93
+
94
+ 3. Build the server:
95
+ ```bash
96
+ cd roam-research
97
+ npm install
98
+ npm run build
99
+ ```
100
+
101
+ ## Usage
102
+
103
+ ### Fetch Page By Title
104
+
105
+ Fetch and read a page's content with resolved block references:
106
+
107
+ ```typescript
108
+ use_mcp_tool roam-research roam_fetch_page_by_title {
109
+ "title": "Example Page"
110
+ }
111
+ ```
112
+
113
+ Returns the page content as markdown with:
114
+
115
+ - Complete hierarchical structure
116
+ - Block references recursively resolved (up to 4 levels deep)
117
+ - Proper indentation for nesting levels
118
+ - Full markdown formatting
119
+
120
+ ### Create Page
121
+
122
+ Create a new page with optional content:
123
+
124
+ ```typescript
125
+ use_mcp_tool roam-research roam_create_page {
126
+ "title": "New Page",
127
+ "content": "Initial content for the page"
128
+ }
129
+ ```
130
+
131
+ Returns the created page's UID on success.
132
+
133
+ ### Create Block
134
+
135
+ Add a new block to a page (defaults to today's daily page if neither page_uid nor title provided):
136
+
137
+ ```typescript
138
+ use_mcp_tool roam-research roam_create_block {
139
+ "content": "Block content",
140
+ "page_uid": "optional-target-page-uid",
141
+ "title": "optional-target-page-title"
142
+ }
143
+ ```
144
+
145
+ You can specify either:
146
+
147
+ - `page_uid`: Direct reference to target page
148
+ - `title`: Name of target page (will be created if it doesn't exist)
149
+ - Neither: Block will be added to today's daily page
150
+
151
+ Returns:
152
+
153
+ ```json
154
+ {
155
+ "success": true,
156
+ "block_uid": "created-block-uid",
157
+ "parent_uid": "parent-page-uid"
158
+ }
159
+ ```
160
+
161
+ ### Add Todo Items
162
+
163
+ Add one or more todo items to today's daily page:
164
+
165
+ ```typescript
166
+ use_mcp_tool roam-research roam_add_todo {
167
+ "todos": [
168
+ "First todo item",
169
+ "Second todo item",
170
+ "Third todo item"
171
+ ]
172
+ }
173
+ ```
174
+
175
+ Features:
176
+
177
+ - Adds todos with Roam checkbox syntax (`{{TODO}} todo text`)
178
+ - Supports adding multiple todos in a single operation
179
+ - Uses batch actions for efficiency when adding >10 todos
180
+ - Automatically creates today's page if it doesn't exist
181
+ - Adds todos as top-level blocks in sequential order
182
+
183
+ ### Import Nested Markdown
184
+
185
+ Import nested markdown content under a specific block:
186
+
187
+ ```typescript
188
+ use_mcp_tool roam-research roam_import_markdown {
189
+ "content": "- Item 1\n - Subitem A\n - Subitem B\n- Item 2",
190
+ "page_uid": "optional-page-uid",
191
+ "page_title": "optional-page-title",
192
+ "parent_uid": "optional-parent-block-uid",
193
+ "parent_string": "optional-exact-block-content",
194
+ "order": "first"
195
+ }
196
+ ```
197
+
198
+ Features:
199
+
200
+ - Import content under specific blocks:
201
+ - Find parent block by UID or exact string match
202
+ - Locate blocks within specific pages by title or UID
203
+ - Defaults to today's page if no page specified
204
+ - Control content placement:
205
+ - Add as first or last child of parent block
206
+ - Preserve hierarchical structure
207
+ - Efficient batch operations for nested content
208
+ - Comprehensive return value:
209
+ ```json
210
+ {
211
+ "success": true,
212
+ "page_uid": "target-page-uid",
213
+ "parent_uid": "parent-block-uid",
214
+ "created_uids": ["uid1", "uid2", ...]
215
+ }
216
+ ```
217
+
218
+ Parameters:
219
+
220
+ - `content`: Nested markdown content to import
221
+ - `page_uid`: UID of the page containing the parent block
222
+ - `page_title`: Title of the page containing the parent block (ignored if page_uid provided)
223
+ - `parent_uid`: UID of the parent block to add content under
224
+ - `parent_string`: Exact string content of the parent block (must provide either page_uid or page_title)
225
+ - `order`: Where to add the content ("first" or "last", defaults to "first")
226
+
227
+ ## Error Handling
228
+
229
+ The server provides comprehensive error handling for common scenarios:
230
+
231
+ - Configuration errors:
232
+ - Missing API token or graph name
233
+ - Invalid environment variables
234
+ - API errors:
235
+ - Authentication failures
236
+ - Invalid requests
237
+ - Failed operations
238
+ - Tool-specific errors:
239
+ - Page not found (with case-insensitive search)
240
+ - Block not found by string match
241
+ - Invalid markdown format
242
+ - Missing required parameters
243
+
244
+ Each error response includes:
245
+
246
+ - Standard MCP error code
247
+ - Detailed error message
248
+ - Suggestions for resolution when applicable
249
+
250
+ ## Development
251
+
252
+ The server is built with TypeScript and includes:
253
+
254
+ - Environment variable handling with .env support
255
+ - Comprehensive input validation
256
+ - Case-insensitive page title matching
257
+ - Recursive block reference resolution
258
+ - Markdown parsing and conversion
259
+ - Daily page integration
260
+ - Detailed debug logging
261
+ - Efficient batch operations
262
+
263
+ To modify or extend the server:
264
+
265
+ 1. Clone the repository
266
+ 2. Install dependencies with `npm install`
267
+ 3. Make changes to the source files
268
+ 4. Build with `npm run build`
269
+ 5. Test locally by configuring environment variables
270
+
271
+ ## License
272
+
273
+ MIT License