@inkdropapp/mcp-server 1.4.0 → 1.6.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/.claude/settings.local.json +1 -3
- package/.oxfmtrc.json +12 -0
- package/README.md +47 -36
- package/dist/api.js +6 -6
- package/dist/index.js +280 -70
- package/dist/utils.js +47 -0
- package/package.json +8 -6
- package/src/api.ts +18 -21
- package/src/index.ts +356 -97
- package/src/utils.ts +50 -0
- package/tsconfig.json +1 -1
- package/.github/workflows/claude-code-review.yml +0 -78
- package/.github/workflows/claude.yml +0 -64
- package/prettier.config.js +0 -12
package/dist/utils.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getNoteUri = getNoteUri;
|
|
4
|
+
exports.getFileUri = getFileUri;
|
|
5
|
+
exports.inferImageContentType = inferImageContentType;
|
|
6
|
+
exports.isViewableImageType = isViewableImageType;
|
|
7
|
+
const node_path_1 = require("node:path");
|
|
8
|
+
const inkdrop_model_1 = require("inkdrop-model");
|
|
4
9
|
/**
|
|
5
10
|
* Builds the canonical Inkdrop note URI for a note ID.
|
|
6
11
|
*
|
|
@@ -14,3 +19,45 @@ exports.getNoteUri = getNoteUri;
|
|
|
14
19
|
function getNoteUri(noteId) {
|
|
15
20
|
return `inkdrop://note/${noteId.replace(/^note:/, '')}`;
|
|
16
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Builds the Inkdrop attachment URI for a file ID.
|
|
24
|
+
*
|
|
25
|
+
* Unlike note links, attachment URIs keep the `file:` prefix and use no slash
|
|
26
|
+
* (`file:foobar` → `inkdrop://file:foobar`). This matches how the desktop app
|
|
27
|
+
* renders an attachment into a note body, so the result can be embedded as-is.
|
|
28
|
+
*
|
|
29
|
+
* @param fileId - The file document ID, with or without the `file:` prefix
|
|
30
|
+
* @returns The `inkdrop://file:<id>` URI
|
|
31
|
+
*/
|
|
32
|
+
function getFileUri(fileId) {
|
|
33
|
+
return `inkdrop://${fileId.startsWith('file:') ? fileId : `file:${fileId}`}`;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Infers the attachment content type from a file name or path extension.
|
|
37
|
+
*
|
|
38
|
+
* `SUPPORTED_IMAGE_MIME_TYPES` is keyed by MIME subtype, which doubles as the file
|
|
39
|
+
* extension for every supported type except SVG, whose subtype is `svg+xml`.
|
|
40
|
+
*
|
|
41
|
+
* @returns The matching image MIME type, or `undefined` when the extension is
|
|
42
|
+
* missing or not a supported attachment type
|
|
43
|
+
*/
|
|
44
|
+
function inferImageContentType(filePath) {
|
|
45
|
+
const ext = (0, node_path_1.extname)(filePath).toLowerCase().replace(/^\./, '');
|
|
46
|
+
return inkdrop_model_1.SUPPORTED_IMAGE_MIME_TYPES[ext === 'svg' ? 'svg+xml' : ext];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Content types the MCP `image` content block can carry. Inkdrop also accepts
|
|
50
|
+
* SVG and HEIC/HEIF attachments, which have to be written to disk instead.
|
|
51
|
+
*/
|
|
52
|
+
const VIEWABLE_IMAGE_TYPES = new Set([
|
|
53
|
+
'image/png',
|
|
54
|
+
'image/jpeg',
|
|
55
|
+
'image/jpg',
|
|
56
|
+
'image/gif'
|
|
57
|
+
]);
|
|
58
|
+
/**
|
|
59
|
+
* Whether an attachment can be returned as an MCP `image` content block.
|
|
60
|
+
*/
|
|
61
|
+
function isViewableImageType(contentType) {
|
|
62
|
+
return contentType !== undefined && VIEWABLE_IMAGE_TYPES.has(contentType);
|
|
63
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkdropapp/mcp-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Inkdrop Model Context Protocol Server",
|
|
5
5
|
"bin": {
|
|
6
6
|
"inkdrop-mcp-server": "dist/index.js"
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
"build": "tsc && chmod +x dist/*.js",
|
|
11
11
|
"prepublishOnly": "npm run build",
|
|
12
12
|
"watch": "tsc --watch",
|
|
13
|
+
"format": "oxfmt",
|
|
14
|
+
"format:check": "oxfmt --check",
|
|
13
15
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
14
16
|
},
|
|
15
17
|
"repository": {
|
|
@@ -24,14 +26,14 @@
|
|
|
24
26
|
"author": "Takuya Matsuyama<contact@inkdrop.app>",
|
|
25
27
|
"license": "Apache-2.0",
|
|
26
28
|
"dependencies": {
|
|
27
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
29
|
+
"@modelcontextprotocol/sdk": "^1.32.1",
|
|
28
30
|
"ajv": "^8.20.0",
|
|
29
|
-
"inkdrop-model": "^
|
|
30
|
-
"zod": "^4.
|
|
31
|
+
"inkdrop-model": "^3.0.1",
|
|
32
|
+
"zod": "^4.6.7"
|
|
31
33
|
},
|
|
32
34
|
"devDependencies": {
|
|
33
|
-
"@types/node": "^26.
|
|
34
|
-
"
|
|
35
|
+
"@types/node": "^26.6.5",
|
|
36
|
+
"oxfmt": "^0.73.0",
|
|
35
37
|
"typescript": "^7.0.2"
|
|
36
38
|
}
|
|
37
39
|
}
|
package/src/api.ts
CHANGED
|
@@ -1,48 +1,45 @@
|
|
|
1
1
|
const config = {
|
|
2
2
|
baseUrl: process.env.INKDROP_LOCAL_SERVER_URL,
|
|
3
3
|
username: process.env.INKDROP_LOCAL_USERNAME,
|
|
4
|
-
password: process.env.INKDROP_LOCAL_PASSWORD
|
|
5
|
-
}
|
|
4
|
+
password: process.env.INKDROP_LOCAL_PASSWORD
|
|
5
|
+
}
|
|
6
6
|
|
|
7
7
|
function getAuthHeaders() {
|
|
8
|
-
const token = Buffer.from(`${config.username}:${config.password}`).toString(
|
|
9
|
-
"base64"
|
|
10
|
-
);
|
|
8
|
+
const token = Buffer.from(`${config.username}:${config.password}`).toString('base64')
|
|
11
9
|
return {
|
|
12
10
|
Authorization: `Basic ${token}`
|
|
13
|
-
}
|
|
11
|
+
}
|
|
14
12
|
}
|
|
15
13
|
|
|
16
14
|
export function buildUrl(path: string, qs: Record<string, any> = {}): string {
|
|
17
|
-
const url = new URL(path, config.baseUrl)
|
|
15
|
+
const url = new URL(path, config.baseUrl)
|
|
18
16
|
for (const [k, v] of Object.entries(qs)) {
|
|
19
|
-
if (v !== undefined && v !== null) url.searchParams.set(k, String(v))
|
|
17
|
+
if (v !== undefined && v !== null) url.searchParams.set(k, String(v))
|
|
20
18
|
}
|
|
21
|
-
return url.toString()
|
|
19
|
+
return url.toString()
|
|
22
20
|
}
|
|
23
21
|
|
|
24
22
|
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() })
|
|
23
|
+
const url = buildUrl(path, qs)
|
|
24
|
+
const resp = await fetch(url, { headers: getAuthHeaders() })
|
|
27
25
|
if (!resp.ok) {
|
|
28
|
-
throw new Error(`Fetch error [${resp.status}] ${resp.statusText}`)
|
|
26
|
+
throw new Error(`Fetch error [${resp.status}] ${resp.statusText}`)
|
|
29
27
|
}
|
|
30
|
-
return await resp.json() as T
|
|
28
|
+
return (await resp.json()) as T
|
|
31
29
|
}
|
|
32
30
|
|
|
33
|
-
export async function postJSON(path: string, body: unknown) {
|
|
34
|
-
const url = buildUrl(path)
|
|
31
|
+
export async function postJSON<T = any>(path: string, body: unknown): Promise<T> {
|
|
32
|
+
const url = buildUrl(path)
|
|
35
33
|
const resp = await fetch(url, {
|
|
36
|
-
method:
|
|
34
|
+
method: 'POST',
|
|
37
35
|
headers: {
|
|
38
36
|
...getAuthHeaders(),
|
|
39
|
-
|
|
37
|
+
'Content-Type': 'application/json'
|
|
40
38
|
},
|
|
41
39
|
body: JSON.stringify(body)
|
|
42
|
-
})
|
|
40
|
+
})
|
|
43
41
|
if (!resp.ok) {
|
|
44
|
-
throw new Error(`Fetch error [${resp.status}] ${resp.statusText}`)
|
|
42
|
+
throw new Error(`Fetch error [${resp.status}] ${resp.statusText}`)
|
|
45
43
|
}
|
|
46
|
-
return await resp.json()
|
|
44
|
+
return (await resp.json()) as T
|
|
47
45
|
}
|
|
48
|
-
|