@inkdropapp/mcp-server 1.0.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/README.md ADDED
@@ -0,0 +1,79 @@
1
+ ## Inkdrop MCP Server
2
+
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
+
5
+ > [!WARNING] This is highly experimental and use at your own risk.
6
+
7
+ ## Installation
8
+
9
+ 1. [Set up a local HTTP server](https://developers.inkdrop.app/guides/access-the-local-database#accessing-via-http-advanced)
10
+
11
+ 2. Add server config to Claude Desktop:
12
+ - MacOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
13
+ - Windows: `%APPDATA%\Claude\claude_desktop_config.json`
14
+
15
+ ```json
16
+ {
17
+ "mcpServers": {
18
+ "inkdrop": {
19
+ "command": "npx",
20
+ "args": [
21
+ "-y",
22
+ "@inkdropapp/mcp-server"
23
+ ],
24
+ "env": {
25
+ "INKDROP_LOCAL_SERVER_URL": "http://localhost:19840",
26
+ "INKDROP_LOCAL_USERNAME": "your-local-server-username"
27
+ "INKDROP_LOCAL_PASSWORD": "your-local-server-password"
28
+ }
29
+ }
30
+ }
31
+ }
32
+ ```
33
+
34
+ ## Components
35
+
36
+ ### Tools
37
+
38
+ 1. **`read-note`**: Retrieve the complete contents of the note by its ID from the database.
39
+ - Required inputs:
40
+ - `noteId`: The ID of the note to retrieve.
41
+ 2. **`search-notes`**: List all notes that contain a given keyword.
42
+ - Required inputs:
43
+ - `keyword`: Keyword to search for.
44
+ 3. **`create-note`**: Create a new note in the database
45
+ - Required inputs:
46
+ - `bookId`: The notebook ID
47
+ - `title`: The note title
48
+ - `body`: The content of the note in Markdown
49
+ - Optional inputs:
50
+ - `status`: The note status (`none`, `active`, `onHold`, `completed`, `dropped`)
51
+ 4. **`update-note`**: Update the existing note in the database
52
+ - Required inputs:
53
+ - `_id`: The note ID
54
+ - `_rev`: The revision ID
55
+ - `bookId`: The notebook ID
56
+ - `title`: The note title
57
+ - `body`: The content of the note in Markdown
58
+ 5. **`list-notebooks`**: Retrieve a list of all notebooks
59
+
60
+ ## Debugging
61
+
62
+ Since MCP servers run over stdio, debugging can be challenging. For the best debugging
63
+ experience, we strongly recommend using the [MCP Inspector](https://github.com/modelcontextprotocol/inspector).
64
+
65
+ You can launch the MCP Inspector via [`npm`](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) with this command:
66
+
67
+ ```bash
68
+ npx @modelcontextprotocol/inspector "./dist/index.js"
69
+ ```
70
+
71
+ Be sure that environment variables are properly configured.
72
+
73
+ Upon launching, the Inspector will display a URL that you can access in your browser to begin debugging.
74
+
75
+ You can also watch the server logs with this command:
76
+
77
+ ```bash
78
+ tail -n 20 -f ~/Library/Logs/Claude/mcp-server-inkdrop.log
79
+ ```
package/dist/api.js ADDED
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildUrl = buildUrl;
4
+ exports.fetchJSON = fetchJSON;
5
+ exports.postJSON = postJSON;
6
+ const config = {
7
+ baseUrl: process.env.INKDROP_LOCAL_SERVER_URL,
8
+ username: process.env.INKDROP_LOCAL_USERNAME,
9
+ password: process.env.INKDROP_LOCAL_PASSWORD,
10
+ };
11
+ function getAuthHeaders() {
12
+ const token = Buffer.from(`${config.username}:${config.password}`).toString("base64");
13
+ return {
14
+ Authorization: `Basic ${token}`
15
+ };
16
+ }
17
+ function buildUrl(path, qs = {}) {
18
+ const url = new URL(path, config.baseUrl);
19
+ for (const [k, v] of Object.entries(qs)) {
20
+ if (v !== undefined && v !== null)
21
+ url.searchParams.set(k, String(v));
22
+ }
23
+ return url.toString();
24
+ }
25
+ async function fetchJSON(path, qs = {}) {
26
+ const url = buildUrl(path, qs);
27
+ const resp = await fetch(url, { headers: getAuthHeaders() });
28
+ if (!resp.ok) {
29
+ throw new Error(`Fetch error [${resp.status}] ${resp.statusText}`);
30
+ }
31
+ return await resp.json();
32
+ }
33
+ async function postJSON(path, body) {
34
+ const url = buildUrl(path);
35
+ const resp = await fetch(url, {
36
+ method: "POST",
37
+ headers: {
38
+ ...getAuthHeaders(),
39
+ "Content-Type": "application/json"
40
+ },
41
+ body: JSON.stringify(body)
42
+ });
43
+ if (!resp.ok) {
44
+ throw new Error(`Fetch error [${resp.status}] ${resp.statusText}`);
45
+ }
46
+ return await resp.json();
47
+ }
package/dist/bak.js ADDED
@@ -0,0 +1,331 @@
1
+ "use strict";
2
+ /**
3
+ * Example: MCP Proxy for Inkdrop's local HTTP server.
4
+ *
5
+ * Requirements:
6
+ * 1) Inkdrop's local server is running at config.baseUrl (e.g. http://localhost:19840).
7
+ * 2) A Basic auth username/password is set in Inkdrop.
8
+ * 3) This script can be run with `npx ts-node inkdrop-mcp-proxy.ts`.
9
+ * 4) Then, an MCP client (e.g. MCP Inspector, or Claude) can connect to:
10
+ * GET http://localhost:3002/sse (SSE endpoint)
11
+ * POST http://localhost:3002/messages (MCP messages endpoint)
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ const url_1 = require("url");
15
+ const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
16
+ const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
17
+ const zod_1 = require("zod");
18
+ /** Configuration for talking to Inkdrop’s local HTTP server */
19
+ const config = {
20
+ baseUrl: "http://localhost:19841", // or https://localhost:19840
21
+ username: "foo@bar.com",
22
+ password: "bar",
23
+ /** If Inkdrop uses self-signed cert over HTTPS, you may need to allow that. */
24
+ };
25
+ /** Build the 'Authorization: Basic ...' header */
26
+ function getAuthHeaders() {
27
+ const token = Buffer.from(`${config.username}:${config.password}`).toString("base64");
28
+ return {
29
+ Authorization: `Basic ${token}`
30
+ };
31
+ }
32
+ /** Helper to attach query parameters to a given path */
33
+ function buildUrl(path, qs = {}) {
34
+ const url = new url_1.URL(path, config.baseUrl);
35
+ for (const [k, v] of Object.entries(qs)) {
36
+ if (v !== undefined && v !== null)
37
+ url.searchParams.set(k, String(v));
38
+ }
39
+ return url.toString();
40
+ }
41
+ /** Helper to do a GET request and return JSON or throw an error. */
42
+ async function fetchJSON(path, qs = {}) {
43
+ const url = buildUrl(path, qs);
44
+ const resp = await fetch(url, { headers: getAuthHeaders() });
45
+ if (!resp.ok) {
46
+ throw new Error(`Fetch error [${resp.status}] ${resp.statusText}`);
47
+ }
48
+ return await resp.json();
49
+ }
50
+ /** Helper to do a POST request with JSON body */
51
+ async function postJSON(path, body) {
52
+ const url = buildUrl(path);
53
+ const resp = await fetch(url, {
54
+ method: "POST",
55
+ headers: {
56
+ ...getAuthHeaders(),
57
+ "Content-Type": "application/json"
58
+ },
59
+ body: JSON.stringify(body)
60
+ });
61
+ if (!resp.ok) {
62
+ throw new Error(`Fetch error [${resp.status}] ${resp.statusText}`);
63
+ }
64
+ return await resp.json();
65
+ }
66
+ /** Helper to do a DELETE request */
67
+ async function deleteJSON(path) {
68
+ const url = buildUrl(path);
69
+ const resp = await fetch(url, {
70
+ method: "DELETE",
71
+ headers: getAuthHeaders()
72
+ });
73
+ if (!resp.ok) {
74
+ throw new Error(`Fetch error [${resp.status}] ${resp.statusText}`);
75
+ }
76
+ return await resp.json();
77
+ }
78
+ /** Create the MCP Server that proxies to Inkdrop’s local API. */
79
+ function createInkdropProxyServer() {
80
+ const server = new mcp_js_1.McpServer({
81
+ name: "Inkdrop MCP Proxy",
82
+ version: "1.0.0"
83
+ });
84
+ //
85
+ // 1) Root meta info (like GET "/")
86
+ //
87
+ server.resource("root", "inkdrop://root", async (uri) => {
88
+ const body = await fetchJSON("/");
89
+ return {
90
+ contents: [
91
+ {
92
+ uri: uri.href,
93
+ text: JSON.stringify(body, null, 2)
94
+ }
95
+ ]
96
+ };
97
+ });
98
+ //
99
+ // 2) Notes
100
+ //
101
+ // 2a) List all notes (proxy GET /notes, with query params)
102
+ server.resource("notes", new mcp_js_1.ResourceTemplate("inkdrop://notes{?keyword,limit,skip,sort,descending}", {
103
+ list: undefined
104
+ }), async (uri) => {
105
+ // forward query to /notes
106
+ const qs = Object.fromEntries(uri.searchParams.entries());
107
+ const body = await fetchJSON("/notes", qs);
108
+ return {
109
+ contents: [
110
+ {
111
+ uri: uri.href,
112
+ text: JSON.stringify(body, null, 2)
113
+ }
114
+ ]
115
+ };
116
+ });
117
+ // 2b) Create/update note (proxy POST /notes)
118
+ server.tool("save-note", {
119
+ _id: zod_1.z.string().optional(),
120
+ _rev: zod_1.z.string().optional(),
121
+ doctype: zod_1.z.string().optional(),
122
+ bookId: zod_1.z.string().optional(),
123
+ status: zod_1.z.string().optional(),
124
+ share: zod_1.z.string().optional(),
125
+ title: zod_1.z.string().optional(),
126
+ body: zod_1.z.string().optional(),
127
+ pinned: zod_1.z.boolean().optional(),
128
+ tags: zod_1.z.array(zod_1.z.string()).optional()
129
+ }, async (args) => {
130
+ const ret = await postJSON("/notes", args);
131
+ return {
132
+ content: [{ type: "text", text: JSON.stringify(ret, null, 2) }]
133
+ };
134
+ });
135
+ // 2c) Get single note (proxy GET /note:docId)
136
+ server.resource("single-note", new mcp_js_1.ResourceTemplate("inkdrop://note/{docId}{?rev,attachments}", { list: undefined }), async (uri, { docId }) => {
137
+ const qs = Object.fromEntries(uri.searchParams.entries());
138
+ const body = await fetchJSON(`/note:${docId}`, qs);
139
+ return {
140
+ contents: [
141
+ {
142
+ uri: uri.href,
143
+ text: JSON.stringify(body, null, 2)
144
+ }
145
+ ]
146
+ };
147
+ });
148
+ // 2d) Delete note (proxy DELETE /note:docId)
149
+ server.tool("delete-note", { docId: zod_1.z.string() }, async ({ docId }) => {
150
+ const ret = await deleteJSON(`/note:${docId}`);
151
+ return {
152
+ content: [{ type: "text", text: JSON.stringify(ret, null, 2) }]
153
+ };
154
+ });
155
+ //
156
+ // 3) Books (Notebooks)
157
+ //
158
+ // 3a) List notebooks (GET /books)
159
+ server.resource("books", new mcp_js_1.ResourceTemplate("inkdrop://books{?limit,skip}", { list: undefined }), async (uri) => {
160
+ const qs = Object.fromEntries(uri.searchParams.entries());
161
+ const body = await fetchJSON("/books", qs);
162
+ return {
163
+ contents: [
164
+ {
165
+ uri: uri.href,
166
+ text: JSON.stringify(body, null, 2)
167
+ }
168
+ ]
169
+ };
170
+ });
171
+ // 3b) Create/update a book (POST /books)
172
+ server.tool("save-book", {
173
+ _id: zod_1.z.string().optional(),
174
+ _rev: zod_1.z.string().optional(),
175
+ name: zod_1.z.string().optional(),
176
+ parentBookId: zod_1.z.string().optional()
177
+ }, async (args) => {
178
+ const ret = await postJSON("/books", args);
179
+ return {
180
+ content: [{ type: "text", text: JSON.stringify(ret, null, 2) }]
181
+ };
182
+ });
183
+ // 3c) Get a single book (GET /book:docId)
184
+ server.resource("single-book", new mcp_js_1.ResourceTemplate("inkdrop://book/{docId}{?rev,attachments}", { list: undefined }), async (uri, { docId }) => {
185
+ const qs = Object.fromEntries(uri.searchParams.entries());
186
+ const body = await fetchJSON(`/book:${docId}`, qs);
187
+ return {
188
+ contents: [
189
+ {
190
+ uri: uri.href,
191
+ text: JSON.stringify(body, null, 2)
192
+ }
193
+ ]
194
+ };
195
+ });
196
+ // 3d) Delete book (DELETE /book:docId)
197
+ server.tool("delete-book", { docId: zod_1.z.string() }, async ({ docId }) => {
198
+ const ret = await deleteJSON(`/book:${docId}`);
199
+ return {
200
+ content: [{ type: "text", text: JSON.stringify(ret, null, 2) }]
201
+ };
202
+ });
203
+ //
204
+ // 4) Tags
205
+ //
206
+ // 4a) List tags (GET /tags)
207
+ server.resource("tags", new mcp_js_1.ResourceTemplate("inkdrop://tags{?limit,skip}", { list: undefined }), async (uri) => {
208
+ const qs = Object.fromEntries(uri.searchParams.entries());
209
+ const body = await fetchJSON("/tags", qs);
210
+ return {
211
+ contents: [
212
+ {
213
+ uri: uri.href,
214
+ text: JSON.stringify(body, null, 2)
215
+ }
216
+ ]
217
+ };
218
+ });
219
+ // 4b) Create/update tag (POST /tags)
220
+ server.tool("save-tag", {
221
+ _id: zod_1.z.string().optional(),
222
+ _rev: zod_1.z.string().optional(),
223
+ name: zod_1.z.string(),
224
+ color: zod_1.z.string().optional()
225
+ }, async (args) => {
226
+ const ret = await postJSON("/tags", args);
227
+ return {
228
+ content: [{ type: "text", text: JSON.stringify(ret, null, 2) }]
229
+ };
230
+ });
231
+ // 4c) Get tag (GET /tag:docId)
232
+ server.resource("single-tag", new mcp_js_1.ResourceTemplate("inkdrop://tag/{docId}{?rev,attachments}", { list: undefined }), async (uri, { docId }) => {
233
+ const qs = Object.fromEntries(uri.searchParams.entries());
234
+ const body = await fetchJSON(`/tag:${docId}`, qs);
235
+ return {
236
+ contents: [
237
+ {
238
+ uri: uri.href,
239
+ text: JSON.stringify(body, null, 2)
240
+ }
241
+ ]
242
+ };
243
+ });
244
+ // 4d) Delete tag (DELETE /tag:docId)
245
+ server.tool("delete-tag", { docId: zod_1.z.string() }, async ({ docId }) => {
246
+ const ret = await deleteJSON(`/tag:${docId}`);
247
+ return {
248
+ content: [{ type: "text", text: JSON.stringify(ret, null, 2) }]
249
+ };
250
+ });
251
+ //
252
+ // 5) Files
253
+ //
254
+ // 5a) List files (GET /files)
255
+ server.resource("files", new mcp_js_1.ResourceTemplate("inkdrop://files{?limit,skip}", { list: undefined }), async (uri) => {
256
+ const qs = Object.fromEntries(uri.searchParams.entries());
257
+ const body = await fetchJSON("/files", qs);
258
+ return {
259
+ contents: [
260
+ {
261
+ uri: uri.href,
262
+ text: JSON.stringify(body, null, 2)
263
+ }
264
+ ]
265
+ };
266
+ });
267
+ // 5b) Create/update file (POST /files)
268
+ server.tool("save-file", {
269
+ _id: zod_1.z.string().optional(),
270
+ _rev: zod_1.z.string().optional(),
271
+ name: zod_1.z.string(),
272
+ contentType: zod_1.z.string().optional(),
273
+ contentLength: zod_1.z.number().optional(),
274
+ publicIn: zod_1.z.array(zod_1.z.string()).optional(),
275
+ _attachments: zod_1.z.any().optional()
276
+ }, async (args) => {
277
+ const ret = await postJSON("/files", args);
278
+ return {
279
+ content: [{ type: "text", text: JSON.stringify(ret, null, 2) }]
280
+ };
281
+ });
282
+ // 5c) Get file (GET /file:docId)
283
+ server.resource("single-file", new mcp_js_1.ResourceTemplate("inkdrop://file/{docId}{?rev,attachments}", { list: undefined }), async (uri, { docId }) => {
284
+ const qs = Object.fromEntries(uri.searchParams.entries());
285
+ const body = await fetchJSON(`/file:${docId}`, qs);
286
+ return {
287
+ contents: [
288
+ {
289
+ uri: uri.href,
290
+ text: JSON.stringify(body, null, 2)
291
+ }
292
+ ]
293
+ };
294
+ });
295
+ // 5d) Delete file (DELETE /file:docId)
296
+ server.tool("delete-file", { docId: zod_1.z.string() }, async ({ docId }) => {
297
+ const ret = await deleteJSON(`/file:${docId}`);
298
+ return {
299
+ content: [{ type: "text", text: JSON.stringify(ret, null, 2) }]
300
+ };
301
+ });
302
+ //
303
+ // 6) Changes feed (GET /_changes)
304
+ //
305
+ server.resource("changes", new mcp_js_1.ResourceTemplate("inkdrop://changes{?descending,since,limit,include_docs,conflicts,attachments}", { list: undefined }), async (uri) => {
306
+ const qs = Object.fromEntries(uri.searchParams.entries());
307
+ const body = await fetchJSON("/_changes", qs);
308
+ return {
309
+ contents: [
310
+ {
311
+ uri: uri.href,
312
+ text: JSON.stringify(body, null, 2)
313
+ }
314
+ ]
315
+ };
316
+ });
317
+ // Done! We have a resource/tool for every Inkdrop endpoint.
318
+ return server;
319
+ }
320
+ /** Actually run an HTTP server exposing this MCP server over SSE and POST. */
321
+ async function main() {
322
+ const mcpServer = createInkdropProxyServer();
323
+ const transport = new stdio_js_1.StdioServerTransport();
324
+ console.log("MCP (stdio) proxy for Inkdrop is now running...");
325
+ console.log("Send MCP requests on stdin, responses come out on stdout.\n");
326
+ await mcpServer.connect(transport);
327
+ }
328
+ main().catch((err) => {
329
+ console.error("Error starting proxy:", err);
330
+ process.exit(1);
331
+ });
package/dist/index.js ADDED
@@ -0,0 +1,242 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
5
+ const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
6
+ const inkdrop_model_1 = require("inkdrop-model");
7
+ const zod_1 = require("zod");
8
+ const api_1 = require("./api");
9
+ const server = new mcp_js_1.McpServer({
10
+ name: 'Inkdrop',
11
+ version: '1.0.0'
12
+ });
13
+ server.resource('note', new mcp_js_1.ResourceTemplate('inkdrop://note/{noteId}', { list: undefined }), {
14
+ description: 'A note data',
15
+ mimeType: 'application/json'
16
+ }, async (uri, { noteId }) => {
17
+ const note = await (0, api_1.fetchJSON)(`/${noteId}`, {});
18
+ return {
19
+ contents: [
20
+ {
21
+ uri: uri.href,
22
+ text: JSON.stringify(note, null, 2),
23
+ mimeType: 'application/json'
24
+ }
25
+ ]
26
+ };
27
+ });
28
+ server.tool('read-note', 'Retrieve the complete contents of the note by its ID from the database.', {
29
+ noteId: zod_1.z
30
+ .string()
31
+ .describe('ID of the note to retrieve. It can be found as `_id` in the note docs')
32
+ }, async ({ noteId }) => {
33
+ const note = await (0, api_1.fetchJSON)(`/${noteId}`, {});
34
+ return {
35
+ content: [
36
+ {
37
+ type: 'text',
38
+ text: JSON.stringify(note, null, 2)
39
+ }
40
+ ]
41
+ };
42
+ });
43
+ server.tool('search-notes', `List all notes that contain a given keyword.
44
+ The result does not include entire note bodies as they are truncated in 200 characters.
45
+ You have to retrieve the full note content by calling \`read-note\`.
46
+ Here are tips to specify keywords effectively:
47
+
48
+ ## Use special qualifiers to narrow down results
49
+
50
+ You can use special qualifiers to get more accurate results. See the qualifiers and their usage examples:
51
+
52
+ - **book**
53
+ \`book:Blog\`: Searches for notes in the 'Blog' notebook.
54
+ - **tag**
55
+ \`tag:JavaScript\`: Searches for all notes having the 'JavaScript' tag. Read more about [tags](https://docs.inkdrop.app/manual/write-notes#tag-notes).
56
+ - **status**
57
+ \`status:onHold\`: Searches for all notes with the 'On hold' status. Read more about [statuses](/reference/note-statuses).
58
+ - **title**
59
+ \`title:"JavaScript setTimeout"\`: Searches for the note with the specified title.
60
+ - **body**
61
+ \`body:KEYWORD\`: Searches for a specific word in all notes. Equivalent to a [global search](#search-for-notes-across-all-notebooks).
62
+
63
+ ### Combine qualifiers
64
+
65
+ You can combine the filter qualifiers to refine data even more.
66
+
67
+ **Find notes that contain the word 'Hello' and have the 'Issue' tag.**
68
+
69
+ \`\`\`text
70
+ Hello tag:Issue
71
+ \`\`\`
72
+
73
+ **Find notes that contain the word 'Typescript,' have the 'Contribution' tag, and the 'Completed' status**
74
+
75
+ \`\`\`text
76
+ Typescript tag:Contribution status:Completed
77
+ \`\`\`
78
+
79
+ ## Search for text with spaces
80
+
81
+ To find the text that includes spaces, put the text into the double quotation marks ("):
82
+
83
+ \`\`\`text
84
+ "database associations"
85
+ \`\`\`
86
+
87
+ ## Exclude text from search
88
+
89
+ To exclude text from the search results or ignore a specific qualifier, put the minus sign (-) before it. You can also combine the exclusions. See the examples:
90
+
91
+ - \`-book:Backend "closure functions"\`: Ignores the 'Backend' notebook while searching for the 'closure functions' phrase.
92
+ - \`-tag:JavaScript\`: Ignores all notes having the 'JavaScript' tag.
93
+ - \`-book:Typescript tag:work "Data types"\`: Ignores the 'Typescript' notebook and the 'work' tag while searching for the 'Data types' phrase.
94
+ - \`-status:dropped title:"Sprint 10.0" debounce\`: Ignores notes with the 'Dropped' status while searching for the 'debounce' word in the note with the 'Sprint 10.0' title.
95
+ - \`-"Phrase to ignore" "in the rest of a sentence"\`: Ignores the 'Phrase to ignore' part while searching for 'in the rest of a sentence'.
96
+
97
+ Note that you can't specify excluding modifiers only without including conditions.
98
+
99
+ **WARNING**: Make sure to enter a text to search for after the exclusion modifier.
100
+
101
+ - ✅ Will work
102
+ \`-book:Backend "closure functions"\`
103
+
104
+ - ⛔️ Won't work
105
+ \`-book:Backend\`. There's no query. Inkdrop doesn't understand what to search for.
106
+ `, {
107
+ keyword: zod_1.z.string().describe(`Keyword to search for.`)
108
+ }, async ({ keyword }) => {
109
+ const notes = await (0, api_1.fetchJSON)('/notes', { keyword, limit: 10 });
110
+ const summaries = notes.map(note => {
111
+ return {
112
+ ...note,
113
+ body: note.body.substring(0, 200)
114
+ };
115
+ });
116
+ return {
117
+ content: [
118
+ {
119
+ type: 'text',
120
+ text: JSON.stringify(summaries, null, 2)
121
+ }
122
+ ]
123
+ };
124
+ });
125
+ server.tool('create-note', 'Create a new note in the database', {
126
+ bookId: zod_1.z
127
+ .string()
128
+ .min(5)
129
+ .max(128)
130
+ .regex(/^(book:|trash$)/)
131
+ .describe('The notebook ID'),
132
+ title: zod_1.z.string().max(128).describe('The note title'),
133
+ body: zod_1.z
134
+ .string()
135
+ .max(1048576)
136
+ .describe('The content of the note represented with Markdown'),
137
+ status: zod_1.z
138
+ .enum(['none', 'active', 'onHold', 'completed', 'dropped'])
139
+ .optional()
140
+ .describe('The status of the note')
141
+ }, async (noteData) => {
142
+ const res = await (0, api_1.postJSON)(`/notes`, noteData);
143
+ return {
144
+ content: [
145
+ {
146
+ type: 'text',
147
+ text: JSON.stringify(res, null, 2)
148
+ }
149
+ ]
150
+ };
151
+ });
152
+ server.tool('update-note', 'Update the existing note in the database', {
153
+ _id: zod_1.z
154
+ .string()
155
+ .min(6)
156
+ .max(128)
157
+ .regex(/^note:/)
158
+ .describe('The unique document ID which should start with `note:` and the remains are randomly generated string'),
159
+ _rev: zod_1.z
160
+ .string()
161
+ .describe('This is a CouchDB specific field. The current MVCC-token/revision of this document (mandatory and immutable).'),
162
+ bookId: zod_1.z
163
+ .string()
164
+ .min(5)
165
+ .max(128)
166
+ .regex(/^(book:|trash$)/)
167
+ .describe('The notebook ID'),
168
+ title: zod_1.z.string().max(128).describe('The note title'),
169
+ body: zod_1.z
170
+ .string()
171
+ .max(1048576)
172
+ .describe('The content of the note represented with Markdown'),
173
+ status: zod_1.z
174
+ .enum(['none', 'active', 'onHold', 'completed', 'dropped'])
175
+ .optional()
176
+ .describe('The status of the note')
177
+ }, async (noteData) => {
178
+ const res = await (0, api_1.postJSON)(`/notes`, noteData);
179
+ return {
180
+ content: [
181
+ {
182
+ type: 'text',
183
+ text: JSON.stringify(res, null, 2)
184
+ }
185
+ ]
186
+ };
187
+ });
188
+ server.tool('list-notebooks', `Retrieve a list of all notebooks`, {}, async () => {
189
+ const books = await (0, api_1.fetchJSON)('/books');
190
+ return {
191
+ content: [
192
+ {
193
+ type: 'text',
194
+ text: JSON.stringify(books, null, 2)
195
+ }
196
+ ]
197
+ };
198
+ });
199
+ server.prompt('inkdrop-prompt', 'Instructions for using the Inkdrop MCP server effectively', () => ({
200
+ messages: [
201
+ {
202
+ role: 'assistant',
203
+ content: {
204
+ type: 'text',
205
+ text: `Inkdrop is a Markdown note-taking app designed for programmers to help their coding workflow.
206
+ This server provides access to the Inkdrop database. Use it to search notes, create new notes, and track issues written in the notes.
207
+
208
+ Key capabilities:
209
+ - Search notes by keyword
210
+ - Get a note by its ID
211
+ - Get a list of all notebooks
212
+
213
+ Best practices:
214
+ - When searching:
215
+ - Use specific, targeted queries for better results (e.g., "auth mobile app" rather than just "auth")
216
+ - Apply relevant filters when asked or when you can infer the appropriate filters to narrow results
217
+ - Use \`read-note\` to get the full note content
218
+
219
+ Model schemas:
220
+
221
+ \`\`\`json
222
+ ${JSON.stringify(inkdrop_model_1.NoteSchema, null, 2)}
223
+ \`\`\`
224
+
225
+ \`\`\`json
226
+ ${JSON.stringify(inkdrop_model_1.BookSchema, null, 2)}
227
+ \`\`\`
228
+
229
+ `
230
+ }
231
+ }
232
+ ]
233
+ }));
234
+ async function runServer() {
235
+ const transport = new stdio_js_1.StdioServerTransport();
236
+ await server.connect(transport);
237
+ console.error('Secure MCP Inkdrop Server running on stdio');
238
+ }
239
+ runServer().catch(error => {
240
+ console.error('Fatal error running server:', error);
241
+ process.exit(1);
242
+ });