@dod/planax-mcp 0.1.4 → 0.2.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/README.md +26 -18
- package/dist/api-client.js +11 -4
- package/dist/server.js +4 -1
- package/dist/tools/comment.tools.js +27 -5
- package/dist/tools/document.tools.js +278 -134
- package/dist/tools/folder.tools.js +40 -17
- package/dist/tools/plan-items.tools.js +8 -4
- package/dist/tools/plan.tools.js +53 -22
- package/dist/tools/project.tools.js +22 -0
- package/dist/tools/resource-link.tools.js +14 -7
- package/dist/tools/shared.js +23 -0
- package/dist/tools/task.tools.js +80 -64
- package/dist/tools/workspace.tools.js +59 -0
- package/package.json +5 -3
|
@@ -2,6 +2,21 @@ import { readFile } from 'node:fs/promises';
|
|
|
2
2
|
import { basename } from 'node:path';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { successResponse, errorResponse } from './types.js';
|
|
5
|
+
import { DateOnlySchema, DocumentStatusSchema } from './shared.js';
|
|
6
|
+
const EMPTY_VALIDITY = { effectiveDate: null, effectiveEndDate: null, nextReviewDate: null };
|
|
7
|
+
/** 버전 목록을 끝까지 넘기며 versionId 의 현재 유효기간을 찾는다. 없으면 null */
|
|
8
|
+
async function findVersionValidity(apiClient, projectId, documentId, versionId) {
|
|
9
|
+
for (let page = 1;; page++) {
|
|
10
|
+
const res = await apiClient.get(`/projects/${projectId}/documents/${documentId}/versions?page=${page}&limit=100`);
|
|
11
|
+
const row = res.versions.find((v) => v.id === versionId);
|
|
12
|
+
if (row) {
|
|
13
|
+
const v = row.validity ?? EMPTY_VALIDITY;
|
|
14
|
+
return { effectiveDate: v.effectiveDate, effectiveEndDate: v.effectiveEndDate, nextReviewDate: v.nextReviewDate };
|
|
15
|
+
}
|
|
16
|
+
if (!res.totalPages || page >= res.totalPages)
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
5
20
|
const MAX_UPLOAD_BYTES = 50 * 1024 * 1024;
|
|
6
21
|
const MIME_BY_EXTENSION = {
|
|
7
22
|
pdf: 'application/pdf',
|
|
@@ -73,54 +88,68 @@ async function loadFilePart(filePath, contentBase64, fileName) {
|
|
|
73
88
|
export function register({ server, apiClient }) {
|
|
74
89
|
// ===== Document List =====
|
|
75
90
|
server.registerTool('document_list', {
|
|
76
|
-
description: `List
|
|
91
|
+
description: `List documents in a project with optional filtering. Returns the whole list (no pagination).
|
|
77
92
|
|
|
78
93
|
**When to use:**
|
|
79
94
|
- View all documents in a project
|
|
80
|
-
- Filter
|
|
81
|
-
-
|
|
82
|
-
-
|
|
83
|
-
- Search documents by title
|
|
95
|
+
- Filter by status, type (FILE, MARKDOWN, PLACEHOLDER, LINK), assignee, due date, or risk/order issues
|
|
96
|
+
- Browse documents in a specific folder, or only those at the root
|
|
97
|
+
- Search documents by title or description
|
|
84
98
|
|
|
85
99
|
**Examples:**
|
|
86
100
|
1. List all documents in a project:
|
|
87
101
|
{ projectId: "..." }
|
|
88
102
|
|
|
89
|
-
2. Filter by status:
|
|
103
|
+
2. Filter by status / type:
|
|
90
104
|
{ projectId: "...", status: "APPROVED" }
|
|
105
|
+
{ projectId: "...", type: "MARKDOWN" }
|
|
91
106
|
|
|
92
|
-
3.
|
|
107
|
+
3. Documents in a folder / only at the root:
|
|
93
108
|
{ projectId: "...", folderId: "folder-uuid" }
|
|
109
|
+
{ projectId: "...", rootOnly: true }
|
|
94
110
|
|
|
95
|
-
4.
|
|
96
|
-
{ projectId: "...",
|
|
111
|
+
4. My documents due by the end of January:
|
|
112
|
+
{ projectId: "...", assigneeId: "user-uuid", dueDateBefore: "2027-01-31" }
|
|
97
113
|
|
|
98
|
-
5. Search documents:
|
|
114
|
+
5. Search documents (title and description):
|
|
99
115
|
{ projectId: "...", search: "protocol" }
|
|
100
116
|
|
|
101
|
-
**Returns:**
|
|
117
|
+
**Returns:** Array of documents (same fields as document_get)`,
|
|
102
118
|
inputSchema: {
|
|
103
119
|
projectId: z.string().uuid().describe('Project ID (UUID) - required'),
|
|
104
|
-
folderId: z.string().uuid().optional().describe('
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
search: z.string().optional().describe('Search in title'),
|
|
120
|
+
folderId: z.string().uuid().optional().describe('Only documents in this folder'),
|
|
121
|
+
rootOnly: z.boolean().optional().describe('Only documents at the root (not in any folder). Do not combine with folderId'),
|
|
122
|
+
status: DocumentStatusSchema.optional().describe('Filter by document status'),
|
|
123
|
+
type: z.enum(['FILE', 'MARKDOWN', 'PLACEHOLDER', 'LINK']).optional().describe('Filter by document type'),
|
|
124
|
+
assigneeId: z.string().uuid().optional().describe('Filter by assignee user ID'),
|
|
125
|
+
dueDateBefore: DateOnlySchema.optional().describe('Expected end date on or before this date (YYYY-MM-DD)'),
|
|
126
|
+
riskyIssueOnly: z.boolean().optional().describe('Only documents with guideline (risk) issues'),
|
|
127
|
+
orderIssueOnly: z.boolean().optional().describe('Only documents with order issues'),
|
|
128
|
+
search: z.string().optional().describe('Search in title and description'),
|
|
114
129
|
},
|
|
115
|
-
}, async ({ projectId, folderId, status, type, search }) => {
|
|
130
|
+
}, async ({ projectId, folderId, rootOnly, status, type, assigneeId, dueDateBefore, riskyIssueOnly, orderIssueOnly, search }) => {
|
|
116
131
|
try {
|
|
132
|
+
if (rootOnly && folderId) {
|
|
133
|
+
return errorResponse(new Error('Use either folderId or rootOnly, not both'));
|
|
134
|
+
}
|
|
117
135
|
const params = new URLSearchParams();
|
|
118
|
-
|
|
136
|
+
// 백엔드: folderId 가 빈 문자열이면 루트만, 빼면 전체
|
|
137
|
+
if (rootOnly)
|
|
138
|
+
params.append('folderId', '');
|
|
139
|
+
else if (folderId)
|
|
119
140
|
params.append('folderId', folderId);
|
|
120
141
|
if (status)
|
|
121
142
|
params.append('status', status);
|
|
122
143
|
if (type)
|
|
123
144
|
params.append('type', type);
|
|
145
|
+
if (assigneeId)
|
|
146
|
+
params.append('assigneeId', assigneeId);
|
|
147
|
+
if (dueDateBefore)
|
|
148
|
+
params.append('dueDateBefore', dueDateBefore);
|
|
149
|
+
if (riskyIssueOnly)
|
|
150
|
+
params.append('riskyIssueOnly', 'true');
|
|
151
|
+
if (orderIssueOnly)
|
|
152
|
+
params.append('orderIssueOnly', 'true');
|
|
124
153
|
if (search)
|
|
125
154
|
params.append('search', search);
|
|
126
155
|
const queryString = params.toString();
|
|
@@ -137,21 +166,20 @@ export function register({ server, apiClient }) {
|
|
|
137
166
|
description: `Get detailed information about a specific document.
|
|
138
167
|
|
|
139
168
|
**When to use:**
|
|
140
|
-
- View full document details
|
|
141
|
-
- Check document metadata (file size, mime type, etc.)
|
|
142
|
-
- See version information
|
|
143
|
-
- View uploader and creation date
|
|
169
|
+
- View full document details: status, dates, assignee, phase, current version and its validity
|
|
144
170
|
|
|
145
171
|
**Examples:**
|
|
146
172
|
1. Get document details:
|
|
147
|
-
{ documentId: "
|
|
148
|
-
|
|
149
|
-
**Returns:** Document object
|
|
150
|
-
- id, title, description, status
|
|
151
|
-
-
|
|
152
|
-
-
|
|
153
|
-
- tags
|
|
154
|
-
-
|
|
173
|
+
{ projectId: "...", documentId: "..." }
|
|
174
|
+
|
|
175
|
+
**Returns:** Document object:
|
|
176
|
+
- id, title, description, projectId, documentType (FILE | MARKDOWN | PLACEHOLDER | LINK), status
|
|
177
|
+
- fileName, fileKey, mimeType, fileSize, uploadedBy (user id)
|
|
178
|
+
- version (current version number), versionLabel, currentVersionValidity { effectiveDate, effectiveEndDate, nextReviewDate, validityStatus, validityDays }
|
|
179
|
+
- folderId, tags, phaseId, phasePath
|
|
180
|
+
- startDate, expectedEndDate, actualEndDate, assigneeId, assigneeName, reviewerId, authorId
|
|
181
|
+
- riskAlerts, copyStatus, createdAt, updatedAt
|
|
182
|
+
The external URL of a LINK document is not in this response.`,
|
|
155
183
|
inputSchema: {
|
|
156
184
|
projectId: z.string().uuid().describe('Project ID (UUID)'),
|
|
157
185
|
documentId: z.string().uuid().describe('Document ID (UUID)'),
|
|
@@ -167,15 +195,15 @@ export function register({ server, apiClient }) {
|
|
|
167
195
|
});
|
|
168
196
|
// ===== Document Update =====
|
|
169
197
|
server.registerTool('document_update', {
|
|
170
|
-
description: `Update document metadata.
|
|
198
|
+
description: `Update document metadata (not the file or markdown body).
|
|
171
199
|
|
|
172
200
|
**When to use:**
|
|
173
|
-
- Change
|
|
174
|
-
-
|
|
175
|
-
-
|
|
176
|
-
- Update document metadata without changing the file itself
|
|
201
|
+
- Change title, description, status or tags
|
|
202
|
+
- Set or clear dates, assignee or reviewer
|
|
203
|
+
- Move to another folder or link to a phase
|
|
177
204
|
|
|
178
|
-
**
|
|
205
|
+
**Clearing:** send null for startDate, expectedEndDate, actualEndDate, assigneeId or reviewerId to clear it.
|
|
206
|
+
Dates are YYYY-MM-DD. To replace the file use document_replace_file; for markdown body use document_update_markdown_content.
|
|
179
207
|
|
|
180
208
|
**Examples:**
|
|
181
209
|
1. Update title:
|
|
@@ -184,24 +212,11 @@ export function register({ server, apiClient }) {
|
|
|
184
212
|
2. Change status to approved:
|
|
185
213
|
{ projectId: "...", documentId: "...", status: "APPROVED" }
|
|
186
214
|
|
|
187
|
-
3.
|
|
188
|
-
{
|
|
189
|
-
projectId: "...",
|
|
190
|
-
documentId: "...",
|
|
191
|
-
title: "Final Protocol",
|
|
192
|
-
description: "Approved by IRB on 2024-03-15",
|
|
193
|
-
status: "APPROVED",
|
|
194
|
-
tags: ["approved", "irb", "2024"]
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
4. Update tags only:
|
|
198
|
-
{ projectId: "...", documentId: "...", tags: ["review", "pending-approval"] }
|
|
199
|
-
|
|
200
|
-
5. Assign document to a user:
|
|
201
|
-
{ projectId: "...", documentId: "...", assigneeId: "user-uuid" }
|
|
215
|
+
3. Set dates and reviewer:
|
|
216
|
+
{ projectId: "...", documentId: "...", startDate: "2027-01-01", expectedEndDate: "2027-02-15", reviewerId: "user-uuid" }
|
|
202
217
|
|
|
203
|
-
|
|
204
|
-
{ projectId: "...", documentId: "...", assigneeId: null }
|
|
218
|
+
4. Clear the assignee and the due date:
|
|
219
|
+
{ projectId: "...", documentId: "...", assigneeId: null, expectedEndDate: null }
|
|
205
220
|
|
|
206
221
|
**Returns:** Updated document object`,
|
|
207
222
|
inputSchema: {
|
|
@@ -209,26 +224,20 @@ export function register({ server, apiClient }) {
|
|
|
209
224
|
documentId: z.string().uuid().describe('Document ID (UUID) - required'),
|
|
210
225
|
title: z.string().min(1).max(255).optional().describe('New document title'),
|
|
211
226
|
description: z.string().optional().describe('New document description'),
|
|
212
|
-
status:
|
|
213
|
-
.enum(['DRAFT', 'REVIEW', 'APPROVED', 'ARCHIVED', 'REJECTED'])
|
|
214
|
-
.optional()
|
|
215
|
-
.describe('New document status'),
|
|
227
|
+
status: DocumentStatusSchema.optional().describe('New document status'),
|
|
216
228
|
tags: z.array(z.string()).optional().describe('New tags (replaces existing)'),
|
|
217
|
-
|
|
229
|
+
folderId: z.string().uuid().optional().describe('Move to this folder'),
|
|
230
|
+
startDate: DateOnlySchema.nullable().optional().describe('Start date (YYYY-MM-DD), null to clear'),
|
|
231
|
+
expectedEndDate: DateOnlySchema.nullable().optional().describe('Expected end (due) date (YYYY-MM-DD), null to clear'),
|
|
232
|
+
actualEndDate: DateOnlySchema.nullable().optional().describe('Actual end date (YYYY-MM-DD), null to clear'),
|
|
233
|
+
assigneeId: z.string().uuid().nullable().optional().describe('Assignee user ID, null to unassign'),
|
|
234
|
+
reviewerId: z.string().uuid().nullable().optional().describe('Reviewer user ID, null to clear'),
|
|
235
|
+
phaseId: z.string().uuid().optional().describe('Link to this phase'),
|
|
218
236
|
},
|
|
219
|
-
}, async ({ projectId, documentId,
|
|
237
|
+
}, async ({ projectId, documentId, ...fields }) => {
|
|
220
238
|
try {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
updateData.title = title;
|
|
224
|
-
if (description !== undefined)
|
|
225
|
-
updateData.description = description;
|
|
226
|
-
if (status !== undefined)
|
|
227
|
-
updateData.status = status;
|
|
228
|
-
if (tags !== undefined)
|
|
229
|
-
updateData.tags = tags;
|
|
230
|
-
if (assigneeId !== undefined)
|
|
231
|
-
updateData.assigneeId = assigneeId;
|
|
239
|
+
// undefined 만 빼고 보낸다. null 은 지우기라 그대로 보낸다
|
|
240
|
+
const updateData = Object.fromEntries(Object.entries(fields).filter(([, v]) => v !== undefined));
|
|
232
241
|
const result = await apiClient.patch(`/projects/${projectId}/documents/${documentId}`, updateData);
|
|
233
242
|
return successResponse(result, 'Document updated successfully');
|
|
234
243
|
}
|
|
@@ -242,14 +251,14 @@ export function register({ server, apiClient }) {
|
|
|
242
251
|
|
|
243
252
|
**When to use:**
|
|
244
253
|
- Remove a document that is no longer needed
|
|
245
|
-
- Archive outdated documents
|
|
246
|
-
- Clean up rejected or obsolete files
|
|
247
254
|
|
|
248
|
-
**Note:**
|
|
255
|
+
**Note:**
|
|
256
|
+
- The document moves to the trash and can be restored (document_list_trash, document_restore).
|
|
257
|
+
- Fails (400) while a signature process is in progress on the document.
|
|
249
258
|
|
|
250
259
|
**Examples:**
|
|
251
260
|
1. Delete a document:
|
|
252
|
-
{ documentId: "
|
|
261
|
+
{ projectId: "...", documentId: "..." }
|
|
253
262
|
|
|
254
263
|
**Returns:** Success confirmation`,
|
|
255
264
|
inputSchema: {
|
|
@@ -276,10 +285,10 @@ export function register({ server, apiClient }) {
|
|
|
276
285
|
|
|
277
286
|
**Examples:**
|
|
278
287
|
1. Move to a folder:
|
|
279
|
-
{ documentId: "...", targetFolderId: "folder-uuid" }
|
|
288
|
+
{ projectId: "...", documentId: "...", targetFolderId: "folder-uuid" }
|
|
280
289
|
|
|
281
290
|
2. Move to root (no folder):
|
|
282
|
-
{ documentId: "...", targetFolderId: null }
|
|
291
|
+
{ projectId: "...", documentId: "...", targetFolderId: null }
|
|
283
292
|
|
|
284
293
|
**Returns:** Updated document with new folder location`,
|
|
285
294
|
inputSchema: {
|
|
@@ -299,36 +308,6 @@ export function register({ server, apiClient }) {
|
|
|
299
308
|
return errorResponse(error);
|
|
300
309
|
}
|
|
301
310
|
});
|
|
302
|
-
// ===== Document Get Related =====
|
|
303
|
-
server.registerTool('document_get_related', {
|
|
304
|
-
description: `Get related information for a document.
|
|
305
|
-
|
|
306
|
-
**When to use:**
|
|
307
|
-
- Find which tasks reference this document
|
|
308
|
-
- Find which phases this document is linked to
|
|
309
|
-
- Discover related documents
|
|
310
|
-
|
|
311
|
-
**Examples:**
|
|
312
|
-
1. Get related info:
|
|
313
|
-
{ documentId: "document-uuid" }
|
|
314
|
-
|
|
315
|
-
**Returns:** Object containing:
|
|
316
|
-
- relatedDocuments: Other documents related to this one
|
|
317
|
-
- linkedTasks: Tasks that reference this document
|
|
318
|
-
- linkedPhases: Plan phases this document is linked to`,
|
|
319
|
-
inputSchema: {
|
|
320
|
-
projectId: z.string().uuid().describe('Project ID (UUID)'),
|
|
321
|
-
documentId: z.string().uuid().describe('Document ID (UUID)'),
|
|
322
|
-
},
|
|
323
|
-
}, async ({ projectId, documentId }) => {
|
|
324
|
-
try {
|
|
325
|
-
const result = await apiClient.get(`/projects/${projectId}/documents/${documentId}/related`);
|
|
326
|
-
return successResponse(result);
|
|
327
|
-
}
|
|
328
|
-
catch (error) {
|
|
329
|
-
return errorResponse(error);
|
|
330
|
-
}
|
|
331
|
-
});
|
|
332
311
|
// ===== Document Get Markdown Content =====
|
|
333
312
|
server.registerTool('document_get_markdown_content', {
|
|
334
313
|
description: `Get the markdown content of a document.
|
|
@@ -342,7 +321,7 @@ export function register({ server, apiClient }) {
|
|
|
342
321
|
|
|
343
322
|
**Examples:**
|
|
344
323
|
1. Get markdown content:
|
|
345
|
-
{ documentId: "
|
|
324
|
+
{ projectId: "...", documentId: "..." }
|
|
346
325
|
|
|
347
326
|
**Returns:** Object with markdown content string`,
|
|
348
327
|
inputSchema: {
|
|
@@ -369,19 +348,23 @@ export function register({ server, apiClient }) {
|
|
|
369
348
|
|
|
370
349
|
**Note:**
|
|
371
350
|
- Only works for documents with type MARKDOWN
|
|
372
|
-
-
|
|
351
|
+
- By default, overwrites the content of the current version (the version number does not change, changeReason is ignored)
|
|
352
|
+
- Set createNewVersion: true to create a new version; changeReason is then recorded in the version history
|
|
373
353
|
|
|
374
354
|
**Examples:**
|
|
375
|
-
1.
|
|
355
|
+
1. Overwrite the current version:
|
|
376
356
|
{
|
|
357
|
+
projectId: "...",
|
|
377
358
|
documentId: "...",
|
|
378
359
|
content: "# Updated Title\\n\\nNew content here..."
|
|
379
360
|
}
|
|
380
361
|
|
|
381
|
-
2.
|
|
362
|
+
2. Create a new version with a change reason:
|
|
382
363
|
{
|
|
364
|
+
projectId: "...",
|
|
383
365
|
documentId: "...",
|
|
384
366
|
content: "# Protocol v2\\n\\nUpdated protocol...",
|
|
367
|
+
createNewVersion: true,
|
|
385
368
|
changeReason: "Updated based on review feedback"
|
|
386
369
|
}
|
|
387
370
|
|
|
@@ -389,13 +372,22 @@ export function register({ server, apiClient }) {
|
|
|
389
372
|
inputSchema: {
|
|
390
373
|
projectId: z.string().uuid().describe('Project ID (UUID)'),
|
|
391
374
|
documentId: z.string().uuid().describe('Document ID (UUID) - must be MARKDOWN type'),
|
|
392
|
-
content: z.string().describe('New markdown content'),
|
|
393
|
-
|
|
375
|
+
content: z.string().min(1).describe('New markdown content (cannot be empty)'),
|
|
376
|
+
createNewVersion: z
|
|
377
|
+
.boolean()
|
|
378
|
+
.optional()
|
|
379
|
+
.describe('true: create a new version. false or omitted (default): overwrite the current version'),
|
|
380
|
+
changeReason: z
|
|
381
|
+
.string()
|
|
382
|
+
.max(500)
|
|
383
|
+
.optional()
|
|
384
|
+
.describe('Reason for the change, recorded in the version history. Used only when createNewVersion is true'),
|
|
394
385
|
},
|
|
395
|
-
}, async ({ projectId, documentId, content, changeReason }) => {
|
|
386
|
+
}, async ({ projectId, documentId, content, createNewVersion, changeReason }) => {
|
|
396
387
|
try {
|
|
397
388
|
const result = await apiClient.patch(`/projects/${projectId}/documents/${documentId}/content`, {
|
|
398
389
|
content,
|
|
390
|
+
createNewVersion: createNewVersion ?? false,
|
|
399
391
|
changeReason,
|
|
400
392
|
});
|
|
401
393
|
return successResponse(result, 'Markdown content updated successfully');
|
|
@@ -436,7 +428,7 @@ export function register({ server, apiClient }) {
|
|
|
436
428
|
inputSchema: {
|
|
437
429
|
projectId: z.string().uuid().describe('Project ID (UUID) - required'),
|
|
438
430
|
title: z.string().min(1).max(255).describe('Document title (required)'),
|
|
439
|
-
content: z.string().describe('Initial markdown content'),
|
|
431
|
+
content: z.string().optional().describe('Initial markdown content (optional)'),
|
|
440
432
|
description: z.string().optional().describe('Document description'),
|
|
441
433
|
folderId: z.string().uuid().optional().describe('Folder ID to place document in'),
|
|
442
434
|
tags: z.array(z.string()).optional().describe('Tags for categorization'),
|
|
@@ -461,29 +453,32 @@ export function register({ server, apiClient }) {
|
|
|
461
453
|
description: `Get version history of a document.
|
|
462
454
|
|
|
463
455
|
**When to use:**
|
|
464
|
-
- View all
|
|
465
|
-
-
|
|
466
|
-
- Find a specific version to download or review
|
|
456
|
+
- View all versions of a document and their signature / validity status
|
|
457
|
+
- Find a version id to set its validity period (document_update_version_validity) or download it
|
|
467
458
|
|
|
468
459
|
**Examples:**
|
|
469
|
-
1. Get
|
|
470
|
-
{ documentId: "
|
|
460
|
+
1. Get versions:
|
|
461
|
+
{ projectId: "...", documentId: "..." }
|
|
471
462
|
|
|
472
463
|
2. With pagination:
|
|
473
|
-
{ documentId: "...", page: 1, limit: 10 }
|
|
464
|
+
{ projectId: "...", documentId: "...", page: 1, limit: 10 }
|
|
474
465
|
|
|
475
|
-
**Returns:**
|
|
476
|
-
|
|
477
|
-
-
|
|
478
|
-
-
|
|
479
|
-
-
|
|
466
|
+
**Returns:** { versions, total, page, limit, totalPages }. The FIRST row is the current version; the rest follow by version number (newest first).
|
|
467
|
+
Each row:
|
|
468
|
+
- id (= versionId for document_update_version_validity), version, versionLabel, fileName, mimeType, fileSize, changeReason
|
|
469
|
+
- createdAt, createdBy, createdByName, canDelete, isArchived
|
|
470
|
+
- versionSignatureStatus, requiredSignatureCount, signedRequiredSignatureCount, signedDocumentStatus, signedDocumentId
|
|
471
|
+
- validity { effectiveDate, effectiveEndDate, nextReviewDate, validityStatus: NONE | SCHEDULED | ACTIVE | EXPIRED, validityDays } (workspace timezone)
|
|
472
|
+
|
|
473
|
+
content (markdown body of each version) and signedUrl (download URL) are left out unless includeContent: true, because they make the response very large.`,
|
|
480
474
|
inputSchema: {
|
|
481
475
|
projectId: z.string().uuid().describe('Project ID (UUID)'),
|
|
482
476
|
documentId: z.string().uuid().describe('Document ID (UUID)'),
|
|
483
477
|
page: z.number().int().min(1).optional().describe('Page number (default: 1)'),
|
|
484
478
|
limit: z.number().int().min(1).max(100).optional().describe('Items per page (default: 20)'),
|
|
479
|
+
includeContent: z.boolean().optional().describe('Include markdown content and download URL of each version (large)'),
|
|
485
480
|
},
|
|
486
|
-
}, async ({ projectId, documentId, page, limit }) => {
|
|
481
|
+
}, async ({ projectId, documentId, page, limit, includeContent }) => {
|
|
487
482
|
try {
|
|
488
483
|
const params = new URLSearchParams();
|
|
489
484
|
if (page)
|
|
@@ -493,12 +488,71 @@ export function register({ server, apiClient }) {
|
|
|
493
488
|
const queryString = params.toString();
|
|
494
489
|
const url = `/projects/${projectId}/documents/${documentId}/versions${queryString ? `?${queryString}` : ''}`;
|
|
495
490
|
const result = await apiClient.get(url);
|
|
491
|
+
if (!includeContent && Array.isArray(result?.versions)) {
|
|
492
|
+
result.versions = result.versions.map(({ content: _content, signedUrl: _signedUrl, ...rest }) => rest);
|
|
493
|
+
}
|
|
496
494
|
return successResponse(result);
|
|
497
495
|
}
|
|
498
496
|
catch (error) {
|
|
499
497
|
return errorResponse(error);
|
|
500
498
|
}
|
|
501
499
|
});
|
|
500
|
+
// ===== Document Update Version Validity =====
|
|
501
|
+
server.registerTool('document_update_version_validity', {
|
|
502
|
+
description: `Set the validity period of one document version: effective (start) date, effective end date, next review date.
|
|
503
|
+
|
|
504
|
+
**When to use:**
|
|
505
|
+
- After uploading/replacing a file or saving a new markdown version, record when that version is valid
|
|
506
|
+
- Change or clear a version's validity dates
|
|
507
|
+
|
|
508
|
+
**Flow:** document_get_versions -> pick the version's \`id\` (the first row is the current version) -> this tool.
|
|
509
|
+
|
|
510
|
+
**Important:** The three dates are replaced together. A date you leave out is CLEARED, unless you pass \`keepOthers: true\`
|
|
511
|
+
(then this tool reads the version's current dates first and keeps the ones you did not send).
|
|
512
|
+
|
|
513
|
+
**Rules (backend returns 400):**
|
|
514
|
+
- effectiveEndDate needs effectiveDate
|
|
515
|
+
- effectiveEndDate cannot be before effectiveDate
|
|
516
|
+
- PLACEHOLDER and LINK documents have no validity; documents still being copied cannot be changed
|
|
517
|
+
- Viewers cannot change validity
|
|
518
|
+
Signed versions and versions in a signature process can still be changed.
|
|
519
|
+
|
|
520
|
+
Status in responses: NONE (no period), SCHEDULED (before start), ACTIVE, EXPIRED. validityDays = days left (ACTIVE) or days since end (EXPIRED). Dates use the workspace timezone.
|
|
521
|
+
|
|
522
|
+
**Example:** { projectId: "...", documentId: "...", versionId: "...", effectiveDate: "2027-01-01", effectiveEndDate: "2027-12-31", nextReviewDate: "2027-06-30" }
|
|
523
|
+
|
|
524
|
+
**Returns:** The updated version row (same shape as one row of document_get_versions)`,
|
|
525
|
+
inputSchema: {
|
|
526
|
+
projectId: z.string().uuid().describe('Project ID (UUID)'),
|
|
527
|
+
documentId: z.string().uuid().describe('Document ID (UUID)'),
|
|
528
|
+
versionId: z.string().uuid().describe('Version ID: the `id` of a row from document_get_versions'),
|
|
529
|
+
effectiveDate: DateOnlySchema.nullable().optional().describe('Effective (start) date, YYYY-MM-DD. null clears'),
|
|
530
|
+
effectiveEndDate: DateOnlySchema.nullable().optional().describe('Effective end date, YYYY-MM-DD. null clears'),
|
|
531
|
+
nextReviewDate: DateOnlySchema.nullable().optional().describe('Next review date, YYYY-MM-DD. null clears'),
|
|
532
|
+
keepOthers: z.boolean().optional().describe('Keep current values for dates you do not send (default false = clear them)'),
|
|
533
|
+
},
|
|
534
|
+
}, async ({ projectId, documentId, versionId, effectiveDate, effectiveEndDate, nextReviewDate, keepOthers }) => {
|
|
535
|
+
try {
|
|
536
|
+
let current = EMPTY_VALIDITY;
|
|
537
|
+
if (keepOthers) {
|
|
538
|
+
const found = await findVersionValidity(apiClient, projectId, documentId, versionId);
|
|
539
|
+
if (!found) {
|
|
540
|
+
return errorResponse(new Error(`Version ${versionId} is not in this document's version list`));
|
|
541
|
+
}
|
|
542
|
+
current = found;
|
|
543
|
+
}
|
|
544
|
+
const body = {
|
|
545
|
+
effectiveDate: effectiveDate !== undefined ? effectiveDate : current.effectiveDate,
|
|
546
|
+
effectiveEndDate: effectiveEndDate !== undefined ? effectiveEndDate : current.effectiveEndDate,
|
|
547
|
+
nextReviewDate: nextReviewDate !== undefined ? nextReviewDate : current.nextReviewDate,
|
|
548
|
+
};
|
|
549
|
+
const result = await apiClient.patch(`/projects/${projectId}/documents/${documentId}/versions/${versionId}/validity`, body);
|
|
550
|
+
return successResponse(result, 'Version validity updated');
|
|
551
|
+
}
|
|
552
|
+
catch (error) {
|
|
553
|
+
return errorResponse(error);
|
|
554
|
+
}
|
|
555
|
+
});
|
|
502
556
|
// ===== Document Create Placeholder =====
|
|
503
557
|
server.registerTool('document_create_placeholder', {
|
|
504
558
|
description: `Create a placeholder document to be filled later.
|
|
@@ -687,13 +741,14 @@ export function register({ server, apiClient }) {
|
|
|
687
741
|
- Not allowed while a signature process is in progress on the document (cancel it first in the web app)
|
|
688
742
|
- A MARKDOWN document becomes a FILE document; its previous text stays in version history
|
|
689
743
|
- If the replaced version went through signing, the document status resets to DRAFT
|
|
744
|
+
- You can set the new version's validity dates (effectiveDate, effectiveEndDate, nextReviewDate). Wrong dates fail with 400 before the file is uploaded. Later changes: document_update_version_validity
|
|
690
745
|
|
|
691
746
|
**Input:** Provide either \`filePath\` (absolute path on the machine running this MCP server) or \`contentBase64\` with \`fileName\`. Max 50MB.
|
|
692
747
|
|
|
693
748
|
**Example:**
|
|
694
749
|
{ projectId: "...", documentId: "...", filePath: "/Users/me/Documents/protocol_v2.pdf", changeReason: "IRB 의견 반영" }
|
|
695
750
|
|
|
696
|
-
**Returns:** Updated document (new version number)`,
|
|
751
|
+
**Returns:** Updated document (new version number, currentVersionValidity)`,
|
|
697
752
|
inputSchema: {
|
|
698
753
|
projectId: z.string().uuid().describe('Project ID (UUID) - required'),
|
|
699
754
|
documentId: z.string().uuid().describe('Document ID (UUID) to replace the file of'),
|
|
@@ -702,8 +757,11 @@ export function register({ server, apiClient }) {
|
|
|
702
757
|
fileName: z.string().optional().describe('File name with extension (required with contentBase64)'),
|
|
703
758
|
changeReason: z.string().max(500).optional().describe('Reason shown in version history'),
|
|
704
759
|
versionLabel: z.string().optional().describe('Version label (e.g., "v2.0")'),
|
|
760
|
+
effectiveDate: DateOnlySchema.optional().describe('Validity start of the new version, YYYY-MM-DD'),
|
|
761
|
+
effectiveEndDate: DateOnlySchema.optional().describe('Validity end of the new version, YYYY-MM-DD (needs effectiveDate)'),
|
|
762
|
+
nextReviewDate: DateOnlySchema.optional().describe('Next review date of the new version, YYYY-MM-DD'),
|
|
705
763
|
},
|
|
706
|
-
}, async ({ projectId, documentId, filePath, contentBase64, fileName, changeReason, versionLabel }) => {
|
|
764
|
+
}, async ({ projectId, documentId, filePath, contentBase64, fileName, changeReason, versionLabel, effectiveDate, effectiveEndDate, nextReviewDate }) => {
|
|
707
765
|
try {
|
|
708
766
|
const { blob, name } = await loadFilePart(filePath, contentBase64, fileName);
|
|
709
767
|
const form = new FormData();
|
|
@@ -712,6 +770,12 @@ export function register({ server, apiClient }) {
|
|
|
712
770
|
form.append('changeReason', changeReason);
|
|
713
771
|
if (versionLabel)
|
|
714
772
|
form.append('versionLabel', versionLabel);
|
|
773
|
+
if (effectiveDate)
|
|
774
|
+
form.append('effectiveDate', effectiveDate);
|
|
775
|
+
if (effectiveEndDate)
|
|
776
|
+
form.append('effectiveEndDate', effectiveEndDate);
|
|
777
|
+
if (nextReviewDate)
|
|
778
|
+
form.append('nextReviewDate', nextReviewDate);
|
|
715
779
|
const result = await apiClient.patchForm(`/projects/${projectId}/documents/${documentId}/replace-file`, form);
|
|
716
780
|
return successResponse(result, `File replaced with "${name}" (new version)`);
|
|
717
781
|
}
|
|
@@ -733,6 +797,7 @@ export function register({ server, apiClient }) {
|
|
|
733
797
|
**Examples:**
|
|
734
798
|
1. Convert to markdown:
|
|
735
799
|
{
|
|
800
|
+
projectId: "...",
|
|
736
801
|
documentId: "...",
|
|
737
802
|
targetType: "MARKDOWN",
|
|
738
803
|
content: "# Document Title\\n\\nContent here..."
|
|
@@ -740,6 +805,7 @@ export function register({ server, apiClient }) {
|
|
|
740
805
|
|
|
741
806
|
2. Convert to an uploaded file:
|
|
742
807
|
{
|
|
808
|
+
projectId: "...",
|
|
743
809
|
documentId: "...",
|
|
744
810
|
targetType: "FILE",
|
|
745
811
|
filePath: "/Users/me/Documents/protocol.pdf"
|
|
@@ -747,6 +813,7 @@ export function register({ server, apiClient }) {
|
|
|
747
813
|
|
|
748
814
|
3. Convert to external link:
|
|
749
815
|
{
|
|
816
|
+
projectId: "...",
|
|
750
817
|
documentId: "...",
|
|
751
818
|
targetType: "LINK",
|
|
752
819
|
externalUrl: "https://docs.google.com/...",
|
|
@@ -755,6 +822,7 @@ export function register({ server, apiClient }) {
|
|
|
755
822
|
|
|
756
823
|
4. With change reason:
|
|
757
824
|
{
|
|
825
|
+
projectId: "...",
|
|
758
826
|
documentId: "...",
|
|
759
827
|
targetType: "MARKDOWN",
|
|
760
828
|
content: "# Protocol\\n\\nStudy protocol content...",
|
|
@@ -769,7 +837,7 @@ export function register({ server, apiClient }) {
|
|
|
769
837
|
filePath: z.string().optional().describe('Absolute path of local file (FILE conversion)'),
|
|
770
838
|
contentBase64: z.string().optional().describe('Base64 file content (FILE conversion, use with fileName)'),
|
|
771
839
|
fileName: z.string().optional().describe('File name with extension (required with contentBase64)'),
|
|
772
|
-
content: z.string().optional().describe('Markdown content
|
|
840
|
+
content: z.string().optional().describe('Markdown content for MARKDOWN conversion (optional)'),
|
|
773
841
|
externalUrl: z.string().url().optional().describe('External URL (required for LINK conversion)'),
|
|
774
842
|
linkType: z
|
|
775
843
|
.enum(['google-docs', 'notion', 'confluence', 'other'])
|
|
@@ -816,18 +884,21 @@ export function register({ server, apiClient }) {
|
|
|
816
884
|
**Examples:**
|
|
817
885
|
1. Update URL:
|
|
818
886
|
{
|
|
887
|
+
projectId: "...",
|
|
819
888
|
documentId: "...",
|
|
820
889
|
externalUrl: "https://new-url.example.com/doc"
|
|
821
890
|
}
|
|
822
891
|
|
|
823
892
|
2. Update link type:
|
|
824
893
|
{
|
|
894
|
+
projectId: "...",
|
|
825
895
|
documentId: "...",
|
|
826
896
|
linkType: "notion"
|
|
827
897
|
}
|
|
828
898
|
|
|
829
899
|
3. Update both:
|
|
830
900
|
{
|
|
901
|
+
projectId: "...",
|
|
831
902
|
documentId: "...",
|
|
832
903
|
externalUrl: "https://www.notion.so/new-page",
|
|
833
904
|
linkType: "notion"
|
|
@@ -857,4 +928,77 @@ export function register({ server, apiClient }) {
|
|
|
857
928
|
return errorResponse(error);
|
|
858
929
|
}
|
|
859
930
|
});
|
|
931
|
+
// ===== Document Trash / Restore =====
|
|
932
|
+
server.registerTool('document_list_trash', {
|
|
933
|
+
description: `List deleted documents (the project's trash), newest deletion first.
|
|
934
|
+
|
|
935
|
+
**When to use:**
|
|
936
|
+
- Find a document id to restore with document_restore
|
|
937
|
+
|
|
938
|
+
**Returns:** Array of deleted documents (same fields as document_get, plus deletedAt)`,
|
|
939
|
+
inputSchema: {
|
|
940
|
+
projectId: z.string().uuid().describe('Project ID (UUID)'),
|
|
941
|
+
},
|
|
942
|
+
}, async ({ projectId }) => {
|
|
943
|
+
try {
|
|
944
|
+
const result = await apiClient.get(`/projects/${projectId}/documents/trash`);
|
|
945
|
+
return successResponse(result);
|
|
946
|
+
}
|
|
947
|
+
catch (error) {
|
|
948
|
+
return errorResponse(error);
|
|
949
|
+
}
|
|
950
|
+
});
|
|
951
|
+
server.registerTool('document_restore', {
|
|
952
|
+
description: `Restore a deleted document from the trash.
|
|
953
|
+
|
|
954
|
+
**Example:** { projectId: "...", documentId: "..." }
|
|
955
|
+
|
|
956
|
+
**Returns:** Restored document`,
|
|
957
|
+
inputSchema: {
|
|
958
|
+
projectId: z.string().uuid().describe('Project ID (UUID)'),
|
|
959
|
+
documentId: z.string().uuid().describe('Deleted document ID (from document_list_trash)'),
|
|
960
|
+
},
|
|
961
|
+
}, async ({ projectId, documentId }) => {
|
|
962
|
+
try {
|
|
963
|
+
const result = await apiClient.post(`/projects/${projectId}/documents/${documentId}/restore`);
|
|
964
|
+
return successResponse(result, 'Document restored successfully');
|
|
965
|
+
}
|
|
966
|
+
catch (error) {
|
|
967
|
+
return errorResponse(error);
|
|
968
|
+
}
|
|
969
|
+
});
|
|
970
|
+
// ===== Document Download URL =====
|
|
971
|
+
server.registerTool('document_get_download_url', {
|
|
972
|
+
description: `Get a temporary download (or preview) URL for a FILE document.
|
|
973
|
+
|
|
974
|
+
**When to use:**
|
|
975
|
+
- Read or download the file of a document (current version, or a specific version from document_get_versions)
|
|
976
|
+
- MARKDOWN documents: use document_get_markdown_content instead
|
|
977
|
+
|
|
978
|
+
**Examples:**
|
|
979
|
+
1. Current version: { projectId: "...", documentId: "..." }
|
|
980
|
+
2. A specific version: { projectId: "...", documentId: "...", versionId: "..." }
|
|
981
|
+
3. Preview (inline) URL: { projectId: "...", documentId: "...", preview: true }
|
|
982
|
+
|
|
983
|
+
**Returns:** { url, fileName, mimeType, expiresIn } — the URL expires after expiresIn seconds (1 hour).`,
|
|
984
|
+
inputSchema: {
|
|
985
|
+
projectId: z.string().uuid().describe('Project ID (UUID)'),
|
|
986
|
+
documentId: z.string().uuid().describe('Document ID (UUID)'),
|
|
987
|
+
versionId: z.string().uuid().optional().describe('Version ID (from document_get_versions); omit for the current version'),
|
|
988
|
+
preview: z.boolean().optional().describe('Preview URL instead of download (current version only)'),
|
|
989
|
+
},
|
|
990
|
+
}, async ({ projectId, documentId, versionId, preview }) => {
|
|
991
|
+
try {
|
|
992
|
+
if (versionId && preview) {
|
|
993
|
+
return errorResponse(new Error('preview works only for the current version; omit versionId'));
|
|
994
|
+
}
|
|
995
|
+
const base = `/projects/${projectId}/documents/${documentId}`;
|
|
996
|
+
const path = versionId ? `${base}/versions/${versionId}/download` : preview ? `${base}/preview` : `${base}/download`;
|
|
997
|
+
const result = await apiClient.get(path);
|
|
998
|
+
return successResponse(result);
|
|
999
|
+
}
|
|
1000
|
+
catch (error) {
|
|
1001
|
+
return errorResponse(error);
|
|
1002
|
+
}
|
|
1003
|
+
});
|
|
860
1004
|
}
|