@taiga-ai/mcp-server 0.2.3-dev.267 → 0.2.3-dev.268

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 (42) hide show
  1. package/dist/index.js +690 -62
  2. package/package.json +12 -10
  3. package/scripts/build.mjs +37 -0
  4. package/scripts/prepare-publish.cjs +15 -7
  5. package/src/client.ts +13 -5
  6. package/src/index.ts +19 -7
  7. package/src/server.integration.test.ts +100 -46
  8. package/src/tools/documents.ts +1 -1
  9. package/src/tools/index.ts +5 -1
  10. package/src/tools/projects.ts +6 -2
  11. package/taiga-ai-mcp-server-0.2.3-dev.268.tgz +0 -0
  12. package/tsconfig.json +2 -1
  13. package/dist/client.d.ts +0 -109
  14. package/dist/client.d.ts.map +0 -1
  15. package/dist/client.js +0 -228
  16. package/dist/client.test.d.ts +0 -2
  17. package/dist/client.test.d.ts.map +0 -1
  18. package/dist/client.test.js +0 -203
  19. package/dist/index.d.ts +0 -3
  20. package/dist/index.d.ts.map +0 -1
  21. package/dist/server.integration.test.d.ts +0 -2
  22. package/dist/server.integration.test.d.ts.map +0 -1
  23. package/dist/server.integration.test.js +0 -358
  24. package/dist/tools/backlogs.d.ts +0 -4
  25. package/dist/tools/backlogs.d.ts.map +0 -1
  26. package/dist/tools/backlogs.js +0 -6
  27. package/dist/tools/documents.d.ts +0 -4
  28. package/dist/tools/documents.d.ts.map +0 -1
  29. package/dist/tools/documents.js +0 -97
  30. package/dist/tools/index.d.ts +0 -12
  31. package/dist/tools/index.d.ts.map +0 -1
  32. package/dist/tools/index.js +0 -18
  33. package/dist/tools/projects.d.ts +0 -4
  34. package/dist/tools/projects.d.ts.map +0 -1
  35. package/dist/tools/projects.js +0 -64
  36. package/dist/tools/skills.d.ts +0 -4
  37. package/dist/tools/skills.d.ts.map +0 -1
  38. package/dist/tools/skills.js +0 -45
  39. package/dist/tools/summarize.d.ts +0 -15
  40. package/dist/tools/summarize.d.ts.map +0 -1
  41. package/dist/tools/summarize.js +0 -26
  42. package/taiga-ai-mcp-server-0.2.3-dev.267.tgz +0 -0
package/dist/index.js CHANGED
@@ -1,67 +1,695 @@
1
1
  #!/usr/bin/env node
2
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
- import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
- import { TaigaClient } from './client.js';
5
- import { registerAllTools } from './tools/index.js';
6
- const DEFAULT_API_URL = 'https://api.taiga.app';
2
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
+ import { z } from "zod";
5
+ //#region ../../packages/feature-flags/dist/index.js
6
+ /**
7
+ * Feature flags shared across web, api, mcp-server, and the documentation site.
8
+ *
9
+ * {@link featureFlagDefinitions} is the single source of truth for WHICH flags
10
+ * exist, HOW each one resolves per environment, and what it is for; the
11
+ * {@link FeatureFlags} type is derived from it. Every app calls
12
+ * {@link resolveFeatureFlags} with its own environment identifier so a feature
13
+ * is shown or hidden consistently everywhere from one rule set:
14
+ * - web: `resolveFeatureFlags(config.VITE_APP_ENV)` (baked at build time)
15
+ * - api: a fail-safe wrapper (`apps/api/src/shared/config/feature-flags.ts`)
16
+ * that resolves `ENVIRONMENT` and defaults to `prod` for any unrecognized
17
+ * value when deployed, so a WIP feature is never leaked
18
+ * - docs: `apps/docs/src/content.config.ts` resolves flags for the
19
+ * environment being built and DROPS pages carrying `flag: <name>` where
20
+ * that flag is off, so docs.tai.ga never describes a feature customers
21
+ * cannot see (PRO-1033)
22
+ *
23
+ * Flags are boot-time constants — no remote source. Changing a rule here
24
+ * re-derives the flag everywhere.
25
+ *
26
+ * ## Adding a flag
27
+ *
28
+ * One entry in {@link featureFlagDefinitions}: its `availability`, a one-line
29
+ * `description` for the web dev panel, and the full account of what it gates
30
+ * and why as the JSDoc above the entry. If the flag is OFF in prod, two more
31
+ * things follow, and the first will stop you:
32
+ *
33
+ * 1. **`make docs-check-claims` fails until the flag is registered** in
34
+ * `FLAG_PHRASES` (`apps/docs/scripts/check-claims.py`). That is deliberate:
35
+ * the check used to iterate its own dict, so an unregistered flag was never
36
+ * examined and a page could describe an invisible feature. Register the
37
+ * words a page would use for the feature, or `[]` if it has a page of its
38
+ * own that declares the flag.
39
+ * 2. **A page for the feature can be written now**, carrying `flag: <name>` in
40
+ * its frontmatter. It is published on dev and staging and excluded from
41
+ * prod, and it publishes by itself when the flag graduates — no docs change.
42
+ * See the `flag:` section in `apps/docs/AGENTS.md`, which also covers the
43
+ * one constraint: nothing published may link to a flagged page.
44
+ */
45
+ /**
46
+ * THE registry: one entry per flag. Adding a flag is adding an entry here;
47
+ * {@link FeatureFlags} and {@link resolveFeatureFlags} derive from it.
48
+ */
49
+ const featureFlagDefinitions = Object.freeze({
50
+ /**
51
+ * Skills feature. When `false` the feature is fully dormant:
52
+ * - web: nav groups, dashboard governance row, and skills routes are hidden
53
+ * - api: the `/v1/agent-skills*` endpoints are not registered
54
+ * - mcp: the skill tools, their instruction mentions, and the
55
+ * `getProjectContext` skills summary are omitted
56
+ * - agent runtime: no skills are injected into agent prompts
57
+ * - seeding: no default skills are created for new tenants/teams/projects
58
+ *
59
+ * Hidden for now (not needed in the product yet; may return later).
60
+ */
61
+ skills: {
62
+ description: "Agent skills: the skills routes and pages, the MCP skill tools, and skills injected into agent prompts. Hidden in every environment for now.",
63
+ availability: "nowhere"
64
+ },
65
+ /**
66
+ * Insights surface (Learn loop) — production feedback and customer signals
67
+ * feeding the next iteration.
68
+ *
69
+ * Release toggle: ON in local/dev/staging, OFF in prod. Surfaces the
70
+ * scaffold page in lower environments only while the feature is designed.
71
+ * **Remove this flag (and its gates) at GA.**
72
+ */
73
+ insights: {
74
+ description: "Insights section of the Learn loop: production feedback and customer signals feeding the next iteration.",
75
+ availability: "non-prod"
76
+ },
77
+ /**
78
+ * UI Studio (PRO-630) — the workbench for AI-generated UI concepts of the
79
+ * CUSTOMER's app: the concept gallery, the sparring chat, iterate, and
80
+ * promoting an element into a Design Standards component. When `false` the
81
+ * workbench is fully dormant:
82
+ * - web: the concept gallery, the Studio, the initiative cockpit's
83
+ * direction card and the `/dev/ui-artifact-test` route are not
84
+ * registered
85
+ * - api: the Studio's own routes (persist, delete, feedback, iterate,
86
+ * promote-component) are not registered, and their job assemblers refuse
87
+ *
88
+ * NOT under this flag: the Look & Feel document (PRO-1376) and everything it
89
+ * runs on -- the concept compile/list/read/choose routes, the direction job,
90
+ * "Propose 2 more", the planner's direction summary and the build-time
91
+ * direction. Those shipped in PRO-1537. The flow surface moved out from under
92
+ * this flag in PRO-1029 and graduated to production in PRO-1535; it carries
93
+ * no flag any more.
94
+ *
95
+ * Release toggle: ON in local/dev/staging, OFF in prod until the workbench
96
+ * has its own rollout decision. **Remove this flag (and its gates) at GA.**
97
+ */
98
+ uiSparring: {
99
+ description: "UI Studio: the workbench for AI-generated UI concepts of the customer's application, with its own API endpoints. Look & Feel is not under it.",
100
+ availability: "non-prod"
101
+ },
102
+ /**
103
+ * Customer-definable check-and-stamp checklists (PRO-946..948, design
104
+ * PRO-933). When `false` the feature is fully dormant:
105
+ * - api: the `/v1/checklist-*` endpoints are not registered
106
+ * - api: no checklist instances are created on project creation (PR 2/3)
107
+ * - web: no discovery-pipeline checklist step, no org-settings editor
108
+ *
109
+ * Release toggle: ON in local/dev/staging, OFF in prod while the three
110
+ * slices (schema/API → gate + project surface → template editor) land.
111
+ * **Remove this flag (and its gates) at GA.**
112
+ */
113
+ checklists: {
114
+ description: "Customer-defined check-and-stamp checklists: the discovery pipeline step, the organization settings editor and their API endpoints.",
115
+ availability: "non-prod"
116
+ },
117
+ /**
118
+ * Factory v2 engineer pod (PRO-1313..1315, PRO-1331). Two roles:
119
+ * - the admin-only `/v1/engineer/*` endpoints that trigger the EC2-backed
120
+ * Runtime Instances probe runtime (when `false` the routes are not
121
+ * registered, so nothing in the product can reach that runtime);
122
+ * - the environment kill-switch for agent-runtime routing (PRO-1331): with
123
+ * it on, a tenant holding a live `engineer_runtime` entitlement has its
124
+ * initiative planning jobs and build runs routed to the engineer runtime
125
+ * (fail-closed until the run contract lands, PRO-1333); with it off,
126
+ * every tenant stays on the legacy agents whatever the entitlement rows
127
+ * say.
128
+ * OFF in prod until the real engineer pod ships behind its own, separate
129
+ * rollout decision.
130
+ */
131
+ engineerPod: {
132
+ description: "Factory v2 engineer pod: the admin-only /v1/engineer probe endpoints, and the kill-switch for routing engineer_runtime-entitled tenants to the engineer runtime (dev/staging only).",
133
+ availability: "non-prod"
134
+ },
135
+ /**
136
+ * Questionnaire filling (PRO-932) — a customer uploads their own requirement
137
+ * spreadsheet, Taiga answers what the project's evidence supports with
138
+ * `document@version` citations, a human attests, and the answers are written
139
+ * back into that same workbook. ASTORI's THL Liite 4 is the first named
140
+ * preset, not a modelled regulation.
141
+ *
142
+ * When `false` the feature is fully dormant:
143
+ * - api: the `/v1/questionnaires*` and `/v1/projects/:id/questionnaires`
144
+ * endpoints are not registered
145
+ *
146
+ * Release toggle: ON in local/dev/staging, OFF in prod while the slices
147
+ * (import → fill → attest + export) land.
148
+ * **Remove this flag (and its gates) at GA.**
149
+ */
150
+ questionnaires: {
151
+ description: "Questionnaire filling: answer an uploaded requirement spreadsheet from project evidence with citations, attest, and write the answers back.",
152
+ availability: "non-prod"
153
+ },
154
+ /**
155
+ * Notification delivery (PRO-1553) -- taking an inbox item that needs a human
156
+ * and putting it in front of them somewhere other than the app.
157
+ *
158
+ * The first (and so far only) recipient type is an "alternate contact": a
159
+ * verified email address attached to an org or a project rather than to a
160
+ * person, in the AWS alternate-contacts sense. The flagship consumer is a
161
+ * Slack channel's email address, which is how a customer gets Taiga
162
+ * notifications into Slack without us shipping a Slack app.
163
+ *
164
+ * When `false` the feature is fully dormant:
165
+ * - api: the `/v1/notification-recipients*` and
166
+ * `/v1/projects/:id/notification-recipients` endpoints are not registered,
167
+ * the delivery worker does not start, and the inbox raise path writes no
168
+ * `notification_deliveries` rows -- so nothing is queued that a later
169
+ * flag flip would suddenly send
170
+ * - web: the notification-contacts card is not rendered in project settings
171
+ *
172
+ * Release toggle: ON in local/dev/staging, OFF in prod while per-user
173
+ * recipients, the preference matrix and digests land behind it.
174
+ * **Remove this flag (and its gates) at GA.**
175
+ */
176
+ notifications: {
177
+ description: "Notification delivery: verified per-scope email contacts (alternate contacts) that receive inbox items, plus the delivery queue and worker behind them.",
178
+ availability: "non-prod"
179
+ }
180
+ });
181
+ /** Every flag name, in registry order. */
182
+ const featureFlagNames = Object.keys(featureFlagDefinitions);
183
+ /**
184
+ * Resolve the full flag set for an environment from the registry. Frozen so a
185
+ * resolved set cannot be mutated at runtime — changing a flag is a source edit
186
+ * in {@link featureFlagDefinitions}, not an assignment in an app.
187
+ */
188
+ function resolveFeatureFlags(env) {
189
+ const isOn = (availability) => availability === "everywhere" || availability === "non-prod" && env !== "prod";
190
+ const resolved = {};
191
+ for (const name of featureFlagNames) resolved[name] = isOn(featureFlagDefinitions[name].availability);
192
+ return Object.freeze(resolved);
193
+ }
194
+ /**
195
+ * Safe-default snapshot, resolved as `prod`: every still-gated release toggle
196
+ * is off. Prefer
197
+ * {@link resolveFeatureFlags} with the app's real environment. Retained for
198
+ * consumers that have no environment of their own — notably the published MCP
199
+ * server — so an unconfigured runtime never leaks a work-in-progress feature.
200
+ */
201
+ const featureFlags = resolveFeatureFlags("prod");
202
+ //#endregion
203
+ //#region src/client.ts
204
+ /**
205
+ * HTTP client for the Taiga API.
206
+ * Used by the MCP server to proxy tool calls to the backend.
207
+ */
208
+ var TaigaClient = class {
209
+ baseUrl;
210
+ apiKey;
211
+ introspection = null;
212
+ constructor(opts) {
213
+ this.baseUrl = opts.baseUrl.replace(/\/+$/, "");
214
+ this.apiKey = opts.apiKey;
215
+ }
216
+ async request(method, path, body) {
217
+ const url = `${this.baseUrl}/v1${path}`;
218
+ const headers = {
219
+ Authorization: `Bearer ${this.apiKey}`,
220
+ "Content-Type": "application/json",
221
+ "User-Agent": "taiga-ai-mcp-server/0.0.1"
222
+ };
223
+ const response = await fetch(url, {
224
+ method,
225
+ headers,
226
+ body: body ? JSON.stringify(body) : void 0
227
+ });
228
+ if (!response.ok) {
229
+ const text = await response.text().catch(() => "");
230
+ throw new Error(`Taiga API ${method} ${path} failed (${response.status}): ${text}`);
231
+ }
232
+ return response.json();
233
+ }
234
+ async introspect() {
235
+ const result = await this.request("GET", "/auth/introspect");
236
+ this.introspection = result.data;
237
+ return result.data;
238
+ }
239
+ getIntrospection() {
240
+ return this.introspection;
241
+ }
242
+ hasCapability(capability) {
243
+ if (!this.introspection) return false;
244
+ return this.introspection.capabilities.includes(capability);
245
+ }
246
+ async listProjects(opts) {
247
+ const params = new URLSearchParams();
248
+ if (opts?.teamId) params.set("teamId", opts.teamId);
249
+ if (opts?.status) params.set("status", opts.status);
250
+ if (opts?.limit) params.set("limit", String(opts.limit));
251
+ const qs = params.toString();
252
+ return this.request("GET", `/projects${qs ? `?${qs}` : ""}`);
253
+ }
254
+ async getProject(id) {
255
+ return this.request("GET", `/projects/${id}`);
256
+ }
257
+ async listTenantDocuments(opts) {
258
+ const params = new URLSearchParams();
259
+ if (opts?.limit) params.set("limit", String(opts.limit));
260
+ const qs = params.toString();
261
+ return this.request("GET", `/tenants/current/documents${qs ? `?${qs}` : ""}`);
262
+ }
263
+ async getTenantDocument(type) {
264
+ return this.request("GET", `/tenants/current/documents/${type}`);
265
+ }
266
+ async saveTenantDocumentDraft(type, body) {
267
+ return this.request("PUT", `/tenants/current/documents/${type}/draft`, body);
268
+ }
269
+ async listTeamDocuments(teamId, opts) {
270
+ const params = new URLSearchParams();
271
+ if (opts?.limit) params.set("limit", String(opts.limit));
272
+ const qs = params.toString();
273
+ return this.request("GET", `/teams/${teamId}/documents${qs ? `?${qs}` : ""}`);
274
+ }
275
+ async getTeamDocument(teamId, type) {
276
+ return this.request("GET", `/teams/${teamId}/documents/${type}`);
277
+ }
278
+ async saveTeamDocumentDraft(teamId, type, body) {
279
+ return this.request("PUT", `/teams/${teamId}/documents/${type}/draft`, body);
280
+ }
281
+ async listProjectDocuments(projectId, opts) {
282
+ const params = new URLSearchParams();
283
+ if (opts?.limit) params.set("limit", String(opts.limit));
284
+ const qs = params.toString();
285
+ return this.request("GET", `/projects/${projectId}/documents${qs ? `?${qs}` : ""}`);
286
+ }
287
+ async getProjectDocument(projectId, type) {
288
+ return this.request("GET", `/projects/${projectId}/documents/${type}`);
289
+ }
290
+ async listSkills(opts) {
291
+ const params = new URLSearchParams();
292
+ if (opts?.scope) params.set("scope", opts.scope);
293
+ if (opts?.scopeId) params.set("scopeId", opts.scopeId);
294
+ if (opts?.limit) params.set("limit", String(opts.limit));
295
+ const qs = params.toString();
296
+ return this.request("GET", `/agent-skills${qs ? `?${qs}` : ""}`);
297
+ }
298
+ async getSkill(id) {
299
+ return this.request("GET", `/agent-skills/${id}`);
300
+ }
301
+ async updateSkill(id, body) {
302
+ return this.request("PATCH", `/agent-skills/${id}`, body);
303
+ }
304
+ /**
305
+ * Fetch the full context for a project in parallel: project metadata,
306
+ * team documents, project documents, and team skills.
307
+ * Returns a structured bundle optimized for coding agent consumption.
308
+ */
309
+ async getProjectContext(projectId) {
310
+ const project = await this.request("GET", `/projects/${projectId}`);
311
+ const teamId = project.data.teamId;
312
+ const [projectDocs, teamDocs, skills] = await Promise.all([
313
+ this.listProjectDocuments(projectId, { limit: 20 }).catch(() => ({ data: [] })),
314
+ teamId ? this.listTeamDocuments(teamId, { limit: 20 }).catch(() => ({ data: [] })) : Promise.resolve({ data: [] }),
315
+ featureFlags.skills ? this.listSkills({ limit: 100 }).catch(() => ({ data: [] })) : Promise.resolve({ data: [] })
316
+ ]);
317
+ const keyProjectDocTypes = [
318
+ "specification",
319
+ "architecture",
320
+ "technology_decisions"
321
+ ];
322
+ const keyTeamDocTypes = [
323
+ "domain_context",
324
+ "tech_preferences",
325
+ "architecture_constraints"
326
+ ];
327
+ const docFetches = [];
328
+ for (const docType of keyProjectDocTypes) if (projectDocs.data.some((d) => d.type === docType && !d.isDraft)) docFetches.push(this.getProjectDocument(projectId, docType).then((r) => ({
329
+ type: docType,
330
+ scope: "project",
331
+ data: r.data
332
+ })).catch(() => ({
333
+ type: docType,
334
+ scope: "project",
335
+ data: null
336
+ })));
337
+ if (teamId) {
338
+ for (const docType of keyTeamDocTypes) if (teamDocs.data.some((d) => d.type === docType && !d.isDraft)) docFetches.push(this.getTeamDocument(teamId, docType).then((r) => ({
339
+ type: docType,
340
+ scope: "team",
341
+ data: r.data
342
+ })).catch(() => ({
343
+ type: docType,
344
+ scope: "team",
345
+ data: null
346
+ })));
347
+ }
348
+ const fetchedDocs = await Promise.all(docFetches);
349
+ const context = {
350
+ project: project.data,
351
+ documents: {
352
+ project: Object.fromEntries(fetchedDocs.filter((d) => d.scope === "project" && d.data).map((d) => [d.type, d.data])),
353
+ team: Object.fromEntries(fetchedDocs.filter((d) => d.scope === "team" && d.data).map((d) => [d.type, d.data]))
354
+ },
355
+ available_documents: {
356
+ project: projectDocs.data.map((d) => ({
357
+ type: d.type,
358
+ name: d.name,
359
+ version: d.version,
360
+ isDraft: d.isDraft
361
+ })),
362
+ team: teamDocs.data.map((d) => ({
363
+ type: d.type,
364
+ name: d.name,
365
+ version: d.version,
366
+ isDraft: d.isDraft
367
+ }))
368
+ }
369
+ };
370
+ if (featureFlags.skills) context.skills_summary = skills.data.filter((s) => !s.teamId || s.teamId === teamId).map((s) => ({
371
+ id: s.id,
372
+ name: s.name,
373
+ slug: s.slug,
374
+ description: s.description
375
+ }));
376
+ return context;
377
+ }
378
+ async listBacklogItems(projectId, opts) {
379
+ const params = new URLSearchParams();
380
+ if (opts?.limit) params.set("limit", String(opts.limit));
381
+ const qs = params.toString();
382
+ return this.request("GET", `/projects/${projectId}/backlog${qs ? `?${qs}` : ""}`);
383
+ }
384
+ async getBacklogItem(itemId) {
385
+ return this.request("GET", `/backlog/${itemId}`);
386
+ }
387
+ async listEnvironments(projectId) {
388
+ return this.request("GET", `/projects/${projectId}/environments`);
389
+ }
390
+ async listTeams(opts) {
391
+ const params = new URLSearchParams();
392
+ if (opts?.limit) params.set("limit", String(opts.limit));
393
+ const qs = params.toString();
394
+ return this.request("GET", `/teams${qs ? `?${qs}` : ""}`);
395
+ }
396
+ };
397
+ //#endregion
398
+ //#region src/tools/summarize.ts
399
+ /**
400
+ * Strip heavy content from list responses to avoid context window bloat.
401
+ *
402
+ * List endpoints return summaries (id, name, description, metadata).
403
+ * Get endpoints return the full content.
404
+ *
405
+ * This keeps list calls cheap (~100 tokens per item) and lets the AI
406
+ * selectively load full content only for the items it needs.
407
+ */
408
+ /** Fields to strip from list responses -- these contain the bulk content. */
409
+ const HEAVY_FIELDS = [
410
+ "content",
411
+ "data",
412
+ "sections"
413
+ ];
414
+ /**
415
+ * Remove heavy content fields from each item in an array.
416
+ * Preserves all metadata (id, name, description, type, dates, etc).
417
+ */
418
+ function summarizeList(items) {
419
+ return items.map((item) => {
420
+ const summary = { ...item };
421
+ for (const field of HEAVY_FIELDS) if (field in summary) delete summary[field];
422
+ return summary;
423
+ });
424
+ }
425
+ //#endregion
426
+ //#region src/tools/projects.ts
427
+ function registerProjectTools(server, client) {
428
+ if (client.hasCapability("teams:read")) server.tool("taiga_list_teams", "List all teams in the organization. Use this to find team IDs for reading team documents, skills, and understanding team structure. Teams own domain context, tech preferences, and architecture constraints.", { limit: z.number().min(1).max(100).optional().describe("Max results (default 25)") }, {
429
+ readOnlyHint: true,
430
+ openWorldHint: false
431
+ }, async (params) => {
432
+ const result = await client.listTeams(params);
433
+ return { content: [{
434
+ type: "text",
435
+ text: JSON.stringify(result.data, null, 2)
436
+ }] };
437
+ });
438
+ if (client.hasCapability("projects:read")) {
439
+ server.tool("taiga_list_projects", "List projects in the organization. Use this to find the project you are working on so you can read its specification, architecture, and threat model. Can filter by team; a status filter also exists but no longer distinguishes anything (see its description).", {
440
+ teamId: z.string().uuid().optional().describe("Filter by team ID -- get team IDs from taiga_list_teams"),
441
+ status: z.enum([
442
+ "draft",
443
+ "active",
444
+ "archived"
445
+ ]).optional().describe("Filter by status. Taiga no longer surfaces project status in its UI (PRO-543), so every project is currently \"draft\" and filtering by \"active\" or \"archived\" returns nothing. Omit this unless you are working with data set through the API directly."),
446
+ limit: z.number().min(1).max(100).optional().describe("Max results (default 25)")
447
+ }, {
448
+ readOnlyHint: true,
449
+ openWorldHint: false
450
+ }, async (params) => {
451
+ const result = await client.listProjects(params);
452
+ return { content: [{
453
+ type: "text",
454
+ text: JSON.stringify(result.data, null, 2)
455
+ }] };
456
+ });
457
+ server.tool("taiga_list_project_documents", "List documents for a specific project (names and types only). Project documents are generated during intake: specification (requirements), architecture (system design), technology decisions, data flow, privacy assessment, threat model (security risks), risk register, and user flow. Use taiga_get_project_document to read the full content.", {
458
+ projectId: z.string().uuid().describe("Project ID -- get from taiga_list_projects"),
459
+ limit: z.number().min(1).max(100).optional().describe("Max results (default 25)")
460
+ }, {
461
+ readOnlyHint: true,
462
+ openWorldHint: false
463
+ }, async (params) => {
464
+ const summaries = summarizeList((await client.listProjectDocuments(params.projectId, { limit: params.limit })).data);
465
+ return { content: [{
466
+ type: "text",
467
+ text: JSON.stringify(summaries, null, 2)
468
+ }] };
469
+ });
470
+ server.tool("taiga_get_project_document", "Get the full content of a specific project document. Use this when you need to understand what to build (specification), how the system is designed (architecture), what security risks exist (threat model), or what technology choices were made (technology_decisions). Types: specification, architecture, technology_decisions, data_flow, privacy_assessment, threat_model, risk_register, user_flow.", {
471
+ projectId: z.string().uuid().describe("Project ID -- get from taiga_list_projects"),
472
+ type: z.string().describe("Document type -- get available types from taiga_list_project_documents. Common: specification, architecture, threat_model, technology_decisions")
473
+ }, {
474
+ readOnlyHint: true,
475
+ openWorldHint: false
476
+ }, async (params) => {
477
+ const result = await client.getProjectDocument(params.projectId, params.type);
478
+ return { content: [{
479
+ type: "text",
480
+ text: JSON.stringify(result.data, null, 2)
481
+ }] };
482
+ });
483
+ }
484
+ }
485
+ //#endregion
486
+ //#region src/tools/documents.ts
487
+ function registerDocumentTools(server, client) {
488
+ if (client.hasCapability("tenant:documents:read")) {
489
+ server.tool("taiga_list_documents", "List company-level policy documents (names and types only). Policies define security, data privacy, SDLC, operations, architecture, and compliance rules that apply across all teams and projects. Use taiga_get_document with the document type to read the full policy content.", { limit: z.number().min(1).max(100).optional().describe("Max results (default 25)") }, {
490
+ readOnlyHint: true,
491
+ openWorldHint: false
492
+ }, async (params) => {
493
+ const summaries = summarizeList((await client.listTenantDocuments(params)).data);
494
+ return { content: [{
495
+ type: "text",
496
+ text: JSON.stringify(summaries, null, 2)
497
+ }] };
498
+ });
499
+ server.tool("taiga_get_document", "Get the full content of a company policy document. Use this when you need to understand security requirements, data handling rules, architecture standards, or compliance controls that apply to your code. Types: policy_security, policy_data, policy_sdlc, policy_ops, policy_tic, policy_risk, policy_architecture, policy_supply_chain, policy_cloud_governance, policy_acceptable_use, policy_ip.", { type: z.string().describe("Document type -- get available types from taiga_list_documents. Common: policy_security, policy_data, policy_sdlc, policy_architecture") }, {
500
+ readOnlyHint: true,
501
+ openWorldHint: false
502
+ }, async (params) => {
503
+ const result = await client.getTenantDocument(params.type);
504
+ return { content: [{
505
+ type: "text",
506
+ text: JSON.stringify(result.data, null, 2)
507
+ }] };
508
+ });
509
+ }
510
+ if (client.hasCapability("tenant:documents:write")) server.tool("taiga_update_document", "Update the draft content of a company policy document. Only updates the draft -- does not publish. Use this when you notice a policy is outdated or needs corrections while reviewing code.", {
511
+ type: z.string().describe("Document type (e.g. policy_security, policy_sdlc)"),
512
+ data: z.record(z.string(), z.unknown()).describe("Document content to save as JSON")
513
+ }, {
514
+ readOnlyHint: false,
515
+ destructiveHint: false,
516
+ idempotentHint: true,
517
+ openWorldHint: false
518
+ }, async (params) => {
519
+ const { type, ...body } = params;
520
+ const result = await client.saveTenantDocumentDraft(type, body);
521
+ return { content: [{
522
+ type: "text",
523
+ text: JSON.stringify(result.data, null, 2)
524
+ }] };
525
+ });
526
+ if (client.hasCapability("teams:read")) {
527
+ server.tool("taiga_list_team_documents", "List documents for a specific team (names and types only). Team documents define how the team works: domain context (entities, ubiquitous language), tech preferences (approved stack), architecture constraints, SLO targets, definition of done, and team charter. Use taiga_get_team_document to read the full content.", {
528
+ teamId: z.string().uuid().describe("Team ID -- get from taiga_list_teams"),
529
+ limit: z.number().min(1).max(100).optional().describe("Max results (default 25)")
530
+ }, {
531
+ readOnlyHint: true,
532
+ openWorldHint: false
533
+ }, async (params) => {
534
+ const summaries = summarizeList((await client.listTeamDocuments(params.teamId, { limit: params.limit })).data);
535
+ return { content: [{
536
+ type: "text",
537
+ text: JSON.stringify(summaries, null, 2)
538
+ }] };
539
+ });
540
+ server.tool("taiga_get_team_document", "Get the full content of a specific team document. Use this when you need the team domain context (ubiquitous language, entities, business rules), tech preferences (approved stack, patterns), or architecture constraints. Types: team_charter, definition_of_done, tech_preferences, architecture_constraints, slo_targets, domain_context.", {
541
+ teamId: z.string().uuid().describe("Team ID -- get from taiga_list_teams"),
542
+ type: z.string().describe("Document type -- get available types from taiga_list_team_documents. Most useful: domain_context (entities, language), tech_preferences (stack, patterns)")
543
+ }, {
544
+ readOnlyHint: true,
545
+ openWorldHint: false
546
+ }, async (params) => {
547
+ const result = await client.getTeamDocument(params.teamId, params.type);
548
+ return { content: [{
549
+ type: "text",
550
+ text: JSON.stringify(result.data, null, 2)
551
+ }] };
552
+ });
553
+ }
554
+ if (client.hasCapability("teams:read") && client.hasCapability("tenant:documents:write")) server.tool("taiga_update_team_document", "Update the draft content of a team document. Only updates the draft -- does not publish. Use this when you notice team conventions, domain context, or tech preferences need updating while working on the codebase.", {
555
+ teamId: z.string().uuid().describe("Team ID -- get from taiga_list_teams"),
556
+ type: z.string().describe("Document type (e.g. domain_context, tech_preferences)"),
557
+ data: z.record(z.string(), z.unknown()).describe("Document content to save as JSON")
558
+ }, {
559
+ readOnlyHint: false,
560
+ destructiveHint: false,
561
+ idempotentHint: true,
562
+ openWorldHint: false
563
+ }, async (params) => {
564
+ const { teamId, type, ...body } = params;
565
+ const result = await client.saveTeamDocumentDraft(teamId, type, body);
566
+ return { content: [{
567
+ type: "text",
568
+ text: JSON.stringify(result.data, null, 2)
569
+ }] };
570
+ });
571
+ }
572
+ //#endregion
573
+ //#region src/tools/skills.ts
574
+ function registerSkillTools(server, client) {
575
+ if (client.hasCapability("tenant:documents:read")) {
576
+ server.tool("taiga_list_skills", "List agent skills available in the organization (names and descriptions only). Skills are reusable knowledge modules that guide coding: coding standards, security requirements, architecture patterns, database conventions, etc. Use taiga_get_skill with the skill ID to read the full content.", { limit: z.number().min(1).max(100).optional().describe("Max results (default 25)") }, {
577
+ readOnlyHint: true,
578
+ openWorldHint: false
579
+ }, async (params) => {
580
+ const summaries = summarizeList((await client.listSkills(params)).data);
581
+ return { content: [{
582
+ type: "text",
583
+ text: JSON.stringify(summaries, null, 2)
584
+ }] };
585
+ });
586
+ server.tool("taiga_get_skill", "Get the full content of a specific agent skill. Use this when you need detailed coding guidelines, patterns, or conventions for a specific topic (e.g., security requirements, API design, testing strategy). Returns the complete markdown content with code examples and best practices.", { id: z.string().uuid().describe("Skill ID -- get from taiga_list_skills") }, {
587
+ readOnlyHint: true,
588
+ openWorldHint: false
589
+ }, async (params) => {
590
+ const result = await client.getSkill(params.id);
591
+ return { content: [{
592
+ type: "text",
593
+ text: JSON.stringify(result.data, null, 2)
594
+ }] };
595
+ });
596
+ }
597
+ if (client.hasCapability("tenant:documents:write")) server.tool("taiga_update_skill", "Update an agent skill (coding standards, patterns, conventions). Use this when you notice a skill is outdated, incomplete, or needs corrections while working on the codebase. Changes are saved immediately.", {
598
+ id: z.string().uuid().describe("Skill ID -- get from taiga_list_skills"),
599
+ name: z.string().optional().describe("Updated skill name"),
600
+ description: z.string().optional().describe("Updated skill description"),
601
+ content: z.string().optional().describe("Updated skill content (markdown)")
602
+ }, {
603
+ readOnlyHint: false,
604
+ destructiveHint: false,
605
+ idempotentHint: true,
606
+ openWorldHint: false
607
+ }, async (params) => {
608
+ const { id, ...body } = params;
609
+ const result = await client.updateSkill(id, body);
610
+ return { content: [{
611
+ type: "text",
612
+ text: JSON.stringify(result.data, null, 2)
613
+ }] };
614
+ });
615
+ }
616
+ //#endregion
617
+ //#region src/tools/index.ts
618
+ /**
619
+ * Register all MCP tools based on the API key's effective capabilities.
620
+ * Only tools matching the key's scopes are registered -- the AI assistant
621
+ * never sees tools it can't use.
622
+ *
623
+ * Beta scope: Knowledge base access (policies, skills, team documents).
624
+ * Post-beta: Projects, backlog items, environments, composite tools.
625
+ */
626
+ function registerAllTools(server, client) {
627
+ registerProjectTools(server, client);
628
+ registerDocumentTools(server, client);
629
+ if (featureFlags.skills) registerSkillTools(server, client);
630
+ }
631
+ //#endregion
632
+ //#region src/index.ts
633
+ const DEFAULT_API_URL = "https://api.taiga.app";
7
634
  async function main() {
8
- const apiKey = process.env.TAIGA_API_KEY;
9
- if (!apiKey) {
10
- console.error('Error: TAIGA_API_KEY environment variable is required.');
11
- console.error('Create an API key at https://app.taiga.app/settings/api-keys');
12
- process.exit(1);
13
- }
14
- const apiUrl = process.env.TAIGA_API_URL ?? DEFAULT_API_URL;
15
- const client = new TaigaClient({ baseUrl: apiUrl, apiKey });
16
- // Introspect the API key to discover available capabilities
17
- const introspection = await client.introspect().catch((error) => {
18
- const message = error instanceof Error ? error.message : String(error);
19
- console.error(`Error: Failed to validate API key: ${message}`);
20
- console.error('Check that your TAIGA_API_KEY is valid and not expired.');
21
- process.exit(1);
22
- });
23
- // Create MCP server with dynamic tool registration and instructions
24
- const server = new McpServer({
25
- name: 'taiga',
26
- version: '0.0.1',
27
- }, {
28
- instructions: [
29
- 'You have access to Taiga -- a policy-aware software development platform.',
30
- "Taiga provides your organization's engineering knowledge base:",
31
- '',
32
- '**Company policies** (taiga_list_documents / taiga_get_document):',
33
- 'Security, data privacy, SDLC, architecture, and compliance rules that apply to all code.',
34
- 'Read the relevant policy BEFORE writing code that touches security, data handling, or infrastructure.',
35
- '',
36
- '**Team documents** (taiga_list_team_documents / taiga_get_team_document):',
37
- 'Domain context (ubiquitous language, entities, business rules), tech preferences (approved stack, patterns),',
38
- 'architecture constraints, and SLO targets. Read these to understand HOW this team builds software.',
39
- '',
40
- '**Project documents** (taiga_list_project_documents / taiga_get_project_document):',
41
- "Specification (what to build), architecture (how it's designed), threat model (security risks),",
42
- 'technology decisions, and data flow. Read these to understand the specific project context.',
43
- '',
44
- '**Skills** (taiga_list_skills / taiga_get_skill):',
45
- 'Coding standards, security requirements, API design patterns, testing strategy, database patterns,',
46
- 'and more. These are detailed engineering guidelines with code examples.',
47
- '',
48
- "Workflow: Start with taiga_list_teams to find your team, then read the team's domain_context",
49
- 'and tech_preferences. For project-specific work, use taiga_list_projects to find the project,',
50
- 'then read its specification and architecture. Use skills for coding patterns.',
51
- '',
52
- 'When you notice a policy, skill, or team document is outdated, use the update tools',
53
- '(taiga_update_document, taiga_update_skill, taiga_update_team_document) to fix it.',
54
- 'This keeps the knowledge base accurate for everyone.',
55
- ].join('\n'),
56
- });
57
- registerAllTools(server, client);
58
- const toolCount = introspection.capabilities.length;
59
- console.error(`Taiga MCP server started (${toolCount} capabilities, user: ${introspection.email}, role: ${introspection.role})`);
60
- // Connect via stdio transport
61
- const transport = new StdioServerTransport();
62
- await server.connect(transport);
635
+ const apiKey = process.env.TAIGA_API_KEY;
636
+ if (!apiKey) {
637
+ console.error("Error: TAIGA_API_KEY environment variable is required.");
638
+ console.error("Create an API key at https://app.taiga.app/settings/api-keys");
639
+ process.exit(1);
640
+ }
641
+ const client = new TaigaClient({
642
+ baseUrl: process.env.TAIGA_API_URL ?? DEFAULT_API_URL,
643
+ apiKey
644
+ });
645
+ const introspection = await client.introspect().catch((error) => {
646
+ const message = error instanceof Error ? error.message : String(error);
647
+ console.error(`Error: Failed to validate API key: ${message}`);
648
+ console.error("Check that your TAIGA_API_KEY is valid and not expired.");
649
+ process.exit(1);
650
+ });
651
+ const server = new McpServer({
652
+ name: "taiga",
653
+ version: "0.0.1"
654
+ }, { instructions: [
655
+ "You have access to Taiga -- a policy-aware software development platform.",
656
+ "Taiga provides your organization's engineering knowledge base:",
657
+ "",
658
+ "**Company policies** (taiga_list_documents / taiga_get_document):",
659
+ "Security, data privacy, SDLC, architecture, and compliance rules that apply to all code.",
660
+ "Read the relevant policy BEFORE writing code that touches security, data handling, or infrastructure.",
661
+ "",
662
+ "**Team documents** (taiga_list_team_documents / taiga_get_team_document):",
663
+ "Domain context (ubiquitous language, entities, business rules), tech preferences (approved stack, patterns),",
664
+ "architecture constraints, and SLO targets. Read these to understand HOW this team builds software.",
665
+ "",
666
+ "**Project documents** (taiga_list_project_documents / taiga_get_project_document):",
667
+ "Specification (what to build), architecture (how it's designed), threat model (security risks),",
668
+ "technology decisions, and data flow. Read these to understand the specific project context.",
669
+ "",
670
+ ...featureFlags.skills ? [
671
+ "**Skills** (taiga_list_skills / taiga_get_skill):",
672
+ "Coding standards, security requirements, API design patterns, testing strategy, database patterns,",
673
+ "and more. These are detailed engineering guidelines with code examples.",
674
+ ""
675
+ ] : [],
676
+ "Workflow: Start with taiga_list_teams to find your team, then read the team's domain_context",
677
+ "and tech_preferences. For project-specific work, use taiga_list_projects to find the project,",
678
+ featureFlags.skills ? "then read its specification and architecture. Use skills for coding patterns." : "then read its specification and architecture.",
679
+ "",
680
+ featureFlags.skills ? "When you notice a policy, skill, or team document is outdated, use the update tools" : "When you notice a policy or team document is outdated, use the update tools",
681
+ featureFlags.skills ? "(taiga_update_document, taiga_update_skill, taiga_update_team_document) to fix it." : "(taiga_update_document, taiga_update_team_document) to fix it.",
682
+ "This keeps the knowledge base accurate for everyone."
683
+ ].join("\n") });
684
+ registerAllTools(server, client);
685
+ const toolCount = introspection.capabilities.length;
686
+ console.error(`Taiga MCP server started (${toolCount} capabilities, user: ${introspection.email}, role: ${introspection.role})`);
687
+ const transport = new StdioServerTransport();
688
+ await server.connect(transport);
63
689
  }
64
690
  main().catch((error) => {
65
- console.error('Fatal error:', error);
66
- process.exit(1);
691
+ console.error("Fatal error:", error);
692
+ process.exit(1);
67
693
  });
694
+ //#endregion
695
+ export {};