@taiga-ai/mcp-server 0.39.1-dev.1241 → 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 +430 -27
  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.39.1`), 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.39.1
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.39.1
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.39.1
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.39.1
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.39.1
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.39.1
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.39.1"],
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.39.1"],
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.39.1"],
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
@@ -23720,6 +23720,13 @@ var TaigaClient = class {
23720
23720
  return this.request("PUT", `/tenants/current/documents/${seg(type)}/draft`, body);
23721
23721
  }
23722
23722
  /**
23723
+ * One section of an organization document's draft (PRO-5087); 409 `draft_changed` when it changed since
23724
+ * `expectedContent`. Not the design standards, which are saved whole.
23725
+ */
23726
+ async saveTenantDocumentSection(type, sectionId, body) {
23727
+ return this.request("PUT", `/tenants/current/documents/${seg(type)}/draft/sections/${seg(sectionId)}`, body);
23728
+ }
23729
+ /**
23723
23730
  * Publish the draft. With `requireTokensAligned` the API checks, in the same transaction as the publish, that a
23724
23731
  * design standards draft's text and tokens agree, and answers 409 `tokens_out_of_line` without publishing when
23725
23732
  * they do not. The POST stays bodiless.
@@ -23749,6 +23756,10 @@ var TaigaClient = class {
23749
23756
  async saveFactoryDocumentDraft(factoryId, type, body) {
23750
23757
  return this.request("PUT", `/factories/${seg(factoryId)}/documents/${seg(type)}/draft`, body);
23751
23758
  }
23759
+ /** One section of a factory document's draft (PRO-5087); 409 `draft_changed` when it changed since `expectedContent`. */
23760
+ async saveFactoryDocumentSection(factoryId, type, sectionId, body) {
23761
+ return this.request("PUT", `/factories/${seg(factoryId)}/documents/${seg(type)}/draft/sections/${seg(sectionId)}`, body);
23762
+ }
23752
23763
  async publishFactoryDocument(factoryId, type) {
23753
23764
  return this.request("POST", `/factories/${seg(factoryId)}/documents/${seg(type)}/publish`);
23754
23765
  }
@@ -23781,6 +23792,10 @@ var TaigaClient = class {
23781
23792
  async saveProductDocumentDraft(productId, type, body) {
23782
23793
  return this.request("PUT", `/products/${seg(productId)}/documents/${seg(type)}/draft`, body);
23783
23794
  }
23795
+ /** One section of a product document's draft (PRO-5087); 409 `draft_changed` when it changed since `expectedContent`. */
23796
+ async saveProductDocumentSection(productId, type, sectionId, body) {
23797
+ return this.request("PUT", `/products/${seg(productId)}/documents/${seg(type)}/draft/sections/${seg(sectionId)}`, body);
23798
+ }
23784
23799
  async publishProductDocument(productId, type) {
23785
23800
  return this.request("POST", `/products/${seg(productId)}/documents/${seg(type)}/publish`);
23786
23801
  }
@@ -23800,6 +23815,30 @@ var TaigaClient = class {
23800
23815
  const qs = origin ? `?${new URLSearchParams({ origin })}` : "";
23801
23816
  return this.request("GET", `/products/${seg(productId)}/documents/${seg(type)}${qs}`);
23802
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
+ }
23803
23842
  async listBacklogItems(productId, opts) {
23804
23843
  const params = new URLSearchParams();
23805
23844
  if (opts?.status) params.set("status", opts.status);
@@ -31825,6 +31864,81 @@ const SIGNAL_KINDS = [
31825
31864
  */
31826
31865
  const DEPLOYMENT_NOTES_MAX_LENGTH = 4e3;
31827
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
31828
31942
  //#region ../../packages/types/dist/licenses/spdx-license-list.js
31829
31943
  /**
31830
31944
  * The SPDX License List 3.29.0 (licenses and exceptions), as `license-normalise` reads it: each
@@ -37367,7 +37481,7 @@ function outsideAllowlist(expression, allowlist) {
37367
37481
  * reads as deleted) and fields they explain would simply be missing. So it
37368
37482
  * refuses to start, and says what to do.
37369
37483
  */
37370
- function apiLevelProblem(introspection, apiUrl, required = 10, version = SERVER_VERSION) {
37484
+ function apiLevelProblem(introspection, apiUrl, required = 12, version = SERVER_VERSION) {
37371
37485
  const offered = introspection.mcpApiLevel ?? 0;
37372
37486
  if (offered >= required) return null;
37373
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.`;
@@ -37438,6 +37552,8 @@ const TOOLSET_OF = {
37438
37552
  taiga_update_product: "setup",
37439
37553
  taiga_move_product: "setup",
37440
37554
  taiga_preview_product_move: "setup",
37555
+ taiga_preview_product_markets: "setup",
37556
+ taiga_set_product_markets: "setup",
37441
37557
  taiga_link_repository: "setup",
37442
37558
  taiga_unlink_repository: "setup",
37443
37559
  taiga_list_linkable_repositories: "setup",
@@ -37478,6 +37594,8 @@ const TOOLSET_OF = {
37478
37594
  taiga_update_factory_document: "documents",
37479
37595
  taiga_publish_factory_document: "documents",
37480
37596
  taiga_update_product_document: "documents",
37597
+ taiga_remove_product_document_section: "documents",
37598
+ taiga_delete_product_document: "documents",
37481
37599
  taiga_publish_product_document: "documents",
37482
37600
  taiga_mark_product_document_reviewed: "documents",
37483
37601
  taiga_generate_product_documents: "documents",
@@ -37783,7 +37901,7 @@ function setupNextStep(product) {
37783
37901
  if (product.discoveryStep === void 0) return null;
37784
37902
  switch (product.discoveryStep) {
37785
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}`;
37786
- 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}`;
37787
37905
  }
37788
37906
  }
37789
37907
  //#endregion
@@ -39715,7 +39833,7 @@ function nextStepFor(state) {
39715
39833
  }
39716
39834
  }
39717
39835
  if (!state.missing) return setupNextStep(state.product);
39718
- 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." : "");
39719
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.`;
39720
39838
  return `Every required document is published: ${finish}`;
39721
39839
  }
@@ -40168,17 +40286,19 @@ function registerProductTools(server, client) {
40168
40286
  }));
40169
40287
  server.registerTool("taiga_get_product_document", {
40170
40288
  title: "Get product document",
40171
- 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.",
40172
40290
  inputSchema: object({
40173
40291
  productId,
40174
40292
  type: _enum(PRODUCT_DOCUMENT_TYPES).optional().describe("Document type; omit to list what the product has on both timelines"),
40175
40293
  origin: originInput,
40176
- 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)")
40177
40297
  }),
40178
40298
  annotations: READ_ONLY
40179
40299
  }, (params) => runTool(async () => {
40180
40300
  if (params.type === void 0) {
40181
- 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.");
40182
40302
  const { unlistable: _unlistable, ...timelines } = await documentTimelines(client, params.productId);
40183
40303
  return toolResult(timelines);
40184
40304
  }
@@ -40186,18 +40306,62 @@ function registerProductTools(server, client) {
40186
40306
  let product;
40187
40307
  if (!params.origin) product = (await client.getProduct(params.productId)).data;
40188
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
+ }
40189
40332
  try {
40190
40333
  const doc = stripProvenance((await client.getProductDocument(params.productId, type, origin)).data);
40191
40334
  if (!params.sections) return toolResult(doc);
40192
40335
  return sectionReadResult(doc, params.sections, `${origin} ${type}`);
40193
40336
  } catch (error) {
40194
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
+ }
40195
40353
  product ??= (await client.getProduct(params.productId)).data;
40196
40354
  return toolError("NOT_FOUND", describeMiss(type, origin, await documentTimelines(client, params.productId, product), product));
40197
40355
  }
40198
40356
  }));
40199
40357
  }
40200
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
+ }
40201
40365
  //#endregion
40202
40366
  //#region src/tools/documents.ts
40203
40367
  /**
@@ -40276,6 +40440,15 @@ async function editBase(scope) {
40276
40440
  throw error;
40277
40441
  }
40278
40442
  }
40443
+ /** The section of that id, an own property only: `__proto__` is a section name like any other. */
40444
+ function ownSection(sections, id) {
40445
+ return Object.hasOwn(sections, id) ? sections[id] : void 0;
40446
+ }
40447
+ /** A section's markdown as the API reads it (`sectionText`): its string content, a bare string, else none. */
40448
+ function storedText(section) {
40449
+ if (typeof section === "string") return section;
40450
+ return isRecord$1(section) && typeof section["content"] === "string" ? section["content"] : null;
40451
+ }
40279
40452
  /**
40280
40453
  * Edit one section of a document's draft; the edit keeps every other section
40281
40454
  * and the section's own metadata, see sections.ts.
@@ -40283,10 +40456,26 @@ async function editBase(scope) {
40283
40456
  async function updateSection(scope, type, id, content, options = {}) {
40284
40457
  const { base, revision, publishedVersion } = await editBase(scope);
40285
40458
  const sections = sectionsOf(base);
40286
- 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;
40462
+ if (scope.saveSection && !options.sendRevision) {
40463
+ const saved = await saveOneSection(scope, id, {
40464
+ content: text,
40465
+ expectedContent: storedText(ownSection(sections, id))
40466
+ });
40467
+ if (isToolResult(saved)) return saved;
40468
+ return toolResult({
40469
+ ...documentSummary(saved.data),
40470
+ section: {
40471
+ id,
40472
+ content: sectionContent(sectionsOf(saved.data.data) ?? {}, id)
40473
+ }
40474
+ });
40475
+ }
40287
40476
  const edited = {
40288
40477
  ...base,
40289
- sections: applySectionEdit(sections, id, content)
40478
+ sections: applySectionEdit(sections, id, text)
40290
40479
  };
40291
40480
  const saved = await scope.saveDraft(edited, options.sendRevision && revision !== void 0 ? {
40292
40481
  expectedRevision: revision,
@@ -40300,6 +40489,47 @@ async function updateSection(scope, type, id, content, options = {}) {
40300
40489
  }
40301
40490
  });
40302
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
+ }
40303
40533
  /**
40304
40534
  * Publish the draft; the API answers 404 when there is none and 400 when the
40305
40535
  * residue gate refuses it. A publish can succeed with warnings about this
@@ -40484,6 +40714,7 @@ function registerDocumentTools(server, client) {
40484
40714
  }));
40485
40715
  if (client.hasCapability("tenant:documents:read") && client.hasCapability("tenant:documents:write")) {
40486
40716
  const tenantScope = (type) => ({
40717
+ readTool: "taiga_get_organization_document",
40487
40718
  getDraft: () => client.getTenantDocumentDraft(type),
40488
40719
  getPublished: () => client.getTenantDocument(type),
40489
40720
  saveDraft: (data, options) => client.saveTenantDocumentDraft(type, {
@@ -40491,7 +40722,8 @@ function registerDocumentTools(server, client) {
40491
40722
  ...options?.expectedRevision !== void 0 ? { expectedRevision: options.expectedRevision } : {},
40492
40723
  ...options?.expectedPublishedVersion !== void 0 ? { expectedPublishedVersion: options.expectedPublishedVersion } : {}
40493
40724
  }),
40494
- publish: (options) => client.publishTenantDocument(type, options)
40725
+ publish: (options) => client.publishTenantDocument(type, options),
40726
+ ...type === DESIGN_STANDARDS ? {} : { saveSection: (sectionId, body) => client.saveTenantDocumentSection(type, sectionId, body) }
40495
40727
  });
40496
40728
  server.registerTool("taiga_update_organization_document", {
40497
40729
  title: "Update a section of an organization document draft",
@@ -40536,10 +40768,12 @@ function registerDocumentTools(server, client) {
40536
40768
  }));
40537
40769
  if (client.hasCapability("factories:read") && client.hasCapability("factories:documents:write")) {
40538
40770
  const factoryScope = (factoryId, type) => ({
40771
+ readTool: "taiga_get_factory_document",
40539
40772
  getDraft: () => client.getFactoryDocumentDraft(factoryId, type),
40540
40773
  getPublished: () => client.getFactoryDocument(factoryId, type),
40541
40774
  saveDraft: (data) => client.saveFactoryDocumentDraft(factoryId, type, { data }),
40542
- publish: () => client.publishFactoryDocument(factoryId, type)
40775
+ publish: () => client.publishFactoryDocument(factoryId, type),
40776
+ saveSection: (sectionId, body) => client.saveFactoryDocumentSection(factoryId, type, sectionId, body)
40543
40777
  });
40544
40778
  const factoryId = idInput("factory", "taiga_list_factories (query finds one by name) gives it");
40545
40779
  const factoryDocumentType = _enum(FACTORY_DOCUMENT_TYPES).default("factory_instructions").describe("Document type");
@@ -44465,6 +44699,76 @@ function registerObserveTools(server, client) {
44465
44699
  return toolResult(pickFields([updated], ENVIRONMENT_FIELDS)[0]);
44466
44700
  }));
44467
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
+ }
44468
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");
44469
44773
  /** The documents a person reviews: the discovery chain, not the snapshot or the product's own instructions. */
44470
44774
  const reviewableType = _enum(REVIEWABLE_PRODUCT_DOCUMENT_TYPES).describe("Document type -- one of the discovery documents a person reviews");
@@ -44474,22 +44778,40 @@ function registerProductDocumentWrites(server, client) {
44474
44778
  if (!client.hasCapability("products:write")) return;
44475
44779
  const canRead = client.hasCapability("products:read");
44476
44780
  const productScope = (product, type) => ({
44781
+ readTool: "taiga_get_product_document",
44477
44782
  getDraft: () => client.getProductDocumentDraft(product, type),
44478
44783
  getPublished: () => client.getProductDocument(product, type, "plan"),
44479
44784
  saveDraft: (data) => client.saveProductDocumentDraft(product, type, { data }),
44480
- publish: () => client.publishProductDocument(product, type)
44785
+ publish: () => client.publishProductDocument(product, type),
44786
+ saveSection: (sectionId, body) => client.saveProductDocumentSection(product, type, sectionId, body)
44481
44787
  });
44482
- if (canRead) server.registerTool("taiga_update_product_document", {
44483
- title: "Update a section of a product document draft",
44484
- description: "Change one section of a product document's draft (plan timeline only). Refused once setup is finished, until it is reopened.",
44485
- inputSchema: object({
44486
- productId,
44487
- type: documentType,
44488
- sectionId: sectionIdFrom("taiga_get_product_document (the plan timeline)"),
44489
- content: sectionContentInput
44490
- }),
44491
- annotations: WRITE
44492
- }, (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
+ }
44493
44815
  server.registerTool("taiga_publish_product_document", {
44494
44816
  title: "Publish a product document draft",
44495
44817
  description: "Publish a product document's draft; the documents built from it are marked outdated.",
@@ -44518,7 +44840,7 @@ function registerProductDocumentWrites(server, client) {
44518
44840
  annotations: OPERATE
44519
44841
  }, (params) => runTool(async () => {
44520
44842
  const product = SETUP_REQUIRED_DOCUMENT_TYPES.includes(params.type) ? (await client.getProduct(params.productId)).data : null;
44521
- 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.");
44522
44844
  const job = (await client.createAgentJob({
44523
44845
  scope: "product",
44524
44846
  type: "generate_document",
@@ -44533,6 +44855,21 @@ function registerProductDocumentWrites(server, client) {
44533
44855
  inputSchema: object({ productId }),
44534
44856
  annotations: OPERATE
44535
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
+ }));
44536
44873
  server.registerTool("taiga_stop_generating_documents", {
44537
44874
  title: "Stop generating product documents",
44538
44875
  description: "Stop generating documents: the ones in progress are cancelled, published ones stay.",
@@ -44540,6 +44877,20 @@ function registerProductDocumentWrites(server, client) {
44540
44877
  annotations: OPERATE
44541
44878
  }, (params) => runTool(async () => toolResult((await client.stopGeneratingDocuments(params.productId)).data)));
44542
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
+ }
44543
44894
  //#endregion
44544
44895
  //#region ../../node_modules/.pnpm/mdast-util-to-string@4.0.0/node_modules/mdast-util-to-string/lib/index.js
44545
44896
  /**
@@ -59828,7 +60179,7 @@ const buildScope = {
59828
60179
  };
59829
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");
59830
60181
  /** How a missing required document comes to exist, said with a documents_incomplete refusal. */
59831
- 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.";
59832
60183
  /**
59833
60184
  * Refuse a name already taken (PRO-2800): the API appends -2 to the slug and
59834
60185
  * creates a second one, so a retried call or two agents at once left
@@ -59978,10 +60329,62 @@ function registerSetupTools(server, client) {
59978
60329
  });
59979
60330
  }));
59980
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
+ }
59981
60384
  if (!client.hasCapability("products:write")) return;
59982
60385
  server.registerTool("taiga_create_product", {
59983
60386
  title: "Create a product",
59984
- 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.",
59985
60388
  inputSchema: object({
59986
60389
  factoryId,
59987
60390
  name: string$2().trim().min(1).max(255).describe("The product name"),
@@ -60491,7 +60894,7 @@ const SERVER_INSTRUCTIONS = [
60491
60894
  "canceled); plan and build are stations, and the line starts the next queued initiative when both are empty. A",
60492
60895
  "run is one coding-agent attempt; hardening is its security pass; handed back means a person must act. A gate is",
60493
60896
  "a person's review; a sweep is a scan for findings; standing is how a product meets policy. Discovery sets",
60494
- "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.",
60495
60898
  "",
60496
60899
  "**IDs** are UUIDs; the product, factory and initiative lists take query (product and factory misses may name the",
60497
60900
  "closest). A NOT_FOUND names the tool that lists the right ones. Lists page with nextCursor. outcome, situation",
@@ -60504,7 +60907,7 @@ const SERVER_INSTRUCTIONS = [
60504
60907
  "**Only in the web** (say so): connecting GitHub, GitLab or Azure DevOps; members, roles and access requests;",
60505
60908
  "the Discovery conversation; creating an initiative as written (request one); stamping checks; a run's",
60506
60909
  "start-over or coding agent; Auroras switches; notification recipients; environment cloud accounts and deletes;",
60507
- "UI direction; questionnaires; markets; organization admin; deleting factories and products."
60910
+ "UI direction; questionnaires; organization admin; deleting factories and products."
60508
60911
  ].join("\n");
60509
60912
  //#endregion
60510
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.39.1-dev.1241",
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",