@shortcut/mcp 0.11.2 → 0.12.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 +29 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
4
|
import { ShortcutClient } from "@shortcut/client";
|
|
5
|
+
import { File } from "node:buffer";
|
|
6
|
+
import { readFileSync } from "node:fs";
|
|
7
|
+
import { basename } from "node:path";
|
|
5
8
|
import { z } from "zod";
|
|
6
9
|
|
|
7
10
|
//#region src/client/cache.ts
|
|
@@ -422,6 +425,18 @@ var ShortcutClientWrapper = class {
|
|
|
422
425
|
if (!doc) throw new Error(`Failed to create the document: ${response.status}`);
|
|
423
426
|
return doc;
|
|
424
427
|
}
|
|
428
|
+
async uploadFile(storyId, filePath) {
|
|
429
|
+
const fileContent = readFileSync(filePath);
|
|
430
|
+
const fileName = basename(filePath);
|
|
431
|
+
const file = new File([fileContent], fileName);
|
|
432
|
+
const response = await this.client.uploadFiles({
|
|
433
|
+
story_id: storyId,
|
|
434
|
+
file0: file
|
|
435
|
+
});
|
|
436
|
+
const uploadedFile = response?.data ?? null;
|
|
437
|
+
if (!uploadedFile?.length) throw new Error(`Failed to upload the file: ${response.status}`);
|
|
438
|
+
return uploadedFile[0];
|
|
439
|
+
}
|
|
425
440
|
async getCustomFieldMap(customFieldIds) {
|
|
426
441
|
await this.loadCustomFields();
|
|
427
442
|
return new Map(customFieldIds.map((id) => [id, this.customFieldCache.get(id)]).filter((customField) => customField[1] !== null));
|
|
@@ -435,7 +450,7 @@ var ShortcutClientWrapper = class {
|
|
|
435
450
|
//#endregion
|
|
436
451
|
//#region package.json
|
|
437
452
|
var name = "@shortcut/mcp";
|
|
438
|
-
var version = "0.
|
|
453
|
+
var version = "0.12.0";
|
|
439
454
|
|
|
440
455
|
//#endregion
|
|
441
456
|
//#region src/tools/base.ts
|
|
@@ -1194,6 +1209,10 @@ The story will be added to the default state for the workflow.
|
|
|
1194
1209
|
description: z.string().optional().describe("The description of the label")
|
|
1195
1210
|
})).optional().describe("Labels to assign to the story")
|
|
1196
1211
|
}, async (params) => await tools.updateStory(params));
|
|
1212
|
+
server$1.tool("upload-file-to-story", "Upload a file and link it to a story.", {
|
|
1213
|
+
storyPublicId: z.number().positive().describe("The public ID of the story"),
|
|
1214
|
+
filePath: z.string().describe("The path to the file to upload")
|
|
1215
|
+
}, async ({ storyPublicId, filePath }) => await tools.uploadFileToStory(storyPublicId, filePath));
|
|
1197
1216
|
server$1.tool("assign-current-user-as-owner", "Assign the current user as the owner of a story", { storyPublicId: z.number().positive().describe("The public ID of the story") }, async ({ storyPublicId }) => await tools.assignCurrentUserAsOwner(storyPublicId));
|
|
1198
1217
|
server$1.tool("unassign-current-user-as-owner", "Unassign the current user as the owner of a story", { storyPublicId: z.number().positive().describe("The public ID of the story") }, async ({ storyPublicId }) => await tools.unassignCurrentUserAsOwner(storyPublicId));
|
|
1199
1218
|
server$1.tool("create-story-comment", "Create a comment on a story", {
|
|
@@ -1326,6 +1345,15 @@ The story will be added to the default state for the workflow.
|
|
|
1326
1345
|
const updatedStory = await this.client.updateStory(storyPublicId, updateParams);
|
|
1327
1346
|
return this.toResult(`Updated story sc-${storyPublicId}. Story URL: ${updatedStory.app_url}`);
|
|
1328
1347
|
}
|
|
1348
|
+
async uploadFileToStory(storyPublicId, filePath) {
|
|
1349
|
+
if (!storyPublicId) throw new Error("Story public ID is required");
|
|
1350
|
+
if (!filePath) throw new Error("File path is required");
|
|
1351
|
+
const story = await this.client.getStory(storyPublicId);
|
|
1352
|
+
if (!story) throw new Error(`Failed to retrieve Shortcut story with public ID: ${storyPublicId}`);
|
|
1353
|
+
const uploadedFile = await this.client.uploadFile(storyPublicId, filePath);
|
|
1354
|
+
if (!uploadedFile) throw new Error(`Failed to upload file to story sc-${storyPublicId}`);
|
|
1355
|
+
return this.toResult(`Uploaded file "${uploadedFile.name}" to story sc-${storyPublicId}. File ID is: ${uploadedFile.id}`);
|
|
1356
|
+
}
|
|
1329
1357
|
async addTaskToStory({ storyPublicId, taskDescription, taskOwnerIds }) {
|
|
1330
1358
|
if (!storyPublicId) throw new Error("Story public ID is required");
|
|
1331
1359
|
if (!taskDescription) throw new Error("Task description is required");
|