@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.
- package/.claude/settings.local.json +7 -0
- package/README.md +16 -11
- package/dist/index.js +195 -120
- package/package.json +8 -7
- package/src/index.ts +265 -178
- package/tsconfig.json +2 -1
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/
|
|
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. **`
|
|
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
|
-
- `
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
- `
|
|
80
|
-
|
|
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
|
-
|
|
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.
|
|
12
|
+
version: '1.3.0'
|
|
12
13
|
});
|
|
13
|
-
server.
|
|
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.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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.
|
|
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
|
-
|
|
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.
|
|
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
|
-
|
|
135
|
-
.
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
.
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
.
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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.
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
.
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
.string()
|
|
189
|
-
.
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
.
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
.
|
|
198
|
-
|
|
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.
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
.
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
.
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
.max(
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
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
|
|
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.
|
|
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.
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
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.
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
.
|
|
283
|
-
|
|
284
|
-
|
|
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.
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
.
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
.
|
|
309
|
-
|
|
310
|
-
|
|
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.
|
|
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.
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
27
|
+
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
28
28
|
"ajv": "^8.17.1",
|
|
29
|
-
"
|
|
30
|
-
"
|
|
29
|
+
"diff": "^8.0.3",
|
|
30
|
+
"inkdrop-model": "^2.11.1",
|
|
31
|
+
"zod": "^4.3.6"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
|
-
"@types/node": "^
|
|
34
|
-
"prettier": "^3.
|
|
35
|
-
"typescript": "^5.
|
|
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.
|
|
23
|
+
version: '1.3.0'
|
|
23
24
|
})
|
|
24
25
|
|
|
25
|
-
server.
|
|
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.
|
|
47
|
+
server.registerTool(
|
|
47
48
|
'read-note',
|
|
48
|
-
'Retrieve the complete contents of the note by its ID from the database.',
|
|
49
49
|
{
|
|
50
|
-
|
|
51
|
-
.
|
|
52
|
-
|
|
53
|
-
|
|
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.
|
|
74
|
+
server.registerTool(
|
|
71
75
|
'search-notes',
|
|
72
|
-
|
|
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
|
-
|
|
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.
|
|
167
|
+
server.registerTool(
|
|
162
168
|
'list-notes',
|
|
163
|
-
|
|
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
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
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.
|
|
228
|
+
server.registerTool(
|
|
221
229
|
'create-note',
|
|
222
|
-
'Create a new note in the database',
|
|
223
230
|
{
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
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.
|
|
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
|
-
|
|
268
|
-
.
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
.max(
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
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
|
|
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.
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
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.
|
|
414
|
+
server.registerTool(
|
|
336
415
|
'read-tag',
|
|
337
|
-
`Retrieve a single tag`,
|
|
338
416
|
{
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
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.
|
|
442
|
+
server.registerTool(
|
|
362
443
|
'create-tag',
|
|
363
|
-
'Create a new tag in the database',
|
|
364
444
|
{
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
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.
|
|
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
|
-
|
|
390
|
-
.
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
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.
|
|
510
|
+
server.registerTool(
|
|
425
511
|
'list-notebooks',
|
|
426
|
-
|
|
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.
|
|
526
|
+
server.registerTool(
|
|
442
527
|
'read-book',
|
|
443
|
-
`Retrieve a single book`,
|
|
444
528
|
{
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
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.
|
|
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
|
{
|