-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
1609 lines (1486 loc) · 59.6 KB
/
index.ts
File metadata and controls
1609 lines (1486 loc) · 59.6 KB
1
2
3
4
5
6
7
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* MCP server for Autodesk Platform Services (APS).
*
* Auth Tools:
* aps_login – 3‑legged OAuth login (opens browser)
* aps_logout – clear 3‑legged session
* aps_get_token – verify credentials / obtain 2‑legged token
*
* Data Management Tools:
* aps_dm_request – raw Data Management API (power‑user)
* aps_list_hubs – simplified hub listing
* aps_list_projects – simplified project listing
* aps_get_top_folders – root folders of a project
* aps_get_folder_contents – summarised folder contents (filters, sizes)
* aps_get_item_details – single file / item metadata
* aps_get_folder_tree – recursive folder tree
* aps_docs – APS quick‑reference documentation
*
* Issues Tools:
* aps_issues_request – raw Issues API (power‑user)
* aps_issues_get_types – issue categories & types
* aps_issues_list – list / search issues (summarised)
* aps_issues_get – single issue detail
* aps_issues_create – create a new issue
* aps_issues_update – update an existing issue
* aps_issues_get_comments – list comments on an issue
* aps_issues_create_comment – add a comment
* aps_issues_docs – Issues API quick‑reference
*
* Submittals Tools:
* aps_submittals_request – raw Submittals API (power‑user)
* aps_list_submittal_items – list submittal items
* aps_get_submittal_item – single submittal item details
* aps_list_submittal_packages – list submittal packages
* aps_list_submittal_specs – list spec sections
* aps_get_submittal_item_attachments – attachments for a submittal item
* aps_submittals_docs – Submittals quick‑reference documentation
*/
import { Server } from "@modelcontextprotocol/sdk/server";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import {
ListToolsRequestSchema,
CallToolRequestSchema,
} from "@modelcontextprotocol/sdk/types.js";
import {
getApsToken,
apsDmRequest,
ApsApiError,
performAps3loLogin,
getValid3loToken,
clear3loLogin,
} from "./aps-auth.js";
import {
summarizeHubs,
summarizeProjects,
summarizeTopFolders,
summarizeFolderContents,
summarizeItem,
buildFolderTree,
getErrorContext,
validatePath,
validateHubId,
validateProjectId,
validateFolderId,
validateItemId,
APS_DOCS,
} from "./aps-dm-helpers.js";
import {
toIssuesProjectId,
summarizeIssuesList,
summarizeIssueDetail,
summarizeIssueTypes,
summarizeComments,
validateIssuesProjectId,
validateIssueId,
validateIssuesPath,
ISSUES_DOCS,
} from "./aps-issues-helpers.js";
import {
summarizeSubmittalItems,
summarizeSubmittalPackages,
summarizeSubmittalSpecs,
summarizeSubmittalAttachments,
submittalPath,
validateSubmittalProjectId,
validateSubmittalItemId,
validateSubmittalPath,
SUBMITTALS_DOCS,
} from "./aps-submittals-helpers.js";
// ── Environment ──────────────────────────────────────────────────
const APS_CLIENT_ID = process.env.APS_CLIENT_ID ?? "";
const APS_CLIENT_SECRET = process.env.APS_CLIENT_SECRET ?? "";
const APS_SCOPE = process.env.APS_SCOPE ?? "";
const APS_CALLBACK_PORT = parseInt(process.env.APS_CALLBACK_PORT ?? "8910", 10);
function requireApsEnv(): void {
if (!APS_CLIENT_ID || !APS_CLIENT_SECRET) {
throw new Error(
"APS_CLIENT_ID and APS_CLIENT_SECRET environment variables are required.",
);
}
}
/**
* Obtain a valid access token.
* Prefers a cached 3‑legged token (user context) when available,
* otherwise falls back to 2‑legged (app context).
*/
async function token(): Promise<string> {
requireApsEnv();
const three = await getValid3loToken(APS_CLIENT_ID, APS_CLIENT_SECRET);
if (three) return three;
return getApsToken(APS_CLIENT_ID, APS_CLIENT_SECRET, APS_SCOPE || undefined);
}
// ── Helpers ──────────────────────────────────────────────────────
function ok(text: string) {
return { content: [{ type: "text" as const, text }] };
}
function fail(text: string) {
return { content: [{ type: "text" as const, text }], isError: true as const };
}
function json(obj: unknown) {
return ok(JSON.stringify(obj, null, 2));
}
/** Format an ApsApiError with troubleshooting context. */
function richError(err: ApsApiError) {
const ctx = getErrorContext(err.statusCode, err.method, err.path, err.responseBody);
return fail(JSON.stringify(ctx, null, 2));
}
// ── Tool definitions ─────────────────────────────────────────────
const TOOLS = [
// 0a ── aps_login (3‑legged OAuth)
{
name: "aps_login",
description:
"Start a 3‑legged OAuth login for APS (user context). " +
"Opens the user's browser to the Autodesk sign‑in page. " +
"After the user logs in and grants consent, the token is cached to disk " +
"and auto‑refreshed. All subsequent API calls use the 3LO token " +
"(with the user's own permissions) until aps_logout is called. " +
"The OAuth scope is determined by the APS_SCOPE setting configured by the user.",
inputSchema: {
type: "object" as const,
properties: {},
},
},
// 0b ── aps_logout (clear 3LO session)
{
name: "aps_logout",
description:
"Clear the cached 3‑legged OAuth token. " +
"After this, API calls fall back to the 2‑legged (app‑context) token.",
inputSchema: { type: "object" as const, properties: {} },
},
// 1 ── aps_get_token
{
name: "aps_get_token",
description:
"Get a 2‑legged access token for Autodesk Platform Services (APS). " +
"Use this to verify that credentials are configured correctly. " +
"The token is cached and auto‑refreshed by all other tools, so you rarely need to call this explicitly.",
inputSchema: { type: "object" as const, properties: {} },
},
// 2 ── aps_dm_request (raw / power‑user)
{
name: "aps_dm_request",
description:
"Call any APS Data Management API endpoint (project/v1, data/v1). " +
"This is the raw / power‑user tool – it returns the full JSON:API response which can be very large (100 K+ tokens for folder listings). " +
"Prefer the simplified tools (aps_list_hubs, aps_list_projects, aps_get_folder_contents, etc.) for everyday browsing. " +
"Use this tool when you need full control: pagination, POST/PATCH/DELETE, or endpoints not covered by simplified tools.\n\n" +
"Response guidance – when summarising large responses focus on:\n" +
"• Folders: name, id, item count\n" +
"• Files: name, type/extension, size, last modified, version info\n" +
"• Ignore: relationship links, JSON:API meta, and extended attributes unless specifically needed.",
inputSchema: {
type: "object" as const,
properties: {
method: {
type: "string",
enum: ["GET", "POST", "PATCH", "DELETE"],
description: "HTTP method.",
},
path: {
type: "string",
description:
"API path relative to developer.api.autodesk.com (e.g. 'project/v1/hubs' or " +
"'data/v1/projects/b.xxx/folders/urn:adsk.wipprod:fs.folder:co.xxx/contents'). " +
"Must include the version prefix (project/v1 or data/v1).",
},
query: {
type: "object",
description:
"Optional query parameters as key/value pairs (e.g. { \"page[limit]\": \"200\", \"includeHidden\": \"true\" }).",
additionalProperties: { type: "string" },
},
body: {
type: "object",
description: "Optional JSON body for POST/PATCH requests.",
},
},
required: ["method", "path"],
},
},
// 3 ── aps_list_hubs
{
name: "aps_list_hubs",
description:
"List all ACC / BIM 360 hubs (accounts) accessible to this app. " +
"Returns a compact summary: hub name, id, type, and region. " +
"Use the returned hub id (e.g. 'b.abc123…') in subsequent calls to aps_list_projects.",
inputSchema: { type: "object" as const, properties: {} },
},
// 4 ── aps_list_projects
{
name: "aps_list_projects",
description:
"List projects in an ACC / BIM 360 hub. " +
"Returns a compact summary: project name, id, platform (ACC / BIM 360), and last modified date. " +
"Use the returned project id with aps_get_top_folders or aps_get_folder_contents.",
inputSchema: {
type: "object" as const,
properties: {
hub_id: {
type: "string",
description: "Hub (account) ID – starts with 'b.' (e.g. 'b.abc12345-6789-…'). Get this from aps_list_hubs.",
},
},
required: ["hub_id"],
},
},
// 5 ── aps_get_top_folders
{
name: "aps_get_top_folders",
description:
"Get the root / top‑level folders for an ACC / BIM 360 project. " +
"Common root folders: 'Project Files', 'Plans', 'Shared', 'Recycle Bin'. " +
"Returns folder name, id, and item count. Use the folder id with aps_get_folder_contents.",
inputSchema: {
type: "object" as const,
properties: {
hub_id: {
type: "string",
description: "Hub (account) ID – starts with 'b.'.",
},
project_id: {
type: "string",
description: "Project ID – starts with 'b.'.",
},
},
required: ["hub_id", "project_id"],
},
},
// 6 ── aps_get_folder_contents
{
name: "aps_get_folder_contents",
description:
"Get a summarised listing of a folder's contents. " +
"Returns a compact JSON with: summary (item counts, file type breakdown, total size), " +
"folders (name, id, item count), and files (name, id, type, size, version, dates). " +
"This is ~95 % smaller than the raw API response.\n\n" +
"Supports optional filtering by file extension and hiding hidden items. " +
"For the full raw response, use aps_dm_request instead.",
inputSchema: {
type: "object" as const,
properties: {
project_id: {
type: "string",
description: "Project ID – starts with 'b.'.",
},
folder_id: {
type: "string",
description: "Folder URN – starts with 'urn:'.",
},
filter_extensions: {
type: "array",
items: { type: "string" },
description:
"Optional list of file extensions to include (e.g. [\".rvt\", \".nwd\", \".ifc\"]). " +
"Omit to return all file types.",
},
exclude_hidden: {
type: "boolean",
description: "When true, exclude hidden items. Defaults to false.",
},
page_limit: {
type: "number",
description: "Max items per page (1‑200). Defaults to 200.",
},
},
required: ["project_id", "folder_id"],
},
},
// 7 ── aps_get_item_details
{
name: "aps_get_item_details",
description:
"Get summarised metadata for a single file / item: name, type, size, version number, dates. " +
"Much smaller than the raw JSON:API response. " +
"Use for quick file lookups when you already have the item_id from a folder listing.",
inputSchema: {
type: "object" as const,
properties: {
project_id: {
type: "string",
description: "Project ID – starts with 'b.'.",
},
item_id: {
type: "string",
description: "Item (lineage) URN – starts with 'urn:'.",
},
},
required: ["project_id", "item_id"],
},
},
// 8 ── aps_get_folder_tree
{
name: "aps_get_folder_tree",
description:
"Build a recursive folder‑tree structure showing subfolder hierarchy and file counts per folder. " +
"Useful for understanding a project's organisation at a glance. " +
"⚠️ Each level makes an API call, so keep max_depth low (default 3) to avoid rate limits.",
inputSchema: {
type: "object" as const,
properties: {
project_id: {
type: "string",
description: "Project ID – starts with 'b.'.",
},
folder_id: {
type: "string",
description: "Root folder URN – starts with 'urn:'.",
},
max_depth: {
type: "number",
description: "Maximum recursion depth (1‑5). Default 3.",
},
},
required: ["project_id", "folder_id"],
},
},
// 9 ── aps_docs
{
name: "aps_docs",
description:
"Return APS Data Management quick‑reference documentation: " +
"common ID formats, typical browsing workflow, raw API paths, query parameters, " +
"BIM file extensions, and error troubleshooting. " +
"Call this before your first APS interaction or when unsure about ID formats or API paths.",
inputSchema: { type: "object" as const, properties: {} },
},
// ═══════════════════════════════════════════════════════════════
// ACC Issues Tools
// ═══════════════════════════════════════════════════════════════
// 10 ── aps_issues_request (raw / power‑user)
{
name: "aps_issues_request",
description:
"Call any ACC Issues API endpoint (construction/issues/v1). " +
"This is the raw / power‑user tool – it returns the full API response. " +
"Prefer the simplified tools (aps_issues_list, aps_issues_get, etc.) for everyday use. " +
"Use this when you need full control: custom filters, attribute definitions, attribute mappings, " +
"or endpoints not covered by simplified tools.\n\n" +
"⚠️ Project IDs for the Issues API must NOT have the 'b.' prefix. " +
"If you have a Data Management project ID like 'b.abc123', use 'abc123'.",
inputSchema: {
type: "object" as const,
properties: {
method: {
type: "string",
enum: ["GET", "POST", "PATCH", "DELETE"],
description: "HTTP method.",
},
path: {
type: "string",
description:
"API path relative to developer.api.autodesk.com " +
"(e.g. 'construction/issues/v1/projects/{projectId}/issues'). " +
"Must include the version prefix (construction/issues/v1).",
},
query: {
type: "object",
description:
"Optional query parameters as key/value pairs " +
"(e.g. { \"filter[status]\": \"open\", \"limit\": \"50\" }).",
additionalProperties: { type: "string" },
},
body: {
type: "object",
description: "Optional JSON body for POST/PATCH requests.",
},
region: {
type: "string",
enum: ["US", "EMEA", "AUS", "CAN", "DEU", "IND", "JPN", "GBR"],
description: "Data centre region (x-ads-region header). Defaults to US.",
},
},
required: ["method", "path"],
},
},
// 11 ── aps_issues_get_types
{
name: "aps_issues_get_types",
description:
"Get issue categories (types) and their types (subtypes) for a project. " +
"Returns a compact summary: category id, title, active status, and subtypes with code. " +
"Use the returned subtype id when creating issues (issueSubtypeId).",
inputSchema: {
type: "object" as const,
properties: {
project_id: {
type: "string",
description:
"Project ID – accepts with or without 'b.' prefix (e.g. 'b.abc123' or 'abc123'). " +
"Get this from aps_list_projects.",
},
include_subtypes: {
type: "boolean",
description: "Include subtypes for each category. Defaults to true.",
},
region: {
type: "string",
enum: ["US", "EMEA", "AUS", "CAN", "DEU", "IND", "JPN", "GBR"],
description: "Data centre region. Defaults to US.",
},
},
required: ["project_id"],
},
},
// 12 ── aps_issues_list
{
name: "aps_issues_list",
description:
"List and search issues in a project with optional filtering. " +
"Returns a compact summary per issue: id, displayId, title, status, assignee, dates, comment count. " +
"Supports filtering by status, assignee, type, date, search text, and more. " +
"This is much smaller than the raw API response.",
inputSchema: {
type: "object" as const,
properties: {
project_id: {
type: "string",
description: "Project ID – accepts with or without 'b.' prefix.",
},
filter_status: {
type: "string",
description:
"Filter by status. Comma‑separated. " +
"Values: draft, open, pending, in_progress, in_review, completed, not_approved, in_dispute, closed.",
},
filter_assigned_to: {
type: "string",
description: "Filter by assignee Autodesk ID. Comma‑separated for multiple.",
},
filter_issue_type_id: {
type: "string",
description: "Filter by category (type) UUID. Comma‑separated for multiple.",
},
filter_issue_subtype_id: {
type: "string",
description: "Filter by type (subtype) UUID. Comma‑separated for multiple.",
},
filter_due_date: {
type: "string",
description: "Filter by due date (YYYY‑MM‑DD). Comma‑separated for range.",
},
filter_created_at: {
type: "string",
description: "Filter by creation date (YYYY‑MM‑DD or YYYY‑MM‑DDThh:mm:ss.sz).",
},
filter_search: {
type: "string",
description: "Search by title or display ID (e.g. '300' or 'wall crack').",
},
filter_root_cause_id: {
type: "string",
description: "Filter by root cause UUID. Comma‑separated for multiple.",
},
filter_location_id: {
type: "string",
description: "Filter by LBS location UUID. Comma‑separated for multiple.",
},
limit: {
type: "number",
description: "Max issues to return (1‑100). Default 100.",
},
offset: {
type: "number",
description: "Pagination offset. Default 0.",
},
sort_by: {
type: "string",
description:
"Sort field(s). Comma‑separated. Prefix with '-' for descending. " +
"Values: createdAt, updatedAt, displayId, title, status, assignedTo, dueDate, startDate, closedAt.",
},
region: {
type: "string",
enum: ["US", "EMEA", "AUS", "CAN", "DEU", "IND", "JPN", "GBR"],
description: "Data centre region. Defaults to US.",
},
},
required: ["project_id"],
},
},
// 13 ── aps_issues_get
{
name: "aps_issues_get",
description:
"Get detailed information about a single issue. " +
"Returns a compact summary with: id, title, description, status, assignee, dates, location, " +
"custom attributes, linked document count, permitted statuses, and more.",
inputSchema: {
type: "object" as const,
properties: {
project_id: {
type: "string",
description: "Project ID – accepts with or without 'b.' prefix.",
},
issue_id: {
type: "string",
description: "Issue UUID. Get this from aps_issues_list.",
},
region: {
type: "string",
enum: ["US", "EMEA", "AUS", "CAN", "DEU", "IND", "JPN", "GBR"],
description: "Data centre region. Defaults to US.",
},
},
required: ["project_id", "issue_id"],
},
},
// 14 ── aps_issues_create
{
name: "aps_issues_create",
description:
"Create a new issue in a project. " +
"Requires: title, issueSubtypeId (get from aps_issues_get_types), and status. " +
"Optional: description, assignee, dates, location, root cause, custom attributes, watchers. " +
"⚠️ Requires 'data:write' in APS_SCOPE.",
inputSchema: {
type: "object" as const,
properties: {
project_id: {
type: "string",
description: "Project ID – accepts with or without 'b.' prefix.",
},
title: {
type: "string",
description: "Issue title (max 10,000 chars).",
},
issue_subtype_id: {
type: "string",
description: "Type (subtype) UUID – get from aps_issues_get_types.",
},
status: {
type: "string",
enum: ["draft", "open", "pending", "in_progress", "in_review", "completed", "not_approved", "in_dispute", "closed"],
description: "Initial status (e.g. 'open').",
},
description: {
type: "string",
description: "Issue description (max 10,000 chars). Optional.",
},
assigned_to: {
type: "string",
description: "Autodesk ID of assignee (user, company, or role). Optional.",
},
assigned_to_type: {
type: "string",
enum: ["user", "company", "role"],
description: "Type of assignee. Required if assigned_to is set.",
},
due_date: {
type: "string",
description: "Due date in ISO8601 format (e.g. '2025‑12‑31'). Optional.",
},
start_date: {
type: "string",
description: "Start date in ISO8601 format. Optional.",
},
location_id: {
type: "string",
description: "LBS (Location Breakdown Structure) UUID. Optional.",
},
location_details: {
type: "string",
description: "Location as plain text (max 8,300 chars). Optional.",
},
root_cause_id: {
type: "string",
description: "Root cause UUID. Optional.",
},
published: {
type: "boolean",
description: "Whether the issue is published. Default false.",
},
watchers: {
type: "array",
items: { type: "string" },
description: "Array of Autodesk IDs to add as watchers. Optional.",
},
custom_attributes: {
type: "array",
items: {
type: "object",
properties: {
attributeDefinitionId: { type: "string" },
value: {},
},
required: ["attributeDefinitionId", "value"],
},
description: "Custom attribute values. Optional.",
},
region: {
type: "string",
enum: ["US", "EMEA", "AUS", "CAN", "DEU", "IND", "JPN", "GBR"],
description: "Data centre region. Defaults to US.",
},
},
required: ["project_id", "title", "issue_subtype_id", "status"],
},
},
// 15 ── aps_issues_update
{
name: "aps_issues_update",
description:
"Update an existing issue. Only include the fields you want to change. " +
"⚠️ Requires 'data:write' in APS_SCOPE. " +
"To see which fields the current user can update, check permittedAttributes in the issue detail.",
inputSchema: {
type: "object" as const,
properties: {
project_id: {
type: "string",
description: "Project ID – accepts with or without 'b.' prefix.",
},
issue_id: {
type: "string",
description: "Issue UUID to update.",
},
title: { type: "string", description: "New title. Optional." },
description: { type: "string", description: "New description. Optional." },
status: {
type: "string",
enum: ["draft", "open", "pending", "in_progress", "in_review", "completed", "not_approved", "in_dispute", "closed"],
description: "New status. Optional.",
},
assigned_to: { type: "string", description: "New assignee Autodesk ID. Optional." },
assigned_to_type: {
type: "string",
enum: ["user", "company", "role"],
description: "Assignee type. Required if assigned_to is set.",
},
due_date: { type: "string", description: "New due date (ISO8601). Optional." },
start_date: { type: "string", description: "New start date (ISO8601). Optional." },
location_id: { type: "string", description: "New LBS location UUID. Optional." },
location_details: { type: "string", description: "New location text. Optional." },
root_cause_id: { type: "string", description: "New root cause UUID. Optional." },
published: { type: "boolean", description: "Set published state. Optional." },
watchers: {
type: "array",
items: { type: "string" },
description: "New watcher list. Optional.",
},
custom_attributes: {
type: "array",
items: {
type: "object",
properties: {
attributeDefinitionId: { type: "string" },
value: {},
},
required: ["attributeDefinitionId", "value"],
},
description: "Custom attribute values to update. Optional.",
},
region: {
type: "string",
enum: ["US", "EMEA", "AUS", "CAN", "DEU", "IND", "JPN", "GBR"],
description: "Data centre region. Defaults to US.",
},
},
required: ["project_id", "issue_id"],
},
},
// 16 ── aps_issues_get_comments
{
name: "aps_issues_get_comments",
description:
"Get all comments for a specific issue. " +
"Returns a compact list: comment id, body, author, date.",
inputSchema: {
type: "object" as const,
properties: {
project_id: {
type: "string",
description: "Project ID – accepts with or without 'b.' prefix.",
},
issue_id: {
type: "string",
description: "Issue UUID.",
},
limit: {
type: "number",
description: "Max comments to return. Optional.",
},
offset: {
type: "number",
description: "Pagination offset. Optional.",
},
sort_by: {
type: "string",
description: "Sort field (e.g. 'createdAt' or '-createdAt'). Optional.",
},
region: {
type: "string",
enum: ["US", "EMEA", "AUS", "CAN", "DEU", "IND", "JPN", "GBR"],
description: "Data centre region. Defaults to US.",
},
},
required: ["project_id", "issue_id"],
},
},
// 17 ── aps_issues_create_comment
{
name: "aps_issues_create_comment",
description:
"Add a comment to an issue. " +
"⚠️ Requires 'data:write' in APS_SCOPE.",
inputSchema: {
type: "object" as const,
properties: {
project_id: {
type: "string",
description: "Project ID – accepts with or without 'b.' prefix.",
},
issue_id: {
type: "string",
description: "Issue UUID.",
},
body: {
type: "string",
description: "Comment text (max 10,000 chars). Use \\n for newlines.",
},
region: {
type: "string",
enum: ["US", "EMEA", "AUS", "CAN", "DEU", "IND", "JPN", "GBR"],
description: "Data centre region. Defaults to US.",
},
},
required: ["project_id", "issue_id", "body"],
},
},
// 18 ── aps_issues_docs
{
name: "aps_issues_docs",
description:
"Return ACC Issues API quick‑reference documentation: " +
"project ID format, statuses, typical workflow, raw API paths, " +
"common filters, sort options, and error troubleshooting. " +
"Call this before your first Issues interaction.",
inputSchema: { type: "object" as const, properties: {} },
},
// ═══════════════════════════════════════════════════════════════
// ── ACC Submittals tools ───────────────────────────────────────
// ═══════════════════════════════════════════════════════════════
// 19 ── aps_submittals_request (raw / power‑user)
{
name: "aps_submittals_request",
description:
"Call any ACC Submittals API endpoint. " +
"This is the raw / power‑user tool – it returns the full JSON response. " +
"Prefer the simplified tools (aps_list_submittal_items, aps_list_submittal_packages, etc.) for everyday use. " +
"Use this tool when you need full control: pagination, POST/PATCH, or endpoints not covered by simplified tools " +
"(e.g. metadata, settings/mappings, users/me, item-types, responses).\n\n" +
"The base path is: construction/submittals/v2/projects/{projectId}/\n" +
"You only need to provide the sub‑path after 'projects/{projectId}/' (e.g. 'items', 'packages', 'specs').",
inputSchema: {
type: "object" as const,
properties: {
project_id: {
type: "string",
description:
"Project ID – UUID format (e.g. 'abc12345-6789-…'). " +
"If you have a DM project ID with 'b.' prefix, it will be stripped automatically.",
},
method: {
type: "string",
enum: ["GET", "POST"],
description: "HTTP method. Default: GET.",
},
path: {
type: "string",
description:
"Sub‑path relative to 'projects/{projectId}/' " +
"(e.g. 'items', 'packages', 'specs', 'items/{itemId}', 'metadata', 'responses', 'item-types').",
},
query: {
type: "object",
description:
"Optional query parameters as key/value pairs (e.g. { \"limit\": \"50\", \"offset\": \"0\", \"filter[statusId]\": \"2\" }).",
additionalProperties: { type: "string" },
},
body: {
type: "object",
description: "Optional JSON body for POST requests.",
},
},
required: ["project_id", "path"],
},
},
// 20 ── aps_list_submittal_items
{
name: "aps_list_submittal_items",
description:
"List submittal items in an ACC project. " +
"Returns a compact summary: title, number, spec section, type, status, priority, revision, dates. " +
"Supports filtering by status, package, spec section, and review response.",
inputSchema: {
type: "object" as const,
properties: {
project_id: {
type: "string",
description: "Project ID (UUID or 'b.' prefixed – auto‑converted).",
},
filter_status: {
type: "string",
description:
"Filter by status ID: 1=Required, 2=Open, 3=Closed, 4=Void, 5=Empty, 6=Draft. " +
"Omit to return all statuses.",
},
filter_package_id: {
type: "string",
description: "Filter by package UUID. Omit to return items from all packages.",
},
filter_spec_id: {
type: "string",
description: "Filter by spec section UUID. Omit to return all spec sections.",
},
limit: {
type: "number",
description: "Max items per page (1–200). Default 20.",
},
offset: {
type: "number",
description: "Pagination offset. Default 0.",
},
},
required: ["project_id"],
},
},
// 21 ── aps_get_submittal_item
{
name: "aps_get_submittal_item",
description:
"Get full details for a single submittal item by ID. " +
"Returns the complete item object from the API.",
inputSchema: {
type: "object" as const,
properties: {
project_id: {
type: "string",
description: "Project ID (UUID or 'b.' prefixed – auto‑converted).",
},
item_id: {
type: "string",
description: "Submittal item UUID.",
},
},
required: ["project_id", "item_id"],
},
},
// 22 ── aps_list_submittal_packages
{
name: "aps_list_submittal_packages",
description:
"List submittal packages in an ACC project. " +
"Returns a compact summary: title, identifier, spec section, description, dates.",
inputSchema: {
type: "object" as const,
properties: {
project_id: {
type: "string",
description: "Project ID (UUID or 'b.' prefixed – auto‑converted).",
},
limit: {
type: "number",
description: "Max items per page (1–200). Default 20.",
},
offset: {
type: "number",
description: "Pagination offset. Default 0.",
},
},
required: ["project_id"],
},
},
// 23 ── aps_list_submittal_specs
{
name: "aps_list_submittal_specs",
description:
"List spec sections for submittals in an ACC project. " +
"Returns a compact summary: identifier (e.g. '033100'), title, dates. " +
"Spec sections are the specification divisions that submittal items are organised under.",
inputSchema: {
type: "object" as const,
properties: {
project_id: {
type: "string",
description: "Project ID (UUID or 'b.' prefixed – auto‑converted).",
},
limit: {
type: "number",
description: "Max items per page (1–200). Default 20.",
},
offset: {
type: "number",
description: "Pagination offset. Default 0.",
},
},
required: ["project_id"],
},
},
// 24 ── aps_get_submittal_item_attachments
{
name: "aps_get_submittal_item_attachments",
description:
"Get attachments for a specific submittal item. " +
"Returns file names, URNs, revision numbers, and categories. " +
"Use the URN to download the attachment via the Data Management API.",
inputSchema: {
type: "object" as const,
properties: {
project_id: {
type: "string",
description: "Project ID (UUID or 'b.' prefixed – auto‑converted).",
},
item_id: {
type: "string",
description: "Submittal item UUID.",
},
},
required: ["project_id", "item_id"],
},
},
// 25 ── aps_submittals_docs
{
name: "aps_submittals_docs",
description:
"Return ACC Submittals API quick‑reference documentation: " +
"endpoints, query parameters, statuses, custom numbering, typical workflow, and key concepts. " +
"Call this before your first Submittals interaction or when unsure about Submittals API usage.",
inputSchema: { type: "object" as const, properties: {} },
},
];
// ── Tool handlers ────────────────────────────────────────────────
async function handleTool(
name: string,
args: Record<string, unknown>,