@inkdropapp/mcp-server 1.1.0 → 1.2.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/.github/workflows/claude-code-review.yml +78 -0
- package/.github/workflows/claude.yml +64 -0
- package/README.md +27 -9
- package/dist/index.js +94 -7
- package/package.json +1 -1
- package/src/index.ts +151 -15
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
name: Claude Code Review
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
types: [opened, synchronize]
|
|
6
|
+
# Optional: Only run on specific file changes
|
|
7
|
+
# paths:
|
|
8
|
+
# - "src/**/*.ts"
|
|
9
|
+
# - "src/**/*.tsx"
|
|
10
|
+
# - "src/**/*.js"
|
|
11
|
+
# - "src/**/*.jsx"
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
claude-review:
|
|
15
|
+
# Optional: Filter by PR author
|
|
16
|
+
# if: |
|
|
17
|
+
# github.event.pull_request.user.login == 'external-contributor' ||
|
|
18
|
+
# github.event.pull_request.user.login == 'new-developer' ||
|
|
19
|
+
# github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'
|
|
20
|
+
|
|
21
|
+
runs-on: ubuntu-latest
|
|
22
|
+
permissions:
|
|
23
|
+
contents: read
|
|
24
|
+
pull-requests: read
|
|
25
|
+
issues: read
|
|
26
|
+
id-token: write
|
|
27
|
+
|
|
28
|
+
steps:
|
|
29
|
+
- name: Checkout repository
|
|
30
|
+
uses: actions/checkout@v4
|
|
31
|
+
with:
|
|
32
|
+
fetch-depth: 1
|
|
33
|
+
|
|
34
|
+
- name: Run Claude Code Review
|
|
35
|
+
id: claude-review
|
|
36
|
+
uses: anthropics/claude-code-action@beta
|
|
37
|
+
with:
|
|
38
|
+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
|
|
39
|
+
|
|
40
|
+
# Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4)
|
|
41
|
+
# model: "claude-opus-4-20250514"
|
|
42
|
+
|
|
43
|
+
# Direct prompt for automated review (no @claude mention needed)
|
|
44
|
+
direct_prompt: |
|
|
45
|
+
Please review this pull request and provide feedback on:
|
|
46
|
+
- Code quality and best practices
|
|
47
|
+
- Potential bugs or issues
|
|
48
|
+
- Performance considerations
|
|
49
|
+
- Security concerns
|
|
50
|
+
- Test coverage
|
|
51
|
+
|
|
52
|
+
Be constructive and helpful in your feedback.
|
|
53
|
+
|
|
54
|
+
# Optional: Use sticky comments to make Claude reuse the same comment on subsequent pushes to the same PR
|
|
55
|
+
# use_sticky_comment: true
|
|
56
|
+
|
|
57
|
+
# Optional: Customize review based on file types
|
|
58
|
+
# direct_prompt: |
|
|
59
|
+
# Review this PR focusing on:
|
|
60
|
+
# - For TypeScript files: Type safety and proper interface usage
|
|
61
|
+
# - For API endpoints: Security, input validation, and error handling
|
|
62
|
+
# - For React components: Performance, accessibility, and best practices
|
|
63
|
+
# - For tests: Coverage, edge cases, and test quality
|
|
64
|
+
|
|
65
|
+
# Optional: Different prompts for different authors
|
|
66
|
+
# direct_prompt: |
|
|
67
|
+
# ${{ github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' &&
|
|
68
|
+
# 'Welcome! Please review this PR from a first-time contributor. Be encouraging and provide detailed explanations for any suggestions.' ||
|
|
69
|
+
# 'Please provide a thorough code review focusing on our coding standards and best practices.' }}
|
|
70
|
+
|
|
71
|
+
# Optional: Add specific tools for running tests or linting
|
|
72
|
+
# allowed_tools: "Bash(npm run test),Bash(npm run lint),Bash(npm run typecheck)"
|
|
73
|
+
|
|
74
|
+
# Optional: Skip review for certain conditions
|
|
75
|
+
# if: |
|
|
76
|
+
# !contains(github.event.pull_request.title, '[skip-review]') &&
|
|
77
|
+
# !contains(github.event.pull_request.title, '[WIP]')
|
|
78
|
+
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
name: Claude Code
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
issue_comment:
|
|
5
|
+
types: [created]
|
|
6
|
+
pull_request_review_comment:
|
|
7
|
+
types: [created]
|
|
8
|
+
issues:
|
|
9
|
+
types: [opened, assigned]
|
|
10
|
+
pull_request_review:
|
|
11
|
+
types: [submitted]
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
claude:
|
|
15
|
+
if: |
|
|
16
|
+
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
|
|
17
|
+
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
|
|
18
|
+
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
|
|
19
|
+
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
permissions:
|
|
22
|
+
contents: read
|
|
23
|
+
pull-requests: read
|
|
24
|
+
issues: read
|
|
25
|
+
id-token: write
|
|
26
|
+
actions: read # Required for Claude to read CI results on PRs
|
|
27
|
+
steps:
|
|
28
|
+
- name: Checkout repository
|
|
29
|
+
uses: actions/checkout@v4
|
|
30
|
+
with:
|
|
31
|
+
fetch-depth: 1
|
|
32
|
+
|
|
33
|
+
- name: Run Claude Code
|
|
34
|
+
id: claude
|
|
35
|
+
uses: anthropics/claude-code-action@beta
|
|
36
|
+
with:
|
|
37
|
+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
|
|
38
|
+
|
|
39
|
+
# This is an optional setting that allows Claude to read CI results on PRs
|
|
40
|
+
additional_permissions: |
|
|
41
|
+
actions: read
|
|
42
|
+
|
|
43
|
+
# Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4)
|
|
44
|
+
# model: "claude-opus-4-20250514"
|
|
45
|
+
|
|
46
|
+
# Optional: Customize the trigger phrase (default: @claude)
|
|
47
|
+
# trigger_phrase: "/claude"
|
|
48
|
+
|
|
49
|
+
# Optional: Trigger when specific user is assigned to an issue
|
|
50
|
+
# assignee_trigger: "claude-bot"
|
|
51
|
+
|
|
52
|
+
# Optional: Allow Claude to run specific commands
|
|
53
|
+
# allowed_tools: "Bash(npm install),Bash(npm run build),Bash(npm run test:*),Bash(npm run lint:*)"
|
|
54
|
+
|
|
55
|
+
# Optional: Add custom instructions for Claude to customize its behavior for your project
|
|
56
|
+
# custom_instructions: |
|
|
57
|
+
# Follow our coding standards
|
|
58
|
+
# Ensure all new code has tests
|
|
59
|
+
# Use TypeScript for new files
|
|
60
|
+
|
|
61
|
+
# Optional: Custom environment variables for Claude
|
|
62
|
+
# claude_env: |
|
|
63
|
+
# NODE_ENV: test
|
|
64
|
+
|
package/README.md
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
A [Model Context Protocol](https://github.com/modelcontextprotocol) server for the [Inkdrop Local HTTP Server API](https://developers.inkdrop.app/data-access/local-http-server).
|
|
4
4
|
|
|
5
|
-
>
|
|
6
|
-
|
|
5
|
+
<a href="https://glama.ai/mcp/servers/c7fgtnckbv">
|
|
6
|
+
<img width="380" height="200" src="https://glama.ai/mcp/servers/c7fgtnckbv/badge" alt="Inkdrop Server MCP server" />
|
|
7
|
+
</a>
|
|
7
8
|
|
|
8
9
|
## Installation
|
|
9
10
|
|
|
@@ -18,13 +19,10 @@ A [Model Context Protocol](https://github.com/modelcontextprotocol) server for t
|
|
|
18
19
|
"mcpServers": {
|
|
19
20
|
"inkdrop": {
|
|
20
21
|
"command": "npx",
|
|
21
|
-
"args": [
|
|
22
|
-
"-y",
|
|
23
|
-
"@inkdropapp/mcp-server"
|
|
24
|
-
],
|
|
22
|
+
"args": ["-y", "@inkdropapp/mcp-server"],
|
|
25
23
|
"env": {
|
|
26
24
|
"INKDROP_LOCAL_SERVER_URL": "http://localhost:19840",
|
|
27
|
-
"INKDROP_LOCAL_USERNAME": "your-local-server-username"
|
|
25
|
+
"INKDROP_LOCAL_USERNAME": "your-local-server-username",
|
|
28
26
|
"INKDROP_LOCAL_PASSWORD": "your-local-server-password"
|
|
29
27
|
}
|
|
30
28
|
}
|
|
@@ -44,7 +42,7 @@ A [Model Context Protocol](https://github.com/modelcontextprotocol) server for t
|
|
|
44
42
|
- `keyword`: Keyword to search for.
|
|
45
43
|
- Note: Results include truncated note bodies (200 characters). Use `read-note` to get full content.
|
|
46
44
|
- Supports advanced search qualifiers like `book:`, `tag:`, `status:`, `title:`, etc.
|
|
47
|
-
3. **`list-notes`**: List all notes
|
|
45
|
+
3. **`list-notes`**: List all notes with specified conditions.
|
|
48
46
|
- Required inputs:
|
|
49
47
|
- `bookId`: The notebook ID. It always starts with 'book:'.
|
|
50
48
|
- Optional inputs:
|
|
@@ -60,6 +58,7 @@ A [Model Context Protocol](https://github.com/modelcontextprotocol) server for t
|
|
|
60
58
|
- `body`: The content of the note in Markdown.
|
|
61
59
|
- Optional inputs:
|
|
62
60
|
- `status`: The note status (`none`, `active`, `onHold`, `completed`, `dropped`).
|
|
61
|
+
- `tags`: An array of tag IDs to assign to the note. Each must start with 'tag:'.
|
|
63
62
|
5. **`update-note`**: Update an existing note in the database.
|
|
64
63
|
- Required inputs:
|
|
65
64
|
- `_id`: The note ID. Must start with 'note:'.
|
|
@@ -69,8 +68,27 @@ A [Model Context Protocol](https://github.com/modelcontextprotocol) server for t
|
|
|
69
68
|
- `body`: The content of the note in Markdown.
|
|
70
69
|
- Optional inputs:
|
|
71
70
|
- `status`: The note status (`none`, `active`, `onHold`, `completed`, `dropped`).
|
|
71
|
+
- `tags`: An array of tag IDs to assign to the note. Each must start with 'tag:'.
|
|
72
72
|
6. **`list-notebooks`**: Retrieve a list of all notebooks.
|
|
73
|
-
7. **`
|
|
73
|
+
7. **`read-book`**: Retrieve a single notebook by its ID.
|
|
74
|
+
- 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.
|
|
78
|
+
- Required inputs:
|
|
79
|
+
- `tagId`: The tag ID. Must start with 'tag:'.
|
|
80
|
+
10. **`create-tag`**: Create a new tag in the database.
|
|
81
|
+
- Required inputs:
|
|
82
|
+
- `name`: The name of the tag.
|
|
83
|
+
- Optional inputs:
|
|
84
|
+
- `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.
|
|
86
|
+
- Required inputs:
|
|
87
|
+
- `_id`: The tag ID. Must start with 'tag:'.
|
|
88
|
+
- `_rev`: The revision ID (CouchDB MVCC-token).
|
|
89
|
+
- `name`: The name of the tag.
|
|
90
|
+
- Optional inputs:
|
|
91
|
+
- `color`: The color type of the tag. Default: `default`.
|
|
74
92
|
|
|
75
93
|
## Debugging
|
|
76
94
|
|
package/dist/index.js
CHANGED
|
@@ -127,12 +127,13 @@ Note that you can't specify excluding modifiers only without including condition
|
|
|
127
127
|
]
|
|
128
128
|
};
|
|
129
129
|
});
|
|
130
|
-
server.tool('list-notes', `List all notes
|
|
130
|
+
server.tool('list-notes', `List all notes with specified conditions.
|
|
131
131
|
The result does not include entire note bodies as they are truncated in 200 characters.
|
|
132
132
|
You have to retrieve the full note content by calling \`read-note\`.
|
|
133
133
|
`, {
|
|
134
134
|
bookId: zod_1.z
|
|
135
135
|
.string()
|
|
136
|
+
.optional()
|
|
136
137
|
.describe(`ID of the notebook. It always starts with 'book:'. You can retrieve a list of notebooks with \`list-notebooks\``),
|
|
137
138
|
tagIds: zod_1.z
|
|
138
139
|
.array(zod_1.z.string())
|
|
@@ -151,7 +152,7 @@ You have to retrieve the full note content by calling \`read-note\`.
|
|
|
151
152
|
.default(true)
|
|
152
153
|
.describe(`Reverse the order of the output documents`)
|
|
153
154
|
}, async ({ bookId, tagIds, keyword, sort, descending }) => {
|
|
154
|
-
const bookFilter = `bookId:${bookId.split(':')[1]}
|
|
155
|
+
const bookFilter = bookId ? `bookId:${bookId.split(':')[1]}` : '';
|
|
155
156
|
const tagFilter = tagIds ? tagIds.map(t => `tagId:${t}`).join(' ') : '';
|
|
156
157
|
keyword = `${bookFilter} ${tagFilter} ${keyword || ''}`.trim();
|
|
157
158
|
const notes = await (0, api_1.fetchJSON)('/notes', {
|
|
@@ -190,7 +191,11 @@ server.tool('create-note', 'Create a new note in the database', {
|
|
|
190
191
|
status: zod_1.z
|
|
191
192
|
.enum(['none', 'active', 'onHold', 'completed', 'dropped'])
|
|
192
193
|
.optional()
|
|
193
|
-
.describe('The status of the note')
|
|
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.')
|
|
194
199
|
}, async (noteData) => {
|
|
195
200
|
const res = await (0, api_1.postJSON)(`/notes`, noteData);
|
|
196
201
|
return {
|
|
@@ -226,7 +231,11 @@ server.tool('update-note', 'Update the existing note in the database. You should
|
|
|
226
231
|
status: zod_1.z
|
|
227
232
|
.enum(['none', 'active', 'onHold', 'completed', 'dropped'])
|
|
228
233
|
.optional()
|
|
229
|
-
.describe('The status of the note')
|
|
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.')
|
|
230
239
|
}, async (noteData) => {
|
|
231
240
|
const res = await (0, api_1.postJSON)(`/notes`, noteData);
|
|
232
241
|
return {
|
|
@@ -238,6 +247,78 @@ server.tool('update-note', 'Update the existing note in the database. You should
|
|
|
238
247
|
]
|
|
239
248
|
};
|
|
240
249
|
});
|
|
250
|
+
server.tool('list-tags', `Retrieve a list of all tags`, {}, async () => {
|
|
251
|
+
const tags = await (0, api_1.fetchJSON)('/tags');
|
|
252
|
+
return {
|
|
253
|
+
content: [
|
|
254
|
+
{
|
|
255
|
+
type: 'text',
|
|
256
|
+
text: JSON.stringify(tags, null, 2)
|
|
257
|
+
}
|
|
258
|
+
]
|
|
259
|
+
};
|
|
260
|
+
});
|
|
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:\`.')
|
|
265
|
+
}, async ({ tagId }) => {
|
|
266
|
+
if (!tagId.startsWith('tag:'))
|
|
267
|
+
tagId = `tag:${tagId}`;
|
|
268
|
+
const tag = await (0, api_1.fetchJSON)(`/${tagId}`, {});
|
|
269
|
+
return {
|
|
270
|
+
content: [
|
|
271
|
+
{
|
|
272
|
+
type: 'text',
|
|
273
|
+
text: JSON.stringify(tag, null, 2)
|
|
274
|
+
}
|
|
275
|
+
]
|
|
276
|
+
};
|
|
277
|
+
});
|
|
278
|
+
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')
|
|
285
|
+
}, async (tagData) => {
|
|
286
|
+
const res = await (0, api_1.postJSON)(`/tags`, tagData);
|
|
287
|
+
return {
|
|
288
|
+
content: [
|
|
289
|
+
{
|
|
290
|
+
type: 'text',
|
|
291
|
+
text: JSON.stringify(res, null, 2)
|
|
292
|
+
}
|
|
293
|
+
]
|
|
294
|
+
};
|
|
295
|
+
});
|
|
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')
|
|
311
|
+
}, async (tagData) => {
|
|
312
|
+
const res = await (0, api_1.postJSON)(`/tags`, tagData);
|
|
313
|
+
return {
|
|
314
|
+
content: [
|
|
315
|
+
{
|
|
316
|
+
type: 'text',
|
|
317
|
+
text: JSON.stringify(res, null, 2)
|
|
318
|
+
}
|
|
319
|
+
]
|
|
320
|
+
};
|
|
321
|
+
});
|
|
241
322
|
server.tool('list-notebooks', `Retrieve a list of all notebooks`, {}, async () => {
|
|
242
323
|
const books = await (0, api_1.fetchJSON)('/books');
|
|
243
324
|
return {
|
|
@@ -249,13 +330,19 @@ server.tool('list-notebooks', `Retrieve a list of all notebooks`, {}, async () =
|
|
|
249
330
|
]
|
|
250
331
|
};
|
|
251
332
|
});
|
|
252
|
-
server.tool('
|
|
253
|
-
|
|
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:\`.')
|
|
337
|
+
}, async ({ bookId }) => {
|
|
338
|
+
if (!bookId.startsWith('book:'))
|
|
339
|
+
bookId = `book:${bookId}`;
|
|
340
|
+
const book = await (0, api_1.fetchJSON)(`/${bookId}`, {});
|
|
254
341
|
return {
|
|
255
342
|
content: [
|
|
256
343
|
{
|
|
257
344
|
type: 'text',
|
|
258
|
-
text: JSON.stringify(
|
|
345
|
+
text: JSON.stringify(book, null, 2)
|
|
259
346
|
}
|
|
260
347
|
]
|
|
261
348
|
};
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -5,7 +5,15 @@ import {
|
|
|
5
5
|
ResourceTemplate
|
|
6
6
|
} from '@modelcontextprotocol/sdk/server/mcp.js'
|
|
7
7
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
Note,
|
|
10
|
+
NoteSchema,
|
|
11
|
+
Book,
|
|
12
|
+
BookSchema,
|
|
13
|
+
TagSchema,
|
|
14
|
+
TAG_COLOR,
|
|
15
|
+
Tag
|
|
16
|
+
} from 'inkdrop-model'
|
|
9
17
|
import { z } from 'zod'
|
|
10
18
|
import { fetchJSON, postJSON } from './api'
|
|
11
19
|
|
|
@@ -152,13 +160,14 @@ Note that you can't specify excluding modifiers only without including condition
|
|
|
152
160
|
|
|
153
161
|
server.tool(
|
|
154
162
|
'list-notes',
|
|
155
|
-
`List all notes
|
|
163
|
+
`List all notes with specified conditions.
|
|
156
164
|
The result does not include entire note bodies as they are truncated in 200 characters.
|
|
157
165
|
You have to retrieve the full note content by calling \`read-note\`.
|
|
158
166
|
`,
|
|
159
167
|
{
|
|
160
168
|
bookId: z
|
|
161
169
|
.string()
|
|
170
|
+
.optional()
|
|
162
171
|
.describe(
|
|
163
172
|
`ID of the notebook. It always starts with 'book:'. You can retrieve a list of notebooks with \`list-notebooks\``
|
|
164
173
|
),
|
|
@@ -182,7 +191,7 @@ You have to retrieve the full note content by calling \`read-note\`.
|
|
|
182
191
|
.describe(`Reverse the order of the output documents`)
|
|
183
192
|
},
|
|
184
193
|
async ({ bookId, tagIds, keyword, sort, descending }) => {
|
|
185
|
-
const bookFilter = `bookId:${bookId.split(':')[1]}`
|
|
194
|
+
const bookFilter = bookId ? `bookId:${bookId.split(':')[1]}` : ''
|
|
186
195
|
const tagFilter = tagIds ? tagIds.map(t => `tagId:${t}`).join(' ') : ''
|
|
187
196
|
keyword = `${bookFilter} ${tagFilter} ${keyword || ''}`.trim()
|
|
188
197
|
const notes: Note[] = await fetchJSON('/notes', {
|
|
@@ -229,7 +238,14 @@ server.tool(
|
|
|
229
238
|
status: z
|
|
230
239
|
.enum(['none', 'active', 'onHold', 'completed', 'dropped'])
|
|
231
240
|
.optional()
|
|
232
|
-
.describe('The status of the note')
|
|
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
|
+
)
|
|
233
249
|
},
|
|
234
250
|
async noteData => {
|
|
235
251
|
const res = await postJSON(`/notes`, noteData)
|
|
@@ -282,7 +298,14 @@ server.tool(
|
|
|
282
298
|
status: z
|
|
283
299
|
.enum(['none', 'active', 'onHold', 'completed', 'dropped'])
|
|
284
300
|
.optional()
|
|
285
|
-
.describe('The status of the note')
|
|
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
|
+
)
|
|
286
309
|
},
|
|
287
310
|
async noteData => {
|
|
288
311
|
const res = await postJSON(`/notes`, noteData)
|
|
@@ -297,6 +320,107 @@ server.tool(
|
|
|
297
320
|
}
|
|
298
321
|
)
|
|
299
322
|
|
|
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)
|
|
330
|
+
}
|
|
331
|
+
]
|
|
332
|
+
}
|
|
333
|
+
})
|
|
334
|
+
|
|
335
|
+
server.tool(
|
|
336
|
+
'read-tag',
|
|
337
|
+
`Retrieve a single tag`,
|
|
338
|
+
{
|
|
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
|
+
)
|
|
344
|
+
},
|
|
345
|
+
async ({ tagId }) => {
|
|
346
|
+
if (!tagId.startsWith('tag:')) tagId = `tag:${tagId}`
|
|
347
|
+
const tag: Tag = await fetchJSON(`/${tagId}`, {})
|
|
348
|
+
return {
|
|
349
|
+
content: [
|
|
350
|
+
{
|
|
351
|
+
type: 'text',
|
|
352
|
+
text: JSON.stringify(tag, null, 2)
|
|
353
|
+
}
|
|
354
|
+
]
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
)
|
|
358
|
+
|
|
359
|
+
const TagColors = Object.values(TAG_COLOR) as [string, ...string[]]
|
|
360
|
+
|
|
361
|
+
server.tool(
|
|
362
|
+
'create-tag',
|
|
363
|
+
'Create a new tag in the database',
|
|
364
|
+
{
|
|
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')
|
|
371
|
+
},
|
|
372
|
+
async tagData => {
|
|
373
|
+
const res = await postJSON(`/tags`, tagData)
|
|
374
|
+
return {
|
|
375
|
+
content: [
|
|
376
|
+
{
|
|
377
|
+
type: 'text',
|
|
378
|
+
text: JSON.stringify(res, null, 2)
|
|
379
|
+
}
|
|
380
|
+
]
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
)
|
|
384
|
+
|
|
385
|
+
server.tool(
|
|
386
|
+
'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
|
+
{
|
|
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')
|
|
410
|
+
},
|
|
411
|
+
async tagData => {
|
|
412
|
+
const res = await postJSON(`/tags`, tagData)
|
|
413
|
+
return {
|
|
414
|
+
content: [
|
|
415
|
+
{
|
|
416
|
+
type: 'text',
|
|
417
|
+
text: JSON.stringify(res, null, 2)
|
|
418
|
+
}
|
|
419
|
+
]
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
)
|
|
423
|
+
|
|
300
424
|
server.tool(
|
|
301
425
|
'list-notebooks',
|
|
302
426
|
`Retrieve a list of all notebooks`,
|
|
@@ -314,17 +438,29 @@ server.tool(
|
|
|
314
438
|
}
|
|
315
439
|
)
|
|
316
440
|
|
|
317
|
-
server.tool(
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
441
|
+
server.tool(
|
|
442
|
+
'read-book',
|
|
443
|
+
`Retrieve a single book`,
|
|
444
|
+
{
|
|
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
|
+
)
|
|
450
|
+
},
|
|
451
|
+
async ({ bookId }) => {
|
|
452
|
+
if (!bookId.startsWith('book:')) bookId = `book:${bookId}`
|
|
453
|
+
const book: Book = await fetchJSON(`/${bookId}`, {})
|
|
454
|
+
return {
|
|
455
|
+
content: [
|
|
456
|
+
{
|
|
457
|
+
type: 'text',
|
|
458
|
+
text: JSON.stringify(book, null, 2)
|
|
459
|
+
}
|
|
460
|
+
]
|
|
461
|
+
}
|
|
326
462
|
}
|
|
327
|
-
|
|
463
|
+
)
|
|
328
464
|
|
|
329
465
|
server.prompt(
|
|
330
466
|
'inkdrop-prompt',
|