@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/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
@@ -5,7 +5,7 @@
5
5
  "lib": ["es2024"],
6
6
  "types": ["node"],
7
7
  "stripInternal": true,
8
- "noUnusedLocals": false,
8
+ "noUnusedLocals": true,
9
9
  "strict": true,
10
10
  "target": "es2024",
11
11
  "module": "nodenext",
@@ -1,12 +0,0 @@
1
- /** @type {import('prettier').Options} */
2
- const options = {
3
- arrowParens: 'avoid',
4
- singleQuote: true,
5
- bracketSpacing: true,
6
- endOfLine: 'lf',
7
- semi: false,
8
- tabWidth: 2,
9
- trailingComma: 'none'
10
- }
11
-
12
- export default options