@inkdropapp/mcp-server 1.4.0 → 1.5.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/.github/workflows/claude-code-review.yml +9 -10
- package/.github/workflows/claude.yml +6 -7
- package/.oxfmtrc.json +12 -0
- package/README.md +34 -27
- package/dist/api.js +6 -6
- package/dist/index.js +246 -65
- package/dist/utils.js +47 -0
- package/package.json +8 -6
- package/src/api.ts +18 -21
- package/src/index.ts +313 -92
- package/src/utils.ts +50 -0
- package/tsconfig.json +1 -1
- package/prettier.config.js +0 -12
package/src/utils.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { extname } from 'node:path'
|
|
2
|
+
|
|
3
|
+
import { SUPPORTED_IMAGE_MIME_TYPES, type ImageFileType } from 'inkdrop-model'
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
6
|
* Builds the canonical Inkdrop note URI for a note ID.
|
|
3
7
|
*
|
|
@@ -11,3 +15,49 @@
|
|
|
11
15
|
export function getNoteUri(noteId: string): string {
|
|
12
16
|
return `inkdrop://note/${noteId.replace(/^note:/, '')}`
|
|
13
17
|
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Builds the Inkdrop attachment URI for a file ID.
|
|
21
|
+
*
|
|
22
|
+
* Unlike note links, attachment URIs keep the `file:` prefix and use no slash
|
|
23
|
+
* (`file:foobar` → `inkdrop://file:foobar`). This matches how the desktop app
|
|
24
|
+
* renders an attachment into a note body, so the result can be embedded as-is.
|
|
25
|
+
*
|
|
26
|
+
* @param fileId - The file document ID, with or without the `file:` prefix
|
|
27
|
+
* @returns The `inkdrop://file:<id>` URI
|
|
28
|
+
*/
|
|
29
|
+
export function getFileUri(fileId: string): string {
|
|
30
|
+
return `inkdrop://${fileId.startsWith('file:') ? fileId : `file:${fileId}`}`
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Infers the attachment content type from a file name or path extension.
|
|
35
|
+
*
|
|
36
|
+
* `SUPPORTED_IMAGE_MIME_TYPES` is keyed by MIME subtype, which doubles as the file
|
|
37
|
+
* extension for every supported type except SVG, whose subtype is `svg+xml`.
|
|
38
|
+
*
|
|
39
|
+
* @returns The matching image MIME type, or `undefined` when the extension is
|
|
40
|
+
* missing or not a supported attachment type
|
|
41
|
+
*/
|
|
42
|
+
export function inferImageContentType(filePath: string): ImageFileType | undefined {
|
|
43
|
+
const ext = extname(filePath).toLowerCase().replace(/^\./, '')
|
|
44
|
+
return SUPPORTED_IMAGE_MIME_TYPES[ext === 'svg' ? 'svg+xml' : ext]
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Content types the MCP `image` content block can carry. Inkdrop also accepts
|
|
49
|
+
* SVG and HEIC/HEIF attachments, which have to be written to disk instead.
|
|
50
|
+
*/
|
|
51
|
+
const VIEWABLE_IMAGE_TYPES = new Set<ImageFileType>([
|
|
52
|
+
'image/png',
|
|
53
|
+
'image/jpeg',
|
|
54
|
+
'image/jpg',
|
|
55
|
+
'image/gif'
|
|
56
|
+
])
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Whether an attachment can be returned as an MCP `image` content block.
|
|
60
|
+
*/
|
|
61
|
+
export function isViewableImageType(contentType: ImageFileType | undefined): boolean {
|
|
62
|
+
return contentType !== undefined && VIEWABLE_IMAGE_TYPES.has(contentType)
|
|
63
|
+
}
|
package/tsconfig.json
CHANGED
package/prettier.config.js
DELETED