@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 +79 -0
- package/dist/api.js +47 -0
- package/dist/bak.js +331 -0
- package/dist/index.js +242 -0
- package/package.json +33 -0
- package/prettier.config.js +12 -0
- package/src/api.ts +48 -0
- package/src/bak.ts +433 -0
- package/src/index.ts +303 -0
- package/tsconfig.json +26 -0
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@inkdropapp/mcp-server",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Inkdrop Model Context Protocol Server",
|
|
5
|
+
"bin": {
|
|
6
|
+
"inkdrop-mcp-server": "dist/index.js"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"start": "bun src/index.ts",
|
|
10
|
+
"build": "tsc && chmod +x dist/*.js",
|
|
11
|
+
"prepublishOnly": "npm run build",
|
|
12
|
+
"watch": "tsc --watch",
|
|
13
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"Inkdrop",
|
|
17
|
+
"MCP",
|
|
18
|
+
"Claude"
|
|
19
|
+
],
|
|
20
|
+
"author": "Takuya Matsuyama<contact@inkdrop.app>",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@modelcontextprotocol/sdk": "^1.6.1",
|
|
24
|
+
"ajv": "^8.17.1",
|
|
25
|
+
"inkdrop-model": "^2.8.0",
|
|
26
|
+
"zod": "^3.24.2"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/node": "^22.13.9",
|
|
30
|
+
"prettier": "^3.5.3",
|
|
31
|
+
"typescript": "^5.8.2"
|
|
32
|
+
}
|
|
33
|
+
}
|
package/src/api.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const config = {
|
|
2
|
+
baseUrl: process.env.INKDROP_LOCAL_SERVER_URL,
|
|
3
|
+
username: process.env.INKDROP_LOCAL_USERNAME,
|
|
4
|
+
password: process.env.INKDROP_LOCAL_PASSWORD,
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
function getAuthHeaders() {
|
|
8
|
+
const token = Buffer.from(`${config.username}:${config.password}`).toString(
|
|
9
|
+
"base64"
|
|
10
|
+
);
|
|
11
|
+
return {
|
|
12
|
+
Authorization: `Basic ${token}`
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function buildUrl(path: string, qs: Record<string, any> = {}): string {
|
|
17
|
+
const url = new URL(path, config.baseUrl);
|
|
18
|
+
for (const [k, v] of Object.entries(qs)) {
|
|
19
|
+
if (v !== undefined && v !== null) url.searchParams.set(k, String(v));
|
|
20
|
+
}
|
|
21
|
+
return url.toString();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function fetchJSON<T = any>(path: string, qs: Record<string, any> = {}): Promise<T> {
|
|
25
|
+
const url = buildUrl(path, qs);
|
|
26
|
+
const resp = await fetch(url, { headers: getAuthHeaders() });
|
|
27
|
+
if (!resp.ok) {
|
|
28
|
+
throw new Error(`Fetch error [${resp.status}] ${resp.statusText}`);
|
|
29
|
+
}
|
|
30
|
+
return await resp.json() as T;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export async function postJSON(path: string, body: unknown) {
|
|
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
|
+
}
|
|
48
|
+
|
package/src/bak.ts
ADDED
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example: MCP Proxy for Inkdrop's local HTTP server.
|
|
3
|
+
*
|
|
4
|
+
* Requirements:
|
|
5
|
+
* 1) Inkdrop's local server is running at config.baseUrl (e.g. http://localhost:19840).
|
|
6
|
+
* 2) A Basic auth username/password is set in Inkdrop.
|
|
7
|
+
* 3) This script can be run with `npx ts-node inkdrop-mcp-proxy.ts`.
|
|
8
|
+
* 4) Then, an MCP client (e.g. MCP Inspector, or Claude) can connect to:
|
|
9
|
+
* GET http://localhost:3002/sse (SSE endpoint)
|
|
10
|
+
* POST http://localhost:3002/messages (MCP messages endpoint)
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { URL, URLSearchParams } from "url";
|
|
14
|
+
import {
|
|
15
|
+
McpServer,
|
|
16
|
+
ResourceTemplate
|
|
17
|
+
} from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
18
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
19
|
+
import { z } from "zod";
|
|
20
|
+
|
|
21
|
+
/** Configuration for talking to Inkdrop’s local HTTP server */
|
|
22
|
+
const config = {
|
|
23
|
+
baseUrl: "http://localhost:19841", // or https://localhost:19840
|
|
24
|
+
username: "foo@bar.com",
|
|
25
|
+
password: "bar",
|
|
26
|
+
/** If Inkdrop uses self-signed cert over HTTPS, you may need to allow that. */
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** Build the 'Authorization: Basic ...' header */
|
|
30
|
+
function getAuthHeaders() {
|
|
31
|
+
const token = Buffer.from(`${config.username}:${config.password}`).toString(
|
|
32
|
+
"base64"
|
|
33
|
+
);
|
|
34
|
+
return {
|
|
35
|
+
Authorization: `Basic ${token}`
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Helper to attach query parameters to a given path */
|
|
40
|
+
function buildUrl(path: string, qs: Record<string, any> = {}): string {
|
|
41
|
+
const url = new URL(path, config.baseUrl);
|
|
42
|
+
for (const [k, v] of Object.entries(qs)) {
|
|
43
|
+
if (v !== undefined && v !== null) url.searchParams.set(k, String(v));
|
|
44
|
+
}
|
|
45
|
+
return url.toString();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Helper to do a GET request and return JSON or throw an error. */
|
|
49
|
+
async function fetchJSON(path: string, qs: Record<string, any> = {}) {
|
|
50
|
+
const url = buildUrl(path, qs);
|
|
51
|
+
const resp = await fetch(url, { headers: getAuthHeaders() });
|
|
52
|
+
if (!resp.ok) {
|
|
53
|
+
throw new Error(`Fetch error [${resp.status}] ${resp.statusText}`);
|
|
54
|
+
}
|
|
55
|
+
return await resp.json();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Helper to do a POST request with JSON body */
|
|
59
|
+
async function postJSON(path: string, body: unknown) {
|
|
60
|
+
const url = buildUrl(path);
|
|
61
|
+
const resp = await fetch(url, {
|
|
62
|
+
method: "POST",
|
|
63
|
+
headers: {
|
|
64
|
+
...getAuthHeaders(),
|
|
65
|
+
"Content-Type": "application/json"
|
|
66
|
+
},
|
|
67
|
+
body: JSON.stringify(body)
|
|
68
|
+
});
|
|
69
|
+
if (!resp.ok) {
|
|
70
|
+
throw new Error(`Fetch error [${resp.status}] ${resp.statusText}`);
|
|
71
|
+
}
|
|
72
|
+
return await resp.json();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Helper to do a DELETE request */
|
|
76
|
+
async function deleteJSON(path: string) {
|
|
77
|
+
const url = buildUrl(path);
|
|
78
|
+
const resp = await fetch(url, {
|
|
79
|
+
method: "DELETE",
|
|
80
|
+
headers: getAuthHeaders()
|
|
81
|
+
});
|
|
82
|
+
if (!resp.ok) {
|
|
83
|
+
throw new Error(`Fetch error [${resp.status}] ${resp.statusText}`);
|
|
84
|
+
}
|
|
85
|
+
return await resp.json();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Create the MCP Server that proxies to Inkdrop’s local API. */
|
|
89
|
+
function createInkdropProxyServer() {
|
|
90
|
+
const server = new McpServer({
|
|
91
|
+
name: "Inkdrop MCP Proxy",
|
|
92
|
+
version: "1.0.0"
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
//
|
|
96
|
+
// 1) Root meta info (like GET "/")
|
|
97
|
+
//
|
|
98
|
+
server.resource("root", "inkdrop://root", async (uri) => {
|
|
99
|
+
const body = await fetchJSON("/");
|
|
100
|
+
return {
|
|
101
|
+
contents: [
|
|
102
|
+
{
|
|
103
|
+
uri: uri.href,
|
|
104
|
+
text: JSON.stringify(body, null, 2)
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
};
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
//
|
|
111
|
+
// 2) Notes
|
|
112
|
+
//
|
|
113
|
+
// 2a) List all notes (proxy GET /notes, with query params)
|
|
114
|
+
server.resource(
|
|
115
|
+
"notes",
|
|
116
|
+
new ResourceTemplate("inkdrop://notes{?keyword,limit,skip,sort,descending}", {
|
|
117
|
+
list: undefined
|
|
118
|
+
}),
|
|
119
|
+
async (uri) => {
|
|
120
|
+
// forward query to /notes
|
|
121
|
+
const qs = Object.fromEntries(uri.searchParams.entries());
|
|
122
|
+
const body = await fetchJSON("/notes", qs);
|
|
123
|
+
return {
|
|
124
|
+
contents: [
|
|
125
|
+
{
|
|
126
|
+
uri: uri.href,
|
|
127
|
+
text: JSON.stringify(body, null, 2)
|
|
128
|
+
}
|
|
129
|
+
]
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
// 2b) Create/update note (proxy POST /notes)
|
|
135
|
+
server.tool(
|
|
136
|
+
"save-note",
|
|
137
|
+
{
|
|
138
|
+
_id: z.string().optional(),
|
|
139
|
+
_rev: z.string().optional(),
|
|
140
|
+
doctype: z.string().optional(),
|
|
141
|
+
bookId: z.string().optional(),
|
|
142
|
+
status: z.string().optional(),
|
|
143
|
+
share: z.string().optional(),
|
|
144
|
+
title: z.string().optional(),
|
|
145
|
+
body: z.string().optional(),
|
|
146
|
+
pinned: z.boolean().optional(),
|
|
147
|
+
tags: z.array(z.string()).optional()
|
|
148
|
+
},
|
|
149
|
+
async (args) => {
|
|
150
|
+
const ret = await postJSON("/notes", args);
|
|
151
|
+
return {
|
|
152
|
+
content: [{ type: "text", text: JSON.stringify(ret, null, 2) }]
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
// 2c) Get single note (proxy GET /note:docId)
|
|
158
|
+
server.resource(
|
|
159
|
+
"single-note",
|
|
160
|
+
new ResourceTemplate("inkdrop://note/{docId}{?rev,attachments}", { list: undefined }),
|
|
161
|
+
async (uri, { docId }) => {
|
|
162
|
+
const qs = Object.fromEntries(uri.searchParams.entries());
|
|
163
|
+
const body = await fetchJSON(`/note:${docId}`, qs);
|
|
164
|
+
return {
|
|
165
|
+
contents: [
|
|
166
|
+
{
|
|
167
|
+
uri: uri.href,
|
|
168
|
+
text: JSON.stringify(body, null, 2)
|
|
169
|
+
}
|
|
170
|
+
]
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
// 2d) Delete note (proxy DELETE /note:docId)
|
|
176
|
+
server.tool(
|
|
177
|
+
"delete-note",
|
|
178
|
+
{ docId: z.string() },
|
|
179
|
+
async ({ docId }) => {
|
|
180
|
+
const ret = await deleteJSON(`/note:${docId}`);
|
|
181
|
+
return {
|
|
182
|
+
content: [{ type: "text", text: JSON.stringify(ret, null, 2) }]
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
//
|
|
188
|
+
// 3) Books (Notebooks)
|
|
189
|
+
//
|
|
190
|
+
// 3a) List notebooks (GET /books)
|
|
191
|
+
server.resource(
|
|
192
|
+
"books",
|
|
193
|
+
new ResourceTemplate("inkdrop://books{?limit,skip}", { list: undefined }),
|
|
194
|
+
async (uri) => {
|
|
195
|
+
const qs = Object.fromEntries(uri.searchParams.entries());
|
|
196
|
+
const body = await fetchJSON("/books", qs);
|
|
197
|
+
return {
|
|
198
|
+
contents: [
|
|
199
|
+
{
|
|
200
|
+
uri: uri.href,
|
|
201
|
+
text: JSON.stringify(body, null, 2)
|
|
202
|
+
}
|
|
203
|
+
]
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
);
|
|
207
|
+
|
|
208
|
+
// 3b) Create/update a book (POST /books)
|
|
209
|
+
server.tool(
|
|
210
|
+
"save-book",
|
|
211
|
+
{
|
|
212
|
+
_id: z.string().optional(),
|
|
213
|
+
_rev: z.string().optional(),
|
|
214
|
+
name: z.string().optional(),
|
|
215
|
+
parentBookId: z.string().optional()
|
|
216
|
+
},
|
|
217
|
+
async (args) => {
|
|
218
|
+
const ret = await postJSON("/books", args);
|
|
219
|
+
return {
|
|
220
|
+
content: [{ type: "text", text: JSON.stringify(ret, null, 2) }]
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
// 3c) Get a single book (GET /book:docId)
|
|
226
|
+
server.resource(
|
|
227
|
+
"single-book",
|
|
228
|
+
new ResourceTemplate("inkdrop://book/{docId}{?rev,attachments}", { list: undefined }),
|
|
229
|
+
async (uri, { docId }) => {
|
|
230
|
+
const qs = Object.fromEntries(uri.searchParams.entries());
|
|
231
|
+
const body = await fetchJSON(`/book:${docId}`, qs);
|
|
232
|
+
return {
|
|
233
|
+
contents: [
|
|
234
|
+
{
|
|
235
|
+
uri: uri.href,
|
|
236
|
+
text: JSON.stringify(body, null, 2)
|
|
237
|
+
}
|
|
238
|
+
]
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
// 3d) Delete book (DELETE /book:docId)
|
|
244
|
+
server.tool(
|
|
245
|
+
"delete-book",
|
|
246
|
+
{ docId: z.string() },
|
|
247
|
+
async ({ docId }) => {
|
|
248
|
+
const ret = await deleteJSON(`/book:${docId}`);
|
|
249
|
+
return {
|
|
250
|
+
content: [{ type: "text", text: JSON.stringify(ret, null, 2) }]
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
);
|
|
254
|
+
|
|
255
|
+
//
|
|
256
|
+
// 4) Tags
|
|
257
|
+
//
|
|
258
|
+
// 4a) List tags (GET /tags)
|
|
259
|
+
server.resource(
|
|
260
|
+
"tags",
|
|
261
|
+
new ResourceTemplate("inkdrop://tags{?limit,skip}", { list: undefined }),
|
|
262
|
+
async (uri) => {
|
|
263
|
+
const qs = Object.fromEntries(uri.searchParams.entries());
|
|
264
|
+
const body = await fetchJSON("/tags", qs);
|
|
265
|
+
return {
|
|
266
|
+
contents: [
|
|
267
|
+
{
|
|
268
|
+
uri: uri.href,
|
|
269
|
+
text: JSON.stringify(body, null, 2)
|
|
270
|
+
}
|
|
271
|
+
]
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
);
|
|
275
|
+
|
|
276
|
+
// 4b) Create/update tag (POST /tags)
|
|
277
|
+
server.tool(
|
|
278
|
+
"save-tag",
|
|
279
|
+
{
|
|
280
|
+
_id: z.string().optional(),
|
|
281
|
+
_rev: z.string().optional(),
|
|
282
|
+
name: z.string(),
|
|
283
|
+
color: z.string().optional()
|
|
284
|
+
},
|
|
285
|
+
async (args) => {
|
|
286
|
+
const ret = await postJSON("/tags", args);
|
|
287
|
+
return {
|
|
288
|
+
content: [{ type: "text", text: JSON.stringify(ret, null, 2) }]
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
);
|
|
292
|
+
|
|
293
|
+
// 4c) Get tag (GET /tag:docId)
|
|
294
|
+
server.resource(
|
|
295
|
+
"single-tag",
|
|
296
|
+
new ResourceTemplate("inkdrop://tag/{docId}{?rev,attachments}", { list: undefined }),
|
|
297
|
+
async (uri, { docId }) => {
|
|
298
|
+
const qs = Object.fromEntries(uri.searchParams.entries());
|
|
299
|
+
const body = await fetchJSON(`/tag:${docId}`, qs);
|
|
300
|
+
return {
|
|
301
|
+
contents: [
|
|
302
|
+
{
|
|
303
|
+
uri: uri.href,
|
|
304
|
+
text: JSON.stringify(body, null, 2)
|
|
305
|
+
}
|
|
306
|
+
]
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
);
|
|
310
|
+
|
|
311
|
+
// 4d) Delete tag (DELETE /tag:docId)
|
|
312
|
+
server.tool(
|
|
313
|
+
"delete-tag",
|
|
314
|
+
{ docId: z.string() },
|
|
315
|
+
async ({ docId }) => {
|
|
316
|
+
const ret = await deleteJSON(`/tag:${docId}`);
|
|
317
|
+
return {
|
|
318
|
+
content: [{ type: "text", text: JSON.stringify(ret, null, 2) }]
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
);
|
|
322
|
+
|
|
323
|
+
//
|
|
324
|
+
// 5) Files
|
|
325
|
+
//
|
|
326
|
+
// 5a) List files (GET /files)
|
|
327
|
+
server.resource(
|
|
328
|
+
"files",
|
|
329
|
+
new ResourceTemplate("inkdrop://files{?limit,skip}", { list: undefined }),
|
|
330
|
+
async (uri) => {
|
|
331
|
+
const qs = Object.fromEntries(uri.searchParams.entries());
|
|
332
|
+
const body = await fetchJSON("/files", qs);
|
|
333
|
+
return {
|
|
334
|
+
contents: [
|
|
335
|
+
{
|
|
336
|
+
uri: uri.href,
|
|
337
|
+
text: JSON.stringify(body, null, 2)
|
|
338
|
+
}
|
|
339
|
+
]
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
);
|
|
343
|
+
|
|
344
|
+
// 5b) Create/update file (POST /files)
|
|
345
|
+
server.tool(
|
|
346
|
+
"save-file",
|
|
347
|
+
{
|
|
348
|
+
_id: z.string().optional(),
|
|
349
|
+
_rev: z.string().optional(),
|
|
350
|
+
name: z.string(),
|
|
351
|
+
contentType: z.string().optional(),
|
|
352
|
+
contentLength: z.number().optional(),
|
|
353
|
+
publicIn: z.array(z.string()).optional(),
|
|
354
|
+
_attachments: z.any().optional()
|
|
355
|
+
},
|
|
356
|
+
async (args) => {
|
|
357
|
+
const ret = await postJSON("/files", args);
|
|
358
|
+
return {
|
|
359
|
+
content: [{ type: "text", text: JSON.stringify(ret, null, 2) }]
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
);
|
|
363
|
+
|
|
364
|
+
// 5c) Get file (GET /file:docId)
|
|
365
|
+
server.resource(
|
|
366
|
+
"single-file",
|
|
367
|
+
new ResourceTemplate("inkdrop://file/{docId}{?rev,attachments}", { list: undefined }),
|
|
368
|
+
async (uri, { docId }) => {
|
|
369
|
+
const qs = Object.fromEntries(uri.searchParams.entries());
|
|
370
|
+
const body = await fetchJSON(`/file:${docId}`, qs);
|
|
371
|
+
return {
|
|
372
|
+
contents: [
|
|
373
|
+
{
|
|
374
|
+
uri: uri.href,
|
|
375
|
+
text: JSON.stringify(body, null, 2)
|
|
376
|
+
}
|
|
377
|
+
]
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
);
|
|
381
|
+
|
|
382
|
+
// 5d) Delete file (DELETE /file:docId)
|
|
383
|
+
server.tool(
|
|
384
|
+
"delete-file",
|
|
385
|
+
{ docId: z.string() },
|
|
386
|
+
async ({ docId }) => {
|
|
387
|
+
const ret = await deleteJSON(`/file:${docId}`);
|
|
388
|
+
return {
|
|
389
|
+
content: [{ type: "text", text: JSON.stringify(ret, null, 2) }]
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
);
|
|
393
|
+
|
|
394
|
+
//
|
|
395
|
+
// 6) Changes feed (GET /_changes)
|
|
396
|
+
//
|
|
397
|
+
server.resource(
|
|
398
|
+
"changes",
|
|
399
|
+
new ResourceTemplate(
|
|
400
|
+
"inkdrop://changes{?descending,since,limit,include_docs,conflicts,attachments}",
|
|
401
|
+
{ list: undefined }
|
|
402
|
+
),
|
|
403
|
+
async (uri) => {
|
|
404
|
+
const qs = Object.fromEntries(uri.searchParams.entries());
|
|
405
|
+
const body = await fetchJSON("/_changes", qs);
|
|
406
|
+
return {
|
|
407
|
+
contents: [
|
|
408
|
+
{
|
|
409
|
+
uri: uri.href,
|
|
410
|
+
text: JSON.stringify(body, null, 2)
|
|
411
|
+
}
|
|
412
|
+
]
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
);
|
|
416
|
+
|
|
417
|
+
// Done! We have a resource/tool for every Inkdrop endpoint.
|
|
418
|
+
return server;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/** Actually run an HTTP server exposing this MCP server over SSE and POST. */
|
|
422
|
+
async function main() {
|
|
423
|
+
const mcpServer = createInkdropProxyServer();
|
|
424
|
+
const transport = new StdioServerTransport();
|
|
425
|
+
console.log("MCP (stdio) proxy for Inkdrop is now running...");
|
|
426
|
+
console.log("Send MCP requests on stdin, responses come out on stdout.\n");
|
|
427
|
+
await mcpServer.connect(transport);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
main().catch((err) => {
|
|
431
|
+
console.error("Error starting proxy:", err);
|
|
432
|
+
process.exit(1);
|
|
433
|
+
});
|