@inkdropapp/mcp-server 1.2.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +7 -0
- package/README.md +17 -11
- package/dist/index.js +226 -122
- package/package.json +7 -7
- package/src/index.ts +305 -180
- 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,36 @@ 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 performing an exact string replacement. More efficient than `update-note` for small edits to large notes as it saves tokens. You must first read the note with `read-note` to get the current body.
|
|
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
|
+
- `old_string`: The exact text to find in the note body. Must match exactly one occurrence. Include enough surrounding context to ensure a unique match.
|
|
77
|
+
- `new_string`: The text to replace `old_string` with. Use an empty string to delete the matched text.
|
|
78
|
+
7. **`list-notebooks`**: Retrieve a list of all notebooks.
|
|
79
|
+
8. **`read-book`**: Retrieve a single notebook by its ID.
|
|
78
80
|
- Required inputs:
|
|
79
|
-
- `
|
|
80
|
-
|
|
81
|
+
- `bookId`: The notebook ID. Must start with 'book:'.
|
|
82
|
+
9. **`list-tags`**: Retrieve a list of all tags.
|
|
83
|
+
10. **`read-tag`**: Retrieve a single tag by its ID.
|
|
84
|
+
- Required inputs:
|
|
85
|
+
- `tagId`: The tag ID. Must start with 'tag:'.
|
|
86
|
+
11. **`create-tag`**: Create a new tag in the database.
|
|
81
87
|
- Required inputs:
|
|
82
88
|
- `name`: The name of the tag.
|
|
83
89
|
- Optional inputs:
|
|
84
90
|
- `color`: The color type of the tag (`default`, `red`, `orange`, `yellow`, `olive`, `green`, `teal`, `blue`, `violet`, `purple`, `pink`, `brown`, `grey`, `black`). Default: `default`.
|
|
85
|
-
|
|
91
|
+
12. **`update-tag`**: Update an existing tag in the database.
|
|
86
92
|
- Required inputs:
|
|
87
93
|
- `_id`: The tag ID. Must start with 'tag:'.
|
|
88
94
|
- `_rev`: The revision ID (CouchDB MVCC-token).
|
package/dist/index.js
CHANGED
|
@@ -8,9 +8,9 @@ const zod_1 = require("zod");
|
|
|
8
8
|
const api_1 = require("./api");
|
|
9
9
|
const server = new mcp_js_1.McpServer({
|
|
10
10
|
name: 'Inkdrop',
|
|
11
|
-
version: '1.
|
|
11
|
+
version: '1.3.0'
|
|
12
12
|
});
|
|
13
|
-
server.
|
|
13
|
+
server.registerResource('note', new mcp_js_1.ResourceTemplate('inkdrop://note/{noteId}', { list: undefined }), {
|
|
14
14
|
description: 'A note data',
|
|
15
15
|
mimeType: 'application/json'
|
|
16
16
|
}, async (uri, { noteId }) => {
|
|
@@ -25,10 +25,13 @@ server.resource('note', new mcp_js_1.ResourceTemplate('inkdrop://note/{noteId}',
|
|
|
25
25
|
]
|
|
26
26
|
};
|
|
27
27
|
});
|
|
28
|
-
server.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
server.registerTool('read-note', {
|
|
29
|
+
description: 'Retrieve the complete contents of the note by its ID from the database.',
|
|
30
|
+
inputSchema: {
|
|
31
|
+
noteId: zod_1.z
|
|
32
|
+
.string()
|
|
33
|
+
.describe('ID of the note to retrieve. It can be found as `_id` in the note docs. It always starts with \`note:\`.')
|
|
34
|
+
}
|
|
32
35
|
}, async ({ noteId }) => {
|
|
33
36
|
if (!noteId.startsWith('note:'))
|
|
34
37
|
noteId = `note:${noteId}`;
|
|
@@ -42,7 +45,8 @@ server.tool('read-note', 'Retrieve the complete contents of the note by its ID f
|
|
|
42
45
|
]
|
|
43
46
|
};
|
|
44
47
|
});
|
|
45
|
-
server.
|
|
48
|
+
server.registerTool('search-notes', {
|
|
49
|
+
description: `List all notes that contain a given keyword.
|
|
46
50
|
The result does not include entire note bodies as they are truncated in 200 characters.
|
|
47
51
|
You have to retrieve the full note content by calling \`read-note\`.
|
|
48
52
|
Here are tips to specify keywords effectively:
|
|
@@ -51,18 +55,18 @@ Here are tips to specify keywords effectively:
|
|
|
51
55
|
|
|
52
56
|
You can use special qualifiers to get more accurate results. See the qualifiers and their usage examples:
|
|
53
57
|
|
|
54
|
-
- **book**
|
|
58
|
+
- **book**
|
|
55
59
|
\`book:Blog\`: Searches for notes in the 'Blog' notebook.
|
|
56
60
|
\`book:"Desktop App"\`: Searches for notes in the 'Desktop App' notebook.
|
|
57
61
|
- **bookId**
|
|
58
62
|
\`bookId:kGlLniaV\`: Searches for notes in the notebook ID 'book:kGlLniaV'.
|
|
59
|
-
- **tag**
|
|
63
|
+
- **tag**
|
|
60
64
|
\`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**
|
|
65
|
+
- **status**
|
|
62
66
|
\`status:onHold\`: Searches for all notes with the 'On hold' status. Read more about [statuses](/reference/note-statuses).
|
|
63
|
-
- **title**
|
|
67
|
+
- **title**
|
|
64
68
|
\`title:"JavaScript setTimeout"\`: Searches for the note with the specified title.
|
|
65
|
-
- **body**
|
|
69
|
+
- **body**
|
|
66
70
|
\`body:KEYWORD\`: Searches for a specific word in all notes. Equivalent to a [global search](#search-for-notes-across-all-notebooks).
|
|
67
71
|
|
|
68
72
|
### Combine qualifiers
|
|
@@ -103,13 +107,15 @@ Note that you can't specify excluding modifiers only without including condition
|
|
|
103
107
|
|
|
104
108
|
**WARNING**: Make sure to enter a text to search for after the exclusion modifier.
|
|
105
109
|
|
|
106
|
-
- ✅ Will work
|
|
110
|
+
- ✅ Will work
|
|
107
111
|
\`-book:Backend "closure functions"\`
|
|
108
112
|
|
|
109
|
-
- ⛔️ Won't work
|
|
113
|
+
- ⛔️ Won't work
|
|
110
114
|
\`-book:Backend\`. There's no query. Inkdrop doesn't understand what to search for.
|
|
111
|
-
`,
|
|
112
|
-
|
|
115
|
+
`,
|
|
116
|
+
inputSchema: {
|
|
117
|
+
keyword: zod_1.z.string().describe(`Keyword to search for.`)
|
|
118
|
+
}
|
|
113
119
|
}, async ({ keyword }) => {
|
|
114
120
|
const notes = await (0, api_1.fetchJSON)('/notes', { keyword, limit: 10 });
|
|
115
121
|
const summaries = notes.map(note => {
|
|
@@ -127,31 +133,39 @@ Note that you can't specify excluding modifiers only without including condition
|
|
|
127
133
|
]
|
|
128
134
|
};
|
|
129
135
|
});
|
|
130
|
-
server.
|
|
136
|
+
server.registerTool('list-notes', {
|
|
137
|
+
description: `List all notes with specified conditions.
|
|
131
138
|
The result does not include entire note bodies as they are truncated in 200 characters.
|
|
132
139
|
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
|
-
|
|
154
|
-
|
|
140
|
+
`,
|
|
141
|
+
inputSchema: {
|
|
142
|
+
bookId: zod_1.z
|
|
143
|
+
.string()
|
|
144
|
+
.optional()
|
|
145
|
+
.describe(`ID of the notebook. It always starts with 'book:'. You can retrieve a list of notebooks with \`list-notebooks\``),
|
|
146
|
+
tagIds: zod_1.z
|
|
147
|
+
.array(zod_1.z.string())
|
|
148
|
+
.optional()
|
|
149
|
+
.default([])
|
|
150
|
+
.describe(`An array of tag IDs to filter. It always starts with 'tag:'. You can retrieve a list of available tags from \`list-tags\`.`),
|
|
151
|
+
keyword: zod_1.z.string().optional().describe(`Keyword to filter notes`),
|
|
152
|
+
sort: zod_1.z
|
|
153
|
+
.enum(['updatedAt', 'createdAt', 'title'])
|
|
154
|
+
.optional()
|
|
155
|
+
.default('updatedAt')
|
|
156
|
+
.describe(`Sort the documents by the specified field`),
|
|
157
|
+
descending: zod_1.z
|
|
158
|
+
.boolean()
|
|
159
|
+
.optional()
|
|
160
|
+
.default(true)
|
|
161
|
+
.describe(`Reverse the order of the output documents`),
|
|
162
|
+
limit: zod_1.z
|
|
163
|
+
.number()
|
|
164
|
+
.optional()
|
|
165
|
+
.default(100)
|
|
166
|
+
.describe(`Limit the number of results returned`)
|
|
167
|
+
}
|
|
168
|
+
}, async ({ bookId, tagIds, keyword, sort, descending, limit }) => {
|
|
155
169
|
const bookFilter = bookId ? `bookId:${bookId.split(':')[1]}` : '';
|
|
156
170
|
const tagFilter = tagIds ? tagIds.map(t => `tagId:${t}`).join(' ') : '';
|
|
157
171
|
keyword = `${bookFilter} ${tagFilter} ${keyword || ''}`.trim();
|
|
@@ -159,7 +173,7 @@ You have to retrieve the full note content by calling \`read-note\`.
|
|
|
159
173
|
keyword,
|
|
160
174
|
sort,
|
|
161
175
|
descending,
|
|
162
|
-
limit
|
|
176
|
+
limit
|
|
163
177
|
});
|
|
164
178
|
const summaries = notes.map(note => {
|
|
165
179
|
return {
|
|
@@ -176,26 +190,29 @@ You have to retrieve the full note content by calling \`read-note\`.
|
|
|
176
190
|
]
|
|
177
191
|
};
|
|
178
192
|
});
|
|
179
|
-
server.
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
.
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
.string()
|
|
189
|
-
.
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
.
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
.
|
|
198
|
-
|
|
193
|
+
server.registerTool('create-note', {
|
|
194
|
+
description: 'Create a new note in the database',
|
|
195
|
+
inputSchema: {
|
|
196
|
+
bookId: zod_1.z
|
|
197
|
+
.string()
|
|
198
|
+
.min(5)
|
|
199
|
+
.max(128)
|
|
200
|
+
.regex(/^(book:|trash$)/)
|
|
201
|
+
.describe('The notebook ID'),
|
|
202
|
+
title: zod_1.z.string().max(128).describe('The note title'),
|
|
203
|
+
body: zod_1.z
|
|
204
|
+
.string()
|
|
205
|
+
.max(1048576)
|
|
206
|
+
.describe('The content of the note represented with Markdown'),
|
|
207
|
+
status: zod_1.z
|
|
208
|
+
.enum(['none', 'active', 'onHold', 'completed', 'dropped'])
|
|
209
|
+
.optional()
|
|
210
|
+
.describe('The status of the note'),
|
|
211
|
+
tags: zod_1.z
|
|
212
|
+
.array(zod_1.z.string().startsWith('tag:'))
|
|
213
|
+
.optional()
|
|
214
|
+
.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.')
|
|
215
|
+
}
|
|
199
216
|
}, async (noteData) => {
|
|
200
217
|
const res = await (0, api_1.postJSON)(`/notes`, noteData);
|
|
201
218
|
return {
|
|
@@ -207,37 +224,112 @@ server.tool('create-note', 'Create a new note in the database', {
|
|
|
207
224
|
]
|
|
208
225
|
};
|
|
209
226
|
});
|
|
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
|
-
|
|
227
|
+
server.registerTool('update-note', {
|
|
228
|
+
description: 'Update the existing note in the database. Only the fields you provide will be updated; omitted fields remain unchanged.',
|
|
229
|
+
inputSchema: {
|
|
230
|
+
_id: zod_1.z
|
|
231
|
+
.string()
|
|
232
|
+
.min(6)
|
|
233
|
+
.max(128)
|
|
234
|
+
.regex(/^note:/)
|
|
235
|
+
.describe('The unique document ID which should start with `note:` and the remains are randomly generated string'),
|
|
236
|
+
_rev: zod_1.z
|
|
237
|
+
.string()
|
|
238
|
+
.describe('This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable).'),
|
|
239
|
+
bookId: zod_1.z
|
|
240
|
+
.string()
|
|
241
|
+
.min(5)
|
|
242
|
+
.max(128)
|
|
243
|
+
.regex(/^(book:|trash$)/)
|
|
244
|
+
.optional()
|
|
245
|
+
.describe('The notebook ID'),
|
|
246
|
+
title: zod_1.z.string().max(128).optional().describe('The note title'),
|
|
247
|
+
body: zod_1.z
|
|
248
|
+
.string()
|
|
249
|
+
.max(1048576)
|
|
250
|
+
.optional()
|
|
251
|
+
.describe('The content of the note in Markdown. NOTE: Do not escape special characters like `\\n`.'),
|
|
252
|
+
status: zod_1.z
|
|
253
|
+
.enum(['none', 'active', 'onHold', 'completed', 'dropped'])
|
|
254
|
+
.optional()
|
|
255
|
+
.describe('The status of the note'),
|
|
256
|
+
tags: zod_1.z
|
|
257
|
+
.array(zod_1.z.string().startsWith('tag:'))
|
|
258
|
+
.optional()
|
|
259
|
+
.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.')
|
|
260
|
+
}
|
|
239
261
|
}, async (noteData) => {
|
|
240
|
-
const
|
|
262
|
+
const rev = noteData._rev;
|
|
263
|
+
const existingNote = await (0, api_1.fetchJSON)(`/${noteData._id}`, { rev });
|
|
264
|
+
const res = await (0, api_1.postJSON)(`/notes`, {
|
|
265
|
+
...existingNote,
|
|
266
|
+
...noteData,
|
|
267
|
+
updatedAt: +new Date()
|
|
268
|
+
});
|
|
269
|
+
return {
|
|
270
|
+
content: [
|
|
271
|
+
{
|
|
272
|
+
type: 'text',
|
|
273
|
+
text: JSON.stringify(res, null, 2)
|
|
274
|
+
}
|
|
275
|
+
]
|
|
276
|
+
};
|
|
277
|
+
});
|
|
278
|
+
server.registerTool('patch-note', {
|
|
279
|
+
description: 'Update the body of the existing note by performing an exact string replacement. Use this tool to make partial updates to the note body without replacing the entire content. You must first read the note with `read-note` to get the current body, then specify the exact substring to replace.',
|
|
280
|
+
inputSchema: {
|
|
281
|
+
_id: zod_1.z
|
|
282
|
+
.string()
|
|
283
|
+
.min(6)
|
|
284
|
+
.max(128)
|
|
285
|
+
.regex(/^note:/)
|
|
286
|
+
.describe('The unique document ID which should start with `note:` and the remains are randomly generated string'),
|
|
287
|
+
_rev: zod_1.z
|
|
288
|
+
.string()
|
|
289
|
+
.describe('This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable).'),
|
|
290
|
+
old_string: zod_1.z
|
|
291
|
+
.string()
|
|
292
|
+
.min(1)
|
|
293
|
+
.describe('The exact text to find in the note body. Must match exactly one occurrence. Include enough surrounding context to ensure a unique match.'),
|
|
294
|
+
new_string: zod_1.z
|
|
295
|
+
.string()
|
|
296
|
+
.describe('The text to replace `old_string` with. Use an empty string to delete the matched text.')
|
|
297
|
+
}
|
|
298
|
+
}, async ({ _id, _rev, old_string, new_string }) => {
|
|
299
|
+
const existingNote = await (0, api_1.fetchJSON)(`/${_id}`, { rev: _rev });
|
|
300
|
+
const body = existingNote.body;
|
|
301
|
+
const firstIndex = body.indexOf(old_string);
|
|
302
|
+
if (firstIndex === -1) {
|
|
303
|
+
return {
|
|
304
|
+
content: [
|
|
305
|
+
{
|
|
306
|
+
type: 'text',
|
|
307
|
+
text: 'Failed to patch: `old_string` was not found in the note body.'
|
|
308
|
+
}
|
|
309
|
+
],
|
|
310
|
+
isError: true
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
const secondIndex = body.indexOf(old_string, firstIndex + 1);
|
|
314
|
+
if (secondIndex !== -1) {
|
|
315
|
+
return {
|
|
316
|
+
content: [
|
|
317
|
+
{
|
|
318
|
+
type: 'text',
|
|
319
|
+
text: 'Failed to patch: `old_string` matches multiple locations in the note body. Provide more surrounding context to make it unique.'
|
|
320
|
+
}
|
|
321
|
+
],
|
|
322
|
+
isError: true
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
const patched = body.slice(0, firstIndex) +
|
|
326
|
+
new_string +
|
|
327
|
+
body.slice(firstIndex + old_string.length);
|
|
328
|
+
const res = await (0, api_1.postJSON)('/notes', {
|
|
329
|
+
...existingNote,
|
|
330
|
+
body: patched,
|
|
331
|
+
updatedAt: +new Date()
|
|
332
|
+
});
|
|
241
333
|
return {
|
|
242
334
|
content: [
|
|
243
335
|
{
|
|
@@ -247,7 +339,7 @@ server.tool('update-note', 'Update the existing note in the database. You should
|
|
|
247
339
|
]
|
|
248
340
|
};
|
|
249
341
|
});
|
|
250
|
-
server.
|
|
342
|
+
server.registerTool('list-tags', { description: 'Retrieve a list of all tags' }, async () => {
|
|
251
343
|
const tags = await (0, api_1.fetchJSON)('/tags');
|
|
252
344
|
return {
|
|
253
345
|
content: [
|
|
@@ -258,10 +350,13 @@ server.tool('list-tags', `Retrieve a list of all tags`, {}, async () => {
|
|
|
258
350
|
]
|
|
259
351
|
};
|
|
260
352
|
});
|
|
261
|
-
server.
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
353
|
+
server.registerTool('read-tag', {
|
|
354
|
+
description: 'Retrieve a single tag',
|
|
355
|
+
inputSchema: {
|
|
356
|
+
tagId: zod_1.z
|
|
357
|
+
.string()
|
|
358
|
+
.describe('ID of the tag to retrieve. It can be found as `_id` in the tag docs. It always starts with \`tag:\`.')
|
|
359
|
+
}
|
|
265
360
|
}, async ({ tagId }) => {
|
|
266
361
|
if (!tagId.startsWith('tag:'))
|
|
267
362
|
tagId = `tag:${tagId}`;
|
|
@@ -276,12 +371,15 @@ server.tool('read-tag', `Retrieve a single tag`, {
|
|
|
276
371
|
};
|
|
277
372
|
});
|
|
278
373
|
const TagColors = Object.values(inkdrop_model_1.TAG_COLOR);
|
|
279
|
-
server.
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
.
|
|
283
|
-
|
|
284
|
-
|
|
374
|
+
server.registerTool('create-tag', {
|
|
375
|
+
description: 'Create a new tag in the database',
|
|
376
|
+
inputSchema: {
|
|
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
|
+
}
|
|
285
383
|
}, async (tagData) => {
|
|
286
384
|
const res = await (0, api_1.postJSON)(`/tags`, tagData);
|
|
287
385
|
return {
|
|
@@ -293,21 +391,24 @@ server.tool('create-tag', 'Create a new tag in the database', {
|
|
|
293
391
|
]
|
|
294
392
|
};
|
|
295
393
|
});
|
|
296
|
-
server.
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
.
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
.
|
|
309
|
-
|
|
310
|
-
|
|
394
|
+
server.registerTool('update-tag', {
|
|
395
|
+
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.',
|
|
396
|
+
inputSchema: {
|
|
397
|
+
_id: zod_1.z
|
|
398
|
+
.string()
|
|
399
|
+
.min(6)
|
|
400
|
+
.max(128)
|
|
401
|
+
.regex(/^tag:/)
|
|
402
|
+
.describe('The unique document ID which should start with `tag:` and the remains are randomly generated string'),
|
|
403
|
+
_rev: zod_1.z
|
|
404
|
+
.string()
|
|
405
|
+
.describe('This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable).'),
|
|
406
|
+
color: zod_1.z
|
|
407
|
+
.enum(TagColors)
|
|
408
|
+
.default('default')
|
|
409
|
+
.describe('The color type of the tag'),
|
|
410
|
+
name: zod_1.z.string().max(64).describe('The name of the tag')
|
|
411
|
+
}
|
|
311
412
|
}, async (tagData) => {
|
|
312
413
|
const res = await (0, api_1.postJSON)(`/tags`, tagData);
|
|
313
414
|
return {
|
|
@@ -319,7 +420,7 @@ server.tool('update-tag', 'Update the existing tag in the database. You should r
|
|
|
319
420
|
]
|
|
320
421
|
};
|
|
321
422
|
});
|
|
322
|
-
server.
|
|
423
|
+
server.registerTool('list-notebooks', { description: 'Retrieve a list of all notebooks' }, async () => {
|
|
323
424
|
const books = await (0, api_1.fetchJSON)('/books');
|
|
324
425
|
return {
|
|
325
426
|
content: [
|
|
@@ -330,10 +431,13 @@ server.tool('list-notebooks', `Retrieve a list of all notebooks`, {}, async () =
|
|
|
330
431
|
]
|
|
331
432
|
};
|
|
332
433
|
});
|
|
333
|
-
server.
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
434
|
+
server.registerTool('read-book', {
|
|
435
|
+
description: 'Retrieve a single book',
|
|
436
|
+
inputSchema: {
|
|
437
|
+
bookId: zod_1.z
|
|
438
|
+
.string()
|
|
439
|
+
.describe('ID of the book to retrieve. It can be found as `_id` in the book docs. It always starts with \`book:\`.')
|
|
440
|
+
}
|
|
337
441
|
}, async ({ bookId }) => {
|
|
338
442
|
if (!bookId.startsWith('book:'))
|
|
339
443
|
bookId = `book:${bookId}`;
|
|
@@ -347,7 +451,7 @@ server.tool('read-book', `Retrieve a single book`, {
|
|
|
347
451
|
]
|
|
348
452
|
};
|
|
349
453
|
});
|
|
350
|
-
server.
|
|
454
|
+
server.registerPrompt('inkdrop-prompt', { description: 'Instructions for using the Inkdrop MCP server effectively' }, () => ({
|
|
351
455
|
messages: [
|
|
352
456
|
{
|
|
353
457
|
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.1",
|
|
4
4
|
"description": "Inkdrop Model Context Protocol Server",
|
|
5
5
|
"bin": {
|
|
6
6
|
"inkdrop-mcp-server": "dist/index.js"
|
|
@@ -24,14 +24,14 @@
|
|
|
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
|
-
"inkdrop-model": "^2.
|
|
30
|
-
"zod": "^3.
|
|
29
|
+
"inkdrop-model": "^2.11.1",
|
|
30
|
+
"zod": "^4.3.6"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@types/node": "^
|
|
34
|
-
"prettier": "^3.
|
|
35
|
-
"typescript": "^5.
|
|
33
|
+
"@types/node": "^25.2.3",
|
|
34
|
+
"prettier": "^3.8.1",
|
|
35
|
+
"typescript": "^5.9.3"
|
|
36
36
|
}
|
|
37
37
|
}
|
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
|
+
|
|
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,39 +164,46 @@ 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
|
+
limit: z
|
|
200
|
+
.number()
|
|
201
|
+
.optional()
|
|
202
|
+
.default(100)
|
|
203
|
+
.describe(`Limit the number of results returned`)
|
|
204
|
+
}
|
|
192
205
|
},
|
|
193
|
-
async ({ bookId, tagIds, keyword, sort, descending }) => {
|
|
206
|
+
async ({ bookId, tagIds, keyword, sort, descending, limit }) => {
|
|
194
207
|
const bookFilter = bookId ? `bookId:${bookId.split(':')[1]}` : ''
|
|
195
208
|
const tagFilter = tagIds ? tagIds.map(t => `tagId:${t}`).join(' ') : ''
|
|
196
209
|
keyword = `${bookFilter} ${tagFilter} ${keyword || ''}`.trim()
|
|
@@ -198,7 +211,7 @@ You have to retrieve the full note content by calling \`read-note\`.
|
|
|
198
211
|
keyword,
|
|
199
212
|
sort,
|
|
200
213
|
descending,
|
|
201
|
-
limit
|
|
214
|
+
limit
|
|
202
215
|
})
|
|
203
216
|
const summaries = notes.map(note => {
|
|
204
217
|
return {
|
|
@@ -217,35 +230,37 @@ You have to retrieve the full note content by calling \`read-note\`.
|
|
|
217
230
|
}
|
|
218
231
|
)
|
|
219
232
|
|
|
220
|
-
server.
|
|
233
|
+
server.registerTool(
|
|
221
234
|
'create-note',
|
|
222
|
-
'Create a new note in the database',
|
|
223
235
|
{
|
|
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
|
-
|
|
236
|
+
description: 'Create a new note in the database',
|
|
237
|
+
inputSchema: {
|
|
238
|
+
bookId: z
|
|
239
|
+
.string()
|
|
240
|
+
.min(5)
|
|
241
|
+
.max(128)
|
|
242
|
+
.regex(/^(book:|trash$)/)
|
|
243
|
+
.describe('The notebook ID'),
|
|
244
|
+
|
|
245
|
+
title: z.string().max(128).describe('The note title'),
|
|
246
|
+
|
|
247
|
+
body: z
|
|
248
|
+
.string()
|
|
249
|
+
.max(1048576)
|
|
250
|
+
.describe('The content of the note represented with Markdown'),
|
|
251
|
+
|
|
252
|
+
status: z
|
|
253
|
+
.enum(['none', 'active', 'onHold', 'completed', 'dropped'])
|
|
254
|
+
.optional()
|
|
255
|
+
.describe('The status of the note'),
|
|
256
|
+
|
|
257
|
+
tags: z
|
|
258
|
+
.array(z.string().startsWith('tag:'))
|
|
259
|
+
.optional()
|
|
260
|
+
.describe(
|
|
261
|
+
'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.'
|
|
262
|
+
)
|
|
263
|
+
}
|
|
249
264
|
},
|
|
250
265
|
async noteData => {
|
|
251
266
|
const res = await postJSON(`/notes`, noteData)
|
|
@@ -260,55 +275,67 @@ server.tool(
|
|
|
260
275
|
}
|
|
261
276
|
)
|
|
262
277
|
|
|
263
|
-
server.
|
|
278
|
+
server.registerTool(
|
|
264
279
|
'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
280
|
{
|
|
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
|
-
|
|
281
|
+
description:
|
|
282
|
+
'Update the existing note in the database. Only the fields you provide will be updated; omitted fields remain unchanged.',
|
|
283
|
+
inputSchema: {
|
|
284
|
+
_id: z
|
|
285
|
+
.string()
|
|
286
|
+
.min(6)
|
|
287
|
+
.max(128)
|
|
288
|
+
.regex(/^note:/)
|
|
289
|
+
.describe(
|
|
290
|
+
'The unique document ID which should start with `note:` and the remains are randomly generated string'
|
|
291
|
+
),
|
|
292
|
+
|
|
293
|
+
_rev: z
|
|
294
|
+
.string()
|
|
295
|
+
.describe(
|
|
296
|
+
'This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable).'
|
|
297
|
+
),
|
|
298
|
+
|
|
299
|
+
bookId: z
|
|
300
|
+
.string()
|
|
301
|
+
.min(5)
|
|
302
|
+
.max(128)
|
|
303
|
+
.regex(/^(book:|trash$)/)
|
|
304
|
+
.optional()
|
|
305
|
+
.describe('The notebook ID'),
|
|
306
|
+
|
|
307
|
+
title: z.string().max(128).optional().describe('The note title'),
|
|
308
|
+
|
|
309
|
+
body: z
|
|
310
|
+
.string()
|
|
311
|
+
.max(1048576)
|
|
312
|
+
.optional()
|
|
313
|
+
.describe(
|
|
314
|
+
'The content of the note in Markdown. NOTE: Do not escape special characters like `\\n`.'
|
|
315
|
+
),
|
|
316
|
+
|
|
317
|
+
status: z
|
|
318
|
+
.enum(['none', 'active', 'onHold', 'completed', 'dropped'])
|
|
319
|
+
.optional()
|
|
320
|
+
.describe('The status of the note'),
|
|
321
|
+
|
|
322
|
+
tags: z
|
|
323
|
+
.array(z.string().startsWith('tag:'))
|
|
324
|
+
.optional()
|
|
325
|
+
.describe(
|
|
326
|
+
'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.'
|
|
327
|
+
)
|
|
328
|
+
}
|
|
309
329
|
},
|
|
310
330
|
async noteData => {
|
|
311
|
-
const
|
|
331
|
+
const rev = noteData._rev
|
|
332
|
+
const existingNote = await fetchJSON<Note>(`/${noteData._id}`, { rev })
|
|
333
|
+
|
|
334
|
+
const res = await postJSON(`/notes`, {
|
|
335
|
+
...existingNote,
|
|
336
|
+
...noteData,
|
|
337
|
+
updatedAt: +new Date()
|
|
338
|
+
})
|
|
312
339
|
return {
|
|
313
340
|
content: [
|
|
314
341
|
{
|
|
@@ -320,27 +347,119 @@ server.tool(
|
|
|
320
347
|
}
|
|
321
348
|
)
|
|
322
349
|
|
|
323
|
-
server.
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
350
|
+
server.registerTool(
|
|
351
|
+
'patch-note',
|
|
352
|
+
{
|
|
353
|
+
description:
|
|
354
|
+
'Update the body of the existing note by performing an exact string replacement. Use this tool to make partial updates to the note body without replacing the entire content. You must first read the note with `read-note` to get the current body, then specify the exact substring to replace.',
|
|
355
|
+
inputSchema: {
|
|
356
|
+
_id: z
|
|
357
|
+
.string()
|
|
358
|
+
.min(6)
|
|
359
|
+
.max(128)
|
|
360
|
+
.regex(/^note:/)
|
|
361
|
+
.describe(
|
|
362
|
+
'The unique document ID which should start with `note:` and the remains are randomly generated string'
|
|
363
|
+
),
|
|
364
|
+
|
|
365
|
+
_rev: z
|
|
366
|
+
.string()
|
|
367
|
+
.describe(
|
|
368
|
+
'This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable).'
|
|
369
|
+
),
|
|
370
|
+
|
|
371
|
+
old_string: z
|
|
372
|
+
.string()
|
|
373
|
+
.min(1)
|
|
374
|
+
.describe(
|
|
375
|
+
'The exact text to find in the note body. Must match exactly one occurrence. Include enough surrounding context to ensure a unique match.'
|
|
376
|
+
),
|
|
377
|
+
|
|
378
|
+
new_string: z
|
|
379
|
+
.string()
|
|
380
|
+
.describe(
|
|
381
|
+
'The text to replace `old_string` with. Use an empty string to delete the matched text.'
|
|
382
|
+
)
|
|
383
|
+
}
|
|
384
|
+
},
|
|
385
|
+
async ({ _id, _rev, old_string, new_string }) => {
|
|
386
|
+
const existingNote = await fetchJSON<Note>(`/${_id}`, { rev: _rev })
|
|
387
|
+
const body = existingNote.body
|
|
388
|
+
|
|
389
|
+
const firstIndex = body.indexOf(old_string)
|
|
390
|
+
if (firstIndex === -1) {
|
|
391
|
+
return {
|
|
392
|
+
content: [
|
|
393
|
+
{
|
|
394
|
+
type: 'text',
|
|
395
|
+
text: 'Failed to patch: `old_string` was not found in the note body.'
|
|
396
|
+
}
|
|
397
|
+
],
|
|
398
|
+
isError: true
|
|
330
399
|
}
|
|
331
|
-
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
const secondIndex = body.indexOf(old_string, firstIndex + 1)
|
|
403
|
+
if (secondIndex !== -1) {
|
|
404
|
+
return {
|
|
405
|
+
content: [
|
|
406
|
+
{
|
|
407
|
+
type: 'text',
|
|
408
|
+
text: 'Failed to patch: `old_string` matches multiple locations in the note body. Provide more surrounding context to make it unique.'
|
|
409
|
+
}
|
|
410
|
+
],
|
|
411
|
+
isError: true
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
const patched =
|
|
416
|
+
body.slice(0, firstIndex) +
|
|
417
|
+
new_string +
|
|
418
|
+
body.slice(firstIndex + old_string.length)
|
|
419
|
+
|
|
420
|
+
const res = await postJSON('/notes', {
|
|
421
|
+
...existingNote,
|
|
422
|
+
body: patched,
|
|
423
|
+
updatedAt: +new Date()
|
|
424
|
+
})
|
|
425
|
+
return {
|
|
426
|
+
content: [
|
|
427
|
+
{
|
|
428
|
+
type: 'text',
|
|
429
|
+
text: JSON.stringify(res, null, 2)
|
|
430
|
+
}
|
|
431
|
+
]
|
|
432
|
+
}
|
|
332
433
|
}
|
|
333
|
-
|
|
434
|
+
)
|
|
334
435
|
|
|
335
|
-
server.
|
|
436
|
+
server.registerTool(
|
|
437
|
+
'list-tags',
|
|
438
|
+
{ description: 'Retrieve a list of all tags' },
|
|
439
|
+
async () => {
|
|
440
|
+
const tags: Tag[] = await fetchJSON('/tags')
|
|
441
|
+
return {
|
|
442
|
+
content: [
|
|
443
|
+
{
|
|
444
|
+
type: 'text',
|
|
445
|
+
text: JSON.stringify(tags, null, 2)
|
|
446
|
+
}
|
|
447
|
+
]
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
)
|
|
451
|
+
|
|
452
|
+
server.registerTool(
|
|
336
453
|
'read-tag',
|
|
337
|
-
`Retrieve a single tag`,
|
|
338
454
|
{
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
455
|
+
description: 'Retrieve a single tag',
|
|
456
|
+
inputSchema: {
|
|
457
|
+
tagId: z
|
|
458
|
+
.string()
|
|
459
|
+
.describe(
|
|
460
|
+
'ID of the tag to retrieve. It can be found as `_id` in the tag docs. It always starts with \`tag:\`.'
|
|
461
|
+
)
|
|
462
|
+
}
|
|
344
463
|
},
|
|
345
464
|
async ({ tagId }) => {
|
|
346
465
|
if (!tagId.startsWith('tag:')) tagId = `tag:${tagId}`
|
|
@@ -358,16 +477,18 @@ server.tool(
|
|
|
358
477
|
|
|
359
478
|
const TagColors = Object.values(TAG_COLOR) as [string, ...string[]]
|
|
360
479
|
|
|
361
|
-
server.
|
|
480
|
+
server.registerTool(
|
|
362
481
|
'create-tag',
|
|
363
|
-
'Create a new tag in the database',
|
|
364
482
|
{
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
483
|
+
description: 'Create a new tag in the database',
|
|
484
|
+
inputSchema: {
|
|
485
|
+
color: z
|
|
486
|
+
.enum(TagColors)
|
|
487
|
+
.default('default')
|
|
488
|
+
.describe('The color type of the tag'),
|
|
489
|
+
|
|
490
|
+
name: z.string().max(64).describe('The name of the tag')
|
|
491
|
+
}
|
|
371
492
|
},
|
|
372
493
|
async tagData => {
|
|
373
494
|
const res = await postJSON(`/tags`, tagData)
|
|
@@ -382,31 +503,34 @@ server.tool(
|
|
|
382
503
|
}
|
|
383
504
|
)
|
|
384
505
|
|
|
385
|
-
server.
|
|
506
|
+
server.registerTool(
|
|
386
507
|
'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
508
|
{
|
|
389
|
-
|
|
390
|
-
.
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
509
|
+
description:
|
|
510
|
+
'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.',
|
|
511
|
+
inputSchema: {
|
|
512
|
+
_id: z
|
|
513
|
+
.string()
|
|
514
|
+
.min(6)
|
|
515
|
+
.max(128)
|
|
516
|
+
.regex(/^tag:/)
|
|
517
|
+
.describe(
|
|
518
|
+
'The unique document ID which should start with `tag:` and the remains are randomly generated string'
|
|
519
|
+
),
|
|
520
|
+
|
|
521
|
+
_rev: z
|
|
522
|
+
.string()
|
|
523
|
+
.describe(
|
|
524
|
+
'This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable).'
|
|
525
|
+
),
|
|
526
|
+
|
|
527
|
+
color: z
|
|
528
|
+
.enum(TagColors)
|
|
529
|
+
.default('default')
|
|
530
|
+
.describe('The color type of the tag'),
|
|
531
|
+
|
|
532
|
+
name: z.string().max(64).describe('The name of the tag')
|
|
533
|
+
}
|
|
410
534
|
},
|
|
411
535
|
async tagData => {
|
|
412
536
|
const res = await postJSON(`/tags`, tagData)
|
|
@@ -421,10 +545,9 @@ server.tool(
|
|
|
421
545
|
}
|
|
422
546
|
)
|
|
423
547
|
|
|
424
|
-
server.
|
|
548
|
+
server.registerTool(
|
|
425
549
|
'list-notebooks',
|
|
426
|
-
|
|
427
|
-
{},
|
|
550
|
+
{ description: 'Retrieve a list of all notebooks' },
|
|
428
551
|
async () => {
|
|
429
552
|
const books: Book[] = await fetchJSON('/books')
|
|
430
553
|
return {
|
|
@@ -438,15 +561,17 @@ server.tool(
|
|
|
438
561
|
}
|
|
439
562
|
)
|
|
440
563
|
|
|
441
|
-
server.
|
|
564
|
+
server.registerTool(
|
|
442
565
|
'read-book',
|
|
443
|
-
`Retrieve a single book`,
|
|
444
566
|
{
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
567
|
+
description: 'Retrieve a single book',
|
|
568
|
+
inputSchema: {
|
|
569
|
+
bookId: z
|
|
570
|
+
.string()
|
|
571
|
+
.describe(
|
|
572
|
+
'ID of the book to retrieve. It can be found as `_id` in the book docs. It always starts with \`book:\`.'
|
|
573
|
+
)
|
|
574
|
+
}
|
|
450
575
|
},
|
|
451
576
|
async ({ bookId }) => {
|
|
452
577
|
if (!bookId.startsWith('book:')) bookId = `book:${bookId}`
|
|
@@ -462,9 +587,9 @@ server.tool(
|
|
|
462
587
|
}
|
|
463
588
|
)
|
|
464
589
|
|
|
465
|
-
server.
|
|
590
|
+
server.registerPrompt(
|
|
466
591
|
'inkdrop-prompt',
|
|
467
|
-
'Instructions for using the Inkdrop MCP server effectively',
|
|
592
|
+
{ description: 'Instructions for using the Inkdrop MCP server effectively' },
|
|
468
593
|
() => ({
|
|
469
594
|
messages: [
|
|
470
595
|
{
|