@assetlab/mcp-server 1.5.0 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/oauth.js CHANGED
@@ -77,7 +77,7 @@ export function authServerMetadata(origin) {
77
77
  token_endpoint: `${origin}/token`,
78
78
  registration_endpoint: `${origin}/register`,
79
79
  response_types_supported: ['code'],
80
- grant_types_supported: ['authorization_code'],
80
+ grant_types_supported: ['authorization_code', 'refresh_token'],
81
81
  scopes_supported: ['claudeai', 'mcp'],
82
82
  code_challenge_methods_supported: ['S256'],
83
83
  token_endpoint_auth_methods_supported: ['none'],
@@ -263,6 +263,17 @@ export async function handleAuthorizePost(request, secret) {
263
263
  return Response.redirect(target.toString(), 302);
264
264
  }
265
265
  // ── Token endpoint ──────────────────────────────────────────────────────────
266
+ async function issueTokens(apiKey, scope, secret) {
267
+ const refreshPayload = { apiKey, scope: scope || 'mcp', type: 'refresh' };
268
+ const refreshToken = await encrypt(JSON.stringify(refreshPayload), secret);
269
+ return json({
270
+ access_token: apiKey,
271
+ token_type: 'Bearer',
272
+ expires_in: 86400,
273
+ scope: scope || 'mcp',
274
+ refresh_token: refreshToken,
275
+ });
276
+ }
266
277
  export async function handleToken(request, secret) {
267
278
  let params;
268
279
  const ct = request.headers.get('Content-Type') ?? '';
@@ -273,13 +284,34 @@ export async function handleToken(request, secret) {
273
284
  else {
274
285
  params = new URLSearchParams(await request.text());
275
286
  }
287
+ const grantType = params.get('grant_type');
288
+ console.log('[token]', JSON.stringify({ grantType, contentType: ct }));
289
+ // ── Refresh token grant ──────────────────────────────────────────────────
290
+ if (grantType === 'refresh_token') {
291
+ const refreshToken = params.get('refresh_token');
292
+ if (!refreshToken) {
293
+ return json({ error: 'invalid_request', error_description: 'Missing refresh_token' }, 400);
294
+ }
295
+ let payload;
296
+ try {
297
+ payload = JSON.parse(await decrypt(refreshToken, secret));
298
+ }
299
+ catch (err) {
300
+ console.log('[token] refresh decrypt failed:', err instanceof Error ? err.message : err);
301
+ return json({ error: 'invalid_grant', error_description: 'Invalid refresh token' }, 400);
302
+ }
303
+ if (payload.type !== 'refresh') {
304
+ return json({ error: 'invalid_grant', error_description: 'Invalid refresh token' }, 400);
305
+ }
306
+ console.log('[token] refresh success, issuing new tokens');
307
+ return issueTokens(payload.apiKey, payload.scope, secret);
308
+ }
309
+ // ── Authorization code grant ─────────────────────────────────────────────
276
310
  const code = params.get('code');
277
311
  const codeVerifier = params.get('code_verifier');
278
312
  const redirectUri = params.get('redirect_uri');
279
- const grantType = params.get('grant_type');
280
313
  console.log('[token]', JSON.stringify({
281
- grantType, hasCode: !!code, hasVerifier: !!codeVerifier, redirectUri,
282
- contentType: ct,
314
+ hasCode: !!code, hasVerifier: !!codeVerifier, redirectUri,
283
315
  }));
284
316
  if (!code)
285
317
  return json({ error: 'invalid_request', error_description: 'Missing code' }, 400);
@@ -315,14 +347,8 @@ export async function handleToken(request, secret) {
315
347
  return json({ error: 'invalid_grant', error_description: 'PKCE verification failed' }, 400);
316
348
  }
317
349
  }
318
- console.log('[token] success, returning access_token');
319
- // The API key IS the access token — the MCP handler already reads it from Bearer header
320
- return json({
321
- access_token: payload.apiKey,
322
- token_type: 'Bearer',
323
- expires_in: 3600,
324
- scope: payload.scope || 'mcp',
325
- });
350
+ console.log('[token] success, returning access_token with refresh_token');
351
+ return issueTokens(payload.apiKey, payload.scope, secret);
326
352
  }
327
353
  // ── Utility ─────────────────────────────────────────────────────────────────
328
354
  function escapeHtml(s) {
package/dist/oauth.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"oauth.js","sourceRoot":"","sources":["../src/oauth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,gFAAgF;AAEhF,SAAS,SAAS,CAAC,GAA6B;IAC9C,MAAM,KAAK,GAAG,GAAG,YAAY,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,GAAG,CAAC,CAAA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MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;AACrG,CAAC"}
@@ -125,11 +125,11 @@ export function registerWriteTools(server, client) {
125
125
  salvage_value_percentage: z.number().min(0).max(100).optional().describe('Salvage value percentage (0-100)'),
126
126
  consequence_of_failure_score: z.number().int().min(0).optional().describe('Consequence of failure score'),
127
127
  likelihood_of_failure_score: z.number().int().min(0).optional().describe('Likelihood of failure score'),
128
- safety_impact: z.string().optional().describe('Safety impact description'),
129
- service_impact: z.string().optional().describe('Service impact description'),
130
- environmental_impact: z.string().optional().describe('Environmental impact description'),
131
- regulatory_impact: z.string().optional().describe('Regulatory impact description'),
132
- reputation_impact: z.string().optional().describe('Reputation impact description'),
128
+ safety_impact: z.enum(['LOW', 'MEDIUM', 'HIGH', 'CRITICAL']).optional().describe('Safety impact level (LOW, MEDIUM, HIGH, CRITICAL)'),
129
+ service_impact: z.enum(['LOW', 'MEDIUM', 'HIGH', 'CRITICAL']).optional().describe('Service impact level (LOW, MEDIUM, HIGH, CRITICAL)'),
130
+ environmental_impact: z.enum(['LOW', 'MEDIUM', 'HIGH', 'CRITICAL']).optional().describe('Environmental impact level (LOW, MEDIUM, HIGH, CRITICAL)'),
131
+ regulatory_impact: z.enum(['LOW', 'MEDIUM', 'HIGH', 'CRITICAL']).optional().describe('Regulatory impact level (LOW, MEDIUM, HIGH, CRITICAL)'),
132
+ reputation_impact: z.enum(['LOW', 'MEDIUM', 'HIGH', 'CRITICAL']).optional().describe('Reputation impact level (LOW, MEDIUM, HIGH, CRITICAL)'),
133
133
  }, async (params) => {
134
134
  try {
135
135
  const result = await client.create('assets', buildBody(params));
@@ -170,11 +170,11 @@ export function registerWriteTools(server, client) {
170
170
  salvage_value_percentage: z.number().min(0).max(100).optional().describe('Salvage value percentage (0-100)'),
171
171
  consequence_of_failure_score: z.number().int().min(0).optional().describe('Consequence of failure score'),
172
172
  likelihood_of_failure_score: z.number().int().min(0).optional().describe('Likelihood of failure score'),
173
- safety_impact: z.string().optional().describe('Safety impact description'),
174
- service_impact: z.string().optional().describe('Service impact description'),
175
- environmental_impact: z.string().optional().describe('Environmental impact description'),
176
- regulatory_impact: z.string().optional().describe('Regulatory impact description'),
177
- reputation_impact: z.string().optional().describe('Reputation impact description'),
173
+ safety_impact: z.enum(['LOW', 'MEDIUM', 'HIGH', 'CRITICAL']).optional().describe('Safety impact level (LOW, MEDIUM, HIGH, CRITICAL)'),
174
+ service_impact: z.enum(['LOW', 'MEDIUM', 'HIGH', 'CRITICAL']).optional().describe('Service impact level (LOW, MEDIUM, HIGH, CRITICAL)'),
175
+ environmental_impact: z.enum(['LOW', 'MEDIUM', 'HIGH', 'CRITICAL']).optional().describe('Environmental impact level (LOW, MEDIUM, HIGH, CRITICAL)'),
176
+ regulatory_impact: z.enum(['LOW', 'MEDIUM', 'HIGH', 'CRITICAL']).optional().describe('Regulatory impact level (LOW, MEDIUM, HIGH, CRITICAL)'),
177
+ reputation_impact: z.enum(['LOW', 'MEDIUM', 'HIGH', 'CRITICAL']).optional().describe('Reputation impact level (LOW, MEDIUM, HIGH, CRITICAL)'),
178
178
  }, async ({ id, ...rest }) => {
179
179
  try {
180
180
  const result = await client.update('assets', id, buildBody(rest));
@@ -259,8 +259,8 @@ export function registerWriteTools(server, client) {
259
259
  state: z.string().max(100).optional().describe('State/province'),
260
260
  country: z.string().max(100).optional().describe('Country'),
261
261
  status: z.string().max(50).optional().describe('Vendor status'),
262
- category: z.string().max(100).optional().describe('Vendor category'),
263
- website: z.string().max(500).optional().describe('Website URL'),
262
+ categories: z.array(z.string().max(100)).optional().describe('Vendor categories (e.g. ["HVAC", "Plumbing"])'),
263
+ website: z.string().max(500).optional().describe('Website URL (protocol and www prefix are stripped automatically)'),
264
264
  description: z.string().optional().describe('Description'),
265
265
  }, async (params) => {
266
266
  try {
@@ -282,8 +282,8 @@ export function registerWriteTools(server, client) {
282
282
  state: z.string().max(100).optional().describe('State/province'),
283
283
  country: z.string().max(100).optional().describe('Country'),
284
284
  status: z.string().max(50).optional().describe('Vendor status'),
285
- category: z.string().max(100).optional().describe('Vendor category'),
286
- website: z.string().max(500).optional().describe('Website URL'),
285
+ categories: z.array(z.string().max(100)).optional().describe('Vendor categories (e.g. ["HVAC", "Plumbing"])'),
286
+ website: z.string().max(500).optional().describe('Website URL (protocol and www prefix are stripped automatically)'),
287
287
  description: z.string().optional().describe('Description'),
288
288
  }, async ({ id, ...rest }) => {
289
289
  try {
@@ -485,6 +485,11 @@ export function registerWriteTools(server, client) {
485
485
  asset_ids: z.array(z.string().uuid()).optional().describe('Array of asset IDs'),
486
486
  system_ids: z.array(z.string().uuid()).optional().describe('Array of system IDs'),
487
487
  location_ids: z.array(z.string().uuid()).optional().describe('Array of location IDs'),
488
+ tasks: z.array(z.object({
489
+ id: z.string().describe('Unique task ID (use a random string)'),
490
+ description: z.string().describe('Task description'),
491
+ completed: z.boolean().describe('Whether the task is completed'),
492
+ })).optional().describe('Checklist of tasks for this PM schedule'),
488
493
  }, async (params) => {
489
494
  try {
490
495
  const result = await client.create('pm-schedules', buildBody(params));
@@ -519,6 +524,11 @@ export function registerWriteTools(server, client) {
519
524
  asset_ids: z.array(z.string().uuid()).optional().describe('Array of asset IDs'),
520
525
  system_ids: z.array(z.string().uuid()).optional().describe('Array of system IDs'),
521
526
  location_ids: z.array(z.string().uuid()).optional().describe('Array of location IDs'),
527
+ tasks: z.array(z.object({
528
+ id: z.string().describe('Unique task ID'),
529
+ description: z.string().describe('Task description'),
530
+ completed: z.boolean().describe('Whether the task is completed'),
531
+ })).optional().describe('Checklist of tasks for this PM schedule'),
522
532
  }, async ({ id, ...rest }) => {
523
533
  try {
524
534
  const result = await client.update('pm-schedules', id, buildBody(rest));
@@ -545,7 +555,7 @@ export function registerWriteTools(server, client) {
545
555
  status: z.string().max(100).describe('Project status (required)'),
546
556
  start_date: z.string().describe('Start date (ISO 8601, required)'),
547
557
  project_code: z.string().max(100).optional().describe('Project code'),
548
- project_type: z.string().max(100).optional().describe('Project type'),
558
+ project_type: z.enum(['capital', 'maintenance', 'repair', 'upgrade', 'new_construction', 'renovation', 'deferred_maintenance', 'other']).optional().describe('Project type'),
549
559
  current_phase: z.string().max(100).optional().describe('Current phase'),
550
560
  description: z.string().optional().describe('Description'),
551
561
  end_date: z.string().optional().describe('End date (ISO 8601)'),
@@ -569,7 +579,7 @@ export function registerWriteTools(server, client) {
569
579
  status: z.string().max(100).optional().describe('Project status'),
570
580
  start_date: z.string().optional().describe('Start date (ISO 8601)'),
571
581
  project_code: z.string().max(100).optional().describe('Project code'),
572
- project_type: z.string().max(100).optional().describe('Project type'),
582
+ project_type: z.enum(['capital', 'maintenance', 'repair', 'upgrade', 'new_construction', 'renovation', 'deferred_maintenance', 'other']).optional().describe('Project type'),
573
583
  current_phase: z.string().max(100).optional().describe('Current phase'),
574
584
  description: z.string().optional().describe('Description'),
575
585
  end_date: z.string().optional().describe('End date (ISO 8601)'),
@@ -1672,7 +1682,6 @@ export function registerWriteTools(server, client) {
1672
1682
  // ============================================================
1673
1683
  server.tool('create_system_class', 'Create a new system class (top-level classification, e.g., "HVAC & Mechanical", "Material Handling"). Requires systems:write scope.', {
1674
1684
  name: z.string().min(1).max(500).describe('System class name (required)'),
1675
- code: z.string().max(100).optional().describe('Short code (e.g., "HVAC", "MH")'),
1676
1685
  description: z.string().max(2000).optional().describe('Description'),
1677
1686
  }, async (params) => {
1678
1687
  try {
@@ -1686,7 +1695,6 @@ export function registerWriteTools(server, client) {
1686
1695
  server.tool('update_system_class', 'Update an existing system class by ID. Requires systems:write scope.', {
1687
1696
  id: z.string().uuid().describe('System class ID'),
1688
1697
  name: z.string().min(1).max(500).optional().describe('System class name'),
1689
- code: z.string().max(100).optional().describe('Short code'),
1690
1698
  description: z.string().max(2000).optional().describe('Description'),
1691
1699
  }, async ({ id, ...rest }) => {
1692
1700
  try {
@@ -1937,6 +1945,388 @@ export function registerWriteTools(server, client) {
1937
1945
  }
1938
1946
  });
1939
1947
  // ============================================================
1948
+ // Upload URLs
1949
+ // ============================================================
1950
+ server.tool('create_upload_url', 'Generate a signed upload URL for uploading a file to AssetLab storage. Returns a signed_url to PUT the file to, plus the path to reference when creating a document record. Requires upload_urls:write scope.', {
1951
+ bucket: z.enum(['documents', 'attachments', 'project-documents', 'contract-documents']).describe('Storage bucket (required)'),
1952
+ file_name: z.string().min(1).max(500).describe('File name including extension (required)'),
1953
+ }, async (params) => {
1954
+ try {
1955
+ const result = await client.create('upload-urls', buildBody(params));
1956
+ return formatResult(result);
1957
+ }
1958
+ catch (err) {
1959
+ return formatError(err);
1960
+ }
1961
+ });
1962
+ // ============================================================
1963
+ // Asset Documents (scope: asset_documents)
1964
+ // ============================================================
1965
+ server.tool('create_asset_document', 'Create an asset document record (after uploading the file via create_upload_url). Requires asset_documents:write scope.', {
1966
+ name: z.string().min(1).max(500).describe('Document name (required)'),
1967
+ file_path: z.string().min(1).max(2000).describe('Storage path from upload URL response (required)'),
1968
+ asset_id: z.string().uuid().describe('Asset ID this document belongs to (required)'),
1969
+ category: z.enum(['om', 'commissioning', 'warranty', 'installation', 'specification', 'other']).optional().describe('Document category'),
1970
+ description: z.string().optional().describe('Description'),
1971
+ file_type: z.string().max(200).optional().describe('MIME type'),
1972
+ file_size: z.number().min(0).optional().describe('File size in bytes'),
1973
+ user_id: z.string().max(200).optional().describe('Uploader user ID'),
1974
+ }, async (params) => {
1975
+ try {
1976
+ const result = await client.create('asset-documents', buildBody(params));
1977
+ return formatResult(result);
1978
+ }
1979
+ catch (err) {
1980
+ return formatError(err);
1981
+ }
1982
+ });
1983
+ server.tool('update_asset_document', 'Update an asset document by ID. Requires asset_documents:write scope.', {
1984
+ id: z.string().uuid().describe('Asset document ID'),
1985
+ name: z.string().min(1).max(500).optional().describe('Document name'),
1986
+ file_path: z.string().max(2000).optional().describe('Storage path'),
1987
+ asset_id: z.string().uuid().optional().describe('Asset ID'),
1988
+ category: z.enum(['om', 'commissioning', 'warranty', 'installation', 'specification', 'other']).optional().describe('Document category'),
1989
+ description: z.string().optional().describe('Description'),
1990
+ file_type: z.string().max(200).optional().describe('MIME type'),
1991
+ file_size: z.number().min(0).optional().describe('File size in bytes'),
1992
+ user_id: z.string().max(200).optional().describe('Uploader user ID'),
1993
+ }, async ({ id, ...rest }) => {
1994
+ try {
1995
+ const result = await client.update('asset-documents', id, buildBody(rest));
1996
+ return formatResult(result);
1997
+ }
1998
+ catch (err) {
1999
+ return formatError(err);
2000
+ }
2001
+ });
2002
+ server.tool('delete_asset_document', 'Delete an asset document by ID. Requires asset_documents:write scope.', { id: z.string().uuid().describe('Asset document ID') }, async ({ id }) => {
2003
+ try {
2004
+ const result = await client.remove('asset-documents', id);
2005
+ return formatResult(result);
2006
+ }
2007
+ catch (err) {
2008
+ return formatError(err);
2009
+ }
2010
+ });
2011
+ // ============================================================
2012
+ // Attachments (scope: attachments)
2013
+ // ============================================================
2014
+ server.tool('create_attachment', 'Create an attachment record linked to a work order, work request, PM schedule, or PM template. Exactly one parent ID must be provided. Requires attachments:write scope.', {
2015
+ file_url: z.string().min(1).max(2000).describe('File URL / storage path (required)'),
2016
+ file_name: z.string().min(1).max(500).describe('File name (required)'),
2017
+ file_size: z.number().min(0).optional().describe('File size in bytes'),
2018
+ file_type: z.string().max(200).optional().describe('MIME type'),
2019
+ uploaded_by: z.string().max(200).optional().describe('Uploader user ID'),
2020
+ description: z.string().optional().describe('Description'),
2021
+ work_order_id: z.string().uuid().optional().describe('Work order ID (exactly one parent required)'),
2022
+ work_request_id: z.string().uuid().optional().describe('Work request ID (exactly one parent required)'),
2023
+ pm_schedule_id: z.string().uuid().optional().describe('PM schedule ID (exactly one parent required)'),
2024
+ pm_template_id: z.string().uuid().optional().describe('PM template ID (exactly one parent required)'),
2025
+ }, async (params) => {
2026
+ try {
2027
+ const result = await client.create('attachments', buildBody(params));
2028
+ return formatResult(result);
2029
+ }
2030
+ catch (err) {
2031
+ return formatError(err);
2032
+ }
2033
+ });
2034
+ server.tool('update_attachment', 'Update an attachment by ID. Requires attachments:write scope.', {
2035
+ id: z.string().uuid().describe('Attachment ID'),
2036
+ file_url: z.string().max(2000).optional().describe('File URL / storage path'),
2037
+ file_name: z.string().max(500).optional().describe('File name'),
2038
+ file_size: z.number().min(0).optional().describe('File size in bytes'),
2039
+ file_type: z.string().max(200).optional().describe('MIME type'),
2040
+ uploaded_by: z.string().max(200).optional().describe('Uploader user ID'),
2041
+ description: z.string().optional().describe('Description'),
2042
+ work_order_id: z.string().uuid().optional().describe('Work order ID'),
2043
+ work_request_id: z.string().uuid().optional().describe('Work request ID'),
2044
+ pm_schedule_id: z.string().uuid().optional().describe('PM schedule ID'),
2045
+ pm_template_id: z.string().uuid().optional().describe('PM template ID'),
2046
+ }, async ({ id, ...rest }) => {
2047
+ try {
2048
+ const result = await client.update('attachments', id, buildBody(rest));
2049
+ return formatResult(result);
2050
+ }
2051
+ catch (err) {
2052
+ return formatError(err);
2053
+ }
2054
+ });
2055
+ server.tool('delete_attachment', 'Delete an attachment by ID. Requires attachments:write scope.', { id: z.string().uuid().describe('Attachment ID') }, async ({ id }) => {
2056
+ try {
2057
+ const result = await client.remove('attachments', id);
2058
+ return formatResult(result);
2059
+ }
2060
+ catch (err) {
2061
+ return formatError(err);
2062
+ }
2063
+ });
2064
+ // ============================================================
2065
+ // Project Documents (scope: project_documents)
2066
+ // ============================================================
2067
+ server.tool('create_project_document', 'Create a project document record. Requires project_documents:write scope.', {
2068
+ project_id: z.string().uuid().describe('Project ID (required)'),
2069
+ name: z.string().min(1).max(500).describe('Document name (required)'),
2070
+ file_path: z.string().min(1).max(2000).describe('Storage path from upload URL response (required)'),
2071
+ uploaded_by: z.string().min(1).max(200).describe('Uploader user ID (required)'),
2072
+ folder_id: z.string().uuid().optional().describe('Folder ID'),
2073
+ description: z.string().optional().describe('Description'),
2074
+ file_size: z.number().min(0).optional().describe('File size in bytes'),
2075
+ file_type: z.string().max(200).optional().describe('MIME type'),
2076
+ }, async (params) => {
2077
+ try {
2078
+ const result = await client.create('project-documents', buildBody(params));
2079
+ return formatResult(result);
2080
+ }
2081
+ catch (err) {
2082
+ return formatError(err);
2083
+ }
2084
+ });
2085
+ server.tool('update_project_document', 'Update a project document by ID. Requires project_documents:write scope.', {
2086
+ id: z.string().uuid().describe('Project document ID'),
2087
+ project_id: z.string().uuid().optional().describe('Project ID'),
2088
+ name: z.string().min(1).max(500).optional().describe('Document name'),
2089
+ file_path: z.string().max(2000).optional().describe('Storage path'),
2090
+ uploaded_by: z.string().max(200).optional().describe('Uploader user ID'),
2091
+ folder_id: z.string().uuid().optional().describe('Folder ID'),
2092
+ description: z.string().optional().describe('Description'),
2093
+ file_size: z.number().min(0).optional().describe('File size in bytes'),
2094
+ file_type: z.string().max(200).optional().describe('MIME type'),
2095
+ }, async ({ id, ...rest }) => {
2096
+ try {
2097
+ const result = await client.update('project-documents', id, buildBody(rest));
2098
+ return formatResult(result);
2099
+ }
2100
+ catch (err) {
2101
+ return formatError(err);
2102
+ }
2103
+ });
2104
+ server.tool('delete_project_document', 'Delete a project document by ID. Requires project_documents:write scope.', { id: z.string().uuid().describe('Project document ID') }, async ({ id }) => {
2105
+ try {
2106
+ const result = await client.remove('project-documents', id);
2107
+ return formatResult(result);
2108
+ }
2109
+ catch (err) {
2110
+ return formatError(err);
2111
+ }
2112
+ });
2113
+ // ============================================================
2114
+ // Contract Documents (scope: contract_documents)
2115
+ // ============================================================
2116
+ server.tool('create_contract_document', 'Create a contract document record. Requires contract_documents:write scope.', {
2117
+ contract_id: z.string().uuid().describe('Contract ID (required)'),
2118
+ file_name: z.string().min(1).max(500).describe('File name (required)'),
2119
+ file_path: z.string().min(1).max(2000).describe('Storage path from upload URL response (required)'),
2120
+ file_size: z.number().min(0).optional().describe('File size in bytes'),
2121
+ file_type: z.string().max(200).optional().describe('MIME type'),
2122
+ uploaded_by: z.string().max(200).optional().describe('Uploader user ID'),
2123
+ }, async (params) => {
2124
+ try {
2125
+ const result = await client.create('contract-documents', buildBody(params));
2126
+ return formatResult(result);
2127
+ }
2128
+ catch (err) {
2129
+ return formatError(err);
2130
+ }
2131
+ });
2132
+ server.tool('update_contract_document', 'Update a contract document by ID. Requires contract_documents:write scope.', {
2133
+ id: z.string().uuid().describe('Contract document ID'),
2134
+ contract_id: z.string().uuid().optional().describe('Contract ID'),
2135
+ file_name: z.string().max(500).optional().describe('File name'),
2136
+ file_path: z.string().max(2000).optional().describe('Storage path'),
2137
+ file_size: z.number().min(0).optional().describe('File size in bytes'),
2138
+ file_type: z.string().max(200).optional().describe('MIME type'),
2139
+ uploaded_by: z.string().max(200).optional().describe('Uploader user ID'),
2140
+ }, async ({ id, ...rest }) => {
2141
+ try {
2142
+ const result = await client.update('contract-documents', id, buildBody(rest));
2143
+ return formatResult(result);
2144
+ }
2145
+ catch (err) {
2146
+ return formatError(err);
2147
+ }
2148
+ });
2149
+ server.tool('delete_contract_document', 'Delete a contract document by ID. Requires contract_documents:write scope.', { id: z.string().uuid().describe('Contract document ID') }, async ({ id }) => {
2150
+ try {
2151
+ const result = await client.remove('contract-documents', id);
2152
+ return formatResult(result);
2153
+ }
2154
+ catch (err) {
2155
+ return formatError(err);
2156
+ }
2157
+ });
2158
+ // ============================================================
2159
+ // Project Team Members
2160
+ // ============================================================
2161
+ server.tool('create_project_team_member', 'Add a team member to a project. Requires project_team_members:write scope.', {
2162
+ project_id: z.string().uuid().describe('Project ID (required)'),
2163
+ user_id: z.string().min(1).max(200).describe('Clerk user ID (required)'),
2164
+ role: z.string().min(1).max(100).describe('Role on the project (required)'),
2165
+ responsibilities: z.string().optional().describe('Description of responsibilities'),
2166
+ start_date: z.string().optional().describe('Start date (ISO 8601)'),
2167
+ end_date: z.string().optional().describe('End date (ISO 8601)'),
2168
+ is_active: z.boolean().optional().describe('Whether member is currently active'),
2169
+ }, async (params) => {
2170
+ try {
2171
+ const result = await client.create('project-team-members', buildBody(params));
2172
+ return formatResult(result);
2173
+ }
2174
+ catch (err) {
2175
+ return formatError(err);
2176
+ }
2177
+ });
2178
+ server.tool('update_project_team_member', 'Update a project team member by ID. Requires project_team_members:write scope.', {
2179
+ id: z.string().uuid().describe('Project team member ID'),
2180
+ project_id: z.string().uuid().optional().describe('Project ID'),
2181
+ user_id: z.string().min(1).max(200).optional().describe('Clerk user ID'),
2182
+ role: z.string().min(1).max(100).optional().describe('Role on the project'),
2183
+ responsibilities: z.string().optional().describe('Description of responsibilities'),
2184
+ start_date: z.string().optional().describe('Start date (ISO 8601)'),
2185
+ end_date: z.string().optional().describe('End date (ISO 8601)'),
2186
+ is_active: z.boolean().optional().describe('Whether member is currently active'),
2187
+ }, async ({ id, ...rest }) => {
2188
+ try {
2189
+ const result = await client.update('project-team-members', id, buildBody(rest));
2190
+ return formatResult(result);
2191
+ }
2192
+ catch (err) {
2193
+ return formatError(err);
2194
+ }
2195
+ });
2196
+ server.tool('delete_project_team_member', 'Remove a team member from a project by ID. Requires project_team_members:write scope.', { id: z.string().uuid().describe('Project team member ID') }, async ({ id }) => {
2197
+ try {
2198
+ const result = await client.remove('project-team-members', id);
2199
+ return formatResult(result);
2200
+ }
2201
+ catch (err) {
2202
+ return formatError(err);
2203
+ }
2204
+ });
2205
+ // ============================================================
2206
+ // Project Task Dependencies
2207
+ // ============================================================
2208
+ server.tool('create_project_task_dependency', 'Create a dependency between two project tasks. Requires project_task_dependencies:write scope.', {
2209
+ task_id: z.string().uuid().describe('Task ID (the dependent task, required)'),
2210
+ depends_on_task_id: z.string().uuid().describe('Task ID that must complete first (required)'),
2211
+ dependency_type: z.enum(['finish_to_start', 'start_to_start', 'finish_to_finish', 'start_to_finish']).optional().describe('Dependency type (default: finish_to_start)'),
2212
+ }, async (params) => {
2213
+ try {
2214
+ const result = await client.create('project-task-dependencies', buildBody(params));
2215
+ return formatResult(result);
2216
+ }
2217
+ catch (err) {
2218
+ return formatError(err);
2219
+ }
2220
+ });
2221
+ server.tool('delete_project_task_dependency', 'Delete a task dependency by ID. Requires project_task_dependencies:write scope.', { id: z.string().uuid().describe('Project task dependency ID') }, async ({ id }) => {
2222
+ try {
2223
+ const result = await client.remove('project-task-dependencies', id);
2224
+ return formatResult(result);
2225
+ }
2226
+ catch (err) {
2227
+ return formatError(err);
2228
+ }
2229
+ });
2230
+ // ============================================================
2231
+ // Project Updates
2232
+ // ============================================================
2233
+ server.tool('create_project_update', 'Create a periodic project status update. Requires project_updates:write scope.', {
2234
+ project_id: z.string().uuid().describe('Project ID (required)'),
2235
+ author_id: z.string().min(1).max(200).describe('Author Clerk user ID (required)'),
2236
+ timeframe: z.enum(['monthly', 'quarterly', 'bi-annually', 'annually']).describe('Update timeframe (required)'),
2237
+ period_year: z.number().int().min(2000).max(2100).describe('Year for this update period (required)'),
2238
+ period_value: z.string().min(1).max(20).describe('Period value — 1-12 for monthly, 1-4 for quarterly, etc. (required)'),
2239
+ content: z.string().min(1).describe('Update content (required)'),
2240
+ title: z.string().max(500).optional().describe('Optional custom title'),
2241
+ }, async (params) => {
2242
+ try {
2243
+ const result = await client.create('project-updates', buildBody(params));
2244
+ return formatResult(result);
2245
+ }
2246
+ catch (err) {
2247
+ return formatError(err);
2248
+ }
2249
+ });
2250
+ server.tool('update_project_update', 'Update an existing project update by ID. Requires project_updates:write scope.', {
2251
+ id: z.string().uuid().describe('Project update ID'),
2252
+ project_id: z.string().uuid().optional().describe('Project ID'),
2253
+ author_id: z.string().min(1).max(200).optional().describe('Author Clerk user ID'),
2254
+ timeframe: z.enum(['monthly', 'quarterly', 'bi-annually', 'annually']).optional().describe('Update timeframe'),
2255
+ period_year: z.number().int().min(2000).max(2100).optional().describe('Year for this update period'),
2256
+ period_value: z.string().min(1).max(20).optional().describe('Period value'),
2257
+ content: z.string().min(1).optional().describe('Update content'),
2258
+ title: z.string().max(500).optional().describe('Optional custom title'),
2259
+ }, async ({ id, ...rest }) => {
2260
+ try {
2261
+ const result = await client.update('project-updates', id, buildBody(rest));
2262
+ return formatResult(result);
2263
+ }
2264
+ catch (err) {
2265
+ return formatError(err);
2266
+ }
2267
+ });
2268
+ server.tool('delete_project_update', 'Delete a project update by ID. Requires project_updates:write scope.', { id: z.string().uuid().describe('Project update ID') }, async ({ id }) => {
2269
+ try {
2270
+ const result = await client.remove('project-updates', id);
2271
+ return formatResult(result);
2272
+ }
2273
+ catch (err) {
2274
+ return formatError(err);
2275
+ }
2276
+ });
2277
+ // ============================================================
2278
+ // Project Cost Snapshots
2279
+ // ============================================================
2280
+ server.tool('create_project_cost_snapshot', 'Record a cost snapshot for a project at a point in time. Requires project_cost_snapshots:write scope.', {
2281
+ project_id: z.string().uuid().describe('Project ID (required)'),
2282
+ snapshot_date: z.string().describe('Snapshot date (ISO 8601, required)'),
2283
+ total_budget: z.number().min(0).describe('Total budget amount (required)'),
2284
+ actual_cost: z.number().min(0).describe('Actual cost to date (required)'),
2285
+ forecasted_cost: z.number().min(0).optional().describe('Forecasted total cost'),
2286
+ percent_complete: z.number().min(0).max(100).optional().describe('Completion percentage (0-100)'),
2287
+ }, async (params) => {
2288
+ try {
2289
+ const result = await client.create('project-cost-snapshots', buildBody(params));
2290
+ return formatResult(result);
2291
+ }
2292
+ catch (err) {
2293
+ return formatError(err);
2294
+ }
2295
+ });
2296
+ server.tool('delete_project_cost_snapshot', 'Delete a project cost snapshot by ID. Requires project_cost_snapshots:write scope.', { id: z.string().uuid().describe('Project cost snapshot ID') }, async ({ id }) => {
2297
+ try {
2298
+ const result = await client.remove('project-cost-snapshots', id);
2299
+ return formatResult(result);
2300
+ }
2301
+ catch (err) {
2302
+ return formatError(err);
2303
+ }
2304
+ });
2305
+ // ============================================================
2306
+ // Project Locations
2307
+ // ============================================================
2308
+ server.tool('create_project_location', 'Link a location to a project. Requires project_locations:write scope.', {
2309
+ project_id: z.string().uuid().describe('Project ID (required)'),
2310
+ location_id: z.string().uuid().describe('Location ID (required)'),
2311
+ }, async (params) => {
2312
+ try {
2313
+ const result = await client.create('project-locations', buildBody(params));
2314
+ return formatResult(result);
2315
+ }
2316
+ catch (err) {
2317
+ return formatError(err);
2318
+ }
2319
+ });
2320
+ server.tool('delete_project_location', 'Remove a location from a project by ID. Requires project_locations:write scope.', { id: z.string().uuid().describe('Project location ID') }, async ({ id }) => {
2321
+ try {
2322
+ const result = await client.remove('project-locations', id);
2323
+ return formatResult(result);
2324
+ }
2325
+ catch (err) {
2326
+ return formatError(err);
2327
+ }
2328
+ });
2329
+ // ============================================================
1940
2330
  // Bulk operations
1941
2331
  // ============================================================
1942
2332
  const BULK_RESOURCES = [
@@ -1948,9 +2338,12 @@ export function registerWriteTools(server, client) {
1948
2338
  'asset-comments', 'asset-costs', 'asset-replacement-plans',
1949
2339
  'work-order-comments', 'project-tasks', 'project-milestones',
1950
2340
  'project-phases', 'project-budget-items', 'project-time-entries',
1951
- 'project-comments', 'parts', 'part-categories',
2341
+ 'project-comments', 'project-team-members', 'project-task-dependencies',
2342
+ 'project-updates', 'project-cost-snapshots', 'project-locations',
2343
+ 'parts', 'part-categories',
1952
2344
  'custom-field-definitions', 'custom-field-values',
1953
2345
  'vendor-site-assignments', 'contract-sites',
2346
+ 'asset-documents', 'attachments', 'project-documents', 'contract-documents',
1954
2347
  ];
1955
2348
  server.tool('bulk_create', 'Create multiple records of a resource type in one API call (max 100). Each item is processed independently — one failure does not affect others. Returns per-item results. Requires {resource}:write scope. Counts as 1 request for rate limiting.', {
1956
2349
  resource: z.enum(BULK_RESOURCES).describe('Resource type (e.g. "assets", "work-orders")'),