@taiga-ai/mcp-server 0.40.0-dev.1242 → 0.41.0-dev.1243

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.
Files changed (3) hide show
  1. package/README.md +10 -10
  2. package/dist/index.js +388 -39
  3. package/package.json +2 -1
package/README.md CHANGED
@@ -14,7 +14,7 @@ You need an access key, made in Taiga under **Settings > Account > MCP**, where
14
14
 
15
15
  Create the key first, and choose when it expires: in 30 days, 90 days, a year, or never. Taiga copies it to your clipboard, shows it once, and keeps it on the page until you say you have saved it, so copying the setup next does not lose it.
16
16
 
17
- The same page shows the setup for your client and environment, with the key already filled in where a config file needs it, and a one-click install for Cursor. The examples here pin a release (`@taiga-ai/mcp-server@0.40.0`), so an install runs the version you chose rather than whatever `latest` is at the next start.
17
+ The same page shows the setup for your client and environment, with the key already filled in where a config file needs it, and a one-click install for Cursor. The examples here pin a release (`@taiga-ai/mcp-server@0.41.0`), so an install runs the version you chose rather than whatever `latest` is at the next start.
18
18
 
19
19
  ## Install
20
20
 
@@ -23,29 +23,29 @@ The same page shows the setup for your client and environment, with the key alre
23
23
  Run the command. When it asks for your access key, paste it once and press Enter. Nothing appears as you paste (PowerShell shows asterisks), and the key stays out of your shell history:
24
24
 
25
25
  ```sh
26
- printf 'Taiga access key: ' && read -rs TAIGA_API_KEY && echo && claude mcp add taiga --scope user -e TAIGA_API_KEY="$TAIGA_API_KEY" -- npx -y @taiga-ai/mcp-server@0.40.0
26
+ printf 'Taiga access key: ' && read -rs TAIGA_API_KEY && echo && claude mcp add taiga --scope user -e TAIGA_API_KEY="$TAIGA_API_KEY" -- npx -y @taiga-ai/mcp-server@0.41.0
27
27
  ```
28
28
 
29
29
  ```sh
30
- printf 'Taiga access key: ' && read -rs TAIGA_API_KEY && echo && codex mcp add taiga --env TAIGA_API_KEY="$TAIGA_API_KEY" -- npx -y @taiga-ai/mcp-server@0.40.0
30
+ printf 'Taiga access key: ' && read -rs TAIGA_API_KEY && echo && codex mcp add taiga --env TAIGA_API_KEY="$TAIGA_API_KEY" -- npx -y @taiga-ai/mcp-server@0.41.0
31
31
  ```
32
32
 
33
33
  ```sh
34
- printf 'Taiga access key: ' && read -rs TAIGA_API_KEY && echo && copilot mcp add taiga --env TAIGA_API_KEY="$TAIGA_API_KEY" -- npx -y @taiga-ai/mcp-server@0.40.0
34
+ printf 'Taiga access key: ' && read -rs TAIGA_API_KEY && echo && copilot mcp add taiga --env TAIGA_API_KEY="$TAIGA_API_KEY" -- npx -y @taiga-ai/mcp-server@0.41.0
35
35
  ```
36
36
 
37
37
  On Windows, in PowerShell (Claude Code and Copilot start `npx` through `cmd /c`; the quoted `'--'` survives npm's PowerShell shims):
38
38
 
39
39
  ```powershell
40
- $k = Read-Host 'Taiga access key' -AsSecureString; claude mcp add taiga --scope user -e "TAIGA_API_KEY=$([Net.NetworkCredential]::new('', $k).Password)" '--' cmd /c npx -y @taiga-ai/mcp-server@0.40.0
40
+ $k = Read-Host 'Taiga access key' -AsSecureString; claude mcp add taiga --scope user -e "TAIGA_API_KEY=$([Net.NetworkCredential]::new('', $k).Password)" '--' cmd /c npx -y @taiga-ai/mcp-server@0.41.0
41
41
  ```
42
42
 
43
43
  ```powershell
44
- $k = Read-Host 'Taiga access key' -AsSecureString; codex mcp add taiga --env "TAIGA_API_KEY=$([Net.NetworkCredential]::new('', $k).Password)" '--' npx -y @taiga-ai/mcp-server@0.40.0
44
+ $k = Read-Host 'Taiga access key' -AsSecureString; codex mcp add taiga --env "TAIGA_API_KEY=$([Net.NetworkCredential]::new('', $k).Password)" '--' npx -y @taiga-ai/mcp-server@0.41.0
45
45
  ```
46
46
 
47
47
  ```powershell
48
- $k = Read-Host 'Taiga access key' -AsSecureString; copilot mcp add taiga --env "TAIGA_API_KEY=$([Net.NetworkCredential]::new('', $k).Password)" '--' cmd /c npx -y @taiga-ai/mcp-server@0.40.0
48
+ $k = Read-Host 'Taiga access key' -AsSecureString; copilot mcp add taiga --env "TAIGA_API_KEY=$([Net.NetworkCredential]::new('', $k).Password)" '--' cmd /c npx -y @taiga-ai/mcp-server@0.41.0
49
49
  ```
50
50
 
51
51
  The Copilot command also sets up the GitHub Copilot app. If you have the app but no `copilot` command, add the server to `~/.copilot/mcp-config.json` instead, beside any servers already there. It holds your key, so keep it out of repositories:
@@ -56,7 +56,7 @@ The Copilot command also sets up the GitHub Copilot app. If you have the app but
56
56
  "taiga": {
57
57
  "type": "local",
58
58
  "command": "npx",
59
- "args": ["-y", "@taiga-ai/mcp-server@0.40.0"],
59
+ "args": ["-y", "@taiga-ai/mcp-server@0.41.0"],
60
60
  "env": { "TAIGA_API_KEY": "YOUR_ACCESS_KEY" },
61
61
  "tools": ["*"]
62
62
  }
@@ -73,7 +73,7 @@ Most clients read the same `mcpServers` block. Add it with your key in place of
73
73
  "mcpServers": {
74
74
  "taiga": {
75
75
  "command": "npx",
76
- "args": ["-y", "@taiga-ai/mcp-server@0.40.0"],
76
+ "args": ["-y", "@taiga-ai/mcp-server@0.41.0"],
77
77
  "env": { "TAIGA_API_KEY": "YOUR_ACCESS_KEY" }
78
78
  }
79
79
  }
@@ -101,7 +101,7 @@ In `.vscode/mcp.json`. VS Code reads `servers`, and prompts for the key once and
101
101
  "taiga": {
102
102
  "type": "stdio",
103
103
  "command": "npx",
104
- "args": ["-y", "@taiga-ai/mcp-server@0.40.0"],
104
+ "args": ["-y", "@taiga-ai/mcp-server@0.41.0"],
105
105
  "env": { "TAIGA_API_KEY": "${input:taiga-api-key}" }
106
106
  }
107
107
  }
package/dist/index.js CHANGED
@@ -23815,6 +23815,30 @@ var TaigaClient = class {
23815
23815
  const qs = origin ? `?${new URLSearchParams({ origin })}` : "";
23816
23816
  return this.request("GET", `/products/${seg(productId)}/documents/${seg(type)}${qs}`);
23817
23817
  }
23818
+ /** Every published version of a product document type, newest first, each with its content (PRO-5088). */
23819
+ async listProductDocumentVersions(productId, type, origin) {
23820
+ const qs = origin ? `?${new URLSearchParams({ origin })}` : "";
23821
+ return this.request("GET", `/products/${seg(productId)}/documents/${seg(type)}/versions${qs}`);
23822
+ }
23823
+ /** Every version of a product document type on the plan timeline, its draft too (PRO-5088): 204. */
23824
+ async deleteProductDocuments(productId, type) {
23825
+ await this.request("DELETE", `/products/${seg(productId)}/documents/${seg(type)}`);
23826
+ }
23827
+ /** The countries a product is offered in beyond the organization's own, and the ones that may be chosen. */
23828
+ async getProductMarketCountries(productId) {
23829
+ return this.request("GET", `/products/${seg(productId)}/market-countries`);
23830
+ }
23831
+ /**
23832
+ * What changing a product's market countries would do to the organization's policies, without doing it: the
23833
+ * organization-context preview the web's Markets card shows (PRO-5088).
23834
+ */
23835
+ async previewProductMarkets(markets) {
23836
+ return this.request("POST", "/tenants/current/context/preview", { productMarkets: markets });
23837
+ }
23838
+ /** Change a product's market countries; the organization's policies are brought in line in the same write. */
23839
+ async setProductMarkets(markets) {
23840
+ return this.request("PATCH", "/tenants/current/context", { productMarkets: markets });
23841
+ }
23818
23842
  async listBacklogItems(productId, opts) {
23819
23843
  const params = new URLSearchParams();
23820
23844
  if (opts?.status) params.set("status", opts.status);
@@ -31840,6 +31864,81 @@ const SIGNAL_KINDS = [
31840
31864
  */
31841
31865
  const DEPLOYMENT_NOTES_MAX_LENGTH = 4e3;
31842
31866
  //#endregion
31867
+ //#region ../../packages/types/dist/specification-template.js
31868
+ const SPECIFICATION_SECTIONS = [
31869
+ {
31870
+ id: "vision",
31871
+ number: 1,
31872
+ title: "Vision & Purpose",
31873
+ subsections: [
31874
+ "1.1 Business Goal & Rationale",
31875
+ "1.2 Problem Statement",
31876
+ "1.3 Objectives & Success Indicators",
31877
+ "1.4 Key Assumptions"
31878
+ ]
31879
+ },
31880
+ {
31881
+ id: "users",
31882
+ number: 2,
31883
+ title: "Users & Stakeholders",
31884
+ subsections: ["2.1 Primary Users", "2.2 Stakeholders"]
31885
+ },
31886
+ {
31887
+ id: "capabilities",
31888
+ number: 3,
31889
+ title: "Capabilities",
31890
+ subsections: [
31891
+ "3.1 Core Features",
31892
+ "3.2 Workflows",
31893
+ "3.3 Out of Scope"
31894
+ ]
31895
+ },
31896
+ {
31897
+ id: "data",
31898
+ number: 4,
31899
+ title: "Data & Information",
31900
+ subsections: [
31901
+ "4.1 Key Entities",
31902
+ "4.2 Data Sources",
31903
+ "4.3 Sensitive Data"
31904
+ ]
31905
+ },
31906
+ {
31907
+ id: "technical",
31908
+ number: 5,
31909
+ title: "Technical Context",
31910
+ subsections: [
31911
+ "5.1 Integrations",
31912
+ "5.2 Authentication & Access",
31913
+ "5.3 Constraints & Assumptions"
31914
+ ]
31915
+ },
31916
+ {
31917
+ id: "compliance",
31918
+ number: 6,
31919
+ title: "Compliance & Security",
31920
+ subsections: [
31921
+ "6.1 Data Classification",
31922
+ "6.2 Regulatory Requirements",
31923
+ "6.3 Audit & Retention"
31924
+ ]
31925
+ },
31926
+ {
31927
+ id: "timeline",
31928
+ number: 7,
31929
+ title: "Timeline & Priorities",
31930
+ subsections: [
31931
+ "7.1 Target Timeline",
31932
+ "7.2 MVP Scope",
31933
+ "7.3 Priorities"
31934
+ ]
31935
+ }
31936
+ ];
31937
+ /** A specification section's heading line, as its markdown starts. */
31938
+ function specificationHeading(section) {
31939
+ return `## ${section.number}. ${section.title}`;
31940
+ }
31941
+ //#endregion
31843
31942
  //#region ../../packages/types/dist/licenses/spdx-license-list.js
31844
31943
  /**
31845
31944
  * The SPDX License List 3.29.0 (licenses and exceptions), as `license-normalise` reads it: each
@@ -37382,7 +37481,7 @@ function outsideAllowlist(expression, allowlist) {
37382
37481
  * reads as deleted) and fields they explain would simply be missing. So it
37383
37482
  * refuses to start, and says what to do.
37384
37483
  */
37385
- function apiLevelProblem(introspection, apiUrl, required = 11, version = SERVER_VERSION) {
37484
+ function apiLevelProblem(introspection, apiUrl, required = 12, version = SERVER_VERSION) {
37386
37485
  const offered = introspection.mcpApiLevel ?? 0;
37387
37486
  if (offered >= required) return null;
37388
37487
  return `The Taiga API at ${apiUrl} is older than @taiga-ai/mcp-server ${version} needs (API level ${offered}, needs ${required}). Run the version published for it, or wait for that API to be updated; an earlier release of this package works against it.`;
@@ -37453,6 +37552,8 @@ const TOOLSET_OF = {
37453
37552
  taiga_update_product: "setup",
37454
37553
  taiga_move_product: "setup",
37455
37554
  taiga_preview_product_move: "setup",
37555
+ taiga_preview_product_markets: "setup",
37556
+ taiga_set_product_markets: "setup",
37456
37557
  taiga_link_repository: "setup",
37457
37558
  taiga_unlink_repository: "setup",
37458
37559
  taiga_list_linkable_repositories: "setup",
@@ -37493,6 +37594,8 @@ const TOOLSET_OF = {
37493
37594
  taiga_update_factory_document: "documents",
37494
37595
  taiga_publish_factory_document: "documents",
37495
37596
  taiga_update_product_document: "documents",
37597
+ taiga_remove_product_document_section: "documents",
37598
+ taiga_delete_product_document: "documents",
37496
37599
  taiga_publish_product_document: "documents",
37497
37600
  taiga_mark_product_document_reviewed: "documents",
37498
37601
  taiga_generate_product_documents: "documents",
@@ -37798,7 +37901,7 @@ function setupNextStep(product) {
37798
37901
  if (product.discoveryStep === void 0) return null;
37799
37902
  switch (product.discoveryStep) {
37800
37903
  case "documents": return `The specification is done; the other documents are generated from it (taiga_generate_product_documents starts the ones still missing). Once every required one is published, ${FINISH_DISCOVERY}`;
37801
- default: return `Discovery is a conversation held in the web: the person describes the product there and the specification comes out of it. The other documents follow, then ${FINISH_DISCOVERY}`;
37904
+ default: return `Discovery starts with the specification: the person describes the product in the conversation in the web, or to you, and you write its sections (taiga_get_product_document type specification shows them). The other documents follow, then ${FINISH_DISCOVERY}`;
37802
37905
  }
37803
37906
  }
37804
37907
  //#endregion
@@ -39730,7 +39833,7 @@ function nextStepFor(state) {
39730
39833
  }
39731
39834
  }
39732
39835
  if (!state.missing) return setupNextStep(state.product);
39733
- if (state.missing.includes("specification")) return "The specification comes from the Discovery conversation, held in the web: the person describes the product there. The other documents follow from it." + (state.linked === false ? " Linking a repository (taiga_link_repository) can wait until before the first build." : "");
39836
+ if (state.missing.includes("specification")) return "The specification comes from the Discovery conversation in the web, or the person describes the product to you and you write its sections (taiga_get_product_document type specification shows them). The other documents follow from it." + (state.linked === false ? " Linking a repository (taiga_link_repository) can wait until before the first build." : "");
39734
39837
  if (state.missing.length > 0) return `Still to publish: ${named(state.missing)}. taiga_generate_product_documents generates the missing ones (paid agent work: ask first); a draft is published with taiga_publish_product_document.`;
39735
39838
  return `Every required document is published: ${finish}`;
39736
39839
  }
@@ -40183,17 +40286,19 @@ function registerProductTools(server, client) {
40183
40286
  }));
40184
40287
  server.registerTool("taiga_get_product_document", {
40185
40288
  title: "Get product document",
40186
- description: "Read a product's documents. The plan timeline (specification, architecture, threat model and more) says what to build; the reality timeline says what the code does: read it before changing code. Without type, the list. sections: [] gives the outline, then name the sections you need.",
40289
+ description: "Read a product's documents. The plan timeline (specification, architecture, threat model and more) says what to build; the reality timeline says what the code does: read it before changing code. Without type, the list. sections: [] gives the outline, then name the sections you need. versions: true lists the published versions; version reads one. A specification not yet published reads as its draft and its seven sections.",
40187
40290
  inputSchema: object({
40188
40291
  productId,
40189
40292
  type: _enum(PRODUCT_DOCUMENT_TYPES).optional().describe("Document type; omit to list what the product has on both timelines"),
40190
40293
  origin: originInput,
40191
- sections: sectionsInput
40294
+ sections: sectionsInput,
40295
+ versions: boolean().optional().describe("true: list the published versions, newest first, without content"),
40296
+ version: number$1().int().positive().optional().describe("Read this published version instead of the latest (versions: true lists them)")
40192
40297
  }),
40193
40298
  annotations: READ_ONLY
40194
40299
  }, (params) => runTool(async () => {
40195
40300
  if (params.type === void 0) {
40196
- if (params.sections || params.origin) return toolError("VALIDATION_ERROR", "Name the document (type) to read one timeline or its sections.");
40301
+ if (params.sections || params.origin || params.versions || params.version !== void 0) return toolError("VALIDATION_ERROR", "Name the document (type) to read one timeline or its sections.");
40197
40302
  const { unlistable: _unlistable, ...timelines } = await documentTimelines(client, params.productId);
40198
40303
  return toolResult(timelines);
40199
40304
  }
@@ -40201,18 +40306,62 @@ function registerProductTools(server, client) {
40201
40306
  let product;
40202
40307
  if (!params.origin) product = (await client.getProduct(params.productId)).data;
40203
40308
  const origin = params.origin ?? defaultOriginFor(product, type);
40309
+ if (params.versions || params.version !== void 0) {
40310
+ const versions = (await client.listProductDocumentVersions(params.productId, type, origin)).data;
40311
+ if (params.versions) return toolResult({
40312
+ type,
40313
+ origin,
40314
+ versions: pickFields(versions, [
40315
+ "version",
40316
+ "stage",
40317
+ "createdBy",
40318
+ "updatedBy",
40319
+ "createdAt",
40320
+ "updatedAt"
40321
+ ])
40322
+ });
40323
+ const found = versions.find((doc) => doc.version === params.version);
40324
+ if (!found) {
40325
+ const published = versions.map((doc) => doc.version).filter((v) => v !== null);
40326
+ return toolError("NOT_FOUND", `${origin} ${type} has no version ${params.version}. ` + (published.length > 0 ? `Its versions: ${published.join(", ")}.` : "No version is published."));
40327
+ }
40328
+ const doc = stripProvenance(found);
40329
+ if (!params.sections) return toolResult(doc);
40330
+ return sectionReadResult(doc, params.sections, `${origin} ${type} v${params.version}`);
40331
+ }
40204
40332
  try {
40205
40333
  const doc = stripProvenance((await client.getProductDocument(params.productId, type, origin)).data);
40206
40334
  if (!params.sections) return toolResult(doc);
40207
40335
  return sectionReadResult(doc, params.sections, `${origin} ${type}`);
40208
40336
  } catch (error) {
40209
40337
  if (!(error instanceof TaigaApiError) || error.status !== 404) throw error;
40338
+ if (type === "specification" && origin === "plan") {
40339
+ const draft = (await client.getProductDocumentDraft(params.productId, type)).data;
40340
+ return toolResult({
40341
+ type,
40342
+ origin,
40343
+ published: false,
40344
+ draft: draft ? draftRead(stripProvenance(draft), params.sections) : null,
40345
+ sections: SPECIFICATION_SECTIONS.map((section) => ({
40346
+ id: section.id,
40347
+ heading: specificationHeading(section),
40348
+ subsections: section.subsections
40349
+ })),
40350
+ next: "Write each section with taiga_update_product_document (sectionId: its id; content: its markdown, its subsections as ### headings), from what the person tells you. Publish with taiga_publish_product_document once they have read it; the other documents are generated from it."
40351
+ });
40352
+ }
40210
40353
  product ??= (await client.getProduct(params.productId)).data;
40211
40354
  return toolError("NOT_FOUND", describeMiss(type, origin, await documentTimelines(client, params.productId, product), product));
40212
40355
  }
40213
40356
  }));
40214
40357
  }
40215
40358
  }
40359
+ /** A draft as `sections` asks for it, as sectionReadResult answers a published read; the whole draft without. */
40360
+ function draftRead(doc, sections) {
40361
+ if (!sections) return doc;
40362
+ const first = sectionReadResult(doc, sections, "plan specification draft").content[0];
40363
+ return first?.type === "text" ? JSON.parse(first.text) : doc;
40364
+ }
40216
40365
  //#endregion
40217
40366
  //#region src/tools/documents.ts
40218
40367
  /**
@@ -40307,23 +40456,15 @@ function storedText(section) {
40307
40456
  async function updateSection(scope, type, id, content, options = {}) {
40308
40457
  const { base, revision, publishedVersion } = await editBase(scope);
40309
40458
  const sections = sectionsOf(base);
40310
- if (!sections) return toolError("UNSUPPORTED_DOCUMENT", `Document ${type} is not made of sections and cannot be edited section by section. Edit it in the Taiga app.`);
40459
+ if (!sections) return notSectioned(type);
40460
+ const text = typeof content === "string" ? content : content(storedText(ownSection(sections, id)), sections);
40461
+ if (typeof text !== "string") return text;
40311
40462
  if (scope.saveSection && !options.sendRevision) {
40312
- let saved;
40313
- try {
40314
- saved = await scope.saveSection(id, {
40315
- content,
40316
- expectedContent: storedText(ownSection(sections, id))
40317
- });
40318
- } catch (error) {
40319
- if (conflictReason(error)?.reason !== "draft_changed") throw error;
40320
- const now = (await scope.getDraft()).data;
40321
- const current = now ? storedText(ownSection(sectionsOf(now.data) ?? {}, id)) : null;
40322
- return toolError("CONFLICT", `Section ${id} changed in the draft after this edit read it (someone edited it since), so nothing was saved and their change was kept. details.current is its text now: make the edit to that, then save it again.`, {
40323
- reason: "draft_changed",
40324
- current
40325
- });
40326
- }
40463
+ const saved = await saveOneSection(scope, id, {
40464
+ content: text,
40465
+ expectedContent: storedText(ownSection(sections, id))
40466
+ });
40467
+ if (isToolResult(saved)) return saved;
40327
40468
  return toolResult({
40328
40469
  ...documentSummary(saved.data),
40329
40470
  section: {
@@ -40334,7 +40475,7 @@ async function updateSection(scope, type, id, content, options = {}) {
40334
40475
  }
40335
40476
  const edited = {
40336
40477
  ...base,
40337
- sections: applySectionEdit(sections, id, content)
40478
+ sections: applySectionEdit(sections, id, text)
40338
40479
  };
40339
40480
  const saved = await scope.saveDraft(edited, options.sendRevision && revision !== void 0 ? {
40340
40481
  expectedRevision: revision,
@@ -40348,6 +40489,47 @@ async function updateSection(scope, type, id, content, options = {}) {
40348
40489
  }
40349
40490
  });
40350
40491
  }
40492
+ function isToolResult(value) {
40493
+ return "content" in value;
40494
+ }
40495
+ function notSectioned(type) {
40496
+ return toolError("UNSUPPORTED_DOCUMENT", `Document ${type} is not made of sections and cannot be edited section by section. Edit it in the Taiga app.`);
40497
+ }
40498
+ /** One section written through the section route; a change made to it since the read is a CONFLICT result. */
40499
+ async function saveOneSection(scope, id, body) {
40500
+ if (!scope.saveSection) throw new Error("saveOneSection: the scope saves whole drafts");
40501
+ try {
40502
+ return await scope.saveSection(id, body);
40503
+ } catch (error) {
40504
+ if (conflictReason(error)?.reason !== "draft_changed") throw error;
40505
+ const now = (await scope.getDraft()).data;
40506
+ const current = now ? storedText(ownSection(sectionsOf(now.data) ?? {}, id)) : null;
40507
+ return toolError("CONFLICT", `Section ${id} changed in the draft after this edit read it (someone edited it since), so nothing was saved and their change was kept. details.current is its text now: make the edit to that, then save it again.`, {
40508
+ reason: "draft_changed",
40509
+ current
40510
+ });
40511
+ }
40512
+ }
40513
+ /**
40514
+ * Remove one section from a document's draft (PRO-5088), refused when it changed since it was read. The draft is
40515
+ * made from the published version first when there is none, so the section leaves the next version, not this one.
40516
+ */
40517
+ async function removeSection(scope, type, id) {
40518
+ if (!scope.saveSection) return toolError("UNSUPPORTED_DOCUMENT", `Sections of ${type} cannot be removed one by one.`);
40519
+ const { base } = await editBase(scope);
40520
+ const sections = sectionsOf(base);
40521
+ if (!sections) return notSectioned(type);
40522
+ if (!Object.hasOwn(sections, id)) return toolError("NOT_FOUND", `${type} has no section ${id}. Its sections: ${Object.keys(sections).join(", ")}.`);
40523
+ const saved = await saveOneSection(scope, id, {
40524
+ content: null,
40525
+ expectedContent: storedText(ownSection(sections, id))
40526
+ });
40527
+ if (isToolResult(saved)) return saved;
40528
+ return toolResult({
40529
+ ...documentSummary(saved.data),
40530
+ removed: id
40531
+ });
40532
+ }
40351
40533
  /**
40352
40534
  * Publish the draft; the API answers 404 when there is none and 400 when the
40353
40535
  * residue gate refuses it. A publish can succeed with warnings about this
@@ -44517,6 +44699,76 @@ function registerObserveTools(server, client) {
44517
44699
  return toolResult(pickFields([updated], ENVIRONMENT_FIELDS)[0]);
44518
44700
  }));
44519
44701
  }
44702
+ //#endregion
44703
+ //#region ../../packages/editor-schema/dist/heading.js
44704
+ /**
44705
+ * A document section's title line (PRO-3771): the `## Title` a section's
44706
+ * markdown starts with, kept apart from the section's Yjs document, as
44707
+ * Linear keeps a document's `title` apart from its `DocumentContent`. The
44708
+ * document holds the body alone, which its editor binds to whole; the record
44709
+ * holds the title; the markdown the draft stores is the two joined, as every
44710
+ * reader of it has always read it.
44711
+ *
44712
+ * Read as CommonMark reads a level-2 ATX heading, so the title is what every
44713
+ * markdown reader of the draft sees as one, and every title joins back to the
44714
+ * same title. Plain strings, so a client splits and joins without loading the
44715
+ * editor's conversion (`document.ts`). Linear in the markdown's length: the
44716
+ * server splits every section a save sends, on its event loop.
44717
+ */
44718
+ /** A level-2 ATX heading line, up to three spaces in, and its content. */
44719
+ const HEADING = /^ {0,3}##[ \t]+([^ \t][^]*)$/;
44720
+ /** A line ending, as CommonMark has them. */
44721
+ const LINE_END = /\r\n?|\n/;
44722
+ /** Blank lines, as CommonMark has them: only spaces and tabs. */
44723
+ const BLANK_LINES = /^(?:[ \t]*(?:\r\n?|\n))+/;
44724
+ /** CommonMark's whitespace around heading content: spaces and tabs, nothing else. */
44725
+ const isBlank = (char) => char === " " || char === " ";
44726
+ /**
44727
+ * A heading's content as CommonMark reads it: less a closing run of `#`s --
44728
+ * the whole of it, or after a space or tab -- and the spaces and tabs around.
44729
+ */
44730
+ function headingText(content) {
44731
+ let end = content.length;
44732
+ while (end > 0 && isBlank(content[end - 1])) end--;
44733
+ let run = end;
44734
+ while (run > 0 && content[run - 1] === "#") run--;
44735
+ if (run < end && (run === 0 || isBlank(content[run - 1]))) end = run;
44736
+ let start = 0;
44737
+ while (start < end && isBlank(content[start])) start++;
44738
+ while (end > start && isBlank(content[end - 1])) end--;
44739
+ return content.slice(start, end);
44740
+ }
44741
+ /**
44742
+ * `markdown` as its title and its body: the title is the first line when it
44743
+ * is a level-2 heading with content, the body what follows it past the blank
44744
+ * lines between. Markdown that does not start with one is all body.
44745
+ */
44746
+ function splitSectionHeading(markdown) {
44747
+ const end = LINE_END.exec(markdown);
44748
+ const first = end ? markdown.slice(0, end.index) : markdown;
44749
+ const content = HEADING.exec(first)?.[1];
44750
+ const text = content === void 0 ? "" : headingText(content);
44751
+ if (!text) return {
44752
+ heading: null,
44753
+ body: markdown
44754
+ };
44755
+ return {
44756
+ heading: text,
44757
+ body: (end ? markdown.slice(end.index + end[0].length) : "").replace(BLANK_LINES, "")
44758
+ };
44759
+ }
44760
+ /**
44761
+ * A section's markdown from its title and body, as the draft stores it: the
44762
+ * title as a level-2 heading, a blank line, then the body; the title alone
44763
+ * for an empty body, as a section's document projects one. A title that ends
44764
+ * in what would read as a closing run of `#`s gets one more run, so it reads
44765
+ * back whole.
44766
+ */
44767
+ function joinSectionHeading(heading, body) {
44768
+ if (heading === null) return body;
44769
+ const line = headingText(heading) === heading ? `## ${heading}` : `## ${heading} ##`;
44770
+ return body === "" ? line : `${line}\n\n${body}`;
44771
+ }
44520
44772
  const documentType = _enum(PRODUCT_DOCUMENT_TYPES.filter((type) => type !== "codebase_snapshot")).describe("Document type -- taiga_get_product_document without type shows which ones the product has");
44521
44773
  /** The documents a person reviews: the discovery chain, not the snapshot or the product's own instructions. */
44522
44774
  const reviewableType = _enum(REVIEWABLE_PRODUCT_DOCUMENT_TYPES).describe("Document type -- one of the discovery documents a person reviews");
@@ -44533,17 +44785,33 @@ function registerProductDocumentWrites(server, client) {
44533
44785
  publish: () => client.publishProductDocument(product, type),
44534
44786
  saveSection: (sectionId, body) => client.saveProductDocumentSection(product, type, sectionId, body)
44535
44787
  });
44536
- if (canRead) server.registerTool("taiga_update_product_document", {
44537
- title: "Update a section of a product document draft",
44538
- description: "Change one section of a product document's draft (plan timeline only). Refused once setup is finished, until it is reopened.",
44539
- inputSchema: object({
44540
- productId,
44541
- type: documentType,
44542
- sectionId: sectionIdFrom("taiga_get_product_document (the plan timeline)"),
44543
- content: sectionContentInput
44544
- }),
44545
- annotations: WRITE
44546
- }, (params) => runTool(() => updateSection(productScope(params.productId, params.type), params.type, params.sectionId, params.content)));
44788
+ if (canRead) {
44789
+ server.registerTool("taiga_update_product_document", {
44790
+ title: "Update a section of a product document draft",
44791
+ description: "Change one section of a product document's draft (plan timeline only): its text, its title or both. A section's title is its first `## ` line; text without one keeps the title the section has. A section id that does not exist yet adds the section. A specification has seven sections (taiga_get_product_document type specification shows each one and what it holds). Refused once setup is finished, until taiga_reopen_discovery reopens it.",
44792
+ inputSchema: object({
44793
+ productId,
44794
+ type: documentType,
44795
+ sectionId: sectionIdFrom("taiga_get_product_document (the plan timeline)"),
44796
+ content: string$2().optional().describe("The full new Markdown text of the section; it replaces the old text. Omit to rename only"),
44797
+ title: string$2().trim().min(1).max(200).optional().describe("The section's new title, its `## ` line, without the hashes")
44798
+ }),
44799
+ annotations: WRITE
44800
+ }, (params) => runTool(async () => {
44801
+ if (params.content === void 0 && params.title === void 0) return toolError("VALIDATION_ERROR", "Give the new text (content), the new title, or both.");
44802
+ return updateSection(productScope(params.productId, params.type), params.type, params.sectionId, sectionWrite(params.type, params.sectionId, params.content, params.title));
44803
+ }));
44804
+ server.registerTool("taiga_remove_product_document_section", {
44805
+ title: "Remove a section from a product document draft",
44806
+ description: "Remove one section from a product document's draft (plan timeline only); the published version keeps it until the draft is published. Refused when the section changed since it was read, and once setup is finished, until taiga_reopen_discovery reopens it.",
44807
+ inputSchema: object({
44808
+ productId,
44809
+ type: documentType,
44810
+ sectionId: sectionIdFrom("taiga_get_product_document (the plan timeline)")
44811
+ }),
44812
+ annotations: WRITE
44813
+ }, (params) => runTool(() => removeSection(productScope(params.productId, params.type), params.type, params.sectionId)));
44814
+ }
44547
44815
  server.registerTool("taiga_publish_product_document", {
44548
44816
  title: "Publish a product document draft",
44549
44817
  description: "Publish a product document's draft; the documents built from it are marked outdated.",
@@ -44572,7 +44840,7 @@ function registerProductDocumentWrites(server, client) {
44572
44840
  annotations: OPERATE
44573
44841
  }, (params) => runTool(async () => {
44574
44842
  const product = SETUP_REQUIRED_DOCUMENT_TYPES.includes(params.type) ? (await client.getProduct(params.productId)).data : null;
44575
- if (product && product.status !== "draft") return toolError("CONFLICT", "Discovery is finished for this product, so its documents are locked. Reopen Discovery in the web to regenerate one.");
44843
+ if (product && product.status !== "draft") return toolError("CONFLICT", "Discovery is finished for this product, so its documents are locked. taiga_reopen_discovery reopens it, when the person asks.");
44576
44844
  const job = (await client.createAgentJob({
44577
44845
  scope: "product",
44578
44846
  type: "generate_document",
@@ -44587,6 +44855,21 @@ function registerProductDocumentWrites(server, client) {
44587
44855
  inputSchema: object({ productId }),
44588
44856
  annotations: OPERATE
44589
44857
  }, (params) => runTool(async () => toolResult((await client.generateRemainingDocuments(params.productId)).data)));
44858
+ server.registerTool("taiga_delete_product_document", {
44859
+ title: "Delete a product document",
44860
+ description: "Delete every version of a product document type on the plan timeline, its draft too: no version of it stays to read. Refused once setup is finished, until taiga_reopen_discovery reopens it.",
44861
+ inputSchema: object({
44862
+ productId,
44863
+ type: documentType
44864
+ }),
44865
+ annotations: OPERATE
44866
+ }, (params) => runTool(async () => {
44867
+ await client.deleteProductDocuments(params.productId, params.type);
44868
+ return toolResult({
44869
+ type: params.type,
44870
+ deleted: true
44871
+ });
44872
+ }));
44590
44873
  server.registerTool("taiga_stop_generating_documents", {
44591
44874
  title: "Stop generating product documents",
44592
44875
  description: "Stop generating documents: the ones in progress are cancelled, published ones stay.",
@@ -44594,6 +44877,20 @@ function registerProductDocumentWrites(server, client) {
44594
44877
  annotations: OPERATE
44595
44878
  }, (params) => runTool(async () => toolResult((await client.stopGeneratingDocuments(params.productId)).data)));
44596
44879
  }
44880
+ /**
44881
+ * What a section edit writes (PRO-5088): the new text, the title given, else the one the text starts with, else the
44882
+ * one the section has, else a specification section's own. A specification takes only its seven sections.
44883
+ */
44884
+ function sectionWrite(type, id, content, title) {
44885
+ return (current) => {
44886
+ const spec = type === "specification" ? SPECIFICATION_SECTIONS.find((section) => section.id === id) : void 0;
44887
+ if (type === "specification" && current === null && !spec) return toolError("VALIDATION_ERROR", `A specification has these sections: ${SPECIFICATION_SECTIONS.map((section) => section.id).join(", ")}.`);
44888
+ if (content === void 0 && current === null) return toolError("NOT_FOUND", `There is no section ${id} to rename. Give its text (content) to add it.`);
44889
+ const written = splitSectionHeading(content ?? current ?? "");
44890
+ const kept = current === null ? null : splitSectionHeading(current).heading;
44891
+ return joinSectionHeading(title ?? written.heading ?? kept ?? (spec ? specificationHeading(spec).slice(3) : null), written.body);
44892
+ };
44893
+ }
44597
44894
  //#endregion
44598
44895
  //#region ../../node_modules/.pnpm/mdast-util-to-string@4.0.0/node_modules/mdast-util-to-string/lib/index.js
44599
44896
  /**
@@ -59882,7 +60179,7 @@ const buildScope = {
59882
60179
  };
59883
60180
  const deploymentNotes = string$2().trim().min(1).max(DEPLOYMENT_NOTES_MAX_LENGTH).describe("When a half is off: a sentence on how it is done today, which Taiga designs and plans against");
59884
60181
  /** How a missing required document comes to exist, said with a documents_incomplete refusal. */
59885
- const MISSING_DOCUMENTS_HOW = "An imported product gets them from its import (taiga_start_import); a product started from scratch gets the specification from the Discovery conversation in the web and the rest from taiga_generate_product_documents. A draft is published with taiga_publish_product_document.";
60182
+ const MISSING_DOCUMENTS_HOW = "An imported product gets them from its import (taiga_start_import); a product started from scratch gets the specification from the Discovery conversation in the web, or written section by section with taiga_update_product_document, and the rest from taiga_generate_product_documents. A draft is published with taiga_publish_product_document.";
59886
60183
  /**
59887
60184
  * Refuse a name already taken (PRO-2800): the API appends -2 to the slug and
59888
60185
  * creates a second one, so a retried call or two agents at once left
@@ -60032,10 +60329,62 @@ function registerSetupTools(server, client) {
60032
60329
  });
60033
60330
  }));
60034
60331
  }
60332
+ if (client.hasCapability("tenant:settings") && client.hasCapability("products:read")) {
60333
+ const markets = object({
60334
+ productId,
60335
+ countries: array(string$2().length(2).toUpperCase()).max(250).describe("ISO 3166-1 alpha-2 codes of the countries the product is offered in beyond the organization's own; the whole list, [] clears it. taiga_preview_product_markets without countries shows the ones on offer"),
60336
+ notOfferedAtHome: boolean().optional().describe("true when the product is not offered in the organization's own country; omit to leave it")
60337
+ });
60338
+ const marketsBody = (params) => ({
60339
+ productId: params.productId,
60340
+ countries: params.countries,
60341
+ ...params.notOfferedAtHome !== void 0 ? { notOfferedAtHome: params.notOfferedAtHome } : {}
60342
+ });
60343
+ /** What a context change does, without the context the model did not ask about. */
60344
+ const changeView = (result) => ({
60345
+ documents: result.documents.map(({ type, name, action, conflicts }) => ({
60346
+ type,
60347
+ name,
60348
+ action,
60349
+ ...conflicts && conflicts.length > 0 ? { conflicts } : {}
60350
+ })),
60351
+ ...result.regulations ? { regulations: result.regulations } : {}
60352
+ });
60353
+ server.registerTool("taiga_preview_product_markets", {
60354
+ title: "Preview a product's market countries",
60355
+ description: "Show a product's market countries and the ones on offer, and with countries, what setting them would do to the organization's policies (documents republished, regulations in and out), before taiga_set_product_markets.",
60356
+ inputSchema: markets.partial({ countries: true }),
60357
+ annotations: READ_ONLY
60358
+ }, (params) => runTool(async () => {
60359
+ const current = (await client.getProductMarketCountries(params.productId)).data;
60360
+ if (params.countries === void 0) return toolResult({ current });
60361
+ const preview = (await client.previewProductMarkets(marketsBody({
60362
+ ...params,
60363
+ countries: params.countries
60364
+ }))).data;
60365
+ return toolResult({
60366
+ current,
60367
+ ...changeView(preview)
60368
+ });
60369
+ }));
60370
+ server.registerTool("taiga_set_product_markets", {
60371
+ title: "Set a product's market countries",
60372
+ description: "Set the countries a product is offered in beyond the organization's own. Each brings its consumer, data and accessibility rules into the policies the product is held to, so the organization's policies are republished in the same write: taiga_preview_product_markets shows what changes.",
60373
+ inputSchema: markets,
60374
+ annotations: OPERATE
60375
+ }, (params) => runTool(async () => {
60376
+ const applied = (await client.setProductMarkets(marketsBody(params))).data;
60377
+ const current = (await client.getProductMarketCountries(params.productId)).data;
60378
+ return toolResult({
60379
+ current,
60380
+ ...changeView(applied)
60381
+ });
60382
+ }));
60383
+ }
60035
60384
  if (!client.hasCapability("products:write")) return;
60036
60385
  server.registerTool("taiga_create_product", {
60037
60386
  title: "Create a product",
60038
- description: "Create a product in a factory, from scratch or to import from existing code, and say what it needs next. import: link its repository (taiga_link_repository), then taiga_start_import. scratch: its specification is written in a conversation in the web. A name another product in the factory has is refused unless allowDuplicateName: true.",
60387
+ description: "Create a product in a factory, from scratch or to import from existing code, and say what it needs next. import: link its repository (taiga_link_repository), then taiga_start_import. scratch: its specification is written in a conversation in the web, or by you with the person, section by section (taiga_get_product_document type specification). A name another product in the factory has is refused unless allowDuplicateName: true.",
60039
60388
  inputSchema: object({
60040
60389
  factoryId,
60041
60390
  name: string$2().trim().min(1).max(255).describe("The product name"),
@@ -60545,7 +60894,7 @@ const SERVER_INSTRUCTIONS = [
60545
60894
  "canceled); plan and build are stations, and the line starts the next queued initiative when both are empty. A",
60546
60895
  "run is one coding-agent attempt; hardening is its security pass; handed back means a person must act. A gate is",
60547
60896
  "a person's review; a sweep is a scan for findings; standing is how a product meets policy. Discovery sets",
60548
- "up a new product, from a web conversation or an import. Factories own products.",
60897
+ "up a new product, from a conversation (web or yours) or an import. Factories own products.",
60549
60898
  "",
60550
60899
  "**IDs** are UUIDs; the product, factory and initiative lists take query (product and factory misses may name the",
60551
60900
  "closest). A NOT_FOUND names the tool that lists the right ones. Lists page with nextCursor. outcome, situation",
@@ -60558,7 +60907,7 @@ const SERVER_INSTRUCTIONS = [
60558
60907
  "**Only in the web** (say so): connecting GitHub, GitLab or Azure DevOps; members, roles and access requests;",
60559
60908
  "the Discovery conversation; creating an initiative as written (request one); stamping checks; a run's",
60560
60909
  "start-over or coding agent; Auroras switches; notification recipients; environment cloud accounts and deletes;",
60561
- "UI direction; questionnaires; markets; organization admin; deleting factories and products."
60910
+ "UI direction; questionnaires; organization admin; deleting factories and products."
60562
60911
  ].join("\n");
60563
60912
  //#endregion
60564
60913
  //#region src/server.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taiga-ai/mcp-server",
3
- "version": "0.40.0-dev.1242",
3
+ "version": "0.41.0-dev.1243",
4
4
  "description": "Taiga for AI coding assistants: read products, policies, initiatives and runs, and operate the line, over MCP",
5
5
  "mcpName": "ga.tai/mcp-server",
6
6
  "license": "UNLICENSED",
@@ -41,6 +41,7 @@
41
41
  },
42
42
  "devDependencies": {
43
43
  "@modelcontextprotocol/client": "^2.3.1",
44
+ "@taiga/editor-schema": "workspace:*",
44
45
  "@tsconfig/strictest": "^2.0.8",
45
46
  "@types/mdast": "^4.0.4",
46
47
  "@types/node": "^22.20.1",