@inkdropapp/mcp-server 1.8.0 → 1.10.0-beta.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/actions.lock +10 -0
- package/.github/workflows/ci.yml +65 -0
- package/.github/workflows/publish.yml +10 -1
- package/.oxfmtrc.json +2 -1
- package/README.md +16 -6
- package/dist/client/agent-identity.js +45 -0
- package/dist/client/agent-session.js +66 -0
- package/dist/client/local-server.js +64 -0
- package/dist/features/files/image-type.js +31 -0
- package/dist/features/files/tools.js +191 -0
- package/dist/features/notebooks/tools.js +95 -0
- package/dist/features/notes/note-anchor.js +58 -0
- package/dist/features/notes/note-schemas.js +38 -0
- package/dist/features/notes/note-update.js +16 -0
- package/dist/features/notes/resource.js +26 -0
- package/dist/features/notes/text-edits.js +36 -0
- package/dist/features/notes/tools.js +405 -0
- package/dist/features/tags/tools.js +82 -0
- package/dist/index.js +19 -826
- package/dist/utils/document-fields.js +18 -0
- package/mise.toml +5 -0
- package/oxlint.config.ts +50 -0
- package/package.json +22 -14
- package/pnpm-workspace.yaml +6 -0
- package/src/client/agent-identity.ts +70 -0
- package/src/client/agent-session.ts +75 -0
- package/src/client/local-server.ts +73 -0
- package/src/features/files/image-type.ts +35 -0
- package/src/features/files/tools.ts +230 -0
- package/src/features/notebooks/tools.ts +133 -0
- package/src/features/notes/note-anchor.ts +85 -0
- package/src/features/notes/note-schemas.ts +60 -0
- package/src/features/notes/note-update.ts +27 -0
- package/src/features/notes/resource.ts +34 -0
- package/src/features/notes/text-edits.ts +48 -0
- package/src/features/notes/tools.ts +499 -0
- package/src/features/tags/tools.ts +109 -0
- package/src/index.ts +17 -1049
- package/src/utils/document-fields.ts +21 -0
- package/tests/client/agent-identity.test.ts +98 -0
- package/tests/features/notes/note-anchor.test.ts +125 -0
- package/tests/features/notes/note-schemas.test.ts +27 -0
- package/tests/utils/document-fields.test.ts +41 -0
- package/tsconfig.json +1 -1
- package/dist/api.js +0 -47
- package/dist/utils.js +0 -100
- package/src/api.ts +0 -45
- package/src/utils.ts +0 -112
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { TAG_COLOR, TAG_DOCID_PREFIX } from 'inkdrop-model';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { fetchJSON, postJSON } from '../../client/local-server.js';
|
|
4
|
+
import { documentIdSchema, revisionSchema } from '../../utils/document-fields.js';
|
|
5
|
+
const TagColors = Object.values(TAG_COLOR);
|
|
6
|
+
/**
|
|
7
|
+
* Registers the tools that read, create and update tags.
|
|
8
|
+
*
|
|
9
|
+
* @param server - The MCP server to register on
|
|
10
|
+
*/
|
|
11
|
+
export function registerTagTools(server) {
|
|
12
|
+
server.registerTool('list-tags', { description: 'Retrieve a list of all tags' }, async () => {
|
|
13
|
+
const tags = await fetchJSON('/tags');
|
|
14
|
+
return {
|
|
15
|
+
content: [
|
|
16
|
+
{
|
|
17
|
+
type: 'text',
|
|
18
|
+
text: JSON.stringify(tags, null, 2)
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
server.registerTool('read-tag', {
|
|
24
|
+
description: 'Retrieve a single tag',
|
|
25
|
+
inputSchema: {
|
|
26
|
+
tagId: z
|
|
27
|
+
.string()
|
|
28
|
+
.describe('ID of the tag to retrieve. It can be found as `_id` in the tag docs. It always starts with `tag:`.')
|
|
29
|
+
}
|
|
30
|
+
}, async ({ tagId }) => {
|
|
31
|
+
if (!tagId.startsWith('tag:')) {
|
|
32
|
+
tagId = `tag:${tagId}`;
|
|
33
|
+
}
|
|
34
|
+
const tag = await fetchJSON(`/${tagId}`, {});
|
|
35
|
+
return {
|
|
36
|
+
content: [
|
|
37
|
+
{
|
|
38
|
+
type: 'text',
|
|
39
|
+
text: JSON.stringify(tag, null, 2)
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
server.registerTool('create-tag', {
|
|
45
|
+
description: 'Create a new tag in the database',
|
|
46
|
+
inputSchema: {
|
|
47
|
+
color: z.enum(TagColors).default('default').describe('The color type of the tag'),
|
|
48
|
+
name: z.string().max(64).describe('The name of the tag')
|
|
49
|
+
}
|
|
50
|
+
}, async (tagData) => {
|
|
51
|
+
const res = await postJSON(`/tags`, tagData);
|
|
52
|
+
return {
|
|
53
|
+
content: [
|
|
54
|
+
{
|
|
55
|
+
type: 'text',
|
|
56
|
+
text: JSON.stringify(res, null, 2)
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
server.registerTool('update-tag', {
|
|
62
|
+
description: 'Update the existing tag in the database. Only the fields you provide will be updated; omitted fields remain unchanged, so you do not need to read the tag first. Call `list-tags` or `read-tag` to find the tag ID.',
|
|
63
|
+
inputSchema: {
|
|
64
|
+
_id: documentIdSchema(TAG_DOCID_PREFIX).describe('The unique document ID which should start with `tag:` and the remains are randomly generated string'),
|
|
65
|
+
_rev: revisionSchema
|
|
66
|
+
.optional()
|
|
67
|
+
.describe('This is a CouchDB specific field. The current MVCC-token/revision of this document. Optional: the server merges your fields into the stored tag, so it is only needed as an optimistic-concurrency guard. Pass it when you have read the tag first and want the update to fail on a conflicting concurrent edit.'),
|
|
68
|
+
color: z.enum(TagColors).optional().describe('The color type of the tag'),
|
|
69
|
+
name: z.string().max(64).optional().describe('The name of the tag')
|
|
70
|
+
}
|
|
71
|
+
}, async ({ _id, ...updateFields }) => {
|
|
72
|
+
const res = await postJSON(`/${_id}`, updateFields);
|
|
73
|
+
return {
|
|
74
|
+
content: [
|
|
75
|
+
{
|
|
76
|
+
type: 'text',
|
|
77
|
+
text: JSON.stringify(res, null, 2)
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
}
|