@tasqmate/mcp 0.2.0 → 0.3.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/README.md CHANGED
@@ -88,9 +88,9 @@ so `tasqmate project share` and the web Share dialog are the only ways in.
88
88
  | `billing_period_mark_invoiced` | `tasqmate clients invoice` | `workspace`, `client`, `month`, `invoiceRef` (admins) |
89
89
  | `billing_period_reopen` | `tasqmate clients reopen` | `workspace`, `client`, `month` (admins) |
90
90
  | `comment_add` | `tasqmate comment add` | `workspace`, `body`, `task`, `project`, `doc`, `propose`, `replyTo`, `thread`, `mentions`, `attach` (absolute paths) |
91
- | `file_add` | `tasqmate file add` | `workspace`, `task`, `paths` (absolute paths, up to 100 MB each) |
91
+ | `file_add` | `tasqmate file add` | `workspace`, `task` or `doc`, `paths` (absolute paths, up to 100 MB each), `inline` (returns each file's Markdown line for the body) |
92
92
  | `file_list` | `tasqmate file list` | `workspace`, `task`: the task's files, then each comment's |
93
- | `file_get` | `tasqmate file get` | `workspace`, `id`, `out` (absolute path), `force`, `link`; with neither, a five-minute link plus the text of a text file up to 256 KB |
93
+ | `file_get` | `tasqmate file get` | `workspace`, `id`, `out` (absolute path), `force`, `link`; with neither, a five-minute link plus the text of a text file up to 256 KB or an image up to 5 MB as image content |
94
94
  | `file_remove` | `tasqmate file remove` | `workspace`, `id` |
95
95
  | `thread_view` | `tasqmate thread view` | `workspace`, `threadId` |
96
96
  | `thread_context` | `tasqmate thread context` | `workspace`, `threadId`, `format` (`markdown` by default) |
@@ -22264,6 +22264,29 @@ function formatFileSize(bytes) {
22264
22264
  const rounded = value >= 10 ? Math.round(value) : Math.round(value * 10) / 10;
22265
22265
  return `${rounded} ${units[unit]}`;
22266
22266
  }
22267
+ var PREVIEWABLE_IMAGE_TYPES = /* @__PURE__ */ new Set([
22268
+ "image/png",
22269
+ "image/jpeg",
22270
+ "image/gif",
22271
+ "image/webp",
22272
+ "image/avif"
22273
+ ]);
22274
+ function isPreviewableImage(contentType) {
22275
+ return PREVIEWABLE_IMAGE_TYPES.has(contentType.toLowerCase());
22276
+ }
22277
+ function escapeLinkText(text) {
22278
+ return text.replace(/[\\[\]]/g, (char) => `\\${char}`);
22279
+ }
22280
+ function fileMarkdown(file2, layout = {}) {
22281
+ const href = `tasq:file/${file2.id}`;
22282
+ if (!isPreviewableImage(file2.contentType)) {
22283
+ return `[${escapeLinkText(file2.fileName)}](${href})`;
22284
+ }
22285
+ const size = layout.size ?? "full";
22286
+ const align = layout.align ?? "center";
22287
+ const title = size === "full" && align === "center" ? "" : ` "${size} ${align}"`;
22288
+ return `![${escapeLinkText(layout.caption ?? "")}](${href}${title})`;
22289
+ }
22267
22290
 
22268
22291
  // ../sdk/src/errors.ts
22269
22292
  var TasqmateApiError = class extends Error {
@@ -22612,7 +22635,9 @@ var TasqmateClient = class _TasqmateClient {
22612
22635
  /**
22613
22636
  * Upload a file in one call: `attachment.begin`, the PUT, then
22614
22637
  * `attachment.finish`. With `forComment`, the file is staged for the
22615
- * next `comment.add` that names it in `attachmentIds`.
22638
+ * next `comment.add` that names it in `attachmentIds`. With `inline`,
22639
+ * it is for the task's description or the doc's body (ATT-2): put
22640
+ * `fileMarkdown(result.attachment)` in the body to show it there.
22616
22641
  */
22617
22642
  upload: async (slug, target, file2, options) => {
22618
22643
  const body = file2.data instanceof Blob ? file2.data : new Blob([file2.data]);
@@ -22622,7 +22647,8 @@ var TasqmateClient = class _TasqmateClient {
22622
22647
  fileName: file2.fileName,
22623
22648
  contentType,
22624
22649
  sizeBytes: body.size,
22625
- forComment: file2.forComment
22650
+ forComment: file2.forComment,
22651
+ inline: file2.inline
22626
22652
  });
22627
22653
  const { upload, attachment } = begun.result;
22628
22654
  const put = await this.#fetch(upload.url, {
@@ -31000,7 +31026,7 @@ var EMPTY_COMPLETION_RESULT = {
31000
31026
  // package.json
31001
31027
  var package_default = {
31002
31028
  name: "@tasqmate/mcp",
31003
- version: "0.2.0",
31029
+ version: "0.3.0",
31004
31030
  description: "MCP stdio server for Tasqmate: tasks, threads, comments and mentions for MCP-capable agents",
31005
31031
  keywords: [
31006
31032
  "tasqmate",
@@ -31690,7 +31716,7 @@ function requireAbsolute(path, field) {
31690
31716
  }
31691
31717
  return path;
31692
31718
  }
31693
- async function uploadPaths(client, slug, target, paths, forComment = false) {
31719
+ async function uploadPaths(client, slug, target, paths, options = {}) {
31694
31720
  const uploaded = [];
31695
31721
  for (const path of paths) {
31696
31722
  let data;
@@ -31701,21 +31727,25 @@ async function uploadPaths(client, slug, target, paths, forComment = false) {
31701
31727
  throw new UsageError(`Cannot read "${path}".`);
31702
31728
  }
31703
31729
  const fileName = basename(path);
31730
+ const contentType = contentTypeFor(fileName);
31704
31731
  const done = await client.attachments.upload(slug, target, {
31705
31732
  data,
31706
31733
  fileName,
31707
- contentType: contentTypeFor(fileName),
31708
- forComment
31734
+ contentType,
31735
+ forComment: options.forComment === true,
31736
+ inline: options.inline
31709
31737
  });
31710
31738
  uploaded.push({
31711
31739
  id: done.result.attachment.id,
31712
31740
  fileName,
31741
+ contentType,
31713
31742
  sizeBytes: done.result.attachment.sizeBytes
31714
31743
  });
31715
31744
  }
31716
31745
  return uploaded;
31717
31746
  }
31718
31747
  var INLINE_TEXT_MAX_BYTES = 256 * 1024;
31748
+ var INLINE_IMAGE_MAX_BYTES = 5 * 1024 * 1024;
31719
31749
  function isTextType(contentType) {
31720
31750
  return contentType.startsWith("text/") || ["application/json", "application/yaml", "application/xml"].includes(contentType);
31721
31751
  }
@@ -32362,7 +32392,9 @@ var definitions = [
32362
32392
  }
32363
32393
  const attach = input.attach ?? [];
32364
32394
  if (attach.length > 0) {
32365
- const staged = await uploadPaths(client, slug, target.action, attach, true);
32395
+ const staged = await uploadPaths(client, slug, target.action, attach, {
32396
+ forComment: true
32397
+ });
32366
32398
  action.attachmentIds = staged.map((file2) => file2.id);
32367
32399
  }
32368
32400
  const added = await client.dispatch("comment.add", slug, action);
@@ -32574,20 +32606,40 @@ var definitions = [
32574
32606
  }),
32575
32607
  define({
32576
32608
  name: "file_add",
32577
- description: "Attach local files to a task, up to 100 MB each; to post files with a comment, use comment_add's attach instead.",
32609
+ description: "Attach local files to a task or doc, up to 100 MB each; with inline, get each file's Markdown line to put in the body.",
32578
32610
  schema: external_exports.object({
32579
32611
  ...workspaceFields,
32580
- task: external_exports.string().describe("Task key such as ENG-42, or a task id."),
32581
- paths: external_exports.array(external_exports.string()).min(1).describe("Absolute paths of the files to attach.")
32612
+ task: external_exports.string().optional().describe("Task key such as ENG-42, or a task id."),
32613
+ doc: external_exports.string().optional().describe("Doc id, link or exact title, instead of task."),
32614
+ paths: external_exports.array(external_exports.string()).min(1).describe("Absolute paths of the files to attach."),
32615
+ inline: external_exports.boolean().optional().describe(
32616
+ `For the task description or doc body: returns each file's Markdown line, an image as ![caption](tasq:file/<id> "medium left") (small|medium|full, left|center|right), anything else as [name](tasq:file/<id>), to put in with task_update or doc_update. For a comment, use comment_add's attach.`
32617
+ )
32582
32618
  }),
32583
32619
  run: async ({ client, config: config2 }, input) => {
32584
32620
  const slug = requireWorkspace(config2, input);
32585
- const taskId = await resolveTaskId(client, slug, input.task);
32586
- const uploaded = await uploadPaths(client, slug, { taskId }, input.paths);
32621
+ if (input.task === void 0 === (input.doc === void 0)) {
32622
+ throw new UsageError("Pass either task or doc.");
32623
+ }
32624
+ const target = input.doc === void 0 ? { taskId: await resolveTaskId(client, slug, input.task ?? "") } : { documentId: await resolveDocumentId(client, slug, input.doc) };
32625
+ const uploaded = await uploadPaths(client, slug, target, input.paths, {
32626
+ inline: input.inline
32627
+ });
32628
+ const on = input.task ?? input.doc ?? "";
32629
+ if (input.inline === true) {
32630
+ const files = uploaded.map((file2) => ({ ...file2, markdown: fileMarkdown(file2) }));
32631
+ return {
32632
+ data: files,
32633
+ lines: [
32634
+ `Uploaded for ${on}'s ${input.doc === void 0 ? "description" : "body"}. Put each line where the file should show:`,
32635
+ ...files.map((file2) => file2.markdown)
32636
+ ]
32637
+ };
32638
+ }
32587
32639
  return {
32588
32640
  data: uploaded,
32589
32641
  lines: uploaded.map(
32590
- (file2) => `Attached ${file2.fileName} (${formatFileSize(file2.sizeBytes)}) to ${input.task}.`
32642
+ (file2) => `Attached ${file2.fileName} (${formatFileSize(file2.sizeBytes)}) to ${on}.`
32591
32643
  )
32592
32644
  };
32593
32645
  }
@@ -32615,7 +32667,7 @@ var definitions = [
32615
32667
  }),
32616
32668
  define({
32617
32669
  name: "file_get",
32618
- description: "Read a file: save it to out, or return a five-minute link plus the text itself for a text file up to 256 KB (only the link with link).",
32670
+ description: "Read a file: save it to out, or get a five-minute link plus the text (up to 256 KB) or the image (up to 5 MB) itself.",
32619
32671
  schema: external_exports.object({
32620
32672
  ...workspaceFields,
32621
32673
  id: external_exports.string().describe("File id, from file_list or task_view."),
@@ -32629,11 +32681,20 @@ var definitions = [
32629
32681
  const wantsText = out === void 0 && input.link !== true;
32630
32682
  const link = await client.attachments.link(slug, input.id);
32631
32683
  const textFits = wantsText && isTextType(link.contentType) && link.sizeBytes <= INLINE_TEXT_MAX_BYTES;
32632
- if (out === void 0 && !textFits) return { data: link };
32684
+ const imageFits = wantsText && isPreviewableImage(link.contentType) && link.sizeBytes <= INLINE_IMAGE_MAX_BYTES;
32685
+ if (out === void 0 && !textFits && !imageFits) return { data: link };
32633
32686
  if (out !== void 0 && input.force !== true && existsSync(out)) {
32634
32687
  throw new UsageError(`"${out}" already exists. Pass force to overwrite.`);
32635
32688
  }
32636
32689
  const { data } = await client.attachments.download(slug, input.id);
32690
+ if (out === void 0 && imageFits) {
32691
+ return {
32692
+ data: link,
32693
+ images: [
32694
+ { data: Buffer.from(data).toString("base64"), mimeType: link.contentType }
32695
+ ]
32696
+ };
32697
+ }
32637
32698
  if (out === void 0) {
32638
32699
  return { data: { ...link, text: new TextDecoder().decode(data) } };
32639
32700
  }
@@ -32825,7 +32886,10 @@ function structured(data) {
32825
32886
  function toToolResult(outcome) {
32826
32887
  const text = outcome.text !== void 0 ? outcome.text : [...outcome.lines ?? [], JSON.stringify(outcome.data)].join("\n");
32827
32888
  const result2 = {
32828
- content: [{ type: "text", text }]
32889
+ content: [
32890
+ { type: "text", text },
32891
+ ...(outcome.images ?? []).map((image) => ({ type: "image", ...image }))
32892
+ ]
32829
32893
  };
32830
32894
  const content = structured(outcome.data);
32831
32895
  if (content !== void 0) result2.structuredContent = content;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tasqmate/mcp",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "MCP stdio server for Tasqmate: tasks, threads, comments and mentions for MCP-capable agents",
5
5
  "keywords": [
6
6
  "tasqmate",
@@ -48,7 +48,7 @@
48
48
  "zod": "4.3.6"
49
49
  },
50
50
  "devDependencies": {
51
- "@tasqmate/sdk": "0.2.0",
51
+ "@tasqmate/sdk": "0.3.0",
52
52
  "@types/bun": "^1.3.12",
53
53
  "tsup": "^8.5.0",
54
54
  "typescript": "^5.7.2"