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

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 +421 -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);
@@ -30900,6 +30924,39 @@ object({
30900
30924
  level: string$2().optional()
30901
30925
  }))
30902
30926
  });
30927
+ object({ requirements: array(object({
30928
+ id: string$2(),
30929
+ origin: object({
30930
+ kind: _enum([
30931
+ "region",
30932
+ "country",
30933
+ "market",
30934
+ "industry",
30935
+ "scope_answer",
30936
+ "factory_floor",
30937
+ "product_choice",
30938
+ "baseline"
30939
+ ]),
30940
+ key: string$2()
30941
+ }),
30942
+ content: _enum([
30943
+ "own",
30944
+ "derived",
30945
+ "both"
30946
+ ]),
30947
+ state: object({
30948
+ kind: _enum([
30949
+ "applies",
30950
+ "applies_until_answered",
30951
+ "does_not_apply"
30952
+ ]),
30953
+ /** The open questions of `applies_until_answered`; the one that took it off for `does_not_apply`. */
30954
+ triggers: array(string$2()),
30955
+ answer: _enum(["yes", "no"]).optional()
30956
+ }),
30957
+ /** Each control it brings to the product: the organization's own row, or one a regulation or framework brings. */
30958
+ controls: record(string$2(), _enum(["own", "derived"]))
30959
+ })) });
30903
30960
  object({ floor: array(object({
30904
30961
  framework: string$2(),
30905
30962
  minLevel: string$2().optional()
@@ -31840,6 +31897,81 @@ const SIGNAL_KINDS = [
31840
31897
  */
31841
31898
  const DEPLOYMENT_NOTES_MAX_LENGTH = 4e3;
31842
31899
  //#endregion
31900
+ //#region ../../packages/types/dist/specification-template.js
31901
+ const SPECIFICATION_SECTIONS = [
31902
+ {
31903
+ id: "vision",
31904
+ number: 1,
31905
+ title: "Vision & Purpose",
31906
+ subsections: [
31907
+ "1.1 Business Goal & Rationale",
31908
+ "1.2 Problem Statement",
31909
+ "1.3 Objectives & Success Indicators",
31910
+ "1.4 Key Assumptions"
31911
+ ]
31912
+ },
31913
+ {
31914
+ id: "users",
31915
+ number: 2,
31916
+ title: "Users & Stakeholders",
31917
+ subsections: ["2.1 Primary Users", "2.2 Stakeholders"]
31918
+ },
31919
+ {
31920
+ id: "capabilities",
31921
+ number: 3,
31922
+ title: "Capabilities",
31923
+ subsections: [
31924
+ "3.1 Core Features",
31925
+ "3.2 Workflows",
31926
+ "3.3 Out of Scope"
31927
+ ]
31928
+ },
31929
+ {
31930
+ id: "data",
31931
+ number: 4,
31932
+ title: "Data & Information",
31933
+ subsections: [
31934
+ "4.1 Key Entities",
31935
+ "4.2 Data Sources",
31936
+ "4.3 Sensitive Data"
31937
+ ]
31938
+ },
31939
+ {
31940
+ id: "technical",
31941
+ number: 5,
31942
+ title: "Technical Context",
31943
+ subsections: [
31944
+ "5.1 Integrations",
31945
+ "5.2 Authentication & Access",
31946
+ "5.3 Constraints & Assumptions"
31947
+ ]
31948
+ },
31949
+ {
31950
+ id: "compliance",
31951
+ number: 6,
31952
+ title: "Compliance & Security",
31953
+ subsections: [
31954
+ "6.1 Data Classification",
31955
+ "6.2 Regulatory Requirements",
31956
+ "6.3 Audit & Retention"
31957
+ ]
31958
+ },
31959
+ {
31960
+ id: "timeline",
31961
+ number: 7,
31962
+ title: "Timeline & Priorities",
31963
+ subsections: [
31964
+ "7.1 Target Timeline",
31965
+ "7.2 MVP Scope",
31966
+ "7.3 Priorities"
31967
+ ]
31968
+ }
31969
+ ];
31970
+ /** A specification section's heading line, as its markdown starts. */
31971
+ function specificationHeading(section) {
31972
+ return `## ${section.number}. ${section.title}`;
31973
+ }
31974
+ //#endregion
31843
31975
  //#region ../../packages/types/dist/licenses/spdx-license-list.js
31844
31976
  /**
31845
31977
  * The SPDX License List 3.29.0 (licenses and exceptions), as `license-normalise` reads it: each
@@ -37382,7 +37514,7 @@ function outsideAllowlist(expression, allowlist) {
37382
37514
  * reads as deleted) and fields they explain would simply be missing. So it
37383
37515
  * refuses to start, and says what to do.
37384
37516
  */
37385
- function apiLevelProblem(introspection, apiUrl, required = 11, version = SERVER_VERSION) {
37517
+ function apiLevelProblem(introspection, apiUrl, required = 12, version = SERVER_VERSION) {
37386
37518
  const offered = introspection.mcpApiLevel ?? 0;
37387
37519
  if (offered >= required) return null;
37388
37520
  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 +37585,8 @@ const TOOLSET_OF = {
37453
37585
  taiga_update_product: "setup",
37454
37586
  taiga_move_product: "setup",
37455
37587
  taiga_preview_product_move: "setup",
37588
+ taiga_preview_product_markets: "setup",
37589
+ taiga_set_product_markets: "setup",
37456
37590
  taiga_link_repository: "setup",
37457
37591
  taiga_unlink_repository: "setup",
37458
37592
  taiga_list_linkable_repositories: "setup",
@@ -37493,6 +37627,8 @@ const TOOLSET_OF = {
37493
37627
  taiga_update_factory_document: "documents",
37494
37628
  taiga_publish_factory_document: "documents",
37495
37629
  taiga_update_product_document: "documents",
37630
+ taiga_remove_product_document_section: "documents",
37631
+ taiga_delete_product_document: "documents",
37496
37632
  taiga_publish_product_document: "documents",
37497
37633
  taiga_mark_product_document_reviewed: "documents",
37498
37634
  taiga_generate_product_documents: "documents",
@@ -37798,7 +37934,7 @@ function setupNextStep(product) {
37798
37934
  if (product.discoveryStep === void 0) return null;
37799
37935
  switch (product.discoveryStep) {
37800
37936
  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}`;
37937
+ 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
37938
  }
37803
37939
  }
37804
37940
  //#endregion
@@ -39730,7 +39866,7 @@ function nextStepFor(state) {
39730
39866
  }
39731
39867
  }
39732
39868
  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." : "");
39869
+ 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
39870
  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
39871
  return `Every required document is published: ${finish}`;
39736
39872
  }
@@ -40183,17 +40319,19 @@ function registerProductTools(server, client) {
40183
40319
  }));
40184
40320
  server.registerTool("taiga_get_product_document", {
40185
40321
  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.",
40322
+ 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
40323
  inputSchema: object({
40188
40324
  productId,
40189
40325
  type: _enum(PRODUCT_DOCUMENT_TYPES).optional().describe("Document type; omit to list what the product has on both timelines"),
40190
40326
  origin: originInput,
40191
- sections: sectionsInput
40327
+ sections: sectionsInput,
40328
+ versions: boolean().optional().describe("true: list the published versions, newest first, without content"),
40329
+ version: number$1().int().positive().optional().describe("Read this published version instead of the latest (versions: true lists them)")
40192
40330
  }),
40193
40331
  annotations: READ_ONLY
40194
40332
  }, (params) => runTool(async () => {
40195
40333
  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.");
40334
+ 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
40335
  const { unlistable: _unlistable, ...timelines } = await documentTimelines(client, params.productId);
40198
40336
  return toolResult(timelines);
40199
40337
  }
@@ -40201,18 +40339,62 @@ function registerProductTools(server, client) {
40201
40339
  let product;
40202
40340
  if (!params.origin) product = (await client.getProduct(params.productId)).data;
40203
40341
  const origin = params.origin ?? defaultOriginFor(product, type);
40342
+ if (params.versions || params.version !== void 0) {
40343
+ const versions = (await client.listProductDocumentVersions(params.productId, type, origin)).data;
40344
+ if (params.versions) return toolResult({
40345
+ type,
40346
+ origin,
40347
+ versions: pickFields(versions, [
40348
+ "version",
40349
+ "stage",
40350
+ "createdBy",
40351
+ "updatedBy",
40352
+ "createdAt",
40353
+ "updatedAt"
40354
+ ])
40355
+ });
40356
+ const found = versions.find((doc) => doc.version === params.version);
40357
+ if (!found) {
40358
+ const published = versions.map((doc) => doc.version).filter((v) => v !== null);
40359
+ return toolError("NOT_FOUND", `${origin} ${type} has no version ${params.version}. ` + (published.length > 0 ? `Its versions: ${published.join(", ")}.` : "No version is published."));
40360
+ }
40361
+ const doc = stripProvenance(found);
40362
+ if (!params.sections) return toolResult(doc);
40363
+ return sectionReadResult(doc, params.sections, `${origin} ${type} v${params.version}`);
40364
+ }
40204
40365
  try {
40205
40366
  const doc = stripProvenance((await client.getProductDocument(params.productId, type, origin)).data);
40206
40367
  if (!params.sections) return toolResult(doc);
40207
40368
  return sectionReadResult(doc, params.sections, `${origin} ${type}`);
40208
40369
  } catch (error) {
40209
40370
  if (!(error instanceof TaigaApiError) || error.status !== 404) throw error;
40371
+ if (type === "specification" && origin === "plan") {
40372
+ const draft = (await client.getProductDocumentDraft(params.productId, type)).data;
40373
+ return toolResult({
40374
+ type,
40375
+ origin,
40376
+ published: false,
40377
+ draft: draft ? draftRead(stripProvenance(draft), params.sections) : null,
40378
+ sections: SPECIFICATION_SECTIONS.map((section) => ({
40379
+ id: section.id,
40380
+ heading: specificationHeading(section),
40381
+ subsections: section.subsections
40382
+ })),
40383
+ 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."
40384
+ });
40385
+ }
40210
40386
  product ??= (await client.getProduct(params.productId)).data;
40211
40387
  return toolError("NOT_FOUND", describeMiss(type, origin, await documentTimelines(client, params.productId, product), product));
40212
40388
  }
40213
40389
  }));
40214
40390
  }
40215
40391
  }
40392
+ /** A draft as `sections` asks for it, as sectionReadResult answers a published read; the whole draft without. */
40393
+ function draftRead(doc, sections) {
40394
+ if (!sections) return doc;
40395
+ const first = sectionReadResult(doc, sections, "plan specification draft").content[0];
40396
+ return first?.type === "text" ? JSON.parse(first.text) : doc;
40397
+ }
40216
40398
  //#endregion
40217
40399
  //#region src/tools/documents.ts
40218
40400
  /**
@@ -40307,23 +40489,15 @@ function storedText(section) {
40307
40489
  async function updateSection(scope, type, id, content, options = {}) {
40308
40490
  const { base, revision, publishedVersion } = await editBase(scope);
40309
40491
  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.`);
40492
+ if (!sections) return notSectioned(type);
40493
+ const text = typeof content === "string" ? content : content(storedText(ownSection(sections, id)), sections);
40494
+ if (typeof text !== "string") return text;
40311
40495
  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
- }
40496
+ const saved = await saveOneSection(scope, id, {
40497
+ content: text,
40498
+ expectedContent: storedText(ownSection(sections, id))
40499
+ });
40500
+ if (isToolResult(saved)) return saved;
40327
40501
  return toolResult({
40328
40502
  ...documentSummary(saved.data),
40329
40503
  section: {
@@ -40334,7 +40508,7 @@ async function updateSection(scope, type, id, content, options = {}) {
40334
40508
  }
40335
40509
  const edited = {
40336
40510
  ...base,
40337
- sections: applySectionEdit(sections, id, content)
40511
+ sections: applySectionEdit(sections, id, text)
40338
40512
  };
40339
40513
  const saved = await scope.saveDraft(edited, options.sendRevision && revision !== void 0 ? {
40340
40514
  expectedRevision: revision,
@@ -40348,6 +40522,47 @@ async function updateSection(scope, type, id, content, options = {}) {
40348
40522
  }
40349
40523
  });
40350
40524
  }
40525
+ function isToolResult(value) {
40526
+ return "content" in value;
40527
+ }
40528
+ function notSectioned(type) {
40529
+ return toolError("UNSUPPORTED_DOCUMENT", `Document ${type} is not made of sections and cannot be edited section by section. Edit it in the Taiga app.`);
40530
+ }
40531
+ /** One section written through the section route; a change made to it since the read is a CONFLICT result. */
40532
+ async function saveOneSection(scope, id, body) {
40533
+ if (!scope.saveSection) throw new Error("saveOneSection: the scope saves whole drafts");
40534
+ try {
40535
+ return await scope.saveSection(id, body);
40536
+ } catch (error) {
40537
+ if (conflictReason(error)?.reason !== "draft_changed") throw error;
40538
+ const now = (await scope.getDraft()).data;
40539
+ const current = now ? storedText(ownSection(sectionsOf(now.data) ?? {}, id)) : null;
40540
+ 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.`, {
40541
+ reason: "draft_changed",
40542
+ current
40543
+ });
40544
+ }
40545
+ }
40546
+ /**
40547
+ * Remove one section from a document's draft (PRO-5088), refused when it changed since it was read. The draft is
40548
+ * made from the published version first when there is none, so the section leaves the next version, not this one.
40549
+ */
40550
+ async function removeSection(scope, type, id) {
40551
+ if (!scope.saveSection) return toolError("UNSUPPORTED_DOCUMENT", `Sections of ${type} cannot be removed one by one.`);
40552
+ const { base } = await editBase(scope);
40553
+ const sections = sectionsOf(base);
40554
+ if (!sections) return notSectioned(type);
40555
+ if (!Object.hasOwn(sections, id)) return toolError("NOT_FOUND", `${type} has no section ${id}. Its sections: ${Object.keys(sections).join(", ")}.`);
40556
+ const saved = await saveOneSection(scope, id, {
40557
+ content: null,
40558
+ expectedContent: storedText(ownSection(sections, id))
40559
+ });
40560
+ if (isToolResult(saved)) return saved;
40561
+ return toolResult({
40562
+ ...documentSummary(saved.data),
40563
+ removed: id
40564
+ });
40565
+ }
40351
40566
  /**
40352
40567
  * Publish the draft; the API answers 404 when there is none and 400 when the
40353
40568
  * residue gate refuses it. A publish can succeed with warnings about this
@@ -44517,6 +44732,76 @@ function registerObserveTools(server, client) {
44517
44732
  return toolResult(pickFields([updated], ENVIRONMENT_FIELDS)[0]);
44518
44733
  }));
44519
44734
  }
44735
+ //#endregion
44736
+ //#region ../../packages/editor-schema/dist/heading.js
44737
+ /**
44738
+ * A document section's title line (PRO-3771): the `## Title` a section's
44739
+ * markdown starts with, kept apart from the section's Yjs document, as
44740
+ * Linear keeps a document's `title` apart from its `DocumentContent`. The
44741
+ * document holds the body alone, which its editor binds to whole; the record
44742
+ * holds the title; the markdown the draft stores is the two joined, as every
44743
+ * reader of it has always read it.
44744
+ *
44745
+ * Read as CommonMark reads a level-2 ATX heading, so the title is what every
44746
+ * markdown reader of the draft sees as one, and every title joins back to the
44747
+ * same title. Plain strings, so a client splits and joins without loading the
44748
+ * editor's conversion (`document.ts`). Linear in the markdown's length: the
44749
+ * server splits every section a save sends, on its event loop.
44750
+ */
44751
+ /** A level-2 ATX heading line, up to three spaces in, and its content. */
44752
+ const HEADING = /^ {0,3}##[ \t]+([^ \t][^]*)$/;
44753
+ /** A line ending, as CommonMark has them. */
44754
+ const LINE_END = /\r\n?|\n/;
44755
+ /** Blank lines, as CommonMark has them: only spaces and tabs. */
44756
+ const BLANK_LINES = /^(?:[ \t]*(?:\r\n?|\n))+/;
44757
+ /** CommonMark's whitespace around heading content: spaces and tabs, nothing else. */
44758
+ const isBlank = (char) => char === " " || char === " ";
44759
+ /**
44760
+ * A heading's content as CommonMark reads it: less a closing run of `#`s --
44761
+ * the whole of it, or after a space or tab -- and the spaces and tabs around.
44762
+ */
44763
+ function headingText(content) {
44764
+ let end = content.length;
44765
+ while (end > 0 && isBlank(content[end - 1])) end--;
44766
+ let run = end;
44767
+ while (run > 0 && content[run - 1] === "#") run--;
44768
+ if (run < end && (run === 0 || isBlank(content[run - 1]))) end = run;
44769
+ let start = 0;
44770
+ while (start < end && isBlank(content[start])) start++;
44771
+ while (end > start && isBlank(content[end - 1])) end--;
44772
+ return content.slice(start, end);
44773
+ }
44774
+ /**
44775
+ * `markdown` as its title and its body: the title is the first line when it
44776
+ * is a level-2 heading with content, the body what follows it past the blank
44777
+ * lines between. Markdown that does not start with one is all body.
44778
+ */
44779
+ function splitSectionHeading(markdown) {
44780
+ const end = LINE_END.exec(markdown);
44781
+ const first = end ? markdown.slice(0, end.index) : markdown;
44782
+ const content = HEADING.exec(first)?.[1];
44783
+ const text = content === void 0 ? "" : headingText(content);
44784
+ if (!text) return {
44785
+ heading: null,
44786
+ body: markdown
44787
+ };
44788
+ return {
44789
+ heading: text,
44790
+ body: (end ? markdown.slice(end.index + end[0].length) : "").replace(BLANK_LINES, "")
44791
+ };
44792
+ }
44793
+ /**
44794
+ * A section's markdown from its title and body, as the draft stores it: the
44795
+ * title as a level-2 heading, a blank line, then the body; the title alone
44796
+ * for an empty body, as a section's document projects one. A title that ends
44797
+ * in what would read as a closing run of `#`s gets one more run, so it reads
44798
+ * back whole.
44799
+ */
44800
+ function joinSectionHeading(heading, body) {
44801
+ if (heading === null) return body;
44802
+ const line = headingText(heading) === heading ? `## ${heading}` : `## ${heading} ##`;
44803
+ return body === "" ? line : `${line}\n\n${body}`;
44804
+ }
44520
44805
  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
44806
  /** The documents a person reviews: the discovery chain, not the snapshot or the product's own instructions. */
44522
44807
  const reviewableType = _enum(REVIEWABLE_PRODUCT_DOCUMENT_TYPES).describe("Document type -- one of the discovery documents a person reviews");
@@ -44533,17 +44818,33 @@ function registerProductDocumentWrites(server, client) {
44533
44818
  publish: () => client.publishProductDocument(product, type),
44534
44819
  saveSection: (sectionId, body) => client.saveProductDocumentSection(product, type, sectionId, body)
44535
44820
  });
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)));
44821
+ if (canRead) {
44822
+ server.registerTool("taiga_update_product_document", {
44823
+ title: "Update a section of a product document draft",
44824
+ 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.",
44825
+ inputSchema: object({
44826
+ productId,
44827
+ type: documentType,
44828
+ sectionId: sectionIdFrom("taiga_get_product_document (the plan timeline)"),
44829
+ content: string$2().optional().describe("The full new Markdown text of the section; it replaces the old text. Omit to rename only"),
44830
+ title: string$2().trim().min(1).max(200).optional().describe("The section's new title, its `## ` line, without the hashes")
44831
+ }),
44832
+ annotations: WRITE
44833
+ }, (params) => runTool(async () => {
44834
+ if (params.content === void 0 && params.title === void 0) return toolError("VALIDATION_ERROR", "Give the new text (content), the new title, or both.");
44835
+ return updateSection(productScope(params.productId, params.type), params.type, params.sectionId, sectionWrite(params.type, params.sectionId, params.content, params.title));
44836
+ }));
44837
+ server.registerTool("taiga_remove_product_document_section", {
44838
+ title: "Remove a section from a product document draft",
44839
+ 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.",
44840
+ inputSchema: object({
44841
+ productId,
44842
+ type: documentType,
44843
+ sectionId: sectionIdFrom("taiga_get_product_document (the plan timeline)")
44844
+ }),
44845
+ annotations: WRITE
44846
+ }, (params) => runTool(() => removeSection(productScope(params.productId, params.type), params.type, params.sectionId)));
44847
+ }
44547
44848
  server.registerTool("taiga_publish_product_document", {
44548
44849
  title: "Publish a product document draft",
44549
44850
  description: "Publish a product document's draft; the documents built from it are marked outdated.",
@@ -44572,7 +44873,7 @@ function registerProductDocumentWrites(server, client) {
44572
44873
  annotations: OPERATE
44573
44874
  }, (params) => runTool(async () => {
44574
44875
  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.");
44876
+ 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
44877
  const job = (await client.createAgentJob({
44577
44878
  scope: "product",
44578
44879
  type: "generate_document",
@@ -44587,6 +44888,21 @@ function registerProductDocumentWrites(server, client) {
44587
44888
  inputSchema: object({ productId }),
44588
44889
  annotations: OPERATE
44589
44890
  }, (params) => runTool(async () => toolResult((await client.generateRemainingDocuments(params.productId)).data)));
44891
+ server.registerTool("taiga_delete_product_document", {
44892
+ title: "Delete a product document",
44893
+ 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.",
44894
+ inputSchema: object({
44895
+ productId,
44896
+ type: documentType
44897
+ }),
44898
+ annotations: OPERATE
44899
+ }, (params) => runTool(async () => {
44900
+ await client.deleteProductDocuments(params.productId, params.type);
44901
+ return toolResult({
44902
+ type: params.type,
44903
+ deleted: true
44904
+ });
44905
+ }));
44590
44906
  server.registerTool("taiga_stop_generating_documents", {
44591
44907
  title: "Stop generating product documents",
44592
44908
  description: "Stop generating documents: the ones in progress are cancelled, published ones stay.",
@@ -44594,6 +44910,20 @@ function registerProductDocumentWrites(server, client) {
44594
44910
  annotations: OPERATE
44595
44911
  }, (params) => runTool(async () => toolResult((await client.stopGeneratingDocuments(params.productId)).data)));
44596
44912
  }
44913
+ /**
44914
+ * What a section edit writes (PRO-5088): the new text, the title given, else the one the text starts with, else the
44915
+ * one the section has, else a specification section's own. A specification takes only its seven sections.
44916
+ */
44917
+ function sectionWrite(type, id, content, title) {
44918
+ return (current) => {
44919
+ const spec = type === "specification" ? SPECIFICATION_SECTIONS.find((section) => section.id === id) : void 0;
44920
+ if (type === "specification" && current === null && !spec) return toolError("VALIDATION_ERROR", `A specification has these sections: ${SPECIFICATION_SECTIONS.map((section) => section.id).join(", ")}.`);
44921
+ if (content === void 0 && current === null) return toolError("NOT_FOUND", `There is no section ${id} to rename. Give its text (content) to add it.`);
44922
+ const written = splitSectionHeading(content ?? current ?? "");
44923
+ const kept = current === null ? null : splitSectionHeading(current).heading;
44924
+ return joinSectionHeading(title ?? written.heading ?? kept ?? (spec ? specificationHeading(spec).slice(3) : null), written.body);
44925
+ };
44926
+ }
44597
44927
  //#endregion
44598
44928
  //#region ../../node_modules/.pnpm/mdast-util-to-string@4.0.0/node_modules/mdast-util-to-string/lib/index.js
44599
44929
  /**
@@ -59882,7 +60212,7 @@ const buildScope = {
59882
60212
  };
59883
60213
  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
60214
  /** 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.";
60215
+ 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
60216
  /**
59887
60217
  * Refuse a name already taken (PRO-2800): the API appends -2 to the slug and
59888
60218
  * creates a second one, so a retried call or two agents at once left
@@ -60032,10 +60362,62 @@ function registerSetupTools(server, client) {
60032
60362
  });
60033
60363
  }));
60034
60364
  }
60365
+ if (client.hasCapability("tenant:settings") && client.hasCapability("products:read")) {
60366
+ const markets = object({
60367
+ productId,
60368
+ 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"),
60369
+ notOfferedAtHome: boolean().optional().describe("true when the product is not offered in the organization's own country; omit to leave it")
60370
+ });
60371
+ const marketsBody = (params) => ({
60372
+ productId: params.productId,
60373
+ countries: params.countries,
60374
+ ...params.notOfferedAtHome !== void 0 ? { notOfferedAtHome: params.notOfferedAtHome } : {}
60375
+ });
60376
+ /** What a context change does, without the context the model did not ask about. */
60377
+ const changeView = (result) => ({
60378
+ documents: result.documents.map(({ type, name, action, conflicts }) => ({
60379
+ type,
60380
+ name,
60381
+ action,
60382
+ ...conflicts && conflicts.length > 0 ? { conflicts } : {}
60383
+ })),
60384
+ ...result.regulations ? { regulations: result.regulations } : {}
60385
+ });
60386
+ server.registerTool("taiga_preview_product_markets", {
60387
+ title: "Preview a product's market countries",
60388
+ 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.",
60389
+ inputSchema: markets.partial({ countries: true }),
60390
+ annotations: READ_ONLY
60391
+ }, (params) => runTool(async () => {
60392
+ const current = (await client.getProductMarketCountries(params.productId)).data;
60393
+ if (params.countries === void 0) return toolResult({ current });
60394
+ const preview = (await client.previewProductMarkets(marketsBody({
60395
+ ...params,
60396
+ countries: params.countries
60397
+ }))).data;
60398
+ return toolResult({
60399
+ current,
60400
+ ...changeView(preview)
60401
+ });
60402
+ }));
60403
+ server.registerTool("taiga_set_product_markets", {
60404
+ title: "Set a product's market countries",
60405
+ 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.",
60406
+ inputSchema: markets,
60407
+ annotations: OPERATE
60408
+ }, (params) => runTool(async () => {
60409
+ const applied = (await client.setProductMarkets(marketsBody(params))).data;
60410
+ const current = (await client.getProductMarketCountries(params.productId)).data;
60411
+ return toolResult({
60412
+ current,
60413
+ ...changeView(applied)
60414
+ });
60415
+ }));
60416
+ }
60035
60417
  if (!client.hasCapability("products:write")) return;
60036
60418
  server.registerTool("taiga_create_product", {
60037
60419
  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.",
60420
+ 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
60421
  inputSchema: object({
60040
60422
  factoryId,
60041
60423
  name: string$2().trim().min(1).max(255).describe("The product name"),
@@ -60545,7 +60927,7 @@ const SERVER_INSTRUCTIONS = [
60545
60927
  "canceled); plan and build are stations, and the line starts the next queued initiative when both are empty. A",
60546
60928
  "run is one coding-agent attempt; hardening is its security pass; handed back means a person must act. A gate is",
60547
60929
  "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.",
60930
+ "up a new product, from a conversation (web or yours) or an import. Factories own products.",
60549
60931
  "",
60550
60932
  "**IDs** are UUIDs; the product, factory and initiative lists take query (product and factory misses may name the",
60551
60933
  "closest). A NOT_FOUND names the tool that lists the right ones. Lists page with nextCursor. outcome, situation",
@@ -60558,7 +60940,7 @@ const SERVER_INSTRUCTIONS = [
60558
60940
  "**Only in the web** (say so): connecting GitHub, GitLab or Azure DevOps; members, roles and access requests;",
60559
60941
  "the Discovery conversation; creating an initiative as written (request one); stamping checks; a run's",
60560
60942
  "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."
60943
+ "UI direction; questionnaires; organization admin; deleting factories and products."
60562
60944
  ].join("\n");
60563
60945
  //#endregion
60564
60946
  //#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.1244",
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",