@inkdropapp/mcp-server 1.2.0 → 1.3.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.
@@ -0,0 +1,7 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(claude mcp list:*)"
5
+ ]
6
+ }
7
+ }
package/README.md CHANGED
@@ -8,7 +8,7 @@ A [Model Context Protocol](https://github.com/modelcontextprotocol) server for t
8
8
 
9
9
  ## Installation
10
10
 
11
- 1. [Set up a local HTTP server](https://developers.inkdrop.app/guides/access-the-local-database#accessing-via-http-advanced)
11
+ 1. [Set up a local HTTP server](https://developers.inkdrop.app/guides/integrate-with-external-programs)
12
12
 
13
13
  2. Add server config to Claude Desktop:
14
14
  - MacOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
@@ -59,30 +59,35 @@ A [Model Context Protocol](https://github.com/modelcontextprotocol) server for t
59
59
  - Optional inputs:
60
60
  - `status`: The note status (`none`, `active`, `onHold`, `completed`, `dropped`).
61
61
  - `tags`: An array of tag IDs to assign to the note. Each must start with 'tag:'.
62
- 5. **`update-note`**: Update an existing note in the database.
62
+ 5. **`update-note`**: Update an existing note in the database. Only the fields you provide will be updated; omitted fields remain unchanged.
63
63
  - Required inputs:
64
64
  - `_id`: The note ID. Must start with 'note:'.
65
65
  - `_rev`: The revision ID (CouchDB MVCC-token).
66
+ - Optional inputs:
66
67
  - `bookId`: The notebook ID. Must start with 'book:' or be 'trash'.
67
68
  - `title`: The note title.
68
69
  - `body`: The content of the note in Markdown.
69
- - Optional inputs:
70
70
  - `status`: The note status (`none`, `active`, `onHold`, `completed`, `dropped`).
71
71
  - `tags`: An array of tag IDs to assign to the note. Each must start with 'tag:'.
72
- 6. **`list-notebooks`**: Retrieve a list of all notebooks.
73
- 7. **`read-book`**: Retrieve a single notebook by its ID.
72
+ 6. **`patch-note`**: Update the body of an existing note by applying a unified diff patch. More efficient than `update-note` for small edits to large notes as it saves tokens.
74
73
  - Required inputs:
75
- - `bookId`: The notebook ID. Must start with 'book:'.
76
- 8. **`list-tags`**: Retrieve a list of all tags.
77
- 9. **`read-tag`**: Retrieve a single tag by its ID.
74
+ - `_id`: The note ID. Must start with 'note:'.
75
+ - `_rev`: The revision ID (CouchDB MVCC-token).
76
+ - `patch`: A unified diff string to apply to the note body. Use standard unified diff format with `---`/`+++` headers and `@@ -start,count +start,count @@` hunk markers.
77
+ 7. **`list-notebooks`**: Retrieve a list of all notebooks.
78
+ 8. **`read-book`**: Retrieve a single notebook by its ID.
78
79
  - Required inputs:
79
- - `tagId`: The tag ID. Must start with 'tag:'.
80
- 10. **`create-tag`**: Create a new tag in the database.
80
+ - `bookId`: The notebook ID. Must start with 'book:'.
81
+ 9. **`list-tags`**: Retrieve a list of all tags.
82
+ 10. **`read-tag`**: Retrieve a single tag by its ID.
83
+ - Required inputs:
84
+ - `tagId`: The tag ID. Must start with 'tag:'.
85
+ 11. **`create-tag`**: Create a new tag in the database.
81
86
  - Required inputs:
82
87
  - `name`: The name of the tag.
83
88
  - Optional inputs:
84
89
  - `color`: The color type of the tag (`default`, `red`, `orange`, `yellow`, `olive`, `green`, `teal`, `blue`, `violet`, `purple`, `pink`, `brown`, `grey`, `black`). Default: `default`.
85
- 11. **`update-tag`**: Update an existing tag in the database.
90
+ 12. **`update-tag`**: Update an existing tag in the database.
86
91
  - Required inputs:
87
92
  - `_id`: The tag ID. Must start with 'tag:'.
88
93
  - `_rev`: The revision ID (CouchDB MVCC-token).
package/dist/index.js CHANGED
@@ -5,12 +5,13 @@ const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
5
5
  const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
6
6
  const inkdrop_model_1 = require("inkdrop-model");
7
7
  const zod_1 = require("zod");
8
+ const diff_1 = require("diff");
8
9
  const api_1 = require("./api");
9
10
  const server = new mcp_js_1.McpServer({
10
11
  name: 'Inkdrop',
11
- version: '1.0.0'
12
+ version: '1.3.0'
12
13
  });
13
- server.resource('note', new mcp_js_1.ResourceTemplate('inkdrop://note/{noteId}', { list: undefined }), {
14
+ server.registerResource('note', new mcp_js_1.ResourceTemplate('inkdrop://note/{noteId}', { list: undefined }), {
14
15
  description: 'A note data',
15
16
  mimeType: 'application/json'
16
17
  }, async (uri, { noteId }) => {
@@ -25,10 +26,13 @@ server.resource('note', new mcp_js_1.ResourceTemplate('inkdrop://note/{noteId}',
25
26
  ]
26
27
  };
27
28
  });
28
- server.tool('read-note', 'Retrieve the complete contents of the note by its ID from the database.', {
29
- noteId: zod_1.z
30
- .string()
31
- .describe('ID of the note to retrieve. It can be found as `_id` in the note docs. It always starts with \`note:\`.')
29
+ server.registerTool('read-note', {
30
+ description: 'Retrieve the complete contents of the note by its ID from the database.',
31
+ inputSchema: {
32
+ noteId: zod_1.z
33
+ .string()
34
+ .describe('ID of the note to retrieve. It can be found as `_id` in the note docs. It always starts with \`note:\`.')
35
+ }
32
36
  }, async ({ noteId }) => {
33
37
  if (!noteId.startsWith('note:'))
34
38
  noteId = `note:${noteId}`;
@@ -42,7 +46,8 @@ server.tool('read-note', 'Retrieve the complete contents of the note by its ID f
42
46
  ]
43
47
  };
44
48
  });
45
- server.tool('search-notes', `List all notes that contain a given keyword.
49
+ server.registerTool('search-notes', {
50
+ description: `List all notes that contain a given keyword.
46
51
  The result does not include entire note bodies as they are truncated in 200 characters.
47
52
  You have to retrieve the full note content by calling \`read-note\`.
48
53
  Here are tips to specify keywords effectively:
@@ -51,18 +56,18 @@ Here are tips to specify keywords effectively:
51
56
 
52
57
  You can use special qualifiers to get more accurate results. See the qualifiers and their usage examples:
53
58
 
54
- - **book**
59
+ - **book**
55
60
  \`book:Blog\`: Searches for notes in the 'Blog' notebook.
56
61
  \`book:"Desktop App"\`: Searches for notes in the 'Desktop App' notebook.
57
62
  - **bookId**
58
63
  \`bookId:kGlLniaV\`: Searches for notes in the notebook ID 'book:kGlLniaV'.
59
- - **tag**
64
+ - **tag**
60
65
  \`tag:JavaScript\`: Searches for all notes having the 'JavaScript' tag. Read more about [tags](https://docs.inkdrop.app/manual/write-notes#tag-notes).
61
- - **status**
66
+ - **status**
62
67
  \`status:onHold\`: Searches for all notes with the 'On hold' status. Read more about [statuses](/reference/note-statuses).
63
- - **title**
68
+ - **title**
64
69
  \`title:"JavaScript setTimeout"\`: Searches for the note with the specified title.
65
- - **body**
70
+ - **body**
66
71
  \`body:KEYWORD\`: Searches for a specific word in all notes. Equivalent to a [global search](#search-for-notes-across-all-notebooks).
67
72
 
68
73
  ### Combine qualifiers
@@ -103,13 +108,15 @@ Note that you can't specify excluding modifiers only without including condition
103
108
 
104
109
  **WARNING**: Make sure to enter a text to search for after the exclusion modifier.
105
110
 
106
- - ✅ Will work
111
+ - ✅ Will work
107
112
  \`-book:Backend "closure functions"\`
108
113
 
109
- - ⛔️ Won't work
114
+ - ⛔️ Won't work
110
115
  \`-book:Backend\`. There's no query. Inkdrop doesn't understand what to search for.
111
- `, {
112
- keyword: zod_1.z.string().describe(`Keyword to search for.`)
116
+ `,
117
+ inputSchema: {
118
+ keyword: zod_1.z.string().describe(`Keyword to search for.`)
119
+ }
113
120
  }, async ({ keyword }) => {
114
121
  const notes = await (0, api_1.fetchJSON)('/notes', { keyword, limit: 10 });
115
122
  const summaries = notes.map(note => {
@@ -127,30 +134,33 @@ Note that you can't specify excluding modifiers only without including condition
127
134
  ]
128
135
  };
129
136
  });
130
- server.tool('list-notes', `List all notes with specified conditions.
137
+ server.registerTool('list-notes', {
138
+ description: `List all notes with specified conditions.
131
139
  The result does not include entire note bodies as they are truncated in 200 characters.
132
140
  You have to retrieve the full note content by calling \`read-note\`.
133
- `, {
134
- bookId: zod_1.z
135
- .string()
136
- .optional()
137
- .describe(`ID of the notebook. It always starts with 'book:'. You can retrieve a list of notebooks with \`list-notebooks\``),
138
- tagIds: zod_1.z
139
- .array(zod_1.z.string())
140
- .optional()
141
- .default([])
142
- .describe(`An array of tag IDs to filter. It always starts with 'tag:'. You can retrieve a list of available tags from \`list-tags\`.`),
143
- keyword: zod_1.z.string().optional().describe(`Keyword to filter notes`),
144
- sort: zod_1.z
145
- .enum(['updatedAt', 'createdAt', 'title'])
146
- .optional()
147
- .default('updatedAt')
148
- .describe(`Sort the documents by the specified field`),
149
- descending: zod_1.z
150
- .boolean()
151
- .optional()
152
- .default(true)
153
- .describe(`Reverse the order of the output documents`)
141
+ `,
142
+ inputSchema: {
143
+ bookId: zod_1.z
144
+ .string()
145
+ .optional()
146
+ .describe(`ID of the notebook. It always starts with 'book:'. You can retrieve a list of notebooks with \`list-notebooks\``),
147
+ tagIds: zod_1.z
148
+ .array(zod_1.z.string())
149
+ .optional()
150
+ .default([])
151
+ .describe(`An array of tag IDs to filter. It always starts with 'tag:'. You can retrieve a list of available tags from \`list-tags\`.`),
152
+ keyword: zod_1.z.string().optional().describe(`Keyword to filter notes`),
153
+ sort: zod_1.z
154
+ .enum(['updatedAt', 'createdAt', 'title'])
155
+ .optional()
156
+ .default('updatedAt')
157
+ .describe(`Sort the documents by the specified field`),
158
+ descending: zod_1.z
159
+ .boolean()
160
+ .optional()
161
+ .default(true)
162
+ .describe(`Reverse the order of the output documents`)
163
+ }
154
164
  }, async ({ bookId, tagIds, keyword, sort, descending }) => {
155
165
  const bookFilter = bookId ? `bookId:${bookId.split(':')[1]}` : '';
156
166
  const tagFilter = tagIds ? tagIds.map(t => `tagId:${t}`).join(' ') : '';
@@ -176,26 +186,29 @@ You have to retrieve the full note content by calling \`read-note\`.
176
186
  ]
177
187
  };
178
188
  });
179
- server.tool('create-note', 'Create a new note in the database', {
180
- bookId: zod_1.z
181
- .string()
182
- .min(5)
183
- .max(128)
184
- .regex(/^(book:|trash$)/)
185
- .describe('The notebook ID'),
186
- title: zod_1.z.string().max(128).describe('The note title'),
187
- body: zod_1.z
188
- .string()
189
- .max(1048576)
190
- .describe('The content of the note represented with Markdown'),
191
- status: zod_1.z
192
- .enum(['none', 'active', 'onHold', 'completed', 'dropped'])
193
- .optional()
194
- .describe('The status of the note'),
195
- tags: zod_1.z
196
- .array(zod_1.z.string().startsWith('tag:'))
197
- .optional()
198
- .describe('An array of tag IDs to assign to the note. Call `list-tags` or `read-tag` to retrieve available tags. You can create a new tag with `create-tag` tool if necessary.')
189
+ server.registerTool('create-note', {
190
+ description: 'Create a new note in the database',
191
+ inputSchema: {
192
+ bookId: zod_1.z
193
+ .string()
194
+ .min(5)
195
+ .max(128)
196
+ .regex(/^(book:|trash$)/)
197
+ .describe('The notebook ID'),
198
+ title: zod_1.z.string().max(128).describe('The note title'),
199
+ body: zod_1.z
200
+ .string()
201
+ .max(1048576)
202
+ .describe('The content of the note represented with Markdown'),
203
+ status: zod_1.z
204
+ .enum(['none', 'active', 'onHold', 'completed', 'dropped'])
205
+ .optional()
206
+ .describe('The status of the note'),
207
+ tags: zod_1.z
208
+ .array(zod_1.z.string().startsWith('tag:'))
209
+ .optional()
210
+ .describe('An array of tag IDs to assign to the note. Call `list-tags` or `read-tag` to retrieve available tags. You can create a new tag with `create-tag` tool if necessary.')
211
+ }
199
212
  }, async (noteData) => {
200
213
  const res = await (0, api_1.postJSON)(`/notes`, noteData);
201
214
  return {
@@ -207,37 +220,87 @@ server.tool('create-note', 'Create a new note in the database', {
207
220
  ]
208
221
  };
209
222
  });
210
- server.tool('update-note', 'Update the existing note in the database. You should retrieve the existing note with \`read-note\` first. When updating the note, you must specify not only the changed fields but also all the un-changed fields.', {
211
- _id: zod_1.z
212
- .string()
213
- .min(6)
214
- .max(128)
215
- .regex(/^note:/)
216
- .describe('The unique document ID which should start with `note:` and the remains are randomly generated string'),
217
- _rev: zod_1.z
218
- .string()
219
- .describe('This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable).'),
220
- bookId: zod_1.z
221
- .string()
222
- .min(5)
223
- .max(128)
224
- .regex(/^(book:|trash$)/)
225
- .describe('The notebook ID'),
226
- title: zod_1.z.string().max(128).describe('The note title'),
227
- body: zod_1.z
228
- .string()
229
- .max(1048576)
230
- .describe('The content of the note in Markdown. NOTE: Do not escape special characters like `\\n`.'),
231
- status: zod_1.z
232
- .enum(['none', 'active', 'onHold', 'completed', 'dropped'])
233
- .optional()
234
- .describe('The status of the note'),
235
- tags: zod_1.z
236
- .array(zod_1.z.string().startsWith('tag:'))
237
- .optional()
238
- .describe('An array of tag IDs to assign to the note. Call `list-tags` or `read-tag` to retrieve available tags. You can create a new tag with `create-tag` tool if necessary.')
223
+ server.registerTool('update-note', {
224
+ description: 'Update the existing note in the database. Only the fields you provide will be updated; omitted fields remain unchanged.',
225
+ inputSchema: {
226
+ _id: zod_1.z
227
+ .string()
228
+ .min(6)
229
+ .max(128)
230
+ .regex(/^note:/)
231
+ .describe('The unique document ID which should start with `note:` and the remains are randomly generated string'),
232
+ _rev: zod_1.z
233
+ .string()
234
+ .describe('This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable).'),
235
+ bookId: zod_1.z
236
+ .string()
237
+ .min(5)
238
+ .max(128)
239
+ .regex(/^(book:|trash$)/)
240
+ .optional()
241
+ .describe('The notebook ID'),
242
+ title: zod_1.z.string().max(128).optional().describe('The note title'),
243
+ body: zod_1.z
244
+ .string()
245
+ .max(1048576)
246
+ .optional()
247
+ .describe('The content of the note in Markdown. NOTE: Do not escape special characters like `\\n`.'),
248
+ status: zod_1.z
249
+ .enum(['none', 'active', 'onHold', 'completed', 'dropped'])
250
+ .optional()
251
+ .describe('The status of the note'),
252
+ tags: zod_1.z
253
+ .array(zod_1.z.string().startsWith('tag:'))
254
+ .optional()
255
+ .describe('An array of tag IDs to assign to the note. Call `list-tags` or `read-tag` to retrieve available tags. You can create a new tag with `create-tag` tool if necessary.')
256
+ }
239
257
  }, async (noteData) => {
240
- const res = await (0, api_1.postJSON)(`/notes`, noteData);
258
+ const rev = noteData._rev;
259
+ const existingNote = await (0, api_1.fetchJSON)(`/${noteData._id}`, { rev });
260
+ const res = await (0, api_1.postJSON)(`/notes`, {
261
+ ...existingNote,
262
+ ...noteData
263
+ });
264
+ return {
265
+ content: [
266
+ {
267
+ type: 'text',
268
+ text: JSON.stringify(res, null, 2)
269
+ }
270
+ ]
271
+ };
272
+ });
273
+ server.registerTool('patch-note', {
274
+ description: 'Update the body of the existing note by applying a diff patch in the database. You should use this tool when you want to make partial updates to the note body without replacing the entire content because it is much more efficient for saving token window.',
275
+ inputSchema: {
276
+ _id: zod_1.z
277
+ .string()
278
+ .min(6)
279
+ .max(128)
280
+ .regex(/^note:/)
281
+ .describe('The unique document ID which should start with `note:` and the remains are randomly generated string'),
282
+ _rev: zod_1.z
283
+ .string()
284
+ .describe('This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable).'),
285
+ patch: zod_1.z
286
+ .string()
287
+ .describe('A unified diff string to apply to the note body. Use standard unified diff format with `---`/`+++` headers and `@@ -start,count +start,count @@` hunk markers.')
288
+ }
289
+ }, async ({ _id, _rev, patch }) => {
290
+ const existingNote = await (0, api_1.fetchJSON)(`/${_id}`, { rev: _rev });
291
+ const patched = (0, diff_1.applyPatch)(existingNote.body, patch);
292
+ if (patched === false) {
293
+ return {
294
+ content: [
295
+ {
296
+ type: 'text',
297
+ text: 'Failed to apply the patch. The diff may be malformed or does not match the current note body.'
298
+ }
299
+ ],
300
+ isError: true
301
+ };
302
+ }
303
+ const res = await (0, api_1.postJSON)('/notes', { ...existingNote, body: patched });
241
304
  return {
242
305
  content: [
243
306
  {
@@ -247,7 +310,7 @@ server.tool('update-note', 'Update the existing note in the database. You should
247
310
  ]
248
311
  };
249
312
  });
250
- server.tool('list-tags', `Retrieve a list of all tags`, {}, async () => {
313
+ server.registerTool('list-tags', { description: 'Retrieve a list of all tags' }, async () => {
251
314
  const tags = await (0, api_1.fetchJSON)('/tags');
252
315
  return {
253
316
  content: [
@@ -258,10 +321,13 @@ server.tool('list-tags', `Retrieve a list of all tags`, {}, async () => {
258
321
  ]
259
322
  };
260
323
  });
261
- server.tool('read-tag', `Retrieve a single tag`, {
262
- tagId: zod_1.z
263
- .string()
264
- .describe('ID of the tag to retrieve. It can be found as `_id` in the tag docs. It always starts with \`tag:\`.')
324
+ server.registerTool('read-tag', {
325
+ description: 'Retrieve a single tag',
326
+ inputSchema: {
327
+ tagId: zod_1.z
328
+ .string()
329
+ .describe('ID of the tag to retrieve. It can be found as `_id` in the tag docs. It always starts with \`tag:\`.')
330
+ }
265
331
  }, async ({ tagId }) => {
266
332
  if (!tagId.startsWith('tag:'))
267
333
  tagId = `tag:${tagId}`;
@@ -276,12 +342,15 @@ server.tool('read-tag', `Retrieve a single tag`, {
276
342
  };
277
343
  });
278
344
  const TagColors = Object.values(inkdrop_model_1.TAG_COLOR);
279
- server.tool('create-tag', 'Create a new tag in the database', {
280
- color: zod_1.z
281
- .enum(TagColors)
282
- .default('default')
283
- .describe('The color type of the tag'),
284
- name: zod_1.z.string().max(64).describe('The name of the tag')
345
+ server.registerTool('create-tag', {
346
+ description: 'Create a new tag in the database',
347
+ inputSchema: {
348
+ color: zod_1.z
349
+ .enum(TagColors)
350
+ .default('default')
351
+ .describe('The color type of the tag'),
352
+ name: zod_1.z.string().max(64).describe('The name of the tag')
353
+ }
285
354
  }, async (tagData) => {
286
355
  const res = await (0, api_1.postJSON)(`/tags`, tagData);
287
356
  return {
@@ -293,21 +362,24 @@ server.tool('create-tag', 'Create a new tag in the database', {
293
362
  ]
294
363
  };
295
364
  });
296
- server.tool('update-tag', 'Update the existing tag in the database. You should retrieve the existing tag with \`list-tags\` first. When updating the tag, you must specify not only the changed fields but also all the un-changed fields.', {
297
- _id: zod_1.z
298
- .string()
299
- .min(6)
300
- .max(128)
301
- .regex(/^tag:/)
302
- .describe('The unique document ID which should start with `tag:` and the remains are randomly generated string'),
303
- _rev: zod_1.z
304
- .string()
305
- .describe('This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable).'),
306
- color: zod_1.z
307
- .enum(TagColors)
308
- .default('default')
309
- .describe('The color type of the tag'),
310
- name: zod_1.z.string().max(64).describe('The name of the tag')
365
+ server.registerTool('update-tag', {
366
+ description: 'Update the existing tag in the database. You should retrieve the existing tag with \`list-tags\` first. When updating the tag, you must specify not only the changed fields but also all the un-changed fields.',
367
+ inputSchema: {
368
+ _id: zod_1.z
369
+ .string()
370
+ .min(6)
371
+ .max(128)
372
+ .regex(/^tag:/)
373
+ .describe('The unique document ID which should start with `tag:` and the remains are randomly generated string'),
374
+ _rev: zod_1.z
375
+ .string()
376
+ .describe('This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable).'),
377
+ color: zod_1.z
378
+ .enum(TagColors)
379
+ .default('default')
380
+ .describe('The color type of the tag'),
381
+ name: zod_1.z.string().max(64).describe('The name of the tag')
382
+ }
311
383
  }, async (tagData) => {
312
384
  const res = await (0, api_1.postJSON)(`/tags`, tagData);
313
385
  return {
@@ -319,7 +391,7 @@ server.tool('update-tag', 'Update the existing tag in the database. You should r
319
391
  ]
320
392
  };
321
393
  });
322
- server.tool('list-notebooks', `Retrieve a list of all notebooks`, {}, async () => {
394
+ server.registerTool('list-notebooks', { description: 'Retrieve a list of all notebooks' }, async () => {
323
395
  const books = await (0, api_1.fetchJSON)('/books');
324
396
  return {
325
397
  content: [
@@ -330,10 +402,13 @@ server.tool('list-notebooks', `Retrieve a list of all notebooks`, {}, async () =
330
402
  ]
331
403
  };
332
404
  });
333
- server.tool('read-book', `Retrieve a single book`, {
334
- bookId: zod_1.z
335
- .string()
336
- .describe('ID of the book to retrieve. It can be found as `_id` in the book docs. It always starts with \`book:\`.')
405
+ server.registerTool('read-book', {
406
+ description: 'Retrieve a single book',
407
+ inputSchema: {
408
+ bookId: zod_1.z
409
+ .string()
410
+ .describe('ID of the book to retrieve. It can be found as `_id` in the book docs. It always starts with \`book:\`.')
411
+ }
337
412
  }, async ({ bookId }) => {
338
413
  if (!bookId.startsWith('book:'))
339
414
  bookId = `book:${bookId}`;
@@ -347,7 +422,7 @@ server.tool('read-book', `Retrieve a single book`, {
347
422
  ]
348
423
  };
349
424
  });
350
- server.prompt('inkdrop-prompt', 'Instructions for using the Inkdrop MCP server effectively', () => ({
425
+ server.registerPrompt('inkdrop-prompt', { description: 'Instructions for using the Inkdrop MCP server effectively' }, () => ({
351
426
  messages: [
352
427
  {
353
428
  role: 'assistant',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkdropapp/mcp-server",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Inkdrop Model Context Protocol Server",
5
5
  "bin": {
6
6
  "inkdrop-mcp-server": "dist/index.js"
@@ -24,14 +24,15 @@
24
24
  "author": "Takuya Matsuyama<contact@inkdrop.app>",
25
25
  "license": "Apache-2.0",
26
26
  "dependencies": {
27
- "@modelcontextprotocol/sdk": "^1.6.1",
27
+ "@modelcontextprotocol/sdk": "^1.26.0",
28
28
  "ajv": "^8.17.1",
29
- "inkdrop-model": "^2.8.0",
30
- "zod": "^3.24.2"
29
+ "diff": "^8.0.3",
30
+ "inkdrop-model": "^2.11.1",
31
+ "zod": "^4.3.6"
31
32
  },
32
33
  "devDependencies": {
33
- "@types/node": "^22.13.9",
34
- "prettier": "^3.5.3",
35
- "typescript": "^5.8.2"
34
+ "@types/node": "^25.2.3",
35
+ "prettier": "^3.8.1",
36
+ "typescript": "^5.9.3"
36
37
  }
37
38
  }
package/src/index.ts CHANGED
@@ -15,14 +15,15 @@ import {
15
15
  Tag
16
16
  } from 'inkdrop-model'
17
17
  import { z } from 'zod'
18
+ import { applyPatch } from 'diff'
18
19
  import { fetchJSON, postJSON } from './api'
19
20
 
20
21
  const server = new McpServer({
21
22
  name: 'Inkdrop',
22
- version: '1.0.0'
23
+ version: '1.3.0'
23
24
  })
24
25
 
25
- server.resource(
26
+ server.registerResource(
26
27
  'note',
27
28
  new ResourceTemplate('inkdrop://note/{noteId}', { list: undefined }),
28
29
  {
@@ -43,15 +44,18 @@ server.resource(
43
44
  }
44
45
  )
45
46
 
46
- server.tool(
47
+ server.registerTool(
47
48
  'read-note',
48
- 'Retrieve the complete contents of the note by its ID from the database.',
49
49
  {
50
- noteId: z
51
- .string()
52
- .describe(
53
- 'ID of the note to retrieve. It can be found as `_id` in the note docs. It always starts with \`note:\`.'
54
- )
50
+ description:
51
+ 'Retrieve the complete contents of the note by its ID from the database.',
52
+ inputSchema: {
53
+ noteId: z
54
+ .string()
55
+ .describe(
56
+ 'ID of the note to retrieve. It can be found as `_id` in the note docs. It always starts with \`note:\`.'
57
+ )
58
+ }
55
59
  },
56
60
  async ({ noteId }) => {
57
61
  if (!noteId.startsWith('note:')) noteId = `note:${noteId}`
@@ -67,9 +71,10 @@ server.tool(
67
71
  }
68
72
  )
69
73
 
70
- server.tool(
74
+ server.registerTool(
71
75
  'search-notes',
72
- `List all notes that contain a given keyword.
76
+ {
77
+ description: `List all notes that contain a given keyword.
73
78
  The result does not include entire note bodies as they are truncated in 200 characters.
74
79
  You have to retrieve the full note content by calling \`read-note\`.
75
80
  Here are tips to specify keywords effectively:
@@ -78,18 +83,18 @@ Here are tips to specify keywords effectively:
78
83
 
79
84
  You can use special qualifiers to get more accurate results. See the qualifiers and their usage examples:
80
85
 
81
- - **book**
86
+ - **book**
82
87
  \`book:Blog\`: Searches for notes in the 'Blog' notebook.
83
88
  \`book:"Desktop App"\`: Searches for notes in the 'Desktop App' notebook.
84
89
  - **bookId**
85
90
  \`bookId:kGlLniaV\`: Searches for notes in the notebook ID 'book:kGlLniaV'.
86
- - **tag**
91
+ - **tag**
87
92
  \`tag:JavaScript\`: Searches for all notes having the 'JavaScript' tag. Read more about [tags](https://docs.inkdrop.app/manual/write-notes#tag-notes).
88
- - **status**
93
+ - **status**
89
94
  \`status:onHold\`: Searches for all notes with the 'On hold' status. Read more about [statuses](/reference/note-statuses).
90
- - **title**
95
+ - **title**
91
96
  \`title:"JavaScript setTimeout"\`: Searches for the note with the specified title.
92
- - **body**
97
+ - **body**
93
98
  \`body:KEYWORD\`: Searches for a specific word in all notes. Equivalent to a [global search](#search-for-notes-across-all-notebooks).
94
99
 
95
100
  ### Combine qualifiers
@@ -130,14 +135,15 @@ Note that you can't specify excluding modifiers only without including condition
130
135
 
131
136
  **WARNING**: Make sure to enter a text to search for after the exclusion modifier.
132
137
 
133
- - ✅ Will work
138
+ - ✅ Will work
134
139
  \`-book:Backend "closure functions"\`
135
140
 
136
- - ⛔️ Won't work
141
+ - ⛔️ Won't work
137
142
  \`-book:Backend\`. There's no query. Inkdrop doesn't understand what to search for.
138
143
  `,
139
- {
140
- keyword: z.string().describe(`Keyword to search for.`)
144
+ inputSchema: {
145
+ keyword: z.string().describe(`Keyword to search for.`)
146
+ }
141
147
  },
142
148
  async ({ keyword }) => {
143
149
  const notes: Note[] = await fetchJSON('/notes', { keyword, limit: 10 })
@@ -158,37 +164,39 @@ Note that you can't specify excluding modifiers only without including condition
158
164
  }
159
165
  )
160
166
 
161
- server.tool(
167
+ server.registerTool(
162
168
  'list-notes',
163
- `List all notes with specified conditions.
169
+ {
170
+ description: `List all notes with specified conditions.
164
171
  The result does not include entire note bodies as they are truncated in 200 characters.
165
172
  You have to retrieve the full note content by calling \`read-note\`.
166
173
  `,
167
- {
168
- bookId: z
169
- .string()
170
- .optional()
171
- .describe(
172
- `ID of the notebook. It always starts with 'book:'. You can retrieve a list of notebooks with \`list-notebooks\``
173
- ),
174
- tagIds: z
175
- .array(z.string())
176
- .optional()
177
- .default([])
178
- .describe(
179
- `An array of tag IDs to filter. It always starts with 'tag:'. You can retrieve a list of available tags from \`list-tags\`.`
180
- ),
181
- keyword: z.string().optional().describe(`Keyword to filter notes`),
182
- sort: z
183
- .enum(['updatedAt', 'createdAt', 'title'])
184
- .optional()
185
- .default('updatedAt')
186
- .describe(`Sort the documents by the specified field`),
187
- descending: z
188
- .boolean()
189
- .optional()
190
- .default(true)
191
- .describe(`Reverse the order of the output documents`)
174
+ inputSchema: {
175
+ bookId: z
176
+ .string()
177
+ .optional()
178
+ .describe(
179
+ `ID of the notebook. It always starts with 'book:'. You can retrieve a list of notebooks with \`list-notebooks\``
180
+ ),
181
+ tagIds: z
182
+ .array(z.string())
183
+ .optional()
184
+ .default([])
185
+ .describe(
186
+ `An array of tag IDs to filter. It always starts with 'tag:'. You can retrieve a list of available tags from \`list-tags\`.`
187
+ ),
188
+ keyword: z.string().optional().describe(`Keyword to filter notes`),
189
+ sort: z
190
+ .enum(['updatedAt', 'createdAt', 'title'])
191
+ .optional()
192
+ .default('updatedAt')
193
+ .describe(`Sort the documents by the specified field`),
194
+ descending: z
195
+ .boolean()
196
+ .optional()
197
+ .default(true)
198
+ .describe(`Reverse the order of the output documents`)
199
+ }
192
200
  },
193
201
  async ({ bookId, tagIds, keyword, sort, descending }) => {
194
202
  const bookFilter = bookId ? `bookId:${bookId.split(':')[1]}` : ''
@@ -217,35 +225,37 @@ You have to retrieve the full note content by calling \`read-note\`.
217
225
  }
218
226
  )
219
227
 
220
- server.tool(
228
+ server.registerTool(
221
229
  'create-note',
222
- 'Create a new note in the database',
223
230
  {
224
- bookId: z
225
- .string()
226
- .min(5)
227
- .max(128)
228
- .regex(/^(book:|trash$)/)
229
- .describe('The notebook ID'),
230
-
231
- title: z.string().max(128).describe('The note title'),
232
-
233
- body: z
234
- .string()
235
- .max(1048576)
236
- .describe('The content of the note represented with Markdown'),
237
-
238
- status: z
239
- .enum(['none', 'active', 'onHold', 'completed', 'dropped'])
240
- .optional()
241
- .describe('The status of the note'),
242
-
243
- tags: z
244
- .array(z.string().startsWith('tag:'))
245
- .optional()
246
- .describe(
247
- 'An array of tag IDs to assign to the note. Call `list-tags` or `read-tag` to retrieve available tags. You can create a new tag with `create-tag` tool if necessary.'
248
- )
231
+ description: 'Create a new note in the database',
232
+ inputSchema: {
233
+ bookId: z
234
+ .string()
235
+ .min(5)
236
+ .max(128)
237
+ .regex(/^(book:|trash$)/)
238
+ .describe('The notebook ID'),
239
+
240
+ title: z.string().max(128).describe('The note title'),
241
+
242
+ body: z
243
+ .string()
244
+ .max(1048576)
245
+ .describe('The content of the note represented with Markdown'),
246
+
247
+ status: z
248
+ .enum(['none', 'active', 'onHold', 'completed', 'dropped'])
249
+ .optional()
250
+ .describe('The status of the note'),
251
+
252
+ tags: z
253
+ .array(z.string().startsWith('tag:'))
254
+ .optional()
255
+ .describe(
256
+ 'An array of tag IDs to assign to the note. Call `list-tags` or `read-tag` to retrieve available tags. You can create a new tag with `create-tag` tool if necessary.'
257
+ )
258
+ }
249
259
  },
250
260
  async noteData => {
251
261
  const res = await postJSON(`/notes`, noteData)
@@ -260,55 +270,66 @@ server.tool(
260
270
  }
261
271
  )
262
272
 
263
- server.tool(
273
+ server.registerTool(
264
274
  'update-note',
265
- 'Update the existing note in the database. You should retrieve the existing note with \`read-note\` first. When updating the note, you must specify not only the changed fields but also all the un-changed fields.',
266
275
  {
267
- _id: z
268
- .string()
269
- .min(6)
270
- .max(128)
271
- .regex(/^note:/)
272
- .describe(
273
- 'The unique document ID which should start with `note:` and the remains are randomly generated string'
274
- ),
275
-
276
- _rev: z
277
- .string()
278
- .describe(
279
- 'This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable).'
280
- ),
281
-
282
- bookId: z
283
- .string()
284
- .min(5)
285
- .max(128)
286
- .regex(/^(book:|trash$)/)
287
- .describe('The notebook ID'),
288
-
289
- title: z.string().max(128).describe('The note title'),
290
-
291
- body: z
292
- .string()
293
- .max(1048576)
294
- .describe(
295
- 'The content of the note in Markdown. NOTE: Do not escape special characters like `\\n`.'
296
- ),
297
-
298
- status: z
299
- .enum(['none', 'active', 'onHold', 'completed', 'dropped'])
300
- .optional()
301
- .describe('The status of the note'),
302
-
303
- tags: z
304
- .array(z.string().startsWith('tag:'))
305
- .optional()
306
- .describe(
307
- 'An array of tag IDs to assign to the note. Call `list-tags` or `read-tag` to retrieve available tags. You can create a new tag with `create-tag` tool if necessary.'
308
- )
276
+ description:
277
+ 'Update the existing note in the database. Only the fields you provide will be updated; omitted fields remain unchanged.',
278
+ inputSchema: {
279
+ _id: z
280
+ .string()
281
+ .min(6)
282
+ .max(128)
283
+ .regex(/^note:/)
284
+ .describe(
285
+ 'The unique document ID which should start with `note:` and the remains are randomly generated string'
286
+ ),
287
+
288
+ _rev: z
289
+ .string()
290
+ .describe(
291
+ 'This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable).'
292
+ ),
293
+
294
+ bookId: z
295
+ .string()
296
+ .min(5)
297
+ .max(128)
298
+ .regex(/^(book:|trash$)/)
299
+ .optional()
300
+ .describe('The notebook ID'),
301
+
302
+ title: z.string().max(128).optional().describe('The note title'),
303
+
304
+ body: z
305
+ .string()
306
+ .max(1048576)
307
+ .optional()
308
+ .describe(
309
+ 'The content of the note in Markdown. NOTE: Do not escape special characters like `\\n`.'
310
+ ),
311
+
312
+ status: z
313
+ .enum(['none', 'active', 'onHold', 'completed', 'dropped'])
314
+ .optional()
315
+ .describe('The status of the note'),
316
+
317
+ tags: z
318
+ .array(z.string().startsWith('tag:'))
319
+ .optional()
320
+ .describe(
321
+ 'An array of tag IDs to assign to the note. Call `list-tags` or `read-tag` to retrieve available tags. You can create a new tag with `create-tag` tool if necessary.'
322
+ )
323
+ }
309
324
  },
310
325
  async noteData => {
311
- const res = await postJSON(`/notes`, noteData)
326
+ const rev = noteData._rev
327
+ const existingNote = await fetchJSON<Note>(`/${noteData._id}`, { rev })
328
+
329
+ const res = await postJSON(`/notes`, {
330
+ ...existingNote,
331
+ ...noteData
332
+ })
312
333
  return {
313
334
  content: [
314
335
  {
@@ -320,27 +341,87 @@ server.tool(
320
341
  }
321
342
  )
322
343
 
323
- server.tool('list-tags', `Retrieve a list of all tags`, {}, async () => {
324
- const tags: Tag[] = await fetchJSON('/tags')
325
- return {
326
- content: [
327
- {
328
- type: 'text',
329
- text: JSON.stringify(tags, null, 2)
344
+ server.registerTool(
345
+ 'patch-note',
346
+ {
347
+ description:
348
+ 'Update the body of the existing note by applying a diff patch in the database. You should use this tool when you want to make partial updates to the note body without replacing the entire content because it is much more efficient for saving token window.',
349
+ inputSchema: {
350
+ _id: z
351
+ .string()
352
+ .min(6)
353
+ .max(128)
354
+ .regex(/^note:/)
355
+ .describe(
356
+ 'The unique document ID which should start with `note:` and the remains are randomly generated string'
357
+ ),
358
+
359
+ _rev: z
360
+ .string()
361
+ .describe(
362
+ 'This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable).'
363
+ ),
364
+
365
+ patch: z
366
+ .string()
367
+ .describe(
368
+ 'A unified diff string to apply to the note body. Use standard unified diff format with `---`/`+++` headers and `@@ -start,count +start,count @@` hunk markers.'
369
+ )
370
+ }
371
+ },
372
+ async ({ _id, _rev, patch }) => {
373
+ const existingNote = await fetchJSON<Note>(`/${_id}`, { rev: _rev })
374
+ const patched = applyPatch(existingNote.body, patch)
375
+ if (patched === false) {
376
+ return {
377
+ content: [
378
+ {
379
+ type: 'text',
380
+ text: 'Failed to apply the patch. The diff may be malformed or does not match the current note body.'
381
+ }
382
+ ],
383
+ isError: true
330
384
  }
331
- ]
385
+ }
386
+ const res = await postJSON('/notes', { ...existingNote, body: patched })
387
+ return {
388
+ content: [
389
+ {
390
+ type: 'text',
391
+ text: JSON.stringify(res, null, 2)
392
+ }
393
+ ]
394
+ }
332
395
  }
333
- })
396
+ )
397
+
398
+ server.registerTool(
399
+ 'list-tags',
400
+ { description: 'Retrieve a list of all tags' },
401
+ async () => {
402
+ const tags: Tag[] = await fetchJSON('/tags')
403
+ return {
404
+ content: [
405
+ {
406
+ type: 'text',
407
+ text: JSON.stringify(tags, null, 2)
408
+ }
409
+ ]
410
+ }
411
+ }
412
+ )
334
413
 
335
- server.tool(
414
+ server.registerTool(
336
415
  'read-tag',
337
- `Retrieve a single tag`,
338
416
  {
339
- tagId: z
340
- .string()
341
- .describe(
342
- 'ID of the tag to retrieve. It can be found as `_id` in the tag docs. It always starts with \`tag:\`.'
343
- )
417
+ description: 'Retrieve a single tag',
418
+ inputSchema: {
419
+ tagId: z
420
+ .string()
421
+ .describe(
422
+ 'ID of the tag to retrieve. It can be found as `_id` in the tag docs. It always starts with \`tag:\`.'
423
+ )
424
+ }
344
425
  },
345
426
  async ({ tagId }) => {
346
427
  if (!tagId.startsWith('tag:')) tagId = `tag:${tagId}`
@@ -358,16 +439,18 @@ server.tool(
358
439
 
359
440
  const TagColors = Object.values(TAG_COLOR) as [string, ...string[]]
360
441
 
361
- server.tool(
442
+ server.registerTool(
362
443
  'create-tag',
363
- 'Create a new tag in the database',
364
444
  {
365
- color: z
366
- .enum(TagColors)
367
- .default('default')
368
- .describe('The color type of the tag'),
369
-
370
- name: z.string().max(64).describe('The name of the tag')
445
+ description: 'Create a new tag in the database',
446
+ inputSchema: {
447
+ color: z
448
+ .enum(TagColors)
449
+ .default('default')
450
+ .describe('The color type of the tag'),
451
+
452
+ name: z.string().max(64).describe('The name of the tag')
453
+ }
371
454
  },
372
455
  async tagData => {
373
456
  const res = await postJSON(`/tags`, tagData)
@@ -382,31 +465,34 @@ server.tool(
382
465
  }
383
466
  )
384
467
 
385
- server.tool(
468
+ server.registerTool(
386
469
  'update-tag',
387
- 'Update the existing tag in the database. You should retrieve the existing tag with \`list-tags\` first. When updating the tag, you must specify not only the changed fields but also all the un-changed fields.',
388
470
  {
389
- _id: z
390
- .string()
391
- .min(6)
392
- .max(128)
393
- .regex(/^tag:/)
394
- .describe(
395
- 'The unique document ID which should start with `tag:` and the remains are randomly generated string'
396
- ),
397
-
398
- _rev: z
399
- .string()
400
- .describe(
401
- 'This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable).'
402
- ),
403
-
404
- color: z
405
- .enum(TagColors)
406
- .default('default')
407
- .describe('The color type of the tag'),
408
-
409
- name: z.string().max(64).describe('The name of the tag')
471
+ description:
472
+ 'Update the existing tag in the database. You should retrieve the existing tag with \`list-tags\` first. When updating the tag, you must specify not only the changed fields but also all the un-changed fields.',
473
+ inputSchema: {
474
+ _id: z
475
+ .string()
476
+ .min(6)
477
+ .max(128)
478
+ .regex(/^tag:/)
479
+ .describe(
480
+ 'The unique document ID which should start with `tag:` and the remains are randomly generated string'
481
+ ),
482
+
483
+ _rev: z
484
+ .string()
485
+ .describe(
486
+ 'This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable).'
487
+ ),
488
+
489
+ color: z
490
+ .enum(TagColors)
491
+ .default('default')
492
+ .describe('The color type of the tag'),
493
+
494
+ name: z.string().max(64).describe('The name of the tag')
495
+ }
410
496
  },
411
497
  async tagData => {
412
498
  const res = await postJSON(`/tags`, tagData)
@@ -421,10 +507,9 @@ server.tool(
421
507
  }
422
508
  )
423
509
 
424
- server.tool(
510
+ server.registerTool(
425
511
  'list-notebooks',
426
- `Retrieve a list of all notebooks`,
427
- {},
512
+ { description: 'Retrieve a list of all notebooks' },
428
513
  async () => {
429
514
  const books: Book[] = await fetchJSON('/books')
430
515
  return {
@@ -438,15 +523,17 @@ server.tool(
438
523
  }
439
524
  )
440
525
 
441
- server.tool(
526
+ server.registerTool(
442
527
  'read-book',
443
- `Retrieve a single book`,
444
528
  {
445
- bookId: z
446
- .string()
447
- .describe(
448
- 'ID of the book to retrieve. It can be found as `_id` in the book docs. It always starts with \`book:\`.'
449
- )
529
+ description: 'Retrieve a single book',
530
+ inputSchema: {
531
+ bookId: z
532
+ .string()
533
+ .describe(
534
+ 'ID of the book to retrieve. It can be found as `_id` in the book docs. It always starts with \`book:\`.'
535
+ )
536
+ }
450
537
  },
451
538
  async ({ bookId }) => {
452
539
  if (!bookId.startsWith('book:')) bookId = `book:${bookId}`
@@ -462,9 +549,9 @@ server.tool(
462
549
  }
463
550
  )
464
551
 
465
- server.prompt(
552
+ server.registerPrompt(
466
553
  'inkdrop-prompt',
467
- 'Instructions for using the Inkdrop MCP server effectively',
554
+ { description: 'Instructions for using the Inkdrop MCP server effectively' },
468
555
  () => ({
469
556
  messages: [
470
557
  {
package/tsconfig.json CHANGED
@@ -14,7 +14,8 @@
14
14
  "moduleResolution": "nodenext",
15
15
  "allowSyntheticDefaultImports": true,
16
16
  "resolveJsonModule": true,
17
- "declaration": false
17
+ "declaration": false,
18
+ "skipLibCheck": true
18
19
  },
19
20
  "include": [
20
21
  "src/*.ts"