@agiletortoise/drafts-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/dist/index.js ADDED
@@ -0,0 +1,581 @@
1
+ #!/usr/bin/env node
2
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
3
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
+ import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
5
+ import * as drafts from './drafts.js';
6
+ // Define all available tools
7
+ const TOOLS = [
8
+ {
9
+ name: 'drafts_list_workspaces',
10
+ description: 'List all workspaces in Drafts',
11
+ inputSchema: {
12
+ type: 'object',
13
+ properties: {},
14
+ },
15
+ },
16
+ {
17
+ name: 'drafts_get_current_workspace',
18
+ description: 'Get the current workspace in Drafts',
19
+ inputSchema: {
20
+ type: 'object',
21
+ properties: {},
22
+ },
23
+ },
24
+ {
25
+ name: 'drafts_get_current',
26
+ description: 'Get the current draft open in Drafts',
27
+ inputSchema: {
28
+ type: 'object',
29
+ properties: {},
30
+ },
31
+ },
32
+ {
33
+ name: 'drafts_get_workspace_drafts',
34
+ description: 'Get drafts from a specific workspace, optionally filtered by folder',
35
+ inputSchema: {
36
+ type: 'object',
37
+ properties: {
38
+ workspaceName: {
39
+ type: 'string',
40
+ description: 'The name of the workspace to get drafts from',
41
+ },
42
+ folder: {
43
+ type: 'string',
44
+ enum: ['inbox', 'archive', 'trash'],
45
+ description: 'Optional folder to filter drafts (inbox, archive, or trash)',
46
+ },
47
+ },
48
+ required: ['workspaceName'],
49
+ },
50
+ },
51
+ {
52
+ name: 'drafts_get_drafts',
53
+ description: 'Get drafts with flexible filtering by content, folder, tag, flagged status, and dates',
54
+ inputSchema: {
55
+ type: 'object',
56
+ properties: {
57
+ query: {
58
+ type: 'string',
59
+ description: 'Filter drafts whose content contains this text',
60
+ },
61
+ folder: {
62
+ type: 'string',
63
+ enum: ['inbox', 'archive', 'trash'],
64
+ description: 'Filter by folder (inbox, archive, or trash)',
65
+ },
66
+ tag: {
67
+ type: 'string',
68
+ description: 'Filter drafts that have this tag',
69
+ },
70
+ flagged: {
71
+ type: 'boolean',
72
+ description: 'Filter by flagged status',
73
+ },
74
+ createdAfter: {
75
+ type: 'string',
76
+ description: 'Filter drafts created after this date (e.g., "2024-01-01")',
77
+ },
78
+ createdBefore: {
79
+ type: 'string',
80
+ description: 'Filter drafts created before this date (e.g., "2024-12-31")',
81
+ },
82
+ modifiedAfter: {
83
+ type: 'string',
84
+ description: 'Filter drafts modified after this date (e.g., "2024-01-01")',
85
+ },
86
+ modifiedBefore: {
87
+ type: 'string',
88
+ description: 'Filter drafts modified before this date (e.g., "2024-12-31")',
89
+ },
90
+ },
91
+ },
92
+ },
93
+ {
94
+ name: 'drafts_create_draft',
95
+ description: 'Create a new draft with content and optional tags',
96
+ inputSchema: {
97
+ type: 'object',
98
+ properties: {
99
+ content: {
100
+ type: 'string',
101
+ description: 'The content of the new draft',
102
+ },
103
+ tags: {
104
+ type: 'array',
105
+ items: { type: 'string' },
106
+ description: 'Optional tags to add to the draft',
107
+ },
108
+ flagged: {
109
+ type: 'boolean',
110
+ description: 'Whether to flag the draft',
111
+ },
112
+ },
113
+ required: ['content'],
114
+ },
115
+ },
116
+ {
117
+ name: 'drafts_get_draft',
118
+ description: 'Get a specific draft by its UUID',
119
+ inputSchema: {
120
+ type: 'object',
121
+ properties: {
122
+ uuid: {
123
+ type: 'string',
124
+ description: 'The UUID of the draft to retrieve',
125
+ },
126
+ },
127
+ required: ['uuid'],
128
+ },
129
+ },
130
+ {
131
+ name: 'drafts_update_draft',
132
+ description: 'Update the content of an existing draft',
133
+ inputSchema: {
134
+ type: 'object',
135
+ properties: {
136
+ uuid: {
137
+ type: 'string',
138
+ description: 'The UUID of the draft to update',
139
+ },
140
+ content: {
141
+ type: 'string',
142
+ description: 'The new content for the draft',
143
+ },
144
+ },
145
+ required: ['uuid', 'content'],
146
+ },
147
+ },
148
+ {
149
+ name: 'drafts_add_tags',
150
+ description: 'Add tags to an existing draft',
151
+ inputSchema: {
152
+ type: 'object',
153
+ properties: {
154
+ uuid: {
155
+ type: 'string',
156
+ description: 'The UUID of the draft',
157
+ },
158
+ tags: {
159
+ type: 'array',
160
+ items: { type: 'string' },
161
+ description: 'Tags to add to the draft',
162
+ },
163
+ },
164
+ required: ['uuid', 'tags'],
165
+ },
166
+ },
167
+ {
168
+ name: 'drafts_search',
169
+ description: 'Search for drafts using a query string',
170
+ inputSchema: {
171
+ type: 'object',
172
+ properties: {
173
+ query: {
174
+ type: 'string',
175
+ description: 'The search query',
176
+ },
177
+ },
178
+ required: ['query'],
179
+ },
180
+ },
181
+ {
182
+ name: 'drafts_run_action',
183
+ description: 'Run a Drafts action on a specific draft',
184
+ inputSchema: {
185
+ type: 'object',
186
+ properties: {
187
+ draftUuid: {
188
+ type: 'string',
189
+ description: 'The UUID of the draft to run the action on',
190
+ },
191
+ actionName: {
192
+ type: 'string',
193
+ description: 'The name of the action to run',
194
+ },
195
+ },
196
+ required: ['draftUuid', 'actionName'],
197
+ },
198
+ },
199
+ {
200
+ name: 'drafts_list_actions',
201
+ description: 'List all available actions in Drafts',
202
+ inputSchema: {
203
+ type: 'object',
204
+ properties: {},
205
+ },
206
+ },
207
+ {
208
+ name: 'drafts_flag',
209
+ description: 'Flag or unflag a draft',
210
+ inputSchema: {
211
+ type: 'object',
212
+ properties: {
213
+ uuid: {
214
+ type: 'string',
215
+ description: 'The UUID of the draft',
216
+ },
217
+ flagged: {
218
+ type: 'boolean',
219
+ description: 'Whether to flag (true) or unflag (false) the draft',
220
+ },
221
+ },
222
+ required: ['uuid', 'flagged'],
223
+ },
224
+ },
225
+ {
226
+ name: 'drafts_archive',
227
+ description: 'Archive a draft',
228
+ inputSchema: {
229
+ type: 'object',
230
+ properties: {
231
+ uuid: {
232
+ type: 'string',
233
+ description: 'The UUID of the draft to archive',
234
+ },
235
+ },
236
+ required: ['uuid'],
237
+ },
238
+ },
239
+ {
240
+ name: 'drafts_inbox',
241
+ description: 'Move a draft to inbox',
242
+ inputSchema: {
243
+ type: 'object',
244
+ properties: {
245
+ uuid: {
246
+ type: 'string',
247
+ description: 'The UUID of the draft to move to inbox',
248
+ },
249
+ },
250
+ required: ['uuid'],
251
+ },
252
+ },
253
+ {
254
+ name: 'drafts_trash',
255
+ description: 'Move a draft to trash',
256
+ inputSchema: {
257
+ type: 'object',
258
+ properties: {
259
+ uuid: {
260
+ type: 'string',
261
+ description: 'The UUID of the draft to trash',
262
+ },
263
+ },
264
+ required: ['uuid'],
265
+ },
266
+ },
267
+ {
268
+ name: 'drafts_open',
269
+ description: 'Open a draft in the Drafts editor',
270
+ inputSchema: {
271
+ type: 'object',
272
+ properties: {
273
+ uuid: {
274
+ type: 'string',
275
+ description: 'The UUID of the draft to open',
276
+ },
277
+ },
278
+ required: ['uuid'],
279
+ },
280
+ },
281
+ ];
282
+ /**
283
+ * Main server class
284
+ */
285
+ class DraftsMCPServer {
286
+ server;
287
+ constructor() {
288
+ this.server = new Server({
289
+ name: 'drafts-mcp-server',
290
+ version: '1.0.0',
291
+ }, {
292
+ capabilities: {
293
+ tools: {},
294
+ },
295
+ });
296
+ this.setupHandlers();
297
+ this.setupErrorHandling();
298
+ }
299
+ setupErrorHandling() {
300
+ this.server.onerror = (error) => {
301
+ console.error('[MCP Error]', error);
302
+ };
303
+ process.on('SIGINT', async () => {
304
+ await this.server.close();
305
+ process.exit(0);
306
+ });
307
+ }
308
+ setupHandlers() {
309
+ // List available tools
310
+ this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
311
+ tools: TOOLS,
312
+ }));
313
+ // Handle tool calls
314
+ this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
315
+ const { name, arguments: args } = request.params;
316
+ try {
317
+ switch (name) {
318
+ case 'drafts_list_workspaces': {
319
+ const workspaces = await drafts.listWorkspaces();
320
+ return {
321
+ content: [
322
+ {
323
+ type: 'text',
324
+ text: JSON.stringify(workspaces, null, 2),
325
+ },
326
+ ],
327
+ };
328
+ }
329
+ case 'drafts_get_current_workspace': {
330
+ const workspace = await drafts.getCurrentWorkspace();
331
+ return {
332
+ content: [
333
+ {
334
+ type: 'text',
335
+ text: JSON.stringify(workspace, null, 2),
336
+ },
337
+ ],
338
+ };
339
+ }
340
+ case 'drafts_get_current': {
341
+ const draft = await drafts.getCurrentDraft();
342
+ if (!draft) {
343
+ return {
344
+ content: [
345
+ {
346
+ type: 'text',
347
+ text: 'No current draft',
348
+ },
349
+ ],
350
+ isError: true,
351
+ };
352
+ }
353
+ return {
354
+ content: [
355
+ {
356
+ type: 'text',
357
+ text: JSON.stringify(draft, null, 2),
358
+ },
359
+ ],
360
+ };
361
+ }
362
+ case 'drafts_get_workspace_drafts': {
363
+ const { workspaceName, folder } = args;
364
+ const draftsList = await drafts.getWorkspaceDrafts(workspaceName, folder);
365
+ return {
366
+ content: [
367
+ {
368
+ type: 'text',
369
+ text: JSON.stringify(draftsList, null, 2),
370
+ },
371
+ ],
372
+ };
373
+ }
374
+ case 'drafts_get_drafts': {
375
+ const filter = args;
376
+ const draftsList = await drafts.getDrafts(filter);
377
+ return {
378
+ content: [
379
+ {
380
+ type: 'text',
381
+ text: JSON.stringify(draftsList, null, 2),
382
+ },
383
+ ],
384
+ };
385
+ }
386
+ case 'drafts_create_draft': {
387
+ const { content, tags, flagged } = args;
388
+ const uuid = await drafts.createDraft(content, tags, flagged);
389
+ return {
390
+ content: [
391
+ {
392
+ type: 'text',
393
+ text: `Created draft with UUID: ${uuid}`,
394
+ },
395
+ ],
396
+ };
397
+ }
398
+ case 'drafts_get_draft': {
399
+ const { uuid } = args;
400
+ const draft = await drafts.getDraft(uuid);
401
+ if (!draft) {
402
+ return {
403
+ content: [
404
+ {
405
+ type: 'text',
406
+ text: `Draft not found: ${uuid}`,
407
+ },
408
+ ],
409
+ isError: true,
410
+ };
411
+ }
412
+ return {
413
+ content: [
414
+ {
415
+ type: 'text',
416
+ text: JSON.stringify(draft, null, 2),
417
+ },
418
+ ],
419
+ };
420
+ }
421
+ case 'drafts_update_draft': {
422
+ const { uuid, content } = args;
423
+ const success = await drafts.updateDraft(uuid, content);
424
+ return {
425
+ content: [
426
+ {
427
+ type: 'text',
428
+ text: success ? `Updated draft ${uuid}` : `Failed to update draft ${uuid}`,
429
+ },
430
+ ],
431
+ isError: !success,
432
+ };
433
+ }
434
+ case 'drafts_add_tags': {
435
+ const { uuid, tags } = args;
436
+ const success = await drafts.addTagsToDraft(uuid, tags);
437
+ return {
438
+ content: [
439
+ {
440
+ type: 'text',
441
+ text: success
442
+ ? `Added tags to draft ${uuid}`
443
+ : `Failed to add tags to draft ${uuid}`,
444
+ },
445
+ ],
446
+ isError: !success,
447
+ };
448
+ }
449
+ case 'drafts_search': {
450
+ const { query } = args;
451
+ const results = await drafts.searchDrafts(query);
452
+ return {
453
+ content: [
454
+ {
455
+ type: 'text',
456
+ text: JSON.stringify(results, null, 2),
457
+ },
458
+ ],
459
+ };
460
+ }
461
+ case 'drafts_run_action': {
462
+ const { draftUuid, actionName } = args;
463
+ const success = await drafts.runAction(draftUuid, actionName);
464
+ return {
465
+ content: [
466
+ {
467
+ type: 'text',
468
+ text: success
469
+ ? `Ran action "${actionName}" on draft ${draftUuid}`
470
+ : `Failed to run action "${actionName}" on draft ${draftUuid}`,
471
+ },
472
+ ],
473
+ isError: !success,
474
+ };
475
+ }
476
+ case 'drafts_list_actions': {
477
+ const actions = await drafts.listActions();
478
+ return {
479
+ content: [
480
+ {
481
+ type: 'text',
482
+ text: JSON.stringify(actions, null, 2),
483
+ },
484
+ ],
485
+ };
486
+ }
487
+ case 'drafts_flag': {
488
+ const { uuid, flagged } = args;
489
+ const success = await drafts.setDraftFlagged(uuid, flagged);
490
+ return {
491
+ content: [
492
+ {
493
+ type: 'text',
494
+ text: success
495
+ ? `${flagged ? 'Flagged' : 'Unflagged'} draft ${uuid}`
496
+ : `Failed to ${flagged ? 'flag' : 'unflag'} draft ${uuid}`,
497
+ },
498
+ ],
499
+ isError: !success,
500
+ };
501
+ }
502
+ case 'drafts_archive': {
503
+ const { uuid } = args;
504
+ const success = await drafts.archiveDraft(uuid);
505
+ return {
506
+ content: [
507
+ {
508
+ type: 'text',
509
+ text: success ? `Archived draft ${uuid}` : `Failed to archive draft ${uuid}`,
510
+ },
511
+ ],
512
+ isError: !success,
513
+ };
514
+ }
515
+ case 'drafts_inbox': {
516
+ const { uuid } = args;
517
+ const success = await drafts.inboxDraft(uuid);
518
+ return {
519
+ content: [
520
+ {
521
+ type: 'text',
522
+ text: success ? `Moved draft ${uuid} to inbox` : `Failed to move draft ${uuid} to inbox`,
523
+ },
524
+ ],
525
+ isError: !success,
526
+ };
527
+ }
528
+ case 'drafts_trash': {
529
+ const { uuid } = args;
530
+ const success = await drafts.trashDraft(uuid);
531
+ return {
532
+ content: [
533
+ {
534
+ type: 'text',
535
+ text: success ? `Trashed draft ${uuid}` : `Failed to trash draft ${uuid}`,
536
+ },
537
+ ],
538
+ isError: !success,
539
+ };
540
+ }
541
+ case 'drafts_open': {
542
+ const { uuid } = args;
543
+ const success = await drafts.openDraft(uuid);
544
+ return {
545
+ content: [
546
+ {
547
+ type: 'text',
548
+ text: success ? `Opened draft ${uuid}` : `Failed to open draft ${uuid}`,
549
+ },
550
+ ],
551
+ isError: !success,
552
+ };
553
+ }
554
+ default:
555
+ throw new Error(`Unknown tool: ${name}`);
556
+ }
557
+ }
558
+ catch (error) {
559
+ const errorMessage = error instanceof Error ? error.message : String(error);
560
+ return {
561
+ content: [
562
+ {
563
+ type: 'text',
564
+ text: `Error executing ${name}: ${errorMessage}`,
565
+ },
566
+ ],
567
+ isError: true,
568
+ };
569
+ }
570
+ });
571
+ }
572
+ async run() {
573
+ const transport = new StdioServerTransport();
574
+ await this.server.connect(transport);
575
+ console.error('Drafts MCP Server running on stdio');
576
+ }
577
+ }
578
+ // Start the server
579
+ const server = new DraftsMCPServer();
580
+ server.run().catch(console.error);
581
+ //# sourceMappingUR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,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,GAAG;QACP,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;QAC7C,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACrC,OAAO,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACtD,CAAC;CACF;AAED,mBAAmB;AACnB,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;AACrC,MAAM,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@agiletortoise/drafts-mcp-server",
3
+ "version": "1.0.0",
4
+ "description": "Model Context Protocol server for Drafts app on macOS",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "bin": {
8
+ "drafts-mcp-server": "dist/index.js"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "README.md",
13
+ "LICENSE"
14
+ ],
15
+ "scripts": {
16
+ "build": "tsc",
17
+ "watch": "tsc --watch",
18
+ "prepare": "npm run build",
19
+ "inspector": "npx @modelcontextprotocol/inspector node dist/index.js"
20
+ },
21
+ "keywords": [
22
+ "mcp",
23
+ "model-context-protocol",
24
+ "drafts",
25
+ "applescript",
26
+ "macos",
27
+ "automation",
28
+ "ai"
29
+ ],
30
+ "author": "Agile Tortoise",
31
+ "license": "MIT",
32
+ "engines": {
33
+ "node": ">=18.0.0"
34
+ },
35
+ "os": [
36
+ "darwin"
37
+ ],
38
+ "dependencies": {
39
+ "@modelcontextprotocol/sdk": "^1.0.4"
40
+ },
41
+ "devDependencies": {
42
+ "@types/node": "^22.10.5",
43
+ "typescript": "^5.7.3"
44
+ },
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "https://github.com/agiletortoise/drafts-mcp-server.git"
48
+ },
49
+ "bugs": {
50
+ "url": "https://github.com/agiletortoise/drafts-mcp-server/issues"
51
+ },
52
+ "homepage": "https://github.com/agiletortoise/drafts-mcp-server#readme"
53
+ }