@taiga-ai/mcp-server 0.2.3 → 0.3.0-dev.296
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +419 -62
- package/package.json +13 -11
- package/scripts/build.mjs +37 -0
- package/scripts/prepare-publish.cjs +15 -7
- package/src/client.test.ts +12 -27
- package/src/client.ts +19 -43
- package/src/index.ts +5 -8
- package/src/server.integration.test.ts +13 -50
- package/src/tools/backlogs.ts +1 -1
- package/src/tools/documents.ts +1 -1
- package/src/tools/index.ts +1 -3
- package/src/tools/projects.ts +7 -3
- package/src/version.test.ts +10 -0
- package/src/version.ts +14 -0
- package/taiga-ai-mcp-server-0.3.0-dev.296.tgz +0 -0
- package/tsconfig.json +2 -1
- package/dist/client.d.ts +0 -109
- package/dist/client.d.ts.map +0 -1
- package/dist/client.js +0 -228
- package/dist/client.test.d.ts +0 -2
- package/dist/client.test.d.ts.map +0 -1
- package/dist/client.test.js +0 -203
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/server.integration.test.d.ts +0 -2
- package/dist/server.integration.test.d.ts.map +0 -1
- package/dist/server.integration.test.js +0 -358
- package/dist/tools/backlogs.d.ts +0 -4
- package/dist/tools/backlogs.d.ts.map +0 -1
- package/dist/tools/backlogs.js +0 -6
- package/dist/tools/documents.d.ts +0 -4
- package/dist/tools/documents.d.ts.map +0 -1
- package/dist/tools/documents.js +0 -97
- package/dist/tools/index.d.ts +0 -12
- package/dist/tools/index.d.ts.map +0 -1
- package/dist/tools/index.js +0 -18
- package/dist/tools/projects.d.ts +0 -4
- package/dist/tools/projects.d.ts.map +0 -1
- package/dist/tools/projects.js +0 -64
- package/dist/tools/skills.d.ts +0 -4
- package/dist/tools/skills.d.ts.map +0 -1
- package/dist/tools/skills.js +0 -45
- package/dist/tools/summarize.d.ts +0 -15
- package/dist/tools/summarize.d.ts.map +0 -1
- package/dist/tools/summarize.js +0 -26
- package/src/tools/skills.ts +0 -68
- package/taiga-ai-mcp-server-0.2.3.tgz +0 -0
package/dist/index.js
CHANGED
|
@@ -1,67 +1,424 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
const
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
const SERVER_VERSION = createRequire(import.meta.url)("../package.json").version;
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/client.ts
|
|
9
|
+
/**
|
|
10
|
+
* HTTP client for the Taiga API.
|
|
11
|
+
* Used by the MCP server to proxy tool calls to the backend.
|
|
12
|
+
*/
|
|
13
|
+
var TaigaClient = class {
|
|
14
|
+
baseUrl;
|
|
15
|
+
apiKey;
|
|
16
|
+
introspection = null;
|
|
17
|
+
constructor(opts) {
|
|
18
|
+
this.baseUrl = opts.baseUrl.replace(/\/+$/, "");
|
|
19
|
+
this.apiKey = opts.apiKey;
|
|
20
|
+
}
|
|
21
|
+
async request(method, path, body) {
|
|
22
|
+
const url = `${this.baseUrl}/v1${path}`;
|
|
23
|
+
const headers = {
|
|
24
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
25
|
+
"Content-Type": "application/json",
|
|
26
|
+
"User-Agent": `taiga-ai-mcp-server/${SERVER_VERSION}`
|
|
27
|
+
};
|
|
28
|
+
const response = await fetch(url, {
|
|
29
|
+
method,
|
|
30
|
+
headers,
|
|
31
|
+
body: body ? JSON.stringify(body) : void 0
|
|
32
|
+
});
|
|
33
|
+
if (!response.ok) {
|
|
34
|
+
const text = await response.text().catch(() => "");
|
|
35
|
+
throw new Error(`Taiga API ${method} ${path} failed (${response.status}): ${text}`);
|
|
36
|
+
}
|
|
37
|
+
return response.json();
|
|
38
|
+
}
|
|
39
|
+
async introspect() {
|
|
40
|
+
const result = await this.request("GET", "/auth/introspect");
|
|
41
|
+
this.introspection = result.data;
|
|
42
|
+
return result.data;
|
|
43
|
+
}
|
|
44
|
+
getIntrospection() {
|
|
45
|
+
return this.introspection;
|
|
46
|
+
}
|
|
47
|
+
hasCapability(capability) {
|
|
48
|
+
if (!this.introspection) return false;
|
|
49
|
+
return this.introspection.capabilities.includes(capability);
|
|
50
|
+
}
|
|
51
|
+
async listProjects(opts) {
|
|
52
|
+
const params = new URLSearchParams();
|
|
53
|
+
if (opts?.teamId) params.set("factoryId", opts.teamId);
|
|
54
|
+
if (opts?.status) params.set("status", opts.status);
|
|
55
|
+
if (opts?.limit) params.set("limit", String(opts.limit));
|
|
56
|
+
const qs = params.toString();
|
|
57
|
+
return this.request("GET", `/products${qs ? `?${qs}` : ""}`);
|
|
58
|
+
}
|
|
59
|
+
async getProject(id) {
|
|
60
|
+
return this.request("GET", `/products/${id}`);
|
|
61
|
+
}
|
|
62
|
+
async listTenantDocuments(opts) {
|
|
63
|
+
const params = new URLSearchParams();
|
|
64
|
+
if (opts?.limit) params.set("limit", String(opts.limit));
|
|
65
|
+
const qs = params.toString();
|
|
66
|
+
return this.request("GET", `/tenants/current/documents${qs ? `?${qs}` : ""}`);
|
|
67
|
+
}
|
|
68
|
+
async getTenantDocument(type) {
|
|
69
|
+
return this.request("GET", `/tenants/current/documents/${type}`);
|
|
70
|
+
}
|
|
71
|
+
async saveTenantDocumentDraft(type, body) {
|
|
72
|
+
return this.request("PUT", `/tenants/current/documents/${type}/draft`, body);
|
|
73
|
+
}
|
|
74
|
+
async listTeamDocuments(teamId, opts) {
|
|
75
|
+
const params = new URLSearchParams();
|
|
76
|
+
if (opts?.limit) params.set("limit", String(opts.limit));
|
|
77
|
+
const qs = params.toString();
|
|
78
|
+
return this.request("GET", `/factories/${teamId}/documents${qs ? `?${qs}` : ""}`);
|
|
79
|
+
}
|
|
80
|
+
async getTeamDocument(teamId, type) {
|
|
81
|
+
return this.request("GET", `/factories/${teamId}/documents/${type}`);
|
|
82
|
+
}
|
|
83
|
+
async saveTeamDocumentDraft(teamId, type, body) {
|
|
84
|
+
return this.request("PUT", `/factories/${teamId}/documents/${type}/draft`, body);
|
|
85
|
+
}
|
|
86
|
+
async listProjectDocuments(projectId, opts) {
|
|
87
|
+
const params = new URLSearchParams();
|
|
88
|
+
if (opts?.limit) params.set("limit", String(opts.limit));
|
|
89
|
+
const qs = params.toString();
|
|
90
|
+
return this.request("GET", `/products/${projectId}/documents${qs ? `?${qs}` : ""}`);
|
|
91
|
+
}
|
|
92
|
+
async getProjectDocument(projectId, type) {
|
|
93
|
+
return this.request("GET", `/products/${projectId}/documents/${type}`);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Fetch the full context for a project in parallel: project metadata,
|
|
97
|
+
* team documents and project documents.
|
|
98
|
+
* Returns a structured bundle optimized for coding agent consumption.
|
|
99
|
+
*/
|
|
100
|
+
async getProjectContext(projectId) {
|
|
101
|
+
const project = await this.request("GET", `/products/${projectId}`);
|
|
102
|
+
const teamId = project.data.factoryId;
|
|
103
|
+
const [projectDocs, teamDocs] = await Promise.all([this.listProjectDocuments(projectId, { limit: 20 }).catch(() => ({ data: [] })), teamId ? this.listTeamDocuments(teamId, { limit: 20 }).catch(() => ({ data: [] })) : Promise.resolve({ data: [] })]);
|
|
104
|
+
const keyProjectDocTypes = [
|
|
105
|
+
"specification",
|
|
106
|
+
"architecture",
|
|
107
|
+
"technology_decisions"
|
|
108
|
+
];
|
|
109
|
+
const keyTeamDocTypes = [
|
|
110
|
+
"domain_context",
|
|
111
|
+
"tech_preferences",
|
|
112
|
+
"architecture_constraints"
|
|
113
|
+
];
|
|
114
|
+
const docFetches = [];
|
|
115
|
+
for (const docType of keyProjectDocTypes) if (projectDocs.data.some((d) => d.type === docType && !d.isDraft)) docFetches.push(this.getProjectDocument(projectId, docType).then((r) => ({
|
|
116
|
+
type: docType,
|
|
117
|
+
scope: "project",
|
|
118
|
+
data: r.data
|
|
119
|
+
})).catch(() => ({
|
|
120
|
+
type: docType,
|
|
121
|
+
scope: "project",
|
|
122
|
+
data: null
|
|
123
|
+
})));
|
|
124
|
+
if (teamId) {
|
|
125
|
+
for (const docType of keyTeamDocTypes) if (teamDocs.data.some((d) => d.type === docType && !d.isDraft)) docFetches.push(this.getTeamDocument(teamId, docType).then((r) => ({
|
|
126
|
+
type: docType,
|
|
127
|
+
scope: "team",
|
|
128
|
+
data: r.data
|
|
129
|
+
})).catch(() => ({
|
|
130
|
+
type: docType,
|
|
131
|
+
scope: "team",
|
|
132
|
+
data: null
|
|
133
|
+
})));
|
|
134
|
+
}
|
|
135
|
+
const fetchedDocs = await Promise.all(docFetches);
|
|
136
|
+
return {
|
|
137
|
+
project: project.data,
|
|
138
|
+
documents: {
|
|
139
|
+
project: Object.fromEntries(fetchedDocs.filter((d) => d.scope === "project" && d.data).map((d) => [d.type, d.data])),
|
|
140
|
+
team: Object.fromEntries(fetchedDocs.filter((d) => d.scope === "team" && d.data).map((d) => [d.type, d.data]))
|
|
141
|
+
},
|
|
142
|
+
available_documents: {
|
|
143
|
+
project: projectDocs.data.map((d) => ({
|
|
144
|
+
type: d.type,
|
|
145
|
+
name: d.name,
|
|
146
|
+
version: d.version,
|
|
147
|
+
isDraft: d.isDraft
|
|
148
|
+
})),
|
|
149
|
+
team: teamDocs.data.map((d) => ({
|
|
150
|
+
type: d.type,
|
|
151
|
+
name: d.name,
|
|
152
|
+
version: d.version,
|
|
153
|
+
isDraft: d.isDraft
|
|
154
|
+
}))
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
async listBacklogItems(projectId, opts) {
|
|
159
|
+
const params = new URLSearchParams();
|
|
160
|
+
if (opts?.limit) params.set("limit", String(opts.limit));
|
|
161
|
+
const qs = params.toString();
|
|
162
|
+
return this.request("GET", `/products/${projectId}/backlog${qs ? `?${qs}` : ""}`);
|
|
163
|
+
}
|
|
164
|
+
async getBacklogItem(itemId) {
|
|
165
|
+
return this.request("GET", `/backlog/${itemId}`);
|
|
166
|
+
}
|
|
167
|
+
async listEnvironments(projectId) {
|
|
168
|
+
return this.request("GET", `/products/${projectId}/environments`);
|
|
169
|
+
}
|
|
170
|
+
async listTeams(opts) {
|
|
171
|
+
const params = new URLSearchParams();
|
|
172
|
+
if (opts?.limit) params.set("limit", String(opts.limit));
|
|
173
|
+
const qs = params.toString();
|
|
174
|
+
return this.request("GET", `/factories${qs ? `?${qs}` : ""}`);
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region src/tools/summarize.ts
|
|
179
|
+
/**
|
|
180
|
+
* Strip heavy content from list responses to avoid context window bloat.
|
|
181
|
+
*
|
|
182
|
+
* List endpoints return summaries (id, name, description, metadata).
|
|
183
|
+
* Get endpoints return the full content.
|
|
184
|
+
*
|
|
185
|
+
* This keeps list calls cheap (~100 tokens per item) and lets the AI
|
|
186
|
+
* selectively load full content only for the items it needs.
|
|
187
|
+
*/
|
|
188
|
+
/** Fields to strip from list responses -- these contain the bulk content. */
|
|
189
|
+
const HEAVY_FIELDS = [
|
|
190
|
+
"content",
|
|
191
|
+
"data",
|
|
192
|
+
"sections"
|
|
193
|
+
];
|
|
194
|
+
/**
|
|
195
|
+
* Remove heavy content fields from each item in an array.
|
|
196
|
+
* Preserves all metadata (id, name, description, type, dates, etc).
|
|
197
|
+
*/
|
|
198
|
+
function summarizeList(items) {
|
|
199
|
+
return items.map((item) => {
|
|
200
|
+
const summary = { ...item };
|
|
201
|
+
for (const field of HEAVY_FIELDS) if (field in summary) delete summary[field];
|
|
202
|
+
return summary;
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
//#endregion
|
|
206
|
+
//#region src/tools/projects.ts
|
|
207
|
+
function registerProjectTools(server, client) {
|
|
208
|
+
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 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)") }, {
|
|
209
|
+
readOnlyHint: true,
|
|
210
|
+
openWorldHint: false
|
|
211
|
+
}, async (params) => {
|
|
212
|
+
const result = await client.listTeams(params);
|
|
213
|
+
return { content: [{
|
|
214
|
+
type: "text",
|
|
215
|
+
text: JSON.stringify(result.data, null, 2)
|
|
216
|
+
}] };
|
|
217
|
+
});
|
|
218
|
+
if (client.hasCapability("projects:read")) {
|
|
219
|
+
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).", {
|
|
220
|
+
teamId: z.string().uuid().optional().describe("Filter by team ID -- get team IDs from taiga_list_teams"),
|
|
221
|
+
status: z.enum([
|
|
222
|
+
"draft",
|
|
223
|
+
"active",
|
|
224
|
+
"archived"
|
|
225
|
+
]).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."),
|
|
226
|
+
limit: z.number().min(1).max(100).optional().describe("Max results (default 25)")
|
|
227
|
+
}, {
|
|
228
|
+
readOnlyHint: true,
|
|
229
|
+
openWorldHint: false
|
|
230
|
+
}, async (params) => {
|
|
231
|
+
const result = await client.listProjects(params);
|
|
232
|
+
return { content: [{
|
|
233
|
+
type: "text",
|
|
234
|
+
text: JSON.stringify(result.data, null, 2)
|
|
235
|
+
}] };
|
|
236
|
+
});
|
|
237
|
+
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.", {
|
|
238
|
+
projectId: z.string().uuid().describe("Project ID -- get from taiga_list_projects"),
|
|
239
|
+
limit: z.number().min(1).max(100).optional().describe("Max results (default 25)")
|
|
240
|
+
}, {
|
|
241
|
+
readOnlyHint: true,
|
|
242
|
+
openWorldHint: false
|
|
243
|
+
}, async (params) => {
|
|
244
|
+
const summaries = summarizeList((await client.listProjectDocuments(params.projectId, { limit: params.limit })).data);
|
|
245
|
+
return { content: [{
|
|
246
|
+
type: "text",
|
|
247
|
+
text: JSON.stringify(summaries, null, 2)
|
|
248
|
+
}] };
|
|
249
|
+
});
|
|
250
|
+
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.", {
|
|
251
|
+
projectId: z.string().uuid().describe("Project ID -- get from taiga_list_projects"),
|
|
252
|
+
type: z.string().describe("Document type -- get available types from taiga_list_project_documents. Common: specification, architecture, threat_model, technology_decisions")
|
|
253
|
+
}, {
|
|
254
|
+
readOnlyHint: true,
|
|
255
|
+
openWorldHint: false
|
|
256
|
+
}, async (params) => {
|
|
257
|
+
const result = await client.getProjectDocument(params.projectId, params.type);
|
|
258
|
+
return { content: [{
|
|
259
|
+
type: "text",
|
|
260
|
+
text: JSON.stringify(result.data, null, 2)
|
|
261
|
+
}] };
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
//#endregion
|
|
266
|
+
//#region src/tools/documents.ts
|
|
267
|
+
function registerDocumentTools(server, client) {
|
|
268
|
+
if (client.hasCapability("tenant:documents:read")) {
|
|
269
|
+
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)") }, {
|
|
270
|
+
readOnlyHint: true,
|
|
271
|
+
openWorldHint: false
|
|
272
|
+
}, async (params) => {
|
|
273
|
+
const summaries = summarizeList((await client.listTenantDocuments(params)).data);
|
|
274
|
+
return { content: [{
|
|
275
|
+
type: "text",
|
|
276
|
+
text: JSON.stringify(summaries, null, 2)
|
|
277
|
+
}] };
|
|
278
|
+
});
|
|
279
|
+
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") }, {
|
|
280
|
+
readOnlyHint: true,
|
|
281
|
+
openWorldHint: false
|
|
282
|
+
}, async (params) => {
|
|
283
|
+
const result = await client.getTenantDocument(params.type);
|
|
284
|
+
return { content: [{
|
|
285
|
+
type: "text",
|
|
286
|
+
text: JSON.stringify(result.data, null, 2)
|
|
287
|
+
}] };
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
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.", {
|
|
291
|
+
type: z.string().describe("Document type (e.g. policy_security, policy_sdlc)"),
|
|
292
|
+
data: z.record(z.string(), z.unknown()).describe("Document content to save as JSON")
|
|
293
|
+
}, {
|
|
294
|
+
readOnlyHint: false,
|
|
295
|
+
destructiveHint: false,
|
|
296
|
+
idempotentHint: true,
|
|
297
|
+
openWorldHint: false
|
|
298
|
+
}, async (params) => {
|
|
299
|
+
const { type, ...body } = params;
|
|
300
|
+
const result = await client.saveTenantDocumentDraft(type, body);
|
|
301
|
+
return { content: [{
|
|
302
|
+
type: "text",
|
|
303
|
+
text: JSON.stringify(result.data, null, 2)
|
|
304
|
+
}] };
|
|
305
|
+
});
|
|
306
|
+
if (client.hasCapability("teams:read")) {
|
|
307
|
+
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.", {
|
|
308
|
+
teamId: z.string().uuid().describe("Team ID -- get from taiga_list_teams"),
|
|
309
|
+
limit: z.number().min(1).max(100).optional().describe("Max results (default 25)")
|
|
310
|
+
}, {
|
|
311
|
+
readOnlyHint: true,
|
|
312
|
+
openWorldHint: false
|
|
313
|
+
}, async (params) => {
|
|
314
|
+
const summaries = summarizeList((await client.listTeamDocuments(params.teamId, { limit: params.limit })).data);
|
|
315
|
+
return { content: [{
|
|
316
|
+
type: "text",
|
|
317
|
+
text: JSON.stringify(summaries, null, 2)
|
|
318
|
+
}] };
|
|
319
|
+
});
|
|
320
|
+
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.", {
|
|
321
|
+
teamId: z.string().uuid().describe("Team ID -- get from taiga_list_teams"),
|
|
322
|
+
type: z.string().describe("Document type -- get available types from taiga_list_team_documents. Most useful: domain_context (entities, language), tech_preferences (stack, patterns)")
|
|
323
|
+
}, {
|
|
324
|
+
readOnlyHint: true,
|
|
325
|
+
openWorldHint: false
|
|
326
|
+
}, async (params) => {
|
|
327
|
+
const result = await client.getTeamDocument(params.teamId, params.type);
|
|
328
|
+
return { content: [{
|
|
329
|
+
type: "text",
|
|
330
|
+
text: JSON.stringify(result.data, null, 2)
|
|
331
|
+
}] };
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
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.", {
|
|
335
|
+
teamId: z.string().uuid().describe("Team ID -- get from taiga_list_teams"),
|
|
336
|
+
type: z.string().describe("Document type (e.g. domain_context, tech_preferences)"),
|
|
337
|
+
data: z.record(z.string(), z.unknown()).describe("Document content to save as JSON")
|
|
338
|
+
}, {
|
|
339
|
+
readOnlyHint: false,
|
|
340
|
+
destructiveHint: false,
|
|
341
|
+
idempotentHint: true,
|
|
342
|
+
openWorldHint: false
|
|
343
|
+
}, async (params) => {
|
|
344
|
+
const { teamId, type, ...body } = params;
|
|
345
|
+
const result = await client.saveTeamDocumentDraft(teamId, type, body);
|
|
346
|
+
return { content: [{
|
|
347
|
+
type: "text",
|
|
348
|
+
text: JSON.stringify(result.data, null, 2)
|
|
349
|
+
}] };
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
//#endregion
|
|
353
|
+
//#region src/tools/index.ts
|
|
354
|
+
/**
|
|
355
|
+
* Register all MCP tools based on the API key's effective capabilities.
|
|
356
|
+
* Only tools matching the key's scopes are registered -- the AI assistant
|
|
357
|
+
* never sees tools it can't use.
|
|
358
|
+
*
|
|
359
|
+
* Beta scope: Knowledge base access (policies and team documents).
|
|
360
|
+
* Post-beta: Projects, backlog items, environments, composite tools.
|
|
361
|
+
*/
|
|
362
|
+
function registerAllTools(server, client) {
|
|
363
|
+
registerProjectTools(server, client);
|
|
364
|
+
registerDocumentTools(server, client);
|
|
365
|
+
}
|
|
366
|
+
//#endregion
|
|
367
|
+
//#region src/index.ts
|
|
368
|
+
const DEFAULT_API_URL = "https://api.taiga.app";
|
|
7
369
|
async function main() {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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);
|
|
370
|
+
const apiKey = process.env.TAIGA_API_KEY;
|
|
371
|
+
if (!apiKey) {
|
|
372
|
+
console.error("Error: TAIGA_API_KEY environment variable is required.");
|
|
373
|
+
console.error("Create an API key at https://app.taiga.app/settings/api-keys");
|
|
374
|
+
process.exit(1);
|
|
375
|
+
}
|
|
376
|
+
const client = new TaigaClient({
|
|
377
|
+
baseUrl: process.env.TAIGA_API_URL ?? DEFAULT_API_URL,
|
|
378
|
+
apiKey
|
|
379
|
+
});
|
|
380
|
+
const introspection = await client.introspect().catch((error) => {
|
|
381
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
382
|
+
console.error(`Error: Failed to validate API key: ${message}`);
|
|
383
|
+
console.error("Check that your TAIGA_API_KEY is valid and not expired.");
|
|
384
|
+
process.exit(1);
|
|
385
|
+
});
|
|
386
|
+
const server = new McpServer({
|
|
387
|
+
name: "taiga",
|
|
388
|
+
version: SERVER_VERSION
|
|
389
|
+
}, { instructions: [
|
|
390
|
+
"You have access to Taiga -- a policy-aware software development platform.",
|
|
391
|
+
"Taiga provides your organization's engineering knowledge base:",
|
|
392
|
+
"",
|
|
393
|
+
"**Company policies** (taiga_list_documents / taiga_get_document):",
|
|
394
|
+
"Security, data privacy, SDLC, architecture, and compliance rules that apply to all code.",
|
|
395
|
+
"Read the relevant policy BEFORE writing code that touches security, data handling, or infrastructure.",
|
|
396
|
+
"",
|
|
397
|
+
"**Team documents** (taiga_list_team_documents / taiga_get_team_document):",
|
|
398
|
+
"Domain context (ubiquitous language, entities, business rules), tech preferences (approved stack, patterns),",
|
|
399
|
+
"architecture constraints, and SLO targets. Read these to understand HOW this team builds software.",
|
|
400
|
+
"",
|
|
401
|
+
"**Project documents** (taiga_list_project_documents / taiga_get_project_document):",
|
|
402
|
+
"Specification (what to build), architecture (how it's designed), threat model (security risks),",
|
|
403
|
+
"technology decisions, and data flow. Read these to understand the specific project context.",
|
|
404
|
+
"",
|
|
405
|
+
"Workflow: Start with taiga_list_teams to find your team, then read the team's domain_context",
|
|
406
|
+
"and tech_preferences. For project-specific work, use taiga_list_projects to find the project,",
|
|
407
|
+
"then read its specification and architecture.",
|
|
408
|
+
"",
|
|
409
|
+
"When you notice a policy or team document is outdated, use the update tools",
|
|
410
|
+
"(taiga_update_document, taiga_update_team_document) to fix it.",
|
|
411
|
+
"This keeps the knowledge base accurate for everyone."
|
|
412
|
+
].join("\n") });
|
|
413
|
+
registerAllTools(server, client);
|
|
414
|
+
const toolCount = introspection.capabilities.length;
|
|
415
|
+
console.error(`Taiga MCP server started (${toolCount} capabilities, user: ${introspection.email}, role: ${introspection.role})`);
|
|
416
|
+
const transport = new StdioServerTransport();
|
|
417
|
+
await server.connect(transport);
|
|
63
418
|
}
|
|
64
419
|
main().catch((error) => {
|
|
65
|
-
|
|
66
|
-
|
|
420
|
+
console.error("Fatal error:", error);
|
|
421
|
+
process.exit(1);
|
|
67
422
|
});
|
|
423
|
+
//#endregion
|
|
424
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,34 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taiga-ai/mcp-server",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "MCP server for Taiga -- gives AI assistants access to documents
|
|
3
|
+
"version": "0.3.0-dev.296",
|
|
4
|
+
"description": "MCP server for Taiga -- gives AI assistants access to documents and projects",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
|
-
"types": "./dist/index.d.ts",
|
|
8
7
|
"bin": {
|
|
9
8
|
"taiga-mcp-server": "./dist/index.js"
|
|
10
9
|
},
|
|
11
10
|
"exports": {
|
|
12
11
|
".": {
|
|
13
|
-
"types": "./dist/index.d.ts",
|
|
14
12
|
"import": "./dist/index.js",
|
|
15
13
|
"default": "./dist/index.js"
|
|
16
14
|
}
|
|
17
15
|
},
|
|
18
16
|
"scripts": {
|
|
19
|
-
"build": "tsc",
|
|
17
|
+
"build": "tsc --noEmit && node scripts/build.mjs",
|
|
18
|
+
"typecheck": "tsc --noEmit",
|
|
20
19
|
"dev": "tsc --watch",
|
|
21
|
-
"lint": "
|
|
20
|
+
"lint": "oxlint src",
|
|
21
|
+
"format": "oxfmt --check \"**/*.{ts,tsx,js,jsx,mjs,cjs,json,md}\"",
|
|
22
|
+
"format:fix": "oxfmt \"**/*.{ts,tsx,js,jsx,mjs,cjs,json,md}\"",
|
|
22
23
|
"test": "vitest run"
|
|
23
24
|
},
|
|
24
25
|
"dependencies": {
|
|
25
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
26
|
-
"zod": "^
|
|
26
|
+
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
27
|
+
"zod": "^4.4.3"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
29
|
-
"@types/node": "^22.
|
|
30
|
-
"
|
|
31
|
-
"
|
|
30
|
+
"@types/node": "^22.20.1",
|
|
31
|
+
"rolldown": "^1.2.3",
|
|
32
|
+
"typescript": "^7.0.2",
|
|
33
|
+
"vitest": "^4.1.11"
|
|
32
34
|
},
|
|
33
35
|
"publishConfig": {
|
|
34
36
|
"access": "public"
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { rolldown } from 'rolldown';
|
|
3
|
+
|
|
4
|
+
const OUTFILE = 'dist/index.js';
|
|
5
|
+
const SHEBANG = '#!/usr/bin/env node';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Bundle the MCP server into a single self-contained ESM file.
|
|
9
|
+
*
|
|
10
|
+
* The published npm artifact must not reference private workspace packages, so
|
|
11
|
+
* `@taiga/*` (notably `@taiga/feature-flags`, a runtime value) is inlined. The
|
|
12
|
+
* genuinely-published deps — the MCP SDK and zod — stay external and are
|
|
13
|
+
* installed normally by consumers. Node built-ins are external via platform.
|
|
14
|
+
*/
|
|
15
|
+
const external = [/^@modelcontextprotocol\/sdk(\/|$)/, /^zod(\/|$)/, /^node:/];
|
|
16
|
+
|
|
17
|
+
const bundle = await rolldown({
|
|
18
|
+
input: 'src/index.ts',
|
|
19
|
+
platform: 'node',
|
|
20
|
+
external,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
await bundle.write({
|
|
24
|
+
file: OUTFILE,
|
|
25
|
+
format: 'esm',
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
await bundle.close();
|
|
29
|
+
|
|
30
|
+
// Guarantee the bin shebang survived bundling. Rolldown preserves the entry's
|
|
31
|
+
// shebang today, but bundlers commonly strip them — without a `#!` line the
|
|
32
|
+
// published bin fails to exec under `npx` even when chmod +x. This makes the
|
|
33
|
+
// contract explicit and robust to future bundler changes (no-op if present).
|
|
34
|
+
const code = readFileSync(OUTFILE, 'utf8');
|
|
35
|
+
if (!code.startsWith('#!')) {
|
|
36
|
+
writeFileSync(OUTFILE, `${SHEBANG}\n${code}`);
|
|
37
|
+
}
|
|
@@ -5,10 +5,14 @@
|
|
|
5
5
|
*
|
|
6
6
|
* - Removes `private: true` so npm allows publishing
|
|
7
7
|
* - Sets publishConfig to public access
|
|
8
|
-
* - Strips workspace-only dependencies
|
|
9
|
-
* -
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* - Strips workspace-only dependencies. `@taiga/types` is compile-time only
|
|
9
|
+
* (erased); `@taiga/feature-flags` is a runtime value but is bundled into
|
|
10
|
+
* dist/index.js by the rolldown build, so neither is a real runtime dep.
|
|
11
|
+
* - Drops the `types` entry points — the published artifact is a bundled CLI
|
|
12
|
+
* and ships no `.d.ts` (the build runs `tsc --noEmit`).
|
|
13
|
+
* - Marks the bin entry executable. The bundler emits dist/index.js with mode
|
|
14
|
+
* 0644, so without this `npx -y @taiga-ai/mcp-server` fails with EACCES
|
|
15
|
+
* because the kernel cannot exec a non-executable file despite the shebang.
|
|
12
16
|
*/
|
|
13
17
|
|
|
14
18
|
const fs = require('fs');
|
|
@@ -24,9 +28,13 @@ try {
|
|
|
24
28
|
delete pkg.private;
|
|
25
29
|
pkg.publishConfig = { access: 'public' };
|
|
26
30
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
// Workspace deps are inlined by the bundle — drop them from the published deps.
|
|
32
|
+
delete pkg.dependencies?.['@taiga/types'];
|
|
33
|
+
delete pkg.dependencies?.['@taiga/feature-flags'];
|
|
34
|
+
|
|
35
|
+
// No declarations are shipped for the bundled CLI.
|
|
36
|
+
delete pkg.types;
|
|
37
|
+
delete pkg.exports?.['.']?.types;
|
|
30
38
|
|
|
31
39
|
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n', 'utf8');
|
|
32
40
|
console.log('prepare-publish: package.json updated');
|