@roam-research/roam-mcp 0.3.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 ADDED
@@ -0,0 +1,212 @@
1
+ # Roam MCP
2
+
3
+ A Model Context Protocol (MCP) server and CLI for Roam Research.
4
+
5
+ > **Alpha Software**: This project is in early development and subject to breaking changes.
6
+
7
+ > [!CAUTION]
8
+ > **Full Write Access**: This MCP server gives Claude full read and write access to your Roam graph. Claude can create, modify, and delete pages and blocks. **Changes may be difficult or impossible to undo.** Roam does not have a traditional undo history that can reverse bulk operations or deletions made through the API.
9
+ >
10
+ > **Recommendations:**
11
+ > - Back up your graph before use
12
+ > - Start with a test graph to understand Claude's behavior
13
+ > - Review what Claude plans to do before confirming write operations
14
+ > - Be specific in your instructions to avoid unintended changes
15
+
16
+ ## Prerequisites
17
+
18
+ - **Node.js** v18 or later
19
+ - **Roam Research desktop app** (the local API is not available in the web version)
20
+
21
+ ## How It Works
22
+
23
+ This MCP server connects to Roam's local HTTP API, which runs on your machine when the desktop app is open. If Roam isn't running when a tool is called, the server will automatically launch it via deep link and retry the connection.
24
+
25
+ ## Getting Started
26
+
27
+ ### 1. Roam Desktop App
28
+
29
+ The local API requires the Roam **desktop app** (not the web version). Make sure it's installed and you can open your graph in it.
30
+
31
+ ### 2. Install
32
+
33
+ ```bash
34
+ npm install -g @roam-research/roam-mcp
35
+ ```
36
+
37
+ This gives you two commands:
38
+ - `roam-mcp` — the MCP server
39
+ - `roam` — the CLI
40
+
41
+ ### 3. Connect a Graph
42
+
43
+ **Interactive** (recommended for first-time setup):
44
+
45
+ ```bash
46
+ roam connect
47
+ ```
48
+
49
+ This will walk you through selecting a graph, choosing permissions, and approving the token in Roam.
50
+
51
+ **Non-interactive** (for scripts and LLM agents):
52
+
53
+ ```bash
54
+ # example to connect to your graph called "my-graph-name" which you generally refer to as "My Team Graph"
55
+ roam connect --graph my-graph-name --nickname "My Team Graph" --access-level full
56
+
57
+ # example to connect to a public graph - our "help" graph
58
+ roam connect --graph help --public --nickname "Roam official help graph"
59
+ ```
60
+
61
+ | Flag | Default | Description |
62
+ |------|---------|-------------|
63
+ | `--graph <name>` | — | Graph name (enables non-interactive mode) |
64
+ | `--nickname <name>` | Required with `--graph` | Short name you'll use to refer to this graph |
65
+ | `--access-level <level>` | `full` | `full`, `read-append`, or `read-only` |
66
+ | `--public` | — | Public graph (read-only, hosted) |
67
+ | `--type <type>` | `hosted` | `hosted` or `offline` |
68
+
69
+ **Note:** Both modes require a human to approve the token dialog in the Roam desktop app.
70
+
71
+ To remove a connection:
72
+
73
+ ```bash
74
+ roam connect --remove --graph my-graph-name
75
+ roam connect --remove --nickname "My Team Graph"
76
+ ```
77
+
78
+ Run `roam connect` again to add more graphs or update permissions.
79
+
80
+ ### 4. Connect to an MCP Client
81
+
82
+ Add to your MCP client configuration:
83
+
84
+ ```json
85
+ {
86
+ "mcpServers": {
87
+ "roam": {
88
+ "command": "npx",
89
+ "args": ["-y", "@roam-research/roam-mcp"]
90
+ }
91
+ }
92
+ }
93
+ ```
94
+
95
+ For Claude Desktop, this file is at `~/Library/Application Support/Claude/claude_desktop_config.json` on macOS.
96
+
97
+ **Claude Code**: Run Claude Code from the roam-mcp directory. The MCP server is configured in `.mcp.json` and will be available automatically.
98
+
99
+ ### Multiple Graphs
100
+
101
+ Run `roam connect` multiple times to add additional graphs. Each graph gets a nickname (a short name like "work" or "team acme") for easy selection.
102
+
103
+ **Graph Selection:**
104
+ - **Single graph configured**: Auto-selected, no action needed
105
+ - **Multiple graphs configured**: Pass the `graph` parameter on each tool call with the nickname
106
+
107
+ ### Manual Configuration (Advanced)
108
+
109
+ Instead of using `connect`, you can manually create `~/.roam-tools.json`:
110
+
111
+ ```json
112
+ {
113
+ "graphs": [
114
+ {
115
+ "name": "your-graph-name",
116
+ "type": "hosted",
117
+ "token": "roam-graph-local-token-...",
118
+ "nickname": "my-graph"
119
+ }
120
+ ]
121
+ }
122
+ ```
123
+
124
+ To create a token manually: Roam Desktop → Settings → Graph → Local API Tokens → New Token.
125
+
126
+ | Field | Required | Description |
127
+ |-------|----------|-------------|
128
+ | `name` | Yes | The actual graph name in Roam (as shown in the URL) |
129
+ | `type` | No | `"hosted"` (default) for cloud graphs, `"offline"` for local-only |
130
+ | `token` | Yes | Local API token from Roam settings |
131
+ | `nickname` | Yes | Slug identifier for this graph (lowercase, hyphens, no spaces) |
132
+ | `accessLevel` | No | `"full"` (default), `"read-only"`, or `"read-append"` |
133
+
134
+ ## Available Tools
135
+
136
+ **Graph Management:**
137
+ - `list_graphs` - List all configured graphs with their nicknames
138
+ - `setup_new_graph` - Set up a new graph connection, or list available graphs
139
+
140
+ **Graph Guidelines:**
141
+ - `get_graph_guidelines` - Returns user-defined instructions and preferences for AI agents
142
+
143
+ Graph guidelines let you store preferences and context directly in your Roam graph that AI agents will follow. Create a page called `[[agent guidelines]]` with your instructions. These might include naming conventions, preferred page structures, topics to focus on, or any other context that should guide how the AI interacts with your graph.
144
+
145
+ **Content:**
146
+ - `create_page` - Create page with markdown content
147
+ - `update_page` - Update page title or children view type
148
+ - `delete_page` - Delete a page
149
+ - `create_block` - Add markdown content under a parent
150
+ - `update_block` - Update block content/properties
151
+ - `move_block` - Move a block to a new location
152
+ - `delete_block` - Delete a block
153
+
154
+ **Read:**
155
+ - `search` - Search pages/blocks
156
+ - `search_templates` - Search Roam templates by name
157
+ - `roam_query` - Execute a Roam query (`{{query:}}` blocks, not Datalog)
158
+ - `get_page` - Get page content as markdown
159
+ - `get_block` - Get block content as markdown
160
+ - `get_backlinks` - Get references to a page/block
161
+
162
+ **Navigation:**
163
+ - `get_open_windows` - Main window view and all sidebar windows
164
+ - `get_selection` - Currently focused block and multi-selected blocks
165
+ - `open_main_window` - Navigate to page/block
166
+ - `open_sidebar` - Open in right sidebar
167
+
168
+ **Files:**
169
+ - `file_get` - Fetch a file hosted on Roam (handles decryption for encrypted graphs)
170
+ - `file_upload` - Upload a file to Roam (from local path, URL, or base64)
171
+ - `file_delete` - Delete a file hosted on Roam
172
+
173
+ ## CLI
174
+
175
+ The `roam` command provides direct access to all tools:
176
+
177
+ ```bash
178
+ # Setup
179
+ roam connect # Interactive graph connection
180
+ roam connect --graph <name> --nickname <name> # Non-interactive connection
181
+
182
+ # Tools (same as MCP server)
183
+ roam list-graphs
184
+ roam search --query "my notes"
185
+ roam get-page --title "My Page"
186
+ roam create-block --parent-uid "abc123" --markdown "Hello world"
187
+ ```
188
+
189
+ Run `roam --help` to see all available commands.
190
+
191
+ ## Development
192
+
193
+ To work on this project from source:
194
+
195
+ ```bash
196
+ git clone https://github.com/Roam-Research/roam-mcp.git
197
+ cd roam-mcp
198
+ npm install
199
+ npm run build
200
+ ```
201
+
202
+ Development commands:
203
+
204
+ ```bash
205
+ npm run mcp # Run MCP server in dev mode (tsx)
206
+ npm run cli -- connect # Run CLI in dev mode
207
+ npm run typecheck # Type-check without emitting
208
+ ```
209
+
210
+ ## Contributing
211
+
212
+ This project is changing rapidly. At this time, we prefer suggestions and feedback over pull requests. Please open an issue or join the #ai-in-roam channel on slack to discuss ideas before submitting code.
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+ export interface ConnectOptions {
3
+ graph?: string;
4
+ nickname?: string;
5
+ accessLevel?: string;
6
+ public?: boolean;
7
+ type?: string;
8
+ remove?: boolean;
9
+ }
10
+ export declare function connect(options?: ConnectOptions): Promise<void>;