triliumnext-mcp 0.3.12 → 0.3.14

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
@@ -1,150 +1,197 @@
1
- # TriliumNext Notes' MCP Server
2
-
3
- ⚠️ **DISCLAIMER: This is a prototype for https://github.com/TriliumNext/Notes/issues/705. Suggested only for developer use. Please backup your Trilium notes before using this tool.** ⚠️
4
-
5
- A model context protocol server for TriliumNext Notes. This server provides tools to interact with your Trilium Notes instance through MCP.
6
-
7
- ## Quick Start
8
-
9
- Make sure to set up your environment variables first:
10
- - `TRILIUM_API_URL` (default: http://localhost:8080/etapi)
11
- - `TRILIUM_API_TOKEN` (required, get this from your Trilium Notes settings)
12
- - `PERMISSIONS` (optional, default='READ;WRITE', where READ grants access to `search_notes`, `get_note`, `resolve_note_id`, and `read_attributes`, and WRITE grants access to `create_note`, `update_note`, `delete_note`, and `manage_attributes`)
13
- - `VERBOSE` (optional, default='false', which if true will print verbose debugging logs)
14
-
15
- ## Installation
16
-
17
- ### 1. Using with Claude Desktop
18
-
19
- Add the server config to your Claude Desktop configuration file:
20
-
21
- #### For Local Installation (on Windows)
22
-
23
- ```json
24
- "triliumnext-mcp": {
25
- "command": "cmd",
26
- "args": [
27
- "/k",
28
- "npx",
29
- "-y",
30
- "triliumnext-mcp"
31
- ],
32
- "env": {
33
- "TRILIUM_API_URL": "http://localhost:8080/etapi",
34
- "TRILIUM_API_TOKEN": "<YOUR_TRILIUM_API_TOKEN>",
35
- "PERMISSIONS": "READ;WRITE"
36
- }
37
- }
38
- ```
39
-
40
- #### For Local installation (on Linux)
41
-
42
- ```json
43
- "triliumnext-mcp": {
44
- "command": "npx",
45
- "args": [
46
- "-y",
47
- "triliumnext-mcp"
48
- ],
49
- "env": {
50
- "TRILIUM_API_URL": "http://localhost:8080/etapi",
51
- "TRILIUM_API_TOKEN": "<YOUR_TRILIUM_API_TOKEN>",
52
- "PERMISSIONS": "READ;WRITE"
53
- }
54
- }
55
- ```
56
-
57
- #### For Development (on Windows / Linux)
58
-
59
- ```bash
60
- cd /path/to/triliumnext-mcp
61
- npm run build
62
- ```
63
-
64
- ```json
65
- "triliumnext-mcp": {
66
- "command": "node",
67
- "args": [
68
- "/path/to/triliumnext-mcp/build/index.js"
69
- ],
70
- "env": {
71
- "TRILIUM_API_URL": "http://localhost:8080/etapi",
72
- "TRILIUM_API_TOKEN": "<YOUR_TRILIUM_API_TOKEN>",
73
- "PERMISSIONS": "READ;WRITE",
74
- "VERBOSE": "true"
75
- }
76
- }
77
- ```
78
-
79
- Location of the configuration file:
80
- - Windows: `%APPDATA%/Claude/claude_desktop_config.json`
81
- - MacOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
82
-
83
- **Feedback**: Please report issues and test results at [GitHub Issues](https://github.com/TriliumNext/Notes/issues)
84
-
85
- ## Available Tools
86
-
87
- The server provides the following tools for note management:
88
-
89
- ### Search & Discovery Tools
90
-
91
- - `search_notes` - Unified search with comprehensive filtering capabilities including keyword search, date ranges, field-specific searches, attribute searches, note properties, template-based searches, note type filtering, MIME type filtering, and hierarchy navigation.
92
- - `resolve_note_id` - Find a note's ID by its title. Essential for getting a note's ID to use with other tools.
93
-
94
- ### Note Management Tools
95
-
96
- - `get_note` - Retrieve a note and its content by ID. Can also be used with regex to extract specific patterns from the content.
97
- - `create_note` - Create a new note. Supports 9 note types and allows creating attributes (labels and relations) in the same step.
98
- - `update_note` - Updates a note's title or content. Requires a `mode` (`'overwrite'` or `'append'`) to specify the update type and an `expectedHash` to prevent conflicts.
99
- - `delete_note` - Permanently delete a note (⚠️ cannot be undone).
100
-
101
- ### Attribute Management Tools
102
-
103
- - `read_attributes` - Read all attributes (labels and relations) for a given note.
104
- - `manage_attributes` - Create, update, or delete attributes on a note. Supports batch creation.
105
-
106
- > 📖 **Detailed Usage**: See [Note Management Guide](docs/manage-notes-examples/index.md) for revision control strategy and best practices.
107
-
108
- ## Example Queries
109
-
110
- ### Search & Discovery
111
- - "Find my most recent 10 notes about 'n8n' since the beginning of 2024"
112
- - "Show me notes I've edited in the last 7 days"
113
- - "List all notes under 'n8n Template' folder, including subfolders"
114
-
115
- ### Content Management
116
- - "Add today's update to my work log" (uses `update_note` with `mode: 'append'`)
117
- - "Replace this draft with the final version" (uses `update_note` with `mode: 'overwrite'`)
118
- - "Create a new note called 'Weekly Review' in my journal folder"
119
-
120
- > 📖 **More Examples**: See [User Query Examples](docs/user-query-examples.md) for comprehensive usage scenarios.
121
-
122
- ## Documentation
123
-
124
- - [Note Management Guide](docs/manage-notes-examples/index.md) - Safe content editing with revision control
125
- - [User Query Examples](docs/user-query-examples.md) - Natural language query examples
126
- - [Search Query Examples](docs/search-examples/) - Advanced search syntax and filters
127
-
128
- ## Development
129
-
130
- If you want to contribute or modify the server:
131
-
132
- ```bash
133
- # Clone the repository
134
- git clone https://github.com/tan-yong-sheng/triliumnext-mcp.git
135
-
136
- # Install dependencies
137
- npm install
138
-
139
- # Build the server
140
- npm run build
141
-
142
- # For development with auto-rebuild
143
- npm run watch
144
- ```
145
-
146
- ## Contributing
147
-
148
- Contributions are welcome! If you are looking to improve the server, please familiarize yourself with the official [Trilium Search DSL documentation](https://triliumnext.github.io/Docs/Wiki/search.html) and our internal [Search Query Examples](docs/search-examples/) to understand how search queries are constructed.
149
-
1
+ # TriliumNext Notes' MCP Server
2
+
3
+ ⚠️ **DISCLAIMER: This is a prototype for https://github.com/TriliumNext/Notes/issues/705. Suggested only for developer use. Please backup your Trilium notes before using this tool.** ⚠️
4
+
5
+ A model context protocol server for TriliumNext Notes. This server provides tools to interact with your Trilium Notes instance through MCP.
6
+
7
+ ## Quick Start
8
+
9
+ Make sure to set up your environment variables first:
10
+ - `TRILIUM_API_URL` (default: http://localhost:8080/etapi)
11
+ - `TRILIUM_API_TOKEN` (required, get this from your Trilium Notes settings)
12
+ - `PERMISSIONS` (optional, default='READ;WRITE', where READ grants access to `search_notes`, `get_note`, `resolve_note_id`, and `read_attributes`, and WRITE grants access to `create_note`, `update_note`, `delete_note`, and `manage_attributes`)
13
+ - `VERBOSE` (optional, default='false', which if true will print verbose debugging logs)
14
+
15
+ ## Installation
16
+
17
+
18
+ Below are the installation guide for this MCP on different MCP clients, such as Claude Desktop, Claude Code, Cursor, Cline, etc.
19
+
20
+ <details>
21
+ <summary>Claude Desktop</summary>
22
+
23
+ Add to your Claude Desktop configuration:
24
+
25
+ ```json
26
+ {
27
+ "mcpServers": {
28
+ "triliumnext-mcp": {
29
+ "command": "npx",
30
+ "args": ["triliumnext-mcp"],
31
+ "env": {
32
+ "TRILIUM_API_URL": "http://localhost:8080/etapi",
33
+ "TRILIUM_API_TOKEN": "<YOUR_TRILIUM_API_TOKEN>",
34
+ "PERMISSIONS": "READ;WRITE"
35
+ }
36
+ }
37
+ }
38
+ }
39
+ ```
40
+ </details>
41
+
42
+ <details>
43
+ <summary>Claude Code</summary>
44
+
45
+ ```bash
46
+ claude mcp add triliumnext-mcp \
47
+ -e TRILIUM_API_URL=http://localhost:8080/etapi \
48
+ -e TRILIUM_API_TOKEN=<YOUR_TRILIUM_API_TOKEN> \
49
+ -e PERMISSIONS='READ;WRITE' \
50
+ -- npx triliumnext-mcp
51
+ ```
52
+
53
+ Note: Increase the MCP startup timeout to 1 minutes and MCP tool execution timeout to about 5 minutes by updating `~\.claude\settings.json` as follows:
54
+
55
+ ```json
56
+ {
57
+ "env": {
58
+ "MCP_TIMEOUT": "60000",
59
+ "MCP_TOOL_TIMEOUT": "300000"
60
+ }
61
+ }
62
+ ```
63
+
64
+ </details>
65
+
66
+ <details>
67
+ <summary>Cursor</summary>
68
+
69
+ Go to: Settings -> Cursor Settings -> MCP -> Add new global MCP server
70
+
71
+ Pasting the following configuration into your Cursor ~/.cursor/mcp.json file is the recommended approach. You may also install in a specific project by creating .cursor/mcp.json in your project folder. See [Cursor MCP docs](https://docs.cursor.com/context/model-context-protocol) for more info.
72
+
73
+ ```json
74
+ {
75
+ "mcpServers": {
76
+ "triliumnext-mcp": {
77
+ "command": "npx",
78
+ "args": ["triliumnext-mcp"],
79
+ "env": {
80
+ "TRILIUM_API_URL": "http://localhost:8080/etapi",
81
+ "TRILIUM_API_TOKEN": "<YOUR_TRILIUM_API_TOKEN>",
82
+ "PERMISSIONS": "READ;WRITE"
83
+ }
84
+ }
85
+ }
86
+ }
87
+ ```
88
+ </details>
89
+
90
+
91
+ <details>
92
+ <summary>Cline</summary>
93
+
94
+ Cline uses a JSON configuration file to manage MCP servers. To integrate the provided MCP server configuration:
95
+
96
+ 1. Open Cline and click on the MCP Servers icon in the top navigation bar.
97
+ 2. Select the Installed tab, then click Advanced MCP Settings.
98
+ 3. In the cline_mcp_settings.json file, add the following configuration:
99
+
100
+ (i) Using Google AI Studio Provider
101
+ ```json
102
+ {
103
+ "mcpServers": {
104
+ "timeout": 300,
105
+ "type": "stdio",
106
+ "triliumnext-mcp": {
107
+ "command": "npx",
108
+ "args": ["triliumnext-mcp"],
109
+ "env": {
110
+ "TRILIUM_API_URL": "http://localhost:8080/etapi",
111
+ "TRILIUM_API_TOKEN": "<YOUR_TRILIUM_API_TOKEN>",
112
+ "PERMISSIONS": "READ;WRITE"
113
+ }
114
+ }
115
+ }
116
+ }
117
+ ```
118
+ </details>
119
+
120
+
121
+ <details>
122
+
123
+ <summary>Other MCP clients</summary>
124
+
125
+ The server uses stdio transport and follows the standard MCP protocol. It can be integrated with any MCP-compatible client by running:
126
+
127
+ ```bash
128
+ npx triliumnext-mcp
129
+ ```
130
+ </details>
131
+
132
+ ## Available Tools
133
+
134
+ The server provides the following tools for note management:
135
+
136
+ ### Search & Discovery Tools
137
+
138
+ - `search_notes` - Unified search with comprehensive filtering capabilities including keyword search, date ranges, field-specific searches, attribute searches, note properties, template-based searches, note type filtering, MIME type filtering, and hierarchy navigation.
139
+ - `resolve_note_id` - Find a note's ID by its title. Essential for getting a note's ID to use with other tools.
140
+
141
+ ### Note Management Tools
142
+
143
+ - `get_note` - Retrieve a note and its content by ID. Can also be used with regex to extract specific patterns from the content.
144
+ - `create_note` - Create a new note. Supports 9 note types and allows creating attributes (labels and relations) in the same step.
145
+ - `update_note` - Updates a note's title or content. Requires a `mode` (`'overwrite'` or `'append'`) to specify the update type and an `expectedHash` to prevent conflicts.
146
+ - `delete_note` - Permanently delete a note (⚠️ cannot be undone).
147
+
148
+ ### Attribute Management Tools
149
+
150
+ - `read_attributes` - Read all attributes (labels and relations) for a given note.
151
+ - `manage_attributes` - Create, update, or delete attributes on a note. Supports batch creation.
152
+
153
+ > 📖 **Detailed Usage**: See [Note Management Guide](docs/manage-notes-examples/index.md) for revision control strategy and best practices.
154
+
155
+ ## Example Queries
156
+
157
+ ### Search & Discovery
158
+ - "Find my most recent 10 notes about 'n8n' since the beginning of 2024"
159
+ - "Show me notes I've edited in the last 7 days"
160
+ - "List all notes under 'n8n Template' folder, including subfolders"
161
+
162
+ ### Content Management
163
+ - "Add today's update to my work log" (uses `update_note` with `mode: 'append'`)
164
+ - "Replace this draft with the final version" (uses `update_note` with `mode: 'overwrite'`)
165
+ - "Create a new note called 'Weekly Review' in my journal folder"
166
+
167
+ > 📖 **More Examples**: See [User Query Examples](docs/user-query-examples.md) for comprehensive usage scenarios.
168
+
169
+ ## Documentation
170
+
171
+ - [Note Management Guide](docs/manage-notes-examples/index.md) - Safe content editing with revision control
172
+ - [User Query Examples](docs/user-query-examples.md) - Natural language query examples
173
+ - [Search Query Examples](docs/search-examples/) - Advanced search syntax and filters
174
+
175
+ ## Development
176
+
177
+ If you want to contribute or modify the server:
178
+
179
+ ```bash
180
+ # Clone the repository
181
+ git clone https://github.com/tan-yong-sheng/triliumnext-mcp.git
182
+
183
+ # Install dependencies
184
+ npm install
185
+
186
+ # Build the server
187
+ npm run build
188
+
189
+ # For development with auto-rebuild
190
+ npm run watch
191
+ ```
192
+
193
+ ## Contributing
194
+
195
+ Contributions are welcome! If you are looking to improve the server, please familiarize yourself with the official [Trilium Search DSL documentation](https://triliumnext.github.io/Docs/Wiki/search.html) and our internal [Search Query Examples](docs/search-examples/) to understand how search queries are constructed.
196
+
150
197
  Please feel free to open an issue or submit a pull request.
package/build/index.js CHANGED
@@ -9,7 +9,6 @@ import { handleCreateNoteRequest, handleUpdateNoteRequest, handleDeleteNoteReque
9
9
  import { handleSearchNotesRequest } from "./modules/searchHandler.js";
10
10
  import { handleResolveNoteRequest } from "./modules/resolveHandler.js";
11
11
  import { handleManageAttributes, handleReadAttributes } from "./modules/attributeHandler.js";
12
- import { handleListAttributesRequest } from "./modules/attributeListHandler.js";
13
12
  const TRILIUM_API_URL = process.env.TRILIUM_API_URL;
14
13
  const TRILIUM_API_TOKEN = process.env.TRILIUM_API_TOKEN;
15
14
  const PERMISSIONS = process.env.PERMISSIONS || "READ;WRITE";
@@ -24,7 +23,7 @@ class TriliumServer {
24
23
  this.allowedPermissions = PERMISSIONS.split(';');
25
24
  this.server = new Server({
26
25
  name: "triliumnext-mcp",
27
- version: "0.3.10",
26
+ version: "0.3.13",
28
27
  }, {
29
28
  capabilities: {
30
29
  tools: {},
@@ -78,8 +77,6 @@ class TriliumServer {
78
77
  return await handleReadAttributes(request.params.arguments, this.axiosInstance, this);
79
78
  case "manage_attributes":
80
79
  return await handleManageAttributes(request.params.arguments, this.axiosInstance, this);
81
- case "list_attributes":
82
- return await handleListAttributesRequest(request.params.arguments, this.axiosInstance, this);
83
80
  default:
84
81
  throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${request.params.name}`);
85
82
  }
@@ -221,38 +221,6 @@ function format_attribute_response(result, noteId, operation) {
221
221
  text: `📋 Error details:\n${result.errors.map((err, i) => `${i + 1}. ${err}`).join('\n')}`
222
222
  });
223
223
  }
224
- // Add specific guidance for common errors
225
- if (result.errors && result.errors.some(err => err.includes("already exists"))) {
226
- content.push({
227
- type: "text",
228
- text: `💡 **Attribute Already Exists**
229
-
230
- The attribute you're trying to create already exists on this note. Here are your options:
231
-
232
- 1. **Update the existing attribute** (recommended):
233
- - Use operation: "update" instead of "create"
234
- - Only the value and position can be updated for labels
235
- - Only the position can be updated for relations
236
-
237
- 2. **Delete and recreate** (for inheritable changes):
238
- - First delete with operation: "delete"
239
- - Then recreate with operation: "create"
240
- - Use this when you need to change the 'isInheritable' property
241
-
242
- 3. **View current attributes**:
243
- - Use read_attributes to see all existing attributes
244
- - Check current values, positions, and inheritable settings
245
-
246
- 📋 **Example update operation**:
247
- \`\`\`
248
- {
249
- "noteId": "${noteId}",
250
- "operation": "update",
251
- "attributes": [{"type": "label", "name": "your_attribute", "value": "new_value"}]
252
- }
253
- \`\`\``
254
- });
255
- }
256
224
  }
257
225
  // Add attribute data for successful operations
258
226
  if (result.success && result.attributes && result.attributes.length > 0) {
@@ -278,28 +246,6 @@ The attribute you're trying to create already exists on this note. Here are your
278
246
  });
279
247
  }
280
248
  }
281
- // Add guidance for batch operations with conflicts
282
- if (result.success && operation === "batch_create" && result.errors && result.errors.length > 0) {
283
- const hasConflicts = result.errors.some(err => err.includes("Skipping duplicate") || err.includes("already exist"));
284
- if (hasConflicts) {
285
- content.push({
286
- type: "text",
287
- text: `⚠️ **Batch Operation Summary**
288
-
289
- Some attributes were skipped due to conflicts (already existing). This is normal behavior for batch operations:
290
-
291
- ✅ **Successfully created**: ${result.attributes?.length || 0} attributes
292
- ❌ **Skipped duplicates**: ${result.errors?.filter(err => err.includes("Skipping duplicate") || err.includes("already exist")).length || 0} attributes
293
-
294
- 💡 **To manage skipped attributes**:
295
- - Use \`read_attributes\` to view current attributes
296
- - Use \`update\` operation to modify existing attributes
297
- - Use \`delete\` operation to remove unwanted attributes first
298
-
299
- This approach prevents accidental overwrites while allowing partial success for batch operations.`
300
- });
301
- }
302
- }
303
249
  return { content };
304
250
  }
305
251
  /**
@@ -370,11 +316,5 @@ export function get_attributes_help() {
370
316
  - Template relations require the target note to exist in your Trilium instance
371
317
  - Position values control display order (lower numbers appear first)
372
318
  - Use read_attributes to view existing attributes before making changes
373
-
374
- 🛡️ **Validation & Conflict Handling**:
375
- - Create operations now validate against existing attributes to prevent duplicates
376
- - If an attribute already exists, you'll get detailed error messages with guidance
377
- - Batch operations skip duplicates and continue with valid attributes
378
- - Use "update" to modify existing attributes, "create" for new ones only
379
319
  `;
380
320
  }