@voxslopuli/teamdynamix-mcp 0.0.0-stage → 0.4.0

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/index.js ADDED
@@ -0,0 +1,2083 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/index.ts
4
+ import { McpServer as McpServer2 } from "@modelcontextprotocol/sdk/server/mcp.js";
5
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
6
+
7
+ // src/config.ts
8
+ import { z } from "zod";
9
+
10
+ // package.json
11
+ var package_default = {
12
+ name: "@voxslopuli/teamdynamix-mcp",
13
+ version: "0.3.2",
14
+ private: false,
15
+ description: "A production-ready TypeScript MCP server for TeamDynamix",
16
+ keywords: [
17
+ "mcp",
18
+ "model context protocol",
19
+ "server",
20
+ "tdx",
21
+ "teamdynamix",
22
+ "typescript"
23
+ ],
24
+ homepage: "https://github.com/voxslopuli/teamdynamix-mcp",
25
+ bugs: {
26
+ url: "https://github.com/voxslopuli/teamdynamix-mcp/issues"
27
+ },
28
+ license: "MIT",
29
+ author: "Grand Slopulissimo <slopulissimo@voxslopuli.org>",
30
+ repository: {
31
+ type: "git",
32
+ url: "git+https://github.com/voxslopuli/teamdynamix-mcp.git"
33
+ },
34
+ bin: "dist/index.js",
35
+ type: "module",
36
+ main: "dist/index.js",
37
+ scripts: {
38
+ build: "tsup",
39
+ postbuild: "node scripts/write-dist-package.js",
40
+ dev: "tsx watch src/index.ts",
41
+ "docs:build": "node scripts/prepare-docs-public.js && vitepress build docs",
42
+ "docs:dev": "vitepress dev docs",
43
+ "docs:preview": "vitepress preview docs",
44
+ format: "oxfmt . --write",
45
+ "format:check": "oxfmt . --check",
46
+ lint: "oxlint .",
47
+ "lint:fix": "oxlint . --fix",
48
+ prepare: "husky",
49
+ start: "node dist/index.js",
50
+ test: "vitest run",
51
+ "test:coverage": "vitest run --coverage",
52
+ typecheck: "tsc --noEmit"
53
+ },
54
+ dependencies: {
55
+ "@modelcontextprotocol/sdk": "^1.30.0",
56
+ "@voxslopuli/teamdynamix-ts": "^0.2.0",
57
+ tablemark: "^4.1.0",
58
+ zod: "^4.6.2"
59
+ },
60
+ devDependencies: {
61
+ "@octokit/rest": "^22.0.1",
62
+ "@types/node": "25.9.2",
63
+ "@vitest/coverage-v8": "^5.0.0",
64
+ husky: "^9.1.7",
65
+ "lint-staged": "^17.5.1",
66
+ ora: "^9.4.1",
67
+ oxfmt: "^0.67.0",
68
+ oxlint: "^1.82.0",
69
+ tsup: "^8.5.1",
70
+ tsx: "^4.23.13",
71
+ typescript: "6.0.3",
72
+ vite: "8.3.0",
73
+ vitepress: "^1.6.4",
74
+ vitest: "5.0.0",
75
+ zx: "^8.8.5"
76
+ },
77
+ "lint-staged": {
78
+ "*.{ts,mts,cts,js,mjs,cjs}": [
79
+ "oxlint --fix --no-error-on-unmatched-pattern",
80
+ "oxfmt --no-error-on-unmatched-pattern --write"
81
+ ],
82
+ "*.{json,yaml,yml,md}": [
83
+ "oxfmt --no-error-on-unmatched-pattern --write"
84
+ ]
85
+ },
86
+ packageManager: "pnpm@10.32.1",
87
+ pnpm: {
88
+ overrides: {
89
+ hono: ">=4.12.18",
90
+ "@hono/node-server": ">=1.19.13"
91
+ }
92
+ },
93
+ mcpName: "io.github.selfagency/teamdynamix-mcp"
94
+ };
95
+
96
+ // src/constants.ts
97
+ var SERVER_NAME = "teamdynamix-mcp";
98
+ var SERVER_VERSION = package_default.version;
99
+ var CHARACTER_LIMIT = 25e3;
100
+ var TEAMDYNAMIX_TOOL_PREFIX = "teamdynamix";
101
+ var TEAMDYNAMIX_DEFAULT_TIMEOUT_MS = 3e4;
102
+ var TEAMDYNAMIX_DEFAULT_MAX_RETRIES = 2;
103
+ var TEAMDYNAMIX_MAX_RETRY_ATTEMPTS = 5;
104
+
105
+ // src/config.ts
106
+ var SERVER_NAME_OVERRIDE = process.env["MCP_SERVER_NAME"]?.trim() || void 0;
107
+ var SERVER_VERSION_OVERRIDE = process.env["MCP_SERVER_VERSION"]?.trim() || void 0;
108
+ var validLogLevels = ["debug", "info", "warn", "error"];
109
+ var logLevelSchema = z.enum(validLogLevels);
110
+ var parsedLogLevel = logLevelSchema.safeParse(process.env["MCP_LOG_LEVEL"]?.trim());
111
+ var LOG_LEVEL = parsedLogLevel.success ? parsedLogLevel.data : "info";
112
+ function normalizeOptionalString(value) {
113
+ const normalized = value?.trim();
114
+ return normalized ? normalized : void 0;
115
+ }
116
+ function normalizeOptionalNumber(value) {
117
+ if (!value?.trim()) {
118
+ return void 0;
119
+ }
120
+ const parsed = Number.parseInt(value, 10);
121
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : void 0;
122
+ }
123
+ function normalizeBoolean(value, defaultValue) {
124
+ if (!value) {
125
+ return defaultValue;
126
+ }
127
+ const normalized = value.trim().toLowerCase();
128
+ if (normalized === "true") return true;
129
+ if (normalized === "false") return false;
130
+ return defaultValue;
131
+ }
132
+ function normalizeNumberWithDefault(value, defaultValue, minimum) {
133
+ if (!value?.trim()) {
134
+ return defaultValue;
135
+ }
136
+ const parsed = Number.parseInt(value, 10);
137
+ return Number.isFinite(parsed) && parsed >= minimum ? parsed : defaultValue;
138
+ }
139
+ function normalizeTeamDynamixBaseUrl(value) {
140
+ const normalized = normalizeOptionalString(value);
141
+ return normalized ? normalized.replace(/\/+$/, "") : void 0;
142
+ }
143
+ function validateHttpsBaseUrl(value) {
144
+ if (!value) return void 0;
145
+ const schema = z.string().url().refine((url) => url.startsWith("https://"), {
146
+ message: "TEAMDYNAMIX_BASE_URL must be an https URL."
147
+ });
148
+ const parsed = schema.safeParse(value);
149
+ if (!parsed.success) {
150
+ throw new Error(parsed.error.issues[0]?.message ?? "Invalid TEAMDYNAMIX_BASE_URL.");
151
+ }
152
+ return value;
153
+ }
154
+ function normalizeTeamDynamixAuthMode(value) {
155
+ return value?.trim().toLowerCase() === "admin" ? "admin" : "standard";
156
+ }
157
+ function getTeamDynamixConfig() {
158
+ const baseUrl = validateHttpsBaseUrl(normalizeTeamDynamixBaseUrl(process.env["TEAMDYNAMIX_BASE_URL"]));
159
+ const maxRetries = normalizeNumberWithDefault(
160
+ process.env["TEAMDYNAMIX_MAX_RETRIES"],
161
+ TEAMDYNAMIX_DEFAULT_MAX_RETRIES,
162
+ 0
163
+ );
164
+ if (maxRetries > 5) {
165
+ throw new Error(`TEAMDYNAMIX_MAX_RETRIES must be between 0 and ${TEAMDYNAMIX_MAX_RETRY_ATTEMPTS}.`);
166
+ }
167
+ return {
168
+ baseUrl,
169
+ authMode: normalizeTeamDynamixAuthMode(process.env["TEAMDYNAMIX_AUTH_MODE"]),
170
+ username: normalizeOptionalString(process.env["TEAMDYNAMIX_USERNAME"]),
171
+ password: normalizeOptionalString(process.env["TEAMDYNAMIX_PASSWORD"]),
172
+ beid: normalizeOptionalString(process.env["TEAMDYNAMIX_BEID"]),
173
+ webServicesKey: normalizeOptionalString(process.env["TEAMDYNAMIX_WEB_SERVICES_KEY"]),
174
+ defaultTicketAppId: normalizeOptionalNumber(process.env["TEAMDYNAMIX_DEFAULT_TICKET_APP_ID"]),
175
+ defaultAssetAppId: normalizeOptionalNumber(process.env["TEAMDYNAMIX_DEFAULT_ASSET_APP_ID"]),
176
+ defaultKnowledgeBaseAppId: normalizeOptionalNumber(process.env["TEAMDYNAMIX_DEFAULT_KB_APP_ID"]),
177
+ timeoutMs: normalizeNumberWithDefault(process.env["TEAMDYNAMIX_TIMEOUT_MS"], TEAMDYNAMIX_DEFAULT_TIMEOUT_MS, 1e3),
178
+ maxRetries,
179
+ enableWriteTools: normalizeBoolean(process.env["TEAMDYNAMIX_ENABLE_WRITE_TOOLS"], false),
180
+ enableAdminTools: normalizeBoolean(process.env["TEAMDYNAMIX_ENABLE_ADMIN_TOOLS"], false),
181
+ enableDeleteTools: normalizeBoolean(process.env["TEAMDYNAMIX_ENABLE_DELETE_TOOLS"], false)
182
+ };
183
+ }
184
+ function getTeamDynamixConfigStatus(config = getTeamDynamixConfig()) {
185
+ const missing = /* @__PURE__ */ new Set();
186
+ if (!config.baseUrl) {
187
+ missing.add("TEAMDYNAMIX_BASE_URL");
188
+ }
189
+ if (config.authMode === "admin") {
190
+ if (!config.beid) missing.add("TEAMDYNAMIX_BEID");
191
+ if (!config.webServicesKey) missing.add("TEAMDYNAMIX_WEB_SERVICES_KEY");
192
+ } else {
193
+ if (!config.username) missing.add("TEAMDYNAMIX_USERNAME");
194
+ if (!config.password) missing.add("TEAMDYNAMIX_PASSWORD");
195
+ }
196
+ return {
197
+ configured: missing.size === 0,
198
+ missing: [...missing],
199
+ authMode: config.authMode
200
+ };
201
+ }
202
+
203
+ // src/resources/teamdynamix.resources.ts
204
+ import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
205
+
206
+ // src/services/teamdynamix/core.service.ts
207
+ function redactTeamDynamixConfig(config) {
208
+ return {
209
+ baseUrl: config.baseUrl ?? null,
210
+ authMode: config.authMode,
211
+ username: config.username ? "[configured]" : null,
212
+ password: config.password ? "[configured]" : null,
213
+ beid: config.beid ? "[configured]" : null,
214
+ webServicesKey: config.webServicesKey ? "[configured]" : null,
215
+ defaultTicketAppId: config.defaultTicketAppId ?? null,
216
+ defaultAssetAppId: config.defaultAssetAppId ?? null,
217
+ defaultKnowledgeBaseAppId: config.defaultKnowledgeBaseAppId ?? null,
218
+ timeoutMs: config.timeoutMs,
219
+ maxRetries: config.maxRetries,
220
+ enableWriteTools: config.enableWriteTools,
221
+ enableAdminTools: config.enableAdminTools
222
+ };
223
+ }
224
+
225
+ // src/tools/teamdynamix.domain-gateways.tools.ts
226
+ import { z as z4 } from "zod";
227
+
228
+ // src/schemas/teamdynamix/index.ts
229
+ import { z as z3 } from "zod";
230
+
231
+ // src/schemas/index.ts
232
+ import { z as z2 } from "zod";
233
+ var ResponseFormatSchema = z2.enum(["markdown", "json"]).default("markdown").describe("Output format for the response.");
234
+ var TextTransformModeSchema = z2.enum(["uppercase", "lowercase", "trim", "slug"]).describe("Transformation mode to apply to the input text.");
235
+
236
+ // src/schemas/teamdynamix/index.ts
237
+ var TeamDynamixAppIdSchema = z3.number().int().positive().describe("TeamDynamix application ID.");
238
+ var IsoDateSchema = z3.string().regex(
239
+ /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/,
240
+ "Must be a valid ISO 8601 date string."
241
+ );
242
+ var TeamDynamixGuidSchema = z3.string().uuid().describe("TeamDynamix GUID identifier.");
243
+ var TeamDynamixResponseFormatSchema = ResponseFormatSchema;
244
+ var TicketSearchSchema = z3.object({
245
+ Keywords: z3.string().max(500).optional().describe("Full-text search term."),
246
+ MaxResults: z3.number().int().min(1).max(1e3).optional().default(50).describe("Maximum results to return (1\u20131000)."),
247
+ StatusIDs: z3.array(z3.number().int()).optional().describe("Filter by ticket status IDs."),
248
+ TypeIDs: z3.array(z3.number().int()).optional().describe("Filter by ticket type IDs."),
249
+ PriorityIDs: z3.array(z3.number().int()).optional().describe("Filter by ticket priority IDs."),
250
+ UrgencyIDs: z3.array(z3.number().int()).optional().describe("Filter by ticket urgency IDs."),
251
+ ImpactIDs: z3.array(z3.number().int()).optional().describe("Filter by ticket impact IDs."),
252
+ AccountIDs: z3.array(z3.number().int()).optional().describe("Filter by account/department IDs."),
253
+ ResponsibleGroupIDs: z3.array(z3.number().int()).optional().describe("Filter by responsible group IDs."),
254
+ ResponsibleUids: z3.array(z3.string().uuid()).optional().describe("Filter by responsible user GUIDs."),
255
+ RequestorUids: z3.array(z3.string().uuid()).optional().describe("Filter by requestor user GUIDs."),
256
+ CreatedDateFrom: IsoDateSchema.optional().describe("ISO 8601 start date for creation date filter."),
257
+ CreatedDateTo: IsoDateSchema.optional().describe("ISO 8601 end date for creation date filter."),
258
+ ModifiedDateFrom: IsoDateSchema.optional().describe("ISO 8601 start date for last-modified filter."),
259
+ ModifiedDateTo: IsoDateSchema.optional().describe("ISO 8601 end date for last-modified filter."),
260
+ ClosedDateFrom: IsoDateSchema.optional().describe("ISO 8601 start date for closed date filter."),
261
+ ClosedDateTo: IsoDateSchema.optional().describe("ISO 8601 end date for closed date filter."),
262
+ SortBy: z3.string().max(100).optional().describe("Field name to sort results by."),
263
+ SortOrder: z3.enum(["A", "D"]).optional().describe("Sort order: A = ascending, D = descending.")
264
+ });
265
+ var TicketCreateSchema = z3.object({
266
+ TypeID: z3.number().int().positive().describe("Ticket type ID."),
267
+ Title: z3.string().min(1).max(500).describe("Ticket title/subject."),
268
+ AccountID: z3.number().int().positive().optional().describe("Account/department ID."),
269
+ StatusID: z3.number().int().nonnegative().optional().describe("Initial ticket status ID."),
270
+ PriorityID: z3.number().int().nonnegative().optional().describe("Ticket priority ID."),
271
+ UrgencyID: z3.number().int().nonnegative().optional().describe("Ticket urgency ID."),
272
+ ImpactID: z3.number().int().nonnegative().optional().describe("Ticket impact ID."),
273
+ SourceID: z3.number().int().nonnegative().optional().describe("Ticket source ID."),
274
+ Description: z3.string().max(65535).optional().describe("Full description/body of the ticket (HTML supported)."),
275
+ RequestorUID: z3.string().uuid().optional().describe("GUID of the requestor."),
276
+ ResponsibleUID: z3.string().uuid().optional().describe("GUID of the responsible technician."),
277
+ ResponsibleGroupID: z3.number().int().positive().optional().describe("Responsible group ID."),
278
+ FormID: z3.number().int().positive().optional().describe("Ticket form ID."),
279
+ Attributes: z3.array(
280
+ z3.object({
281
+ ID: z3.number().int(),
282
+ Value: z3.string()
283
+ })
284
+ ).optional().describe("Custom attribute values.")
285
+ });
286
+ var TicketPatchSchema = z3.object({
287
+ TicketID: z3.number().int().positive().describe("Ticket ID to update."),
288
+ Attributes: z3.record(z3.string().max(100), z3.string().max(65535)).refine((obj) => Object.keys(obj).length <= 50, { message: "Attributes may contain at most 50 fields per update." }).describe(
289
+ 'Fields to update as key/value pairs. Keys must be valid ticket field names (e.g. "StatusID", "Title", "ResponsibleUID"). Maximum 50 fields per update.'
290
+ ),
291
+ NotifyRequestor: z3.boolean().optional().default(false).describe("Notify the requestor of the change."),
292
+ NotifyResponsible: z3.boolean().optional().default(false).describe("Notify the responsible technician of the change."),
293
+ Comments: z3.string().max(65535).optional().describe("Comment to attach to this update."),
294
+ IsPrivate: z3.boolean().optional().default(false).describe("Whether the comment is private.")
295
+ });
296
+ var TicketCommentSchema = z3.object({
297
+ TicketID: z3.number().int().positive().describe("Ticket ID to comment on."),
298
+ Body: z3.string().min(1).max(65535).describe("Comment body (HTML supported)."),
299
+ IsPrivate: z3.boolean().optional().default(false).describe("Whether this comment is private."),
300
+ NotifyRequestor: z3.boolean().optional().default(false).describe("Notify the requestor."),
301
+ NotifyResponsible: z3.boolean().optional().default(false).describe("Notify the responsible technician.")
302
+ });
303
+ var UserSearchSchema = z3.object({
304
+ SearchText: z3.string().max(500).optional().describe("Name, username, or email to search for."),
305
+ IsActive: z3.boolean().optional().describe("Filter by active (true) or inactive (false) users."),
306
+ IsEmployee: z3.boolean().optional().describe("Filter to employees only."),
307
+ AppID: z3.number().int().positive().optional().describe("Scope search to a specific application."),
308
+ MaxResults: z3.number().int().min(1).max(1e3).optional().default(25).describe("Maximum results (1\u20131000).")
309
+ });
310
+ var GroupSearchSchema = z3.object({
311
+ NameLike: z3.string().max(500).optional().describe("Partial group name to search."),
312
+ IsActive: z3.boolean().optional().describe("Filter by active (true) or inactive (false) groups."),
313
+ AppID: z3.number().int().positive().optional().describe("Scope search to a specific application.")
314
+ });
315
+ var KbArticleSearchSchema = z3.object({
316
+ SearchText: z3.string().max(500).optional().describe("Full-text search within articles."),
317
+ CategoryID: z3.number().int().positive().optional().describe("Filter by KB category ID."),
318
+ IsPublished: z3.boolean().optional().describe("Filter to published articles only."),
319
+ MaxResults: z3.number().int().min(1).max(500).optional().default(25).describe("Maximum results (1\u2013500).")
320
+ });
321
+ var AssetSearchSchema = z3.object({
322
+ SerialLike: z3.string().max(200).optional().describe("Partial serial number to match."),
323
+ TagLike: z3.string().max(200).optional().describe("Partial asset tag to match."),
324
+ SearchText: z3.string().max(500).optional().describe("General text search across asset fields."),
325
+ StatusIDs: z3.array(z3.number().int()).optional().describe("Filter by asset status IDs."),
326
+ OwnerUID: z3.string().uuid().optional().describe("Filter by asset owner GUID."),
327
+ UsingDepartmentID: z3.number().int().positive().optional().describe("Filter by using department ID."),
328
+ MaxResults: z3.number().int().min(1).max(1e3).optional().default(25).describe("Maximum results (1\u20131000).")
329
+ });
330
+ var ServiceSearchSchema = z3.object({
331
+ SearchText: z3.string().max(500).optional().describe("Full-text search across service fields."),
332
+ IsActive: z3.boolean().optional().describe("Filter to active services only."),
333
+ CategoryID: z3.number().int().positive().optional().describe("Filter by service category ID."),
334
+ MaxResults: z3.number().int().min(1).max(500).optional().default(25).describe("Maximum results (1\u2013500).")
335
+ });
336
+ var ProjectSearchSchema = z3.object({
337
+ NameLike: z3.string().max(500).optional().describe("Partial project name to search."),
338
+ TypeIDs: z3.array(z3.number().int()).optional().describe("Filter by project type IDs."),
339
+ IsActive: z3.boolean().optional().describe("Filter to active projects."),
340
+ ManagerUID: z3.string().uuid().optional().describe("Filter by project manager GUID."),
341
+ MaxResults: z3.number().int().min(1).max(500).optional().default(25).describe("Maximum results (1\u2013500).")
342
+ });
343
+ var TicketTaskCreateSchema = z3.object({
344
+ TicketID: z3.number().int().positive().describe("Parent ticket ID."),
345
+ Title: z3.string().min(1).max(500).describe("Task title."),
346
+ Description: z3.string().max(65535).optional().describe("Task description."),
347
+ IsActive: z3.boolean().optional().default(true).describe("Whether the task is active."),
348
+ AssignedUID: z3.string().uuid().optional().describe("GUID of the assigned user."),
349
+ AssignedGroupID: z3.number().int().positive().optional().describe("Assigned group ID."),
350
+ EstimatedMinutes: z3.number().int().nonnegative().optional().describe("Estimated minutes to complete."),
351
+ StartDate: IsoDateSchema.optional().describe("Task start date (ISO 8601)."),
352
+ EndDate: IsoDateSchema.optional().describe("Task due date (ISO 8601).")
353
+ });
354
+ var KbArticleCreateSchema = z3.object({
355
+ Subject: z3.string().min(1).max(500).describe("Article title/subject."),
356
+ Body: z3.string().min(1).max(5e5).describe("Article body content (HTML supported)."),
357
+ Summary: z3.string().max(2e3).optional().describe("Short article summary."),
358
+ CategoryID: z3.number().int().positive().optional().describe("KB category ID."),
359
+ IsPublished: z3.boolean().optional().default(false).describe("Whether to publish the article immediately."),
360
+ Tags: z3.string().max(1e3).optional().describe("Comma-separated tags for the article.")
361
+ });
362
+ var KbArticleUpdateSchema = KbArticleCreateSchema.partial().extend({
363
+ ArticleID: z3.number().int().positive().describe("KB article ID to update.")
364
+ });
365
+ var CiSearchSchema = z3.object({
366
+ SearchText: z3.string().max(500).optional().describe("Full-text search across CI fields."),
367
+ TypeIDs: z3.array(z3.number().int()).optional().describe("Filter by CI type IDs."),
368
+ OwnerUID: z3.string().uuid().optional().describe("Filter by owner GUID."),
369
+ MaxResults: z3.number().int().min(1).max(1e3).optional().default(25).describe("Maximum results (1\u20131000).")
370
+ });
371
+ var CustomAttributeComponentIdSchema = z3.number().int().positive().describe(
372
+ "TeamDynamix component ID for the attribute context. Common values: 9 = Ticket, 27 = Asset, 63 = KB Article, 31 = Person."
373
+ );
374
+ var ProjectIssueCreateSchema = z3.object({
375
+ Title: z3.string().min(1).max(500).describe("Issue title."),
376
+ Description: z3.string().max(65535).optional().describe("Issue description."),
377
+ AssignedUID: z3.string().uuid().optional().describe("GUID of the assigned user."),
378
+ StatusID: z3.number().int().nonnegative().optional().describe("Issue status ID."),
379
+ PriorityID: z3.number().int().nonnegative().optional().describe("Issue priority ID."),
380
+ DueDate: IsoDateSchema.optional().describe("Issue due date (ISO 8601).")
381
+ });
382
+ var ProjectRiskCreateSchema = z3.object({
383
+ Title: z3.string().min(1).max(500).describe("Risk title."),
384
+ Description: z3.string().max(65535).optional().describe("Risk description."),
385
+ AssignedUID: z3.string().uuid().optional().describe("GUID of the risk owner."),
386
+ StatusID: z3.number().int().nonnegative().optional().describe("Risk status ID."),
387
+ Probability: z3.number().int().min(1).max(100).optional().describe("Probability percentage (1\u2013100)."),
388
+ Impact: z3.number().int().min(1).max(5).optional().describe("Impact level (1 = low, 5 = critical)."),
389
+ DueDate: IsoDateSchema.optional().describe("Risk resolution due date (ISO 8601).")
390
+ });
391
+ var TimeEntryQuerySchema = z3.object({
392
+ StartDate: IsoDateSchema.describe("Start date for time entries query (ISO 8601 date, e.g. 2026-01-01)."),
393
+ EndDate: IsoDateSchema.describe("End date for time entries query (ISO 8601 date, e.g. 2026-01-31).")
394
+ });
395
+ var TeamDynamixEntitySchema = z3.record(z3.string(), z3.unknown()).describe("Base TeamDynamix entity with flexible additional fields");
396
+ var TeamDynamixNamedEntitySchema = z3.object({
397
+ ID: z3.number().int().positive("ID must be a positive integer"),
398
+ Name: z3.string().optional()
399
+ }).catchall(z3.unknown()).describe("TeamDynamix entity with ID and optional Name");
400
+ var TeamDynamixApplicationSchema = TeamDynamixNamedEntitySchema.extend({
401
+ Name: z3.string().optional()
402
+ }).describe("TeamDynamix Application entity");
403
+ var TeamDynamixTicketSchema = TeamDynamixNamedEntitySchema.extend({
404
+ Title: z3.string().optional(),
405
+ Description: z3.string().optional(),
406
+ StatusID: z3.number().int().optional(),
407
+ TypeID: z3.number().int().optional()
408
+ }).describe("TeamDynamix Ticket entity");
409
+ var TeamDynamixKbArticleSchema = TeamDynamixNamedEntitySchema.extend({
410
+ Subject: z3.string().optional(),
411
+ Body: z3.string().optional(),
412
+ IsPublished: z3.boolean().optional()
413
+ }).describe("TeamDynamix Knowledge Base Article entity");
414
+ var TeamDynamixAssetSchema = TeamDynamixNamedEntitySchema.extend({
415
+ Tag: z3.string().optional(),
416
+ StatusID: z3.number().int().optional()
417
+ }).describe("TeamDynamix Asset entity");
418
+ var TeamDynamixProjectSchema = TeamDynamixNamedEntitySchema.extend({
419
+ Status: z3.string().optional()
420
+ }).describe("TeamDynamix Project entity");
421
+ var TeamDynamixGroupSchema = TeamDynamixNamedEntitySchema.extend({
422
+ Description: z3.string().optional()
423
+ }).describe("TeamDynamix Group entity");
424
+ var TeamDynamixUserSchema = z3.object({
425
+ UID: z3.string({ error: "User UID is required" }),
426
+ FullName: z3.string().optional(),
427
+ Email: z3.string().email().optional(),
428
+ IsActive: z3.boolean().optional()
429
+ }).catchall(z3.unknown()).describe("TeamDynamix User entity");
430
+ var TeamDynamixListResponseSchema = z3.array(z3.record(z3.string(), z3.unknown())).describe("Array of TeamDynamix entities");
431
+ var TeamDynamixSingleResponseSchema = z3.record(z3.string(), z3.unknown()).describe("Single TeamDynamix entity response");
432
+
433
+ // src/client/sdk-client.factory.ts
434
+ import { existsSync } from "fs";
435
+ import { createRequire } from "module";
436
+ import { dirname, resolve } from "path";
437
+ import { fileURLToPath } from "url";
438
+ import { createTeamDynamixClient, loginWithPassword, loginWithServiceAccount } from "@voxslopuli/teamdynamix-ts";
439
+ var cachedSpecPath;
440
+ function resolveSdkSpecPath() {
441
+ const override = process.env["TEAMDYNAMIX_SPEC_PATH"]?.trim();
442
+ if (override) return override;
443
+ if (cachedSpecPath) return cachedSpecPath;
444
+ try {
445
+ const require2 = createRequire(fileURLToPath(import.meta.url));
446
+ const entryPath = require2.resolve("@voxslopuli/teamdynamix-ts");
447
+ const pkgRoot = dirname(entryPath);
448
+ const candidates = [
449
+ resolve(pkgRoot, "dist/generated/openapi.json"),
450
+ resolve(pkgRoot, "generated/openapi.json"),
451
+ resolve(pkgRoot, "src/generated/openapi.json")
452
+ ];
453
+ cachedSpecPath = candidates.find((p) => existsSync(p));
454
+ return cachedSpecPath;
455
+ } catch {
456
+ return void 0;
457
+ }
458
+ }
459
+ function createTokenProvider(config, tenant) {
460
+ if (config.authMode === "admin") {
461
+ if (!config.beid || !config.webServicesKey) {
462
+ throw new Error("BEID and WebServicesKey are required for admin authentication");
463
+ }
464
+ return loginWithServiceAccount({
465
+ tenant,
466
+ baseUrl: config.baseUrl,
467
+ beid: config.beid,
468
+ webServicesKey: config.webServicesKey
469
+ });
470
+ }
471
+ if (!config.username || !config.password) {
472
+ throw new Error("Username and password are required for standard authentication");
473
+ }
474
+ return loginWithPassword({
475
+ tenant,
476
+ baseUrl: config.baseUrl,
477
+ username: config.username,
478
+ password: config.password
479
+ });
480
+ }
481
+ function extractTenant(baseUrl) {
482
+ const normalized = baseUrl.replace(/\/+$/, "").replace(/\/TDWebApi$/, "");
483
+ const withoutProtocol = normalized.replace(/^https?:\/\//, "");
484
+ const parts = withoutProtocol.split("/");
485
+ return parts[0] ?? "";
486
+ }
487
+ function buildSdkConfig(config, tenant, tokenProvider) {
488
+ return {
489
+ tenant,
490
+ tokenProvider,
491
+ environment: config.baseUrl?.includes("sandbox") ? "sandbox" : "production",
492
+ baseUrl: config.baseUrl,
493
+ timeoutMs: config.timeoutMs,
494
+ runtimeValidationMode: "fail-open",
495
+ ...resolveSdkSpecPath() ? { specPath: resolveSdkSpecPath() } : {},
496
+ retryPolicy: {
497
+ maxRetries: config.maxRetries
498
+ }
499
+ };
500
+ }
501
+ async function createMcpSdkClient(config) {
502
+ const tenant = extractTenant(config.baseUrl ?? "");
503
+ const tokenProvider = createTokenProvider(config, tenant);
504
+ const sdkConfig = buildSdkConfig(config, tenant, tokenProvider);
505
+ const { client } = await createTeamDynamixClient(sdkConfig);
506
+ return client;
507
+ }
508
+
509
+ // src/services/teamdynamix/client.factory.ts
510
+ var TICKET_SEARCH_FIELD_MAP = {
511
+ ResponsibleGroupIDs: "ResponsibilityGroupIDs",
512
+ ResponsibleGroupID: "ResponsibilityGroupID",
513
+ ResponsibleGroups: "ResponsibilityGroupIDs"
514
+ };
515
+ function mapTicketSearchBody(body) {
516
+ const mapped = {};
517
+ for (const [key, value] of Object.entries(body)) {
518
+ if (value === void 0) continue;
519
+ mapped[TICKET_SEARCH_FIELD_MAP[key] ?? key] = value;
520
+ }
521
+ return mapped;
522
+ }
523
+ var UnifiedTeamDynamixClient = class {
524
+ constructor(config) {
525
+ this.config = config;
526
+ }
527
+ config;
528
+ sdkPromise = null;
529
+ sdk() {
530
+ this.sdkPromise ??= createMcpSdkClient(this.config);
531
+ return this.sdkPromise;
532
+ }
533
+ //
534
+ // Discovery
535
+ //
536
+ getCurrentUser() {
537
+ return this.sdk().then((s) => s.discovery.authGetuser());
538
+ }
539
+ listApplications() {
540
+ return this.sdk().then((s) => s.discovery.applications());
541
+ }
542
+ //
543
+ // Tickets
544
+ //
545
+ getTicket(appId, ticketId) {
546
+ return this.sdk().then((s) => s.tickets.appIdTicketsId({ params: { path: { appId, id: ticketId } } }));
547
+ }
548
+ searchTickets(appId, body) {
549
+ return this.sdk().then(async (s) => {
550
+ const { data, error } = await s.POST("/api/{appId}/tickets/search", {
551
+ params: { path: { appId } },
552
+ body: mapTicketSearchBody(body)
553
+ });
554
+ if (error) {
555
+ throw new Error(`Ticket search failed: ${JSON.stringify(error)}`);
556
+ }
557
+ return Array.isArray(data) ? data : [];
558
+ });
559
+ }
560
+ listTicketTypes(appId) {
561
+ return this.sdk().then((s) => s.tickets.appIdTicketsTypes({ params: { path: { appId } } }));
562
+ }
563
+ listTicketPriorities(appId) {
564
+ return this.sdk().then((s) => s.tickets.appIdTicketsPriorities({ params: { path: { appId } } }));
565
+ }
566
+ listTicketUrgencies(appId) {
567
+ return this.sdk().then((s) => s.tickets.appIdTicketsUrgencies({ params: { path: { appId } } }));
568
+ }
569
+ listTicketImpacts(appId) {
570
+ return this.sdk().then((s) => s.tickets.appIdTicketsImpacts({ params: { path: { appId } } }));
571
+ }
572
+ listTicketSources(appId) {
573
+ return this.sdk().then((s) => s.tickets.appIdTicketsSources({ params: { path: { appId } } }));
574
+ }
575
+ getTicketFeed(appId, ticketId) {
576
+ return this.sdk().then((s) => s.tickets.appIdTicketsIdFeed({ params: { path: { appId, id: ticketId } } }));
577
+ }
578
+ //
579
+ // Ticket Relationships
580
+ //
581
+ getTicketTasks(appId, ticketId) {
582
+ return this.sdk().then(
583
+ (s) => s.ticketRelationships.appIdTicketsTicketIdTasks({ params: { path: { appId, ticketId } } })
584
+ );
585
+ }
586
+ createTicketTask(appId, ticketId, body) {
587
+ return this.sdk().then((s) => s.ticketRelationships.createTicketTask({ appId, ticketId, body }));
588
+ }
589
+ listTicketAssets(appId, ticketId) {
590
+ return this.sdk().then(
591
+ (s) => s.ticketRelationships.appIdTicketsIdAssets({ params: { path: { appId, id: ticketId } } })
592
+ );
593
+ }
594
+ addTicketAsset(appId, ticketId, assetId) {
595
+ return this.sdk().then((s) => s.ticketRelationships.addTicketAsset({ appId, ticketId, assetId }));
596
+ }
597
+ removeTicketAsset(appId, ticketId, assetId) {
598
+ return this.sdk().then((s) => {
599
+ s.ticketRelationships.removeTicketAsset({ appId, ticketId, assetId, confirm: true });
600
+ });
601
+ }
602
+ getTicketContacts(appId, ticketId) {
603
+ return this.sdk().then(
604
+ (s) => s.ticketRelationships.appIdTicketsIdContacts({ params: { path: { appId, id: ticketId } } })
605
+ );
606
+ }
607
+ addTicketContact(appId, ticketId, contactUid) {
608
+ return this.sdk().then((s) => s.ticketRelationships.addTicketContact({ appId, ticketId, contactUid }));
609
+ }
610
+ removeTicketContact(appId, ticketId, contactUid) {
611
+ return this.sdk().then((s) => {
612
+ s.ticketRelationships.removeTicketContact({ appId, ticketId, contactUid, confirm: true });
613
+ });
614
+ }
615
+ //
616
+ // People
617
+ //
618
+ getUser(uid) {
619
+ return this.sdk().then((s) => s.people.peopleUid({ params: { path: { uid } } }));
620
+ }
621
+ searchUsers(body) {
622
+ const searchText = typeof body["SearchText"] === "string" ? body["SearchText"] : "";
623
+ return this.sdk().then((s) => s.people.peopleLookup({ body: { SearchText: searchText } }));
624
+ }
625
+ getGroup(groupId) {
626
+ return this.sdk().then((s) => s.people.groupsId({ params: { path: { id: groupId } } }));
627
+ }
628
+ searchGroups(_body) {
629
+ return this.sdk().then((s) => s.people.searchGroups({ body: {} }));
630
+ }
631
+ getGroupMembers(groupId) {
632
+ return this.sdk().then((s) => s.people.groupsIdMembers({ params: { path: { id: groupId } } }));
633
+ }
634
+ //
635
+ // Knowledge Base
636
+ //
637
+ getKbArticle(appId, articleId) {
638
+ return this.sdk().then((s) => s.knowledgeBase.appIdKnowledgebaseId({ params: { path: { appId, id: articleId } } }));
639
+ }
640
+ searchKbArticles(appId, body) {
641
+ const keyword = typeof body["SearchText"] === "string" ? body["SearchText"] : "";
642
+ return this.sdk().then((s) => s.knowledgeBase.appIdKnowledgebaseId({ params: { path: { appId, id: 0 } } })).then(
643
+ (r) => Array.isArray(r) ? r.filter((item) => {
644
+ const s = typeof item === "object" && item !== null ? JSON.stringify(item).toLowerCase() : "";
645
+ return keyword ? s.includes(keyword.toLowerCase()) : true;
646
+ }) : []
647
+ );
648
+ }
649
+ listKbCategories(appId) {
650
+ return this.sdk().then(
651
+ (s) => s.knowledgeBase.appIdKnowledgebaseCategories({ params: { path: { appId } } })
652
+ );
653
+ }
654
+ //
655
+ // Assets
656
+ //
657
+ getAsset(appId, assetId) {
658
+ return this.sdk().then((s) => s.assets.appIdAssetsId({ params: { path: { appId, id: assetId } } }));
659
+ }
660
+ searchAssets(appId, _body) {
661
+ return this.sdk().then((s) => s.assets.appIdAssetsFeed({ params: { path: { appId } } }));
662
+ }
663
+ listAssetStatuses(appId) {
664
+ return this.sdk().then((s) => s.assets.appIdAssetsStatuses({ params: { path: { appId } } }));
665
+ }
666
+ listProductModels(appId) {
667
+ return this.sdk().then((s) => s.assets.appIdAssetsModels({ params: { path: { appId } } }));
668
+ }
669
+ listVendors(appId) {
670
+ return this.sdk().then((s) => s.cmdb.appIdAssetsVendors({ params: { path: { appId } } }));
671
+ }
672
+ //
673
+ // CMDB
674
+ //
675
+ getConfigurationItem(appId, ciId) {
676
+ return this.sdk().then((s) => s.cmdb.appIdCmdbId({ params: { path: { appId, id: ciId } } }));
677
+ }
678
+ searchConfigurationItems(appId, _body) {
679
+ return this.sdk().then((s) => s.cmdb.appIdCmdbSearches({ params: { path: { appId } } }));
680
+ }
681
+ listCiTypes(appId) {
682
+ return this.sdk().then((s) => s.cmdb.appIdCmdbTypes({ params: { path: { appId } } }));
683
+ }
684
+ listCiRelationshipTypes() {
685
+ return this.sdk().then((s) => s.cmdb.appIdCmdbRelationshiptypes());
686
+ }
687
+ //
688
+ // Services
689
+ //
690
+ listServiceCatalog(appId) {
691
+ return this.sdk().then((s) => s.services.appIdServices({ params: { path: { appId } } }));
692
+ }
693
+ getService(appId, serviceId) {
694
+ return this.sdk().then((s) => s.services.appIdServicesId({ params: { path: { appId, id: serviceId } } }));
695
+ }
696
+ searchServices(appId, body) {
697
+ const keyword = typeof body["Keyword"] === "string" ? body["Keyword"] : "";
698
+ return this.sdk().then((s) => s.services.appIdServices({ params: { path: { appId } } })).then((r) => {
699
+ if (!Array.isArray(r)) return [];
700
+ if (!keyword) return r;
701
+ const lower = keyword.toLowerCase();
702
+ return r.filter((item) => {
703
+ const text = typeof item === "object" && item !== null ? JSON.stringify(item).toLowerCase() : "";
704
+ return text.includes(lower);
705
+ });
706
+ });
707
+ }
708
+ listServiceCategories(appId) {
709
+ return this.sdk().then((s) => s.services.appIdServicesCategories({ params: { path: { appId } } }));
710
+ }
711
+ //
712
+ // Projects
713
+ //
714
+ getProject(projectId) {
715
+ return this.sdk().then((s) => s.projects.projectsId({ params: { path: { id: projectId } } }));
716
+ }
717
+ searchProjects(_body) {
718
+ return this.sdk().then((s) => s.projects.projectsFeed());
719
+ }
720
+ listProjectTypes() {
721
+ return this.sdk().then((s) => s.projects.projectsTypes());
722
+ }
723
+ getProjectPlans(projectId) {
724
+ return this.sdk().then(
725
+ (s) => s.projects.projectsProjectIDPlansPlanID({ params: { path: { id: projectId } } })
726
+ );
727
+ }
728
+ getProjectIssues(projectId) {
729
+ return this.sdk().then(
730
+ (s) => s.projects.projectsProjectIdIssuesCategories({ params: { path: { id: projectId } } })
731
+ );
732
+ }
733
+ getProjectRisks(projectId) {
734
+ return this.sdk().then(
735
+ (s) => s.projects.projectsProjectIdRisksCategories({ params: { path: { id: projectId } } })
736
+ );
737
+ }
738
+ //
739
+ // Time
740
+ //
741
+ listTimeTypes() {
742
+ return this.sdk().then((s) => s.time.timeTypes());
743
+ }
744
+ getMyTimeEntries(_startDate, _endDate) {
745
+ return this.sdk().then((s) => s.time.timeId({ params: { path: { id: 0 } } }));
746
+ }
747
+ //
748
+ // Reference Data
749
+ //
750
+ listAccounts(_appId) {
751
+ return this.sdk().then((s) => s.referenceData.accounts());
752
+ }
753
+ getAccount(accountId) {
754
+ return this.sdk().then((s) => s.referenceData.accountsId({ params: { path: { id: accountId } } }));
755
+ }
756
+ listLocations() {
757
+ return this.sdk().then((s) => s.referenceData.locations());
758
+ }
759
+ listFunctionalRoles() {
760
+ return this.sdk().then((s) => s.referenceData.securityrolesPermissions());
761
+ }
762
+ listCustomAttributes(_componentId, _appId, _associatedTypeId) {
763
+ return this.sdk().then((s) => s.referenceData.attributesCustom());
764
+ }
765
+ listTicketStatuses(appId) {
766
+ return this.sdk().then((s) => s.referenceData.appIdTicketsStatuses({ params: { path: { appId } } }));
767
+ }
768
+ //
769
+ // Mutations
770
+ //
771
+ createTicket(appId, body, _notifyRequestor, _notifyResponsible) {
772
+ return this.sdk().then((s) => s.tickets.createTicket({ appId, body }));
773
+ }
774
+ updateTicket(appId, ticketId, body, _notifyRequestor, _notifyResponsible, _comments, _isPrivate) {
775
+ return this.sdk().then((s) => s.tickets.updateTicket({ appId, ticketId, body }));
776
+ }
777
+ addTicketComment(appId, ticketId, body, _isPrivate, _notifyRequestor, _notifyResponsible) {
778
+ return this.sdk().then((s) => s.tickets.addTicketComment({ appId, ticketId, body: { Body: body } }));
779
+ }
780
+ createKbArticle(appId, body) {
781
+ return this.sdk().then((s) => s.knowledgeBase.createArticle({ appId, body }));
782
+ }
783
+ updateKbArticle(appId, articleId, body) {
784
+ return this.sdk().then((s) => s.knowledgeBase.updateArticle({ appId, articleId, body }));
785
+ }
786
+ createProjectIssue(_projectId, body) {
787
+ return this.sdk().then((s) => s.projects.createIssue({ body }));
788
+ }
789
+ createProjectRisk(_projectId, body) {
790
+ return this.sdk().then((s) => s.projects.createRisk({ body }));
791
+ }
792
+ //
793
+ // Delete mutations (confirm:true required for all)
794
+ //
795
+ deleteAsset(appId, assetId) {
796
+ return this.sdk().then((s) => s.assets.deleteAsset({ appId, assetId, confirm: true }));
797
+ }
798
+ deleteConfigurationItem(appId, ciId) {
799
+ return this.sdk().then((s) => s.cmdb.deleteConfigurationItem({ appId, configurationItemId: ciId, confirm: true }));
800
+ }
801
+ deleteService(appId, serviceId) {
802
+ return this.sdk().then((s) => s.services.deleteService({ appId, serviceId, confirm: true }));
803
+ }
804
+ deleteServiceCategory(appId, categoryId) {
805
+ return this.sdk().then((s) => s.services.deleteServiceCategory({ appId, categoryId, confirm: true }));
806
+ }
807
+ deleteTimeEntry(timeEntryId) {
808
+ return this.sdk().then((s) => s.time.deleteTimeEntry({ timeEntryId, confirm: true }));
809
+ }
810
+ };
811
+ function createConfiguredTeamDynamixClient() {
812
+ return new UnifiedTeamDynamixClient(getTeamDynamixConfig());
813
+ }
814
+ function assertWriteToolsEnabled(config) {
815
+ if (!config.enableWriteTools) {
816
+ throw new Error("Write tools are disabled. Set TEAMDYNAMIX_ENABLE_WRITE_TOOLS=true in your environment.");
817
+ }
818
+ }
819
+ function assertDeleteToolsEnabled(config) {
820
+ if (!config.enableDeleteTools) {
821
+ throw new Error("Delete tools are disabled. Set TEAMDYNAMIX_ENABLE_DELETE_TOOLS=true in your environment.");
822
+ }
823
+ }
824
+
825
+ // src/services/teamdynamix/render.service.ts
826
+ import { tablemark } from "tablemark";
827
+ function render(payload, responseFormat, characterLimit = CHARACTER_LIMIT) {
828
+ if (responseFormat === "json") {
829
+ if (typeof payload === "undefined") return "undefined";
830
+ return JSON.stringify(payload, null, 2);
831
+ }
832
+ const markdown = renderMarkdown(payload);
833
+ return truncateMarkdown(markdown, characterLimit);
834
+ }
835
+ function renderMarkdown(payload) {
836
+ if (payload == null) return "";
837
+ if (typeof payload !== "object") {
838
+ return String(payload);
839
+ }
840
+ if (Array.isArray(payload)) {
841
+ if (payload.length === 0) {
842
+ return "";
843
+ }
844
+ if (payload.every(isPlainObject)) {
845
+ return renderArrayAsMarkdownTable(payload);
846
+ }
847
+ return "```json\n" + JSON.stringify(payload, null, 2) + "\n```";
848
+ }
849
+ if (isPlainObject(payload)) {
850
+ const hasArrayOfObjects = Object.values(payload).some(isArrayOfPlainObjects);
851
+ if (hasArrayOfObjects) {
852
+ return renderObjectWithTables(payload);
853
+ }
854
+ return renderObjectAsMarkdownList(payload);
855
+ }
856
+ return "";
857
+ }
858
+ function isPlainObject(value) {
859
+ return typeof value === "object" && value !== null && !Array.isArray(value);
860
+ }
861
+ function isArrayOfPlainObjects(value) {
862
+ return Array.isArray(value) && value.length > 0 && value.every(isPlainObject);
863
+ }
864
+ function serializeValue(value) {
865
+ if (typeof value !== "object" || value === null) return String(value);
866
+ if (Array.isArray(value)) return value.map(serializeValue).join(", ");
867
+ return "{ " + Object.entries(value).map(([k, v]) => `${k}: ${typeof v === "object" && v !== null ? "[Object]" : String(v)}`).join(", ") + " }";
868
+ }
869
+ function renderObjectAsMarkdownList(obj) {
870
+ const lines = [];
871
+ for (const [key, val] of Object.entries(obj)) {
872
+ lines.push(`- **${key}**: ${truncateCell(serializeValue(val))}`);
873
+ }
874
+ return lines.join("\n");
875
+ }
876
+ function renderObjectWithTables(obj) {
877
+ const lines = [];
878
+ const scalarEntries = [];
879
+ const arrayEntries = [];
880
+ for (const [key, val] of Object.entries(obj)) {
881
+ if (isArrayOfPlainObjects(val)) {
882
+ arrayEntries.push([key, val]);
883
+ } else {
884
+ scalarEntries.push([key, val]);
885
+ }
886
+ }
887
+ if (scalarEntries.length > 0) {
888
+ lines.push("**Metadata:**");
889
+ for (const [key, val] of scalarEntries) {
890
+ lines.push(`- **${key}**: ${truncateCell(serializeValue(val))}`);
891
+ }
892
+ lines.push("");
893
+ }
894
+ for (const [key, arr] of arrayEntries) {
895
+ lines.push(`**${key}:**`);
896
+ const table = renderArrayAsMarkdownTable(arr);
897
+ lines.push(table);
898
+ lines.push("");
899
+ }
900
+ return lines.join("\n");
901
+ }
902
+ function renderArrayAsMarkdownTable(arr) {
903
+ const toCellText = ({ value }) => serializeValue(value);
904
+ let table = tablemark(arr, {
905
+ toCellText,
906
+ headerCase: "preserve"
907
+ });
908
+ table = table.replace(/\| +/g, "| ").replace(/ +\|/g, " |");
909
+ table = table.replace(
910
+ /^(\| +:)(-+)( +\|)/gm,
911
+ (_match, _pre, _dashes, _post, offset, str) => {
912
+ if (str.slice(0, offset).includes(":---")) return _match;
913
+ const headerLine = str.slice(0, offset).split("\n").reverse().find((l) => l.startsWith("|"));
914
+ if (!headerLine) return _match;
915
+ const colCount = headerLine.split("|").length - 2;
916
+ const dashCounts = Array.from({ length: colCount }, (_, i) => 3 + i);
917
+ const newRow = [""].concat(dashCounts.map((n) => ` :${"-".repeat(n)} `)).concat([""]).join("|");
918
+ return newRow;
919
+ }
920
+ );
921
+ return table;
922
+ }
923
+ function truncateCell(str) {
924
+ const MAX = 120;
925
+ if (str.length <= MAX) return str;
926
+ return str.slice(0, MAX) + "\u2026";
927
+ }
928
+ function truncateMarkdown(markdown, limit) {
929
+ if (markdown.length <= limit) return markdown;
930
+ const ellipsis = "...";
931
+ if (limit <= ellipsis.length) return markdown.slice(0, limit);
932
+ const truncated = markdown.slice(0, limit - ellipsis.length).replace(/\n+$/, "");
933
+ return truncated + ellipsis;
934
+ }
935
+
936
+ // src/tools/teamdynamix.domain-gateways.tools.ts
937
+ var teamdynamixDiscoveryActionSchema = z4.enum([
938
+ "server_status",
939
+ "get_current_user",
940
+ "list_applications",
941
+ "list_ticket_statuses"
942
+ ]);
943
+ var teamdynamixTicketActionSchema = z4.enum([
944
+ "list_ticket_types",
945
+ "list_ticket_priorities",
946
+ "list_ticket_urgencies",
947
+ "list_ticket_impacts",
948
+ "list_ticket_sources",
949
+ "get_ticket",
950
+ "search_tickets",
951
+ "create_ticket",
952
+ "update_ticket",
953
+ "add_ticket_comment",
954
+ "get_ticket_feed"
955
+ ]);
956
+ var teamdynamixTicketRelationshipActionSchema = z4.enum([
957
+ "get_ticket_tasks",
958
+ "create_ticket_task",
959
+ "list_ticket_assets",
960
+ "add_ticket_asset",
961
+ "remove_ticket_asset",
962
+ "get_ticket_contacts",
963
+ "add_ticket_contact",
964
+ "remove_ticket_contact"
965
+ ]);
966
+ var teamdynamixPeopleActionSchema = z4.enum([
967
+ "get_user",
968
+ "search_users",
969
+ "get_group",
970
+ "search_groups",
971
+ "get_group_members"
972
+ ]);
973
+ var teamdynamixKnowledgeBaseActionSchema = z4.enum([
974
+ "get_kb_article",
975
+ "search_kb_articles",
976
+ "list_kb_categories",
977
+ "create_kb_article",
978
+ "update_kb_article"
979
+ ]);
980
+ var teamdynamixAssetsActionSchema = z4.enum([
981
+ "get_asset",
982
+ "search_assets",
983
+ "list_asset_statuses",
984
+ "list_product_models",
985
+ "delete_asset"
986
+ ]);
987
+ var teamdynamixCmdbActionSchema = z4.enum([
988
+ "get_ci",
989
+ "search_cis",
990
+ "list_ci_types",
991
+ "list_ci_relationship_types",
992
+ "list_vendors",
993
+ "delete_ci"
994
+ ]);
995
+ var teamdynamixServicesActionSchema = z4.enum([
996
+ "list_services",
997
+ "get_service",
998
+ "search_services",
999
+ "list_service_categories",
1000
+ "delete_service",
1001
+ "delete_service_category"
1002
+ ]);
1003
+ var teamdynamixProjectsActionSchema = z4.enum([
1004
+ "get_project",
1005
+ "search_projects",
1006
+ "list_project_types",
1007
+ "get_project_plans",
1008
+ "get_project_issues",
1009
+ "get_project_risks",
1010
+ "create_project_issue",
1011
+ "create_project_risk"
1012
+ ]);
1013
+ var teamdynamixTimeActionSchema = z4.enum(["list_time_types", "get_my_time_entries"]);
1014
+ var teamdynamixReferenceDataActionSchema = z4.enum([
1015
+ "list_accounts",
1016
+ "get_account",
1017
+ "list_locations",
1018
+ "list_functional_roles",
1019
+ "list_custom_attributes"
1020
+ ]);
1021
+ var gatewayPayloadSchema = z4.record(z4.string(), z4.unknown()).default({});
1022
+ function messageFromError(error) {
1023
+ return error instanceof Error ? error.message : String(error);
1024
+ }
1025
+ function toStructuredContent(payload) {
1026
+ if (typeof payload === "object" && payload !== null && !Array.isArray(payload)) {
1027
+ return payload;
1028
+ }
1029
+ return {
1030
+ data: payload
1031
+ };
1032
+ }
1033
+ function parsePayload(schema, payload, action) {
1034
+ const parsed = schema.safeParse(payload);
1035
+ if (!parsed.success) {
1036
+ const details = parsed.error.issues.map((issue) => `${issue.path.join(".") || "<root>"}: ${issue.message}`).join("; ");
1037
+ throw new Error(`Invalid payload for action "${action}": ${details}`);
1038
+ }
1039
+ return parsed.data;
1040
+ }
1041
+ function toSuccessResponse(payload, responseFormat) {
1042
+ return {
1043
+ content: [{ type: "text", text: render(payload, responseFormat) }],
1044
+ structuredContent: toStructuredContent(payload)
1045
+ };
1046
+ }
1047
+ function toErrorResponse(error) {
1048
+ const message = messageFromError(error);
1049
+ return {
1050
+ content: [{ type: "text", text: `Error: ${message}` }],
1051
+ structuredContent: {
1052
+ ok: false,
1053
+ kind: "unknown",
1054
+ message
1055
+ },
1056
+ isError: true
1057
+ };
1058
+ }
1059
+ var teamdynamixDiscoveryTool = `${TEAMDYNAMIX_TOOL_PREFIX}_discovery`;
1060
+ var teamdynamixTicketsTool = `${TEAMDYNAMIX_TOOL_PREFIX}_tickets`;
1061
+ var teamdynamixTicketRelationshipsTool = `${TEAMDYNAMIX_TOOL_PREFIX}_ticket_relationships`;
1062
+ var teamdynamixPeopleTool = `${TEAMDYNAMIX_TOOL_PREFIX}_people`;
1063
+ var teamdynamixKnowledgeBaseTool = `${TEAMDYNAMIX_TOOL_PREFIX}_knowledge_base`;
1064
+ var teamdynamixAssetsTool = `${TEAMDYNAMIX_TOOL_PREFIX}_assets`;
1065
+ var teamdynamixCmdbTool = `${TEAMDYNAMIX_TOOL_PREFIX}_cmdb`;
1066
+ var teamdynamixServicesTool = `${TEAMDYNAMIX_TOOL_PREFIX}_services`;
1067
+ var teamdynamixProjectsTool = `${TEAMDYNAMIX_TOOL_PREFIX}_projects`;
1068
+ var teamdynamixTimeTool = `${TEAMDYNAMIX_TOOL_PREFIX}_time`;
1069
+ var teamdynamixReferenceDataTool = `${TEAMDYNAMIX_TOOL_PREFIX}_reference_data`;
1070
+ var TEAMDYNAMIX_GATEWAY_SURFACE = {
1071
+ discovery: {
1072
+ tool: teamdynamixDiscoveryTool,
1073
+ actions: teamdynamixDiscoveryActionSchema.options
1074
+ },
1075
+ tickets: {
1076
+ tool: teamdynamixTicketsTool,
1077
+ actions: teamdynamixTicketActionSchema.options
1078
+ },
1079
+ ticketRelationships: {
1080
+ tool: teamdynamixTicketRelationshipsTool,
1081
+ actions: teamdynamixTicketRelationshipActionSchema.options
1082
+ },
1083
+ people: {
1084
+ tool: teamdynamixPeopleTool,
1085
+ actions: teamdynamixPeopleActionSchema.options
1086
+ },
1087
+ knowledgeBase: {
1088
+ tool: teamdynamixKnowledgeBaseTool,
1089
+ actions: teamdynamixKnowledgeBaseActionSchema.options
1090
+ },
1091
+ assets: {
1092
+ tool: teamdynamixAssetsTool,
1093
+ actions: teamdynamixAssetsActionSchema.options
1094
+ },
1095
+ cmdb: {
1096
+ tool: teamdynamixCmdbTool,
1097
+ actions: teamdynamixCmdbActionSchema.options
1098
+ },
1099
+ services: {
1100
+ tool: teamdynamixServicesTool,
1101
+ actions: teamdynamixServicesActionSchema.options
1102
+ },
1103
+ projects: {
1104
+ tool: teamdynamixProjectsTool,
1105
+ actions: teamdynamixProjectsActionSchema.options
1106
+ },
1107
+ time: {
1108
+ tool: teamdynamixTimeTool,
1109
+ actions: teamdynamixTimeActionSchema.options
1110
+ },
1111
+ referenceData: {
1112
+ tool: teamdynamixReferenceDataTool,
1113
+ actions: teamdynamixReferenceDataActionSchema.options
1114
+ }
1115
+ };
1116
+ function registerTeamDynamixDomainGatewayTools(server2) {
1117
+ registerTeamDynamixDiscoveryGateway(server2);
1118
+ registerTeamDynamixTicketsGateway(server2);
1119
+ registerTeamDynamixTicketRelationshipsGateway(server2);
1120
+ registerTeamDynamixPeopleGateway(server2);
1121
+ registerTeamDynamixKnowledgeBaseGateway(server2);
1122
+ registerTeamDynamixAssetsGateway(server2);
1123
+ registerTeamDynamixCmdbGateway(server2);
1124
+ registerTeamDynamixServicesGateway(server2);
1125
+ registerTeamDynamixProjectsGateway(server2);
1126
+ registerTeamDynamixTimeGateway(server2);
1127
+ registerTeamDynamixReferenceDataGateway(server2);
1128
+ }
1129
+ function registerTeamDynamixDiscoveryGateway(server2) {
1130
+ server2.registerTool(
1131
+ teamdynamixDiscoveryTool,
1132
+ {
1133
+ title: "TeamDynamix Discovery Gateway",
1134
+ description: "Gateway for discovery operations: server status, current user, applications, and ticket status lookup.",
1135
+ inputSchema: {
1136
+ action: teamdynamixDiscoveryActionSchema,
1137
+ payload: gatewayPayloadSchema,
1138
+ response_format: TeamDynamixResponseFormatSchema
1139
+ },
1140
+ annotations: { readOnlyHint: true, idempotentHint: false, destructiveHint: false, openWorldHint: true }
1141
+ },
1142
+ async ({ action, payload, response_format }) => {
1143
+ try {
1144
+ const client = createConfiguredTeamDynamixClient();
1145
+ switch (action) {
1146
+ case "server_status": {
1147
+ const config = getTeamDynamixConfig();
1148
+ const status = getTeamDynamixConfigStatus(config);
1149
+ const result = {
1150
+ status,
1151
+ config: redactTeamDynamixConfig(config),
1152
+ gateway: "discovery",
1153
+ actions: TEAMDYNAMIX_GATEWAY_SURFACE.discovery.actions
1154
+ };
1155
+ return toSuccessResponse(result, response_format);
1156
+ }
1157
+ case "get_current_user": {
1158
+ const user = await client.getCurrentUser();
1159
+ return toSuccessResponse(user, response_format);
1160
+ }
1161
+ case "list_applications": {
1162
+ const applications = await client.listApplications();
1163
+ return toSuccessResponse({ count: applications.length, applications }, response_format);
1164
+ }
1165
+ case "list_ticket_statuses": {
1166
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema.optional() }), payload, action);
1167
+ const config = getTeamDynamixConfig();
1168
+ const effectiveAppId = parsed.app_id ?? config.defaultTicketAppId;
1169
+ if (!effectiveAppId) {
1170
+ throw new Error(
1171
+ "No TeamDynamix ticket application ID was provided. Supply payload.app_id or configure TEAMDYNAMIX_DEFAULT_TICKET_APP_ID."
1172
+ );
1173
+ }
1174
+ const statuses = await client.listTicketStatuses(effectiveAppId);
1175
+ return toSuccessResponse({ appId: effectiveAppId, count: statuses.length, statuses }, response_format);
1176
+ }
1177
+ }
1178
+ } catch (error) {
1179
+ return toErrorResponse(error);
1180
+ }
1181
+ }
1182
+ );
1183
+ }
1184
+ function registerTeamDynamixTicketsGateway(server2) {
1185
+ server2.registerTool(
1186
+ teamdynamixTicketsTool,
1187
+ {
1188
+ title: "TeamDynamix Tickets Gateway",
1189
+ description: "Gateway for ticket metadata, read/search, create/update, comments, and feed operations.",
1190
+ inputSchema: {
1191
+ action: teamdynamixTicketActionSchema,
1192
+ payload: gatewayPayloadSchema,
1193
+ response_format: TeamDynamixResponseFormatSchema
1194
+ },
1195
+ annotations: { readOnlyHint: false, idempotentHint: false, destructiveHint: true, openWorldHint: true }
1196
+ },
1197
+ async ({ action, payload, response_format }) => {
1198
+ try {
1199
+ const client = createConfiguredTeamDynamixClient();
1200
+ switch (action) {
1201
+ case "list_ticket_types": {
1202
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
1203
+ const types = await client.listTicketTypes(parsed.app_id);
1204
+ return toSuccessResponse({ appId: parsed.app_id, types }, response_format);
1205
+ }
1206
+ case "list_ticket_priorities": {
1207
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
1208
+ const priorities = await client.listTicketPriorities(parsed.app_id);
1209
+ return toSuccessResponse({ appId: parsed.app_id, priorities }, response_format);
1210
+ }
1211
+ case "list_ticket_urgencies": {
1212
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
1213
+ const urgencies = await client.listTicketUrgencies(parsed.app_id);
1214
+ return toSuccessResponse({ appId: parsed.app_id, urgencies }, response_format);
1215
+ }
1216
+ case "list_ticket_impacts": {
1217
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
1218
+ const impacts = await client.listTicketImpacts(parsed.app_id);
1219
+ return toSuccessResponse({ appId: parsed.app_id, impacts }, response_format);
1220
+ }
1221
+ case "list_ticket_sources": {
1222
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
1223
+ const sources = await client.listTicketSources(parsed.app_id);
1224
+ return toSuccessResponse({ appId: parsed.app_id, sources }, response_format);
1225
+ }
1226
+ case "get_ticket": {
1227
+ const parsed = parsePayload(
1228
+ z4.object({ app_id: TeamDynamixAppIdSchema, ticket_id: z4.number().int().positive() }),
1229
+ payload,
1230
+ action
1231
+ );
1232
+ const ticket = await client.getTicket(parsed.app_id, parsed.ticket_id);
1233
+ return toSuccessResponse(ticket, response_format);
1234
+ }
1235
+ case "search_tickets": {
1236
+ const parsed = parsePayload(
1237
+ z4.object({ app_id: TeamDynamixAppIdSchema, search: TicketSearchSchema }),
1238
+ payload,
1239
+ action
1240
+ );
1241
+ const tickets = await client.searchTickets(parsed.app_id, parsed.search);
1242
+ return toSuccessResponse({ appId: parsed.app_id, count: tickets.length, tickets }, response_format);
1243
+ }
1244
+ case "create_ticket": {
1245
+ const parsed = parsePayload(
1246
+ z4.object({
1247
+ app_id: TeamDynamixAppIdSchema,
1248
+ ticket: TicketCreateSchema,
1249
+ notify_requestor: z4.boolean().optional().default(false),
1250
+ notify_responsible: z4.boolean().optional().default(false)
1251
+ }),
1252
+ payload,
1253
+ action
1254
+ );
1255
+ assertWriteToolsEnabled(getTeamDynamixConfig());
1256
+ const created = await client.createTicket(
1257
+ parsed.app_id,
1258
+ parsed.ticket,
1259
+ parsed.notify_requestor,
1260
+ parsed.notify_responsible
1261
+ );
1262
+ return toSuccessResponse(created, response_format);
1263
+ }
1264
+ case "update_ticket": {
1265
+ const parsed = parsePayload(
1266
+ z4.object({ app_id: TeamDynamixAppIdSchema, patch: TicketPatchSchema }),
1267
+ payload,
1268
+ action
1269
+ );
1270
+ assertWriteToolsEnabled(getTeamDynamixConfig());
1271
+ const updated = await client.updateTicket(
1272
+ parsed.app_id,
1273
+ parsed.patch.TicketID,
1274
+ parsed.patch.Attributes,
1275
+ parsed.patch.NotifyRequestor ?? false,
1276
+ parsed.patch.NotifyResponsible ?? false,
1277
+ parsed.patch.Comments ?? "",
1278
+ parsed.patch.IsPrivate ?? false
1279
+ );
1280
+ return toSuccessResponse(updated, response_format);
1281
+ }
1282
+ case "add_ticket_comment": {
1283
+ const parsed = parsePayload(
1284
+ z4.object({ app_id: TeamDynamixAppIdSchema, comment: TicketCommentSchema }),
1285
+ payload,
1286
+ action
1287
+ );
1288
+ assertWriteToolsEnabled(getTeamDynamixConfig());
1289
+ const entry = await client.addTicketComment(
1290
+ parsed.app_id,
1291
+ parsed.comment.TicketID,
1292
+ parsed.comment.Body,
1293
+ parsed.comment.IsPrivate ?? false,
1294
+ parsed.comment.NotifyRequestor ?? false,
1295
+ parsed.comment.NotifyResponsible ?? false
1296
+ );
1297
+ return toSuccessResponse(entry, response_format);
1298
+ }
1299
+ case "get_ticket_feed": {
1300
+ const parsed = parsePayload(
1301
+ z4.object({ app_id: TeamDynamixAppIdSchema, ticket_id: z4.number().int().positive() }),
1302
+ payload,
1303
+ action
1304
+ );
1305
+ const feed = await client.getTicketFeed(parsed.app_id, parsed.ticket_id);
1306
+ return toSuccessResponse(
1307
+ { appId: parsed.app_id, ticketId: parsed.ticket_id, entries: feed },
1308
+ response_format
1309
+ );
1310
+ }
1311
+ }
1312
+ } catch (error) {
1313
+ return toErrorResponse(error);
1314
+ }
1315
+ }
1316
+ );
1317
+ }
1318
+ function registerTeamDynamixTicketRelationshipsGateway(server2) {
1319
+ server2.registerTool(
1320
+ teamdynamixTicketRelationshipsTool,
1321
+ {
1322
+ title: "TeamDynamix Ticket Relationships Gateway",
1323
+ description: "Gateway for ticket tasks, linked assets, and linked contacts operations.",
1324
+ inputSchema: {
1325
+ action: teamdynamixTicketRelationshipActionSchema,
1326
+ payload: gatewayPayloadSchema,
1327
+ response_format: TeamDynamixResponseFormatSchema
1328
+ },
1329
+ annotations: { readOnlyHint: false, idempotentHint: false, destructiveHint: true, openWorldHint: true }
1330
+ },
1331
+ async ({ action, payload, response_format }) => {
1332
+ try {
1333
+ const client = createConfiguredTeamDynamixClient();
1334
+ switch (action) {
1335
+ case "get_ticket_tasks": {
1336
+ const parsed = parsePayload(
1337
+ z4.object({ app_id: TeamDynamixAppIdSchema, ticket_id: z4.number().int().positive() }),
1338
+ payload,
1339
+ action
1340
+ );
1341
+ const tasks = await client.getTicketTasks(parsed.app_id, parsed.ticket_id);
1342
+ return toSuccessResponse(
1343
+ { appId: parsed.app_id, ticketId: parsed.ticket_id, count: tasks.length, tasks },
1344
+ response_format
1345
+ );
1346
+ }
1347
+ case "create_ticket_task": {
1348
+ const parsed = parsePayload(
1349
+ z4.object({ app_id: TeamDynamixAppIdSchema, task: TicketTaskCreateSchema }),
1350
+ payload,
1351
+ action
1352
+ );
1353
+ assertWriteToolsEnabled(getTeamDynamixConfig());
1354
+ const created = await client.createTicketTask(
1355
+ parsed.app_id,
1356
+ parsed.task.TicketID,
1357
+ parsed.task
1358
+ );
1359
+ return toSuccessResponse(created, response_format);
1360
+ }
1361
+ case "list_ticket_assets": {
1362
+ const parsed = parsePayload(
1363
+ z4.object({ app_id: TeamDynamixAppIdSchema, ticket_id: z4.number().int().positive() }),
1364
+ payload,
1365
+ action
1366
+ );
1367
+ const assets = await client.listTicketAssets(parsed.app_id, parsed.ticket_id);
1368
+ return toSuccessResponse(
1369
+ { appId: parsed.app_id, ticketId: parsed.ticket_id, count: assets.length, assets },
1370
+ response_format
1371
+ );
1372
+ }
1373
+ case "add_ticket_asset": {
1374
+ const parsed = parsePayload(
1375
+ z4.object({
1376
+ app_id: TeamDynamixAppIdSchema,
1377
+ ticket_id: z4.number().int().positive(),
1378
+ asset_id: z4.number().int().positive()
1379
+ }),
1380
+ payload,
1381
+ action
1382
+ );
1383
+ assertWriteToolsEnabled(getTeamDynamixConfig());
1384
+ const result = await client.addTicketAsset(parsed.app_id, parsed.ticket_id, parsed.asset_id);
1385
+ return toSuccessResponse(result, response_format);
1386
+ }
1387
+ case "remove_ticket_asset": {
1388
+ const parsed = parsePayload(
1389
+ z4.object({
1390
+ app_id: TeamDynamixAppIdSchema,
1391
+ ticket_id: z4.number().int().positive(),
1392
+ asset_id: z4.number().int().positive(),
1393
+ confirm: z4.literal(true)
1394
+ }),
1395
+ payload,
1396
+ action
1397
+ );
1398
+ assertWriteToolsEnabled(getTeamDynamixConfig());
1399
+ await client.removeTicketAsset(parsed.app_id, parsed.ticket_id, parsed.asset_id);
1400
+ return toSuccessResponse(
1401
+ {
1402
+ appId: parsed.app_id,
1403
+ ticketId: parsed.ticket_id,
1404
+ assetId: parsed.asset_id,
1405
+ unlinked: true
1406
+ },
1407
+ response_format
1408
+ );
1409
+ }
1410
+ case "get_ticket_contacts": {
1411
+ const parsed = parsePayload(
1412
+ z4.object({ app_id: TeamDynamixAppIdSchema, ticket_id: z4.number().int().positive() }),
1413
+ payload,
1414
+ action
1415
+ );
1416
+ const contacts = await client.getTicketContacts(parsed.app_id, parsed.ticket_id);
1417
+ return toSuccessResponse(
1418
+ { appId: parsed.app_id, ticketId: parsed.ticket_id, count: contacts.length, contacts },
1419
+ response_format
1420
+ );
1421
+ }
1422
+ case "add_ticket_contact": {
1423
+ const parsed = parsePayload(
1424
+ z4.object({
1425
+ app_id: TeamDynamixAppIdSchema,
1426
+ ticket_id: z4.number().int().positive(),
1427
+ contact_uid: TeamDynamixGuidSchema
1428
+ }),
1429
+ payload,
1430
+ action
1431
+ );
1432
+ assertWriteToolsEnabled(getTeamDynamixConfig());
1433
+ const result = await client.addTicketContact(parsed.app_id, parsed.ticket_id, parsed.contact_uid);
1434
+ return toSuccessResponse(result, response_format);
1435
+ }
1436
+ case "remove_ticket_contact": {
1437
+ const parsed = parsePayload(
1438
+ z4.object({
1439
+ app_id: TeamDynamixAppIdSchema,
1440
+ ticket_id: z4.number().int().positive(),
1441
+ contact_uid: TeamDynamixGuidSchema,
1442
+ confirm: z4.literal(true)
1443
+ }),
1444
+ payload,
1445
+ action
1446
+ );
1447
+ assertWriteToolsEnabled(getTeamDynamixConfig());
1448
+ await client.removeTicketContact(parsed.app_id, parsed.ticket_id, parsed.contact_uid);
1449
+ return toSuccessResponse(
1450
+ {
1451
+ appId: parsed.app_id,
1452
+ ticketId: parsed.ticket_id,
1453
+ contactUid: parsed.contact_uid,
1454
+ removed: true
1455
+ },
1456
+ response_format
1457
+ );
1458
+ }
1459
+ }
1460
+ } catch (error) {
1461
+ return toErrorResponse(error);
1462
+ }
1463
+ }
1464
+ );
1465
+ }
1466
+ function registerTeamDynamixPeopleGateway(server2) {
1467
+ server2.registerTool(
1468
+ teamdynamixPeopleTool,
1469
+ {
1470
+ title: "TeamDynamix People Gateway",
1471
+ description: "Gateway for user and group retrieval/search operations.",
1472
+ inputSchema: {
1473
+ action: teamdynamixPeopleActionSchema,
1474
+ payload: gatewayPayloadSchema,
1475
+ response_format: TeamDynamixResponseFormatSchema
1476
+ },
1477
+ annotations: { readOnlyHint: true, idempotentHint: false, destructiveHint: false, openWorldHint: true }
1478
+ },
1479
+ async ({ action, payload, response_format }) => {
1480
+ try {
1481
+ const client = createConfiguredTeamDynamixClient();
1482
+ switch (action) {
1483
+ case "get_user": {
1484
+ const parsed = parsePayload(z4.object({ uid: TeamDynamixGuidSchema }), payload, action);
1485
+ const user = await client.getUser(parsed.uid);
1486
+ return toSuccessResponse(user, response_format);
1487
+ }
1488
+ case "search_users": {
1489
+ const parsed = parsePayload(z4.object({ search: UserSearchSchema }), payload, action);
1490
+ const users = await client.searchUsers(parsed.search);
1491
+ return toSuccessResponse({ count: users.length, users }, response_format);
1492
+ }
1493
+ case "get_group": {
1494
+ const parsed = parsePayload(z4.object({ group_id: z4.number().int().positive() }), payload, action);
1495
+ const group = await client.getGroup(parsed.group_id);
1496
+ return toSuccessResponse(group, response_format);
1497
+ }
1498
+ case "search_groups": {
1499
+ const parsed = parsePayload(z4.object({ search: GroupSearchSchema }), payload, action);
1500
+ const groups = await client.searchGroups(parsed.search);
1501
+ return toSuccessResponse({ count: groups.length, groups }, response_format);
1502
+ }
1503
+ case "get_group_members": {
1504
+ const parsed = parsePayload(z4.object({ group_id: z4.number().int().positive() }), payload, action);
1505
+ const members = await client.getGroupMembers(parsed.group_id);
1506
+ return toSuccessResponse({ groupId: parsed.group_id, count: members.length, members }, response_format);
1507
+ }
1508
+ }
1509
+ } catch (error) {
1510
+ return toErrorResponse(error);
1511
+ }
1512
+ }
1513
+ );
1514
+ }
1515
+ function registerTeamDynamixKnowledgeBaseGateway(server2) {
1516
+ server2.registerTool(
1517
+ teamdynamixKnowledgeBaseTool,
1518
+ {
1519
+ title: "TeamDynamix Knowledge Base Gateway",
1520
+ description: "Gateway for TeamDynamix Knowledge Base retrieval, search, and write operations.",
1521
+ inputSchema: {
1522
+ action: teamdynamixKnowledgeBaseActionSchema,
1523
+ payload: gatewayPayloadSchema,
1524
+ response_format: TeamDynamixResponseFormatSchema
1525
+ },
1526
+ annotations: { readOnlyHint: false, idempotentHint: false, destructiveHint: true, openWorldHint: true }
1527
+ },
1528
+ async ({ action, payload, response_format }) => {
1529
+ try {
1530
+ const client = createConfiguredTeamDynamixClient();
1531
+ switch (action) {
1532
+ case "get_kb_article": {
1533
+ const parsed = parsePayload(
1534
+ z4.object({ app_id: TeamDynamixAppIdSchema, article_id: z4.number().int().positive() }),
1535
+ payload,
1536
+ action
1537
+ );
1538
+ const article = await client.getKbArticle(parsed.app_id, parsed.article_id);
1539
+ return toSuccessResponse(article, response_format);
1540
+ }
1541
+ case "search_kb_articles": {
1542
+ const parsed = parsePayload(
1543
+ z4.object({ app_id: TeamDynamixAppIdSchema, search: KbArticleSearchSchema }),
1544
+ payload,
1545
+ action
1546
+ );
1547
+ const articles = await client.searchKbArticles(parsed.app_id, parsed.search);
1548
+ return toSuccessResponse({ appId: parsed.app_id, count: articles.length, articles }, response_format);
1549
+ }
1550
+ case "list_kb_categories": {
1551
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
1552
+ const categories = await client.listKbCategories(parsed.app_id);
1553
+ return toSuccessResponse({ appId: parsed.app_id, count: categories.length, categories }, response_format);
1554
+ }
1555
+ case "create_kb_article": {
1556
+ const parsed = parsePayload(
1557
+ z4.object({ app_id: TeamDynamixAppIdSchema, article: KbArticleCreateSchema }),
1558
+ payload,
1559
+ action
1560
+ );
1561
+ assertWriteToolsEnabled(getTeamDynamixConfig());
1562
+ const created = await client.createKbArticle(parsed.app_id, parsed.article);
1563
+ return toSuccessResponse(created, response_format);
1564
+ }
1565
+ case "update_kb_article": {
1566
+ const parsed = parsePayload(
1567
+ z4.object({ app_id: TeamDynamixAppIdSchema, article: KbArticleUpdateSchema }),
1568
+ payload,
1569
+ action
1570
+ );
1571
+ assertWriteToolsEnabled(getTeamDynamixConfig());
1572
+ const { ArticleID, ...body } = parsed.article;
1573
+ const updated = await client.updateKbArticle(parsed.app_id, ArticleID, body);
1574
+ return toSuccessResponse(updated, response_format);
1575
+ }
1576
+ }
1577
+ } catch (error) {
1578
+ return toErrorResponse(error);
1579
+ }
1580
+ }
1581
+ );
1582
+ }
1583
+ function registerTeamDynamixAssetsGateway(server2) {
1584
+ server2.registerTool(
1585
+ teamdynamixAssetsTool,
1586
+ {
1587
+ title: "TeamDynamix Assets Gateway",
1588
+ description: "Gateway for TeamDynamix asset retrieval, search, and lookup enumerations.",
1589
+ inputSchema: {
1590
+ action: teamdynamixAssetsActionSchema,
1591
+ payload: gatewayPayloadSchema,
1592
+ response_format: TeamDynamixResponseFormatSchema
1593
+ },
1594
+ annotations: { readOnlyHint: true, idempotentHint: false, destructiveHint: false, openWorldHint: true }
1595
+ },
1596
+ async ({ action, payload, response_format }) => {
1597
+ try {
1598
+ const client = createConfiguredTeamDynamixClient();
1599
+ switch (action) {
1600
+ case "get_asset": {
1601
+ const parsed = parsePayload(
1602
+ z4.object({ app_id: TeamDynamixAppIdSchema, asset_id: z4.number().int().positive() }),
1603
+ payload,
1604
+ action
1605
+ );
1606
+ const asset = await client.getAsset(parsed.app_id, parsed.asset_id);
1607
+ return toSuccessResponse(asset, response_format);
1608
+ }
1609
+ case "search_assets": {
1610
+ const parsed = parsePayload(
1611
+ z4.object({ app_id: TeamDynamixAppIdSchema, search: AssetSearchSchema }),
1612
+ payload,
1613
+ action
1614
+ );
1615
+ const assets = await client.searchAssets(parsed.app_id, parsed.search);
1616
+ return toSuccessResponse({ appId: parsed.app_id, count: assets.length, assets }, response_format);
1617
+ }
1618
+ case "list_asset_statuses": {
1619
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
1620
+ const statuses = await client.listAssetStatuses(parsed.app_id);
1621
+ return toSuccessResponse({ appId: parsed.app_id, count: statuses.length, statuses }, response_format);
1622
+ }
1623
+ case "list_product_models": {
1624
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
1625
+ const models = await client.listProductModels(parsed.app_id);
1626
+ return toSuccessResponse({ appId: parsed.app_id, count: models.length, models }, response_format);
1627
+ }
1628
+ case "delete_asset": {
1629
+ const parsed = parsePayload(
1630
+ z4.object({
1631
+ app_id: TeamDynamixAppIdSchema,
1632
+ asset_id: z4.number().int().positive(),
1633
+ confirm: z4.literal(true)
1634
+ }),
1635
+ payload,
1636
+ action
1637
+ );
1638
+ assertDeleteToolsEnabled(getTeamDynamixConfig());
1639
+ await client.deleteAsset(parsed.app_id, parsed.asset_id);
1640
+ return toSuccessResponse(
1641
+ { appId: parsed.app_id, assetId: parsed.asset_id, deleted: true },
1642
+ response_format
1643
+ );
1644
+ }
1645
+ }
1646
+ } catch (error) {
1647
+ return toErrorResponse(error);
1648
+ }
1649
+ }
1650
+ );
1651
+ }
1652
+ function registerTeamDynamixCmdbGateway(server2) {
1653
+ server2.registerTool(
1654
+ teamdynamixCmdbTool,
1655
+ {
1656
+ title: "TeamDynamix CMDB Gateway",
1657
+ description: "Gateway for CI/CMDB retrieval, search, types, relationship types, and vendors.",
1658
+ inputSchema: {
1659
+ action: teamdynamixCmdbActionSchema,
1660
+ payload: gatewayPayloadSchema,
1661
+ response_format: TeamDynamixResponseFormatSchema
1662
+ },
1663
+ annotations: { readOnlyHint: true, idempotentHint: false, destructiveHint: false, openWorldHint: true }
1664
+ },
1665
+ async ({ action, payload, response_format }) => {
1666
+ try {
1667
+ const client = createConfiguredTeamDynamixClient();
1668
+ switch (action) {
1669
+ case "get_ci": {
1670
+ const parsed = parsePayload(
1671
+ z4.object({ app_id: TeamDynamixAppIdSchema, ci_id: z4.number().int().positive() }),
1672
+ payload,
1673
+ action
1674
+ );
1675
+ const ci = await client.getConfigurationItem(parsed.app_id, parsed.ci_id);
1676
+ return toSuccessResponse(ci, response_format);
1677
+ }
1678
+ case "search_cis": {
1679
+ const parsed = parsePayload(
1680
+ z4.object({ app_id: TeamDynamixAppIdSchema, search: CiSearchSchema }),
1681
+ payload,
1682
+ action
1683
+ );
1684
+ const results = await client.searchConfigurationItems(
1685
+ parsed.app_id,
1686
+ parsed.search
1687
+ );
1688
+ return toSuccessResponse({ appId: parsed.app_id, count: results.length, results }, response_format);
1689
+ }
1690
+ case "list_ci_types": {
1691
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
1692
+ const types = await client.listCiTypes(parsed.app_id);
1693
+ return toSuccessResponse({ appId: parsed.app_id, count: types.length, types }, response_format);
1694
+ }
1695
+ case "list_ci_relationship_types": {
1696
+ const types = await client.listCiRelationshipTypes();
1697
+ return toSuccessResponse({ count: types.length, types }, response_format);
1698
+ }
1699
+ case "list_vendors": {
1700
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
1701
+ const vendors = await client.listVendors(parsed.app_id);
1702
+ return toSuccessResponse({ appId: parsed.app_id, count: vendors.length, vendors }, response_format);
1703
+ }
1704
+ case "delete_ci": {
1705
+ const parsed = parsePayload(
1706
+ z4.object({
1707
+ app_id: TeamDynamixAppIdSchema,
1708
+ ci_id: z4.number().int().positive(),
1709
+ confirm: z4.literal(true)
1710
+ }),
1711
+ payload,
1712
+ action
1713
+ );
1714
+ assertDeleteToolsEnabled(getTeamDynamixConfig());
1715
+ await client.deleteConfigurationItem(parsed.app_id, parsed.ci_id);
1716
+ return toSuccessResponse({ appId: parsed.app_id, ciId: parsed.ci_id, deleted: true }, response_format);
1717
+ }
1718
+ }
1719
+ } catch (error) {
1720
+ return toErrorResponse(error);
1721
+ }
1722
+ }
1723
+ );
1724
+ }
1725
+ function registerTeamDynamixServicesGateway(server2) {
1726
+ server2.registerTool(
1727
+ teamdynamixServicesTool,
1728
+ {
1729
+ title: "TeamDynamix Services Gateway",
1730
+ description: "Gateway for TeamDynamix service catalog list/get/search/category operations.",
1731
+ inputSchema: {
1732
+ action: teamdynamixServicesActionSchema,
1733
+ payload: gatewayPayloadSchema,
1734
+ response_format: TeamDynamixResponseFormatSchema
1735
+ },
1736
+ annotations: { readOnlyHint: true, idempotentHint: false, destructiveHint: false, openWorldHint: true }
1737
+ },
1738
+ async ({ action, payload, response_format }) => {
1739
+ try {
1740
+ const client = createConfiguredTeamDynamixClient();
1741
+ switch (action) {
1742
+ case "list_services": {
1743
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
1744
+ const services = await client.listServiceCatalog(parsed.app_id);
1745
+ return toSuccessResponse({ appId: parsed.app_id, count: services.length, services }, response_format);
1746
+ }
1747
+ case "get_service": {
1748
+ const parsed = parsePayload(
1749
+ z4.object({ app_id: TeamDynamixAppIdSchema, service_id: z4.number().int().positive() }),
1750
+ payload,
1751
+ action
1752
+ );
1753
+ const service = await client.getService(parsed.app_id, parsed.service_id);
1754
+ return toSuccessResponse(service, response_format);
1755
+ }
1756
+ case "search_services": {
1757
+ const parsed = parsePayload(
1758
+ z4.object({ app_id: TeamDynamixAppIdSchema, search: ServiceSearchSchema }),
1759
+ payload,
1760
+ action
1761
+ );
1762
+ const services = await client.searchServices(parsed.app_id, parsed.search);
1763
+ return toSuccessResponse({ appId: parsed.app_id, count: services.length, services }, response_format);
1764
+ }
1765
+ case "list_service_categories": {
1766
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
1767
+ const categories = await client.listServiceCategories(parsed.app_id);
1768
+ return toSuccessResponse({ appId: parsed.app_id, count: categories.length, categories }, response_format);
1769
+ }
1770
+ case "delete_service": {
1771
+ const parsed = parsePayload(
1772
+ z4.object({
1773
+ app_id: TeamDynamixAppIdSchema,
1774
+ service_id: z4.number().int().positive(),
1775
+ confirm: z4.literal(true)
1776
+ }),
1777
+ payload,
1778
+ action
1779
+ );
1780
+ assertDeleteToolsEnabled(getTeamDynamixConfig());
1781
+ await client.deleteService(parsed.app_id, parsed.service_id);
1782
+ return toSuccessResponse(
1783
+ { appId: parsed.app_id, serviceId: parsed.service_id, deleted: true },
1784
+ response_format
1785
+ );
1786
+ }
1787
+ case "delete_service_category": {
1788
+ const parsed = parsePayload(
1789
+ z4.object({
1790
+ app_id: TeamDynamixAppIdSchema,
1791
+ category_id: z4.number().int().positive(),
1792
+ confirm: z4.literal(true)
1793
+ }),
1794
+ payload,
1795
+ action
1796
+ );
1797
+ assertDeleteToolsEnabled(getTeamDynamixConfig());
1798
+ await client.deleteServiceCategory(parsed.app_id, parsed.category_id);
1799
+ return toSuccessResponse(
1800
+ { appId: parsed.app_id, categoryId: parsed.category_id, deleted: true },
1801
+ response_format
1802
+ );
1803
+ }
1804
+ }
1805
+ } catch (error) {
1806
+ return toErrorResponse(error);
1807
+ }
1808
+ }
1809
+ );
1810
+ }
1811
+ function registerTeamDynamixProjectsGateway(server2) {
1812
+ server2.registerTool(
1813
+ teamdynamixProjectsTool,
1814
+ {
1815
+ title: "TeamDynamix Projects Gateway",
1816
+ description: "Gateway for TeamDynamix projects retrieval/search and project issue/risk operations.",
1817
+ inputSchema: {
1818
+ action: teamdynamixProjectsActionSchema,
1819
+ payload: gatewayPayloadSchema,
1820
+ response_format: TeamDynamixResponseFormatSchema
1821
+ },
1822
+ annotations: { readOnlyHint: false, idempotentHint: false, destructiveHint: true, openWorldHint: true }
1823
+ },
1824
+ async ({ action, payload, response_format }) => {
1825
+ try {
1826
+ const client = createConfiguredTeamDynamixClient();
1827
+ switch (action) {
1828
+ case "get_project": {
1829
+ const parsed = parsePayload(z4.object({ project_id: z4.number().int().positive() }), payload, action);
1830
+ const project = await client.getProject(parsed.project_id);
1831
+ return toSuccessResponse(project, response_format);
1832
+ }
1833
+ case "search_projects": {
1834
+ const parsed = parsePayload(z4.object({ search: ProjectSearchSchema }), payload, action);
1835
+ const projects = await client.searchProjects(parsed.search);
1836
+ return toSuccessResponse({ count: projects.length, projects }, response_format);
1837
+ }
1838
+ case "list_project_types": {
1839
+ const types = await client.listProjectTypes();
1840
+ return toSuccessResponse({ count: types.length, types }, response_format);
1841
+ }
1842
+ case "get_project_plans": {
1843
+ const parsed = parsePayload(z4.object({ project_id: z4.number().int().positive() }), payload, action);
1844
+ const plans = await client.getProjectPlans(parsed.project_id);
1845
+ return toSuccessResponse({ projectId: parsed.project_id, count: plans.length, plans }, response_format);
1846
+ }
1847
+ case "get_project_issues": {
1848
+ const parsed = parsePayload(z4.object({ project_id: z4.number().int().positive() }), payload, action);
1849
+ const issues = await client.getProjectIssues(parsed.project_id);
1850
+ return toSuccessResponse({ projectId: parsed.project_id, count: issues.length, issues }, response_format);
1851
+ }
1852
+ case "get_project_risks": {
1853
+ const parsed = parsePayload(z4.object({ project_id: z4.number().int().positive() }), payload, action);
1854
+ const risks = await client.getProjectRisks(parsed.project_id);
1855
+ return toSuccessResponse({ projectId: parsed.project_id, count: risks.length, risks }, response_format);
1856
+ }
1857
+ case "create_project_issue": {
1858
+ const parsed = parsePayload(
1859
+ z4.object({ project_id: z4.number().int().positive(), issue: ProjectIssueCreateSchema }),
1860
+ payload,
1861
+ action
1862
+ );
1863
+ assertWriteToolsEnabled(getTeamDynamixConfig());
1864
+ const created = await client.createProjectIssue(parsed.project_id, parsed.issue);
1865
+ return toSuccessResponse(created, response_format);
1866
+ }
1867
+ case "create_project_risk": {
1868
+ const parsed = parsePayload(
1869
+ z4.object({ project_id: z4.number().int().positive(), risk: ProjectRiskCreateSchema }),
1870
+ payload,
1871
+ action
1872
+ );
1873
+ assertWriteToolsEnabled(getTeamDynamixConfig());
1874
+ const created = await client.createProjectRisk(parsed.project_id, parsed.risk);
1875
+ return toSuccessResponse(created, response_format);
1876
+ }
1877
+ }
1878
+ } catch (error) {
1879
+ return toErrorResponse(error);
1880
+ }
1881
+ }
1882
+ );
1883
+ }
1884
+ function registerTeamDynamixTimeGateway(server2) {
1885
+ server2.registerTool(
1886
+ teamdynamixTimeTool,
1887
+ {
1888
+ title: "TeamDynamix Time Gateway",
1889
+ description: "Gateway for TeamDynamix time type lookup and authenticated user time entries.",
1890
+ inputSchema: {
1891
+ action: teamdynamixTimeActionSchema,
1892
+ payload: gatewayPayloadSchema,
1893
+ response_format: TeamDynamixResponseFormatSchema
1894
+ },
1895
+ annotations: { readOnlyHint: true, idempotentHint: false, destructiveHint: false, openWorldHint: true }
1896
+ },
1897
+ async ({ action, payload, response_format }) => {
1898
+ try {
1899
+ const client = createConfiguredTeamDynamixClient();
1900
+ switch (action) {
1901
+ case "list_time_types": {
1902
+ const types = await client.listTimeTypes();
1903
+ return toSuccessResponse({ count: types.length, types }, response_format);
1904
+ }
1905
+ case "get_my_time_entries": {
1906
+ const parsed = parsePayload(z4.object({ query: TimeEntryQuerySchema }), payload, action);
1907
+ const entries = await client.getMyTimeEntries(parsed.query.StartDate, parsed.query.EndDate);
1908
+ return toSuccessResponse({ count: entries.length, entries }, response_format);
1909
+ }
1910
+ }
1911
+ } catch (error) {
1912
+ return toErrorResponse(error);
1913
+ }
1914
+ }
1915
+ );
1916
+ }
1917
+ function registerTeamDynamixReferenceDataGateway(server2) {
1918
+ server2.registerTool(
1919
+ teamdynamixReferenceDataTool,
1920
+ {
1921
+ title: "TeamDynamix Reference Data Gateway",
1922
+ description: "Gateway for TeamDynamix reference/enumeration lookups such as accounts, locations, roles, and custom attributes.",
1923
+ inputSchema: {
1924
+ action: teamdynamixReferenceDataActionSchema,
1925
+ payload: gatewayPayloadSchema,
1926
+ response_format: TeamDynamixResponseFormatSchema
1927
+ },
1928
+ annotations: { readOnlyHint: true, idempotentHint: false, destructiveHint: false, openWorldHint: true }
1929
+ },
1930
+ async ({ action, payload, response_format }) => {
1931
+ try {
1932
+ const client = createConfiguredTeamDynamixClient();
1933
+ switch (action) {
1934
+ case "list_accounts": {
1935
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema.optional() }), payload, action);
1936
+ const accounts = await client.listAccounts(parsed.app_id);
1937
+ return toSuccessResponse({ count: accounts.length, accounts }, response_format);
1938
+ }
1939
+ case "get_account": {
1940
+ const parsed = parsePayload(z4.object({ account_id: z4.number().int().positive() }), payload, action);
1941
+ const account = await client.getAccount(parsed.account_id);
1942
+ return toSuccessResponse(account, response_format);
1943
+ }
1944
+ case "list_locations": {
1945
+ const locations = await client.listLocations();
1946
+ return toSuccessResponse({ count: locations.length, locations }, response_format);
1947
+ }
1948
+ case "list_functional_roles": {
1949
+ const roles = await client.listFunctionalRoles();
1950
+ return toSuccessResponse({ count: roles.length, roles }, response_format);
1951
+ }
1952
+ case "list_custom_attributes": {
1953
+ const parsed = parsePayload(
1954
+ z4.object({
1955
+ component_id: CustomAttributeComponentIdSchema,
1956
+ app_id: TeamDynamixAppIdSchema.optional(),
1957
+ associated_type_id: z4.number().int().positive().optional()
1958
+ }),
1959
+ payload,
1960
+ action
1961
+ );
1962
+ const attributes = await client.listCustomAttributes(
1963
+ parsed.component_id,
1964
+ parsed.app_id,
1965
+ parsed.associated_type_id
1966
+ );
1967
+ return toSuccessResponse(
1968
+ { componentId: parsed.component_id, count: attributes.length, attributes },
1969
+ response_format
1970
+ );
1971
+ }
1972
+ }
1973
+ } catch (error) {
1974
+ return toErrorResponse(error);
1975
+ }
1976
+ }
1977
+ );
1978
+ }
1979
+
1980
+ // src/resources/teamdynamix.resources.ts
1981
+ function stringify(data) {
1982
+ return JSON.stringify(data, null, 2);
1983
+ }
1984
+ function registerTeamDynamixResources(server2) {
1985
+ const resourceConfig = { list: void 0 };
1986
+ server2.registerResource(
1987
+ "teamdynamix_capabilities",
1988
+ new ResourceTemplate("teamdynamix://capabilities", resourceConfig),
1989
+ {
1990
+ title: "TeamDynamix Capabilities",
1991
+ description: "Read-only snapshot of the currently implemented TeamDynamix MCP surface.",
1992
+ mimeType: "application/json"
1993
+ },
1994
+ async (uri) => {
1995
+ const capabilities = {
1996
+ toolGroups: {
1997
+ discovery: [TEAMDYNAMIX_GATEWAY_SURFACE.discovery.tool],
1998
+ tickets: [TEAMDYNAMIX_GATEWAY_SURFACE.tickets.tool],
1999
+ ticket_relationships: [TEAMDYNAMIX_GATEWAY_SURFACE.ticketRelationships.tool],
2000
+ people: [TEAMDYNAMIX_GATEWAY_SURFACE.people.tool],
2001
+ knowledge_base: [TEAMDYNAMIX_GATEWAY_SURFACE.knowledgeBase.tool],
2002
+ assets: [TEAMDYNAMIX_GATEWAY_SURFACE.assets.tool],
2003
+ cmdb: [TEAMDYNAMIX_GATEWAY_SURFACE.cmdb.tool],
2004
+ services: [TEAMDYNAMIX_GATEWAY_SURFACE.services.tool],
2005
+ projects: [TEAMDYNAMIX_GATEWAY_SURFACE.projects.tool],
2006
+ time: [TEAMDYNAMIX_GATEWAY_SURFACE.time.tool],
2007
+ reference_data: [TEAMDYNAMIX_GATEWAY_SURFACE.referenceData.tool]
2008
+ },
2009
+ gatewayActions: {
2010
+ discovery: TEAMDYNAMIX_GATEWAY_SURFACE.discovery.actions,
2011
+ tickets: TEAMDYNAMIX_GATEWAY_SURFACE.tickets.actions,
2012
+ ticket_relationships: TEAMDYNAMIX_GATEWAY_SURFACE.ticketRelationships.actions,
2013
+ people: TEAMDYNAMIX_GATEWAY_SURFACE.people.actions,
2014
+ knowledge_base: TEAMDYNAMIX_GATEWAY_SURFACE.knowledgeBase.actions,
2015
+ assets: TEAMDYNAMIX_GATEWAY_SURFACE.assets.actions,
2016
+ cmdb: TEAMDYNAMIX_GATEWAY_SURFACE.cmdb.actions,
2017
+ services: TEAMDYNAMIX_GATEWAY_SURFACE.services.actions,
2018
+ projects: TEAMDYNAMIX_GATEWAY_SURFACE.projects.actions,
2019
+ time: TEAMDYNAMIX_GATEWAY_SURFACE.time.actions,
2020
+ reference_data: TEAMDYNAMIX_GATEWAY_SURFACE.referenceData.actions
2021
+ },
2022
+ implementedDomains: [
2023
+ "discovery",
2024
+ "tickets",
2025
+ "ticket_relationships",
2026
+ "people",
2027
+ "knowledge_base",
2028
+ "assets",
2029
+ "cmdb",
2030
+ "services",
2031
+ "projects",
2032
+ "time",
2033
+ "reference_data"
2034
+ ]
2035
+ };
2036
+ return {
2037
+ contents: [{ uri: uri.toString(), mimeType: "application/json", text: stringify(capabilities) }]
2038
+ };
2039
+ }
2040
+ );
2041
+ server2.registerResource(
2042
+ "teamdynamix_config",
2043
+ new ResourceTemplate("teamdynamix://config", resourceConfig),
2044
+ {
2045
+ title: "TeamDynamix Runtime Config",
2046
+ description: "Read-only sanitized TeamDynamix configuration and readiness metadata.",
2047
+ mimeType: "application/json"
2048
+ },
2049
+ async (uri) => {
2050
+ const runtimeConfig = getTeamDynamixConfig();
2051
+ const config = {
2052
+ status: getTeamDynamixConfigStatus(runtimeConfig),
2053
+ config: redactTeamDynamixConfig(runtimeConfig)
2054
+ };
2055
+ return {
2056
+ contents: [{ uri: uri.toString(), mimeType: "application/json", text: stringify(config) }]
2057
+ };
2058
+ }
2059
+ );
2060
+ }
2061
+
2062
+ // src/index.ts
2063
+ var server = new McpServer2({
2064
+ name: SERVER_NAME_OVERRIDE ?? SERVER_NAME,
2065
+ version: SERVER_VERSION_OVERRIDE ?? SERVER_VERSION
2066
+ });
2067
+ registerTeamDynamixDomainGatewayTools(server);
2068
+ registerTeamDynamixResources(server);
2069
+ async function main() {
2070
+ console.error(`[teamdynamix-mcp] log level: ${LOG_LEVEL}`);
2071
+ if (LOG_LEVEL === "debug") {
2072
+ const config = getTeamDynamixConfig();
2073
+ console.error(`[teamdynamix-mcp] sanitized config: ${JSON.stringify(redactTeamDynamixConfig(config))}`);
2074
+ }
2075
+ const transport = new StdioServerTransport();
2076
+ await server.connect(transport);
2077
+ }
2078
+ main().catch((error) => {
2079
+ const message = error instanceof Error ? error.message : String(error);
2080
+ console.error(`Server startup failed: ${message}`);
2081
+ process.exit(1);
2082
+ });
2083
+ //# sourceMappingURL=index.js.map