@dod/planax-mcp 0.1.2 → 0.1.3

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 CHANGED
@@ -127,7 +127,7 @@ env = { PLANAX_ACCESS_TOKEN = "your_token_here" }
127
127
  </details>
128
128
 
129
129
  <details>
130
- <summary><b>Document</b> (15)</summary>
130
+ <summary><b>Document</b> (16)</summary>
131
131
 
132
132
  - `document_list` - 프로젝트의 문서 목록 (필터 지원)
133
133
  - `document_get` - 문서 상세 정보
@@ -135,6 +135,7 @@ env = { PLANAX_ACCESS_TOKEN = "your_token_here" }
135
135
  - `document_get_markdown_content` - Markdown 문서 내용 조회
136
136
  - `document_update_markdown_content` - Markdown 문서 내용 수정
137
137
  - `document_upload` - 파일(PDF, Word, Excel, 이미지 등) 업로드
138
+ - `document_replace_file` - 기존 문서의 파일을 새 파일로 교체 (새 버전으로 올라가고 이전 버전은 이력에 남음)
138
139
  - `document_create_placeholder` - 나중에 채울 자리표시 문서 생성
139
140
  - `document_convert_placeholder` - 자리표시 문서를 실제 문서로 변환
140
141
  - `document_create_link` - 외부 콘텐츠를 가리키는 링크 문서 생성
@@ -43,8 +43,20 @@ export class PlanaxApiClient {
43
43
  * Multipart/form-data POST request (file upload)
44
44
  */
45
45
  async postForm(path, form) {
46
+ return this.sendForm('post', path, form);
47
+ }
48
+ /**
49
+ * Multipart/form-data PATCH request (file replace)
50
+ */
51
+ async patchForm(path, form) {
52
+ return this.sendForm('patch', path, form);
53
+ }
54
+ async sendForm(method, path, form) {
46
55
  try {
47
- const response = await this.client.post(path, form, {
56
+ const response = await this.client.request({
57
+ method,
58
+ url: path,
59
+ data: form,
48
60
  headers: { 'Content-Type': 'multipart/form-data' },
49
61
  maxBodyLength: Infinity,
50
62
  maxContentLength: Infinity,
package/dist/server.js CHANGED
@@ -8,7 +8,7 @@ import { planTools, planItemsTools, workspaceTools, projectTools, folderTools, t
8
8
  export function createServer(config) {
9
9
  const server = new McpServer({
10
10
  name: 'planax-mcp',
11
- version: '0.1.2',
11
+ version: '0.1.3',
12
12
  });
13
13
  const toolContext = {
14
14
  server,
@@ -3,6 +3,44 @@ import { basename } from 'node:path';
3
3
  import { z } from 'zod';
4
4
  import { successResponse, errorResponse } from './types.js';
5
5
  const MAX_UPLOAD_BYTES = 50 * 1024 * 1024;
6
+ const MIME_BY_EXTENSION = {
7
+ pdf: 'application/pdf',
8
+ jpg: 'image/jpeg',
9
+ jpeg: 'image/jpeg',
10
+ png: 'image/png',
11
+ gif: 'image/gif',
12
+ webp: 'image/webp',
13
+ svg: 'image/svg+xml',
14
+ bmp: 'image/bmp',
15
+ txt: 'text/plain',
16
+ csv: 'text/csv',
17
+ md: 'text/markdown',
18
+ html: 'text/html',
19
+ json: 'application/json',
20
+ xml: 'application/xml',
21
+ zip: 'application/zip',
22
+ doc: 'application/msword',
23
+ docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
24
+ xls: 'application/vnd.ms-excel',
25
+ xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
26
+ ppt: 'application/vnd.ms-powerpoint',
27
+ pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
28
+ hwp: 'application/x-hwp',
29
+ mp4: 'video/mp4',
30
+ mov: 'video/quicktime',
31
+ mp3: 'audio/mpeg',
32
+ wav: 'audio/wav',
33
+ };
34
+ /**
35
+ * Guess a MIME type from the file extension.
36
+ * An empty Blob type makes the multipart part go out without Content-Type,
37
+ * so the server stores application/octet-stream and the preview does not show.
38
+ */
39
+ function guessMimeType(fileName) {
40
+ const dot = fileName.lastIndexOf('.');
41
+ const extension = dot >= 0 ? fileName.slice(dot + 1).toLowerCase() : '';
42
+ return MIME_BY_EXTENSION[extension] ?? 'application/octet-stream';
43
+ }
6
44
  /**
7
45
  * Build a Blob from a local file path or base64 content for multipart upload.
8
46
  */
@@ -21,7 +59,7 @@ async function loadFilePart(filePath, contentBase64, fileName) {
21
59
  if (!name) {
22
60
  throw new Error('fileName is required when using contentBase64.');
23
61
  }
24
- return { blob: new Blob([new Uint8Array(buffer)]), name };
62
+ return { blob: new Blob([new Uint8Array(buffer)], { type: guessMimeType(name) }), name };
25
63
  }
26
64
  /**
27
65
  * Document Tools Module
@@ -637,6 +675,50 @@ export function register({ server, apiClient }) {
637
675
  return errorResponse(error);
638
676
  }
639
677
  });
678
+ // ===== Document Replace File (new version) =====
679
+ server.registerTool('document_replace_file', {
680
+ description: `Replace the file of an existing document with a new one. The document gets a new version; earlier versions stay in version history.
681
+
682
+ **When to use:**
683
+ - Upload a revised file (e.g., "protocol v2.pdf") to a document that already exists
684
+ - Use document_upload instead to create a new document
685
+
686
+ **Note:**
687
+ - Not allowed while a signature process is in progress on the document (cancel it first in the web app)
688
+ - A MARKDOWN document becomes a FILE document; its previous text stays in version history
689
+ - If the replaced version went through signing, the document status resets to DRAFT
690
+
691
+ **Input:** Provide either \`filePath\` (absolute path on the machine running this MCP server) or \`contentBase64\` with \`fileName\`. Max 50MB.
692
+
693
+ **Example:**
694
+ { projectId: "...", documentId: "...", filePath: "/Users/me/Documents/protocol_v2.pdf", changeReason: "IRB 의견 반영" }
695
+
696
+ **Returns:** Updated document (new version number)`,
697
+ inputSchema: {
698
+ projectId: z.string().uuid().describe('Project ID (UUID) - required'),
699
+ documentId: z.string().uuid().describe('Document ID (UUID) to replace the file of'),
700
+ filePath: z.string().optional().describe('Absolute path of the local file to upload'),
701
+ contentBase64: z.string().optional().describe('Base64-encoded file content (use with fileName)'),
702
+ fileName: z.string().optional().describe('File name with extension (required with contentBase64)'),
703
+ changeReason: z.string().max(500).optional().describe('Reason shown in version history'),
704
+ versionLabel: z.string().optional().describe('Version label (e.g., "v2.0")'),
705
+ },
706
+ }, async ({ projectId, documentId, filePath, contentBase64, fileName, changeReason, versionLabel }) => {
707
+ try {
708
+ const { blob, name } = await loadFilePart(filePath, contentBase64, fileName);
709
+ const form = new FormData();
710
+ form.append('file', blob, name);
711
+ if (changeReason)
712
+ form.append('changeReason', changeReason);
713
+ if (versionLabel)
714
+ form.append('versionLabel', versionLabel);
715
+ const result = await apiClient.patchForm(`/projects/${projectId}/documents/${documentId}/replace-file`, form);
716
+ return successResponse(result, `File replaced with "${name}" (new version)`);
717
+ }
718
+ catch (error) {
719
+ return errorResponse(error);
720
+ }
721
+ });
640
722
  // ===== Document Convert Placeholder =====
641
723
  server.registerTool('document_convert_placeholder', {
642
724
  description: `Convert a placeholder document to an actual document.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dod/planax-mcp",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "PlanAX MCP Server - Access projects, documents, and tasks via Model Context Protocol",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",