aidocx-mcp-server 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +34 -16
- package/build/index.js +14 -14
- package/build/tools/analyze-document.d.ts +3 -0
- package/build/tools/analyze-document.js +36 -0
- package/build/tools/create-document.d.ts +3 -0
- package/build/tools/create-document.js +77 -0
- package/build/tools/delete-document.d.ts +3 -0
- package/build/tools/delete-document.js +30 -0
- package/build/tools/delete-folder.js +2 -4
- package/build/tools/get-document.d.ts +3 -0
- package/build/tools/get-document.js +35 -0
- package/build/tools/list-documents.d.ts +3 -0
- package/build/tools/list-documents.js +52 -0
- package/build/tools/search-documents.d.ts +3 -0
- package/build/tools/search-documents.js +69 -0
- package/build/tools/upload-document.d.ts +3 -0
- package/build/tools/upload-document.js +42 -0
- package/package.json +7 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
# aidocx-mcp-server
|
|
2
2
|
|
|
3
|
-
MCP (Model Context Protocol) server for [AiDocX](https://aidocx.ai) — AI-powered
|
|
3
|
+
MCP (Model Context Protocol) server for [AiDocX](https://aidocx.ai) — AI-powered document management platform.
|
|
4
4
|
|
|
5
|
-
Create, upload, and manage
|
|
5
|
+
Create, upload, and manage business documents directly from AI assistants like Claude Desktop, Claude Code, and other MCP-compatible clients.
|
|
6
|
+
|
|
7
|
+
**Supported document types:** Contracts, Proposals, Quotations, Resumes, Business Plans, Reports, Official Letters, Purchase Orders, Manuals/SOPs, and more.
|
|
6
8
|
|
|
7
9
|
## Quick Start
|
|
8
10
|
|
|
@@ -44,32 +46,48 @@ claude mcp add aidocx \
|
|
|
44
46
|
|
|
45
47
|
Ask your AI assistant:
|
|
46
48
|
|
|
47
|
-
- "계약서
|
|
48
|
-
- "
|
|
49
|
+
- "NDA 계약서 작성해줘" (Draft an NDA contract)
|
|
50
|
+
- "견적서 만들어줘" (Create a quotation)
|
|
51
|
+
- "이력서 작성해줘" (Create a resume)
|
|
52
|
+
- "제안서 만들어줘" (Create a proposal)
|
|
49
53
|
- "내 문서 목록 보여줘" (Show my documents)
|
|
50
|
-
- "이
|
|
51
|
-
- "계약서 검색해줘" (Search my contracts)
|
|
54
|
+
- "이 문서 AI로 분석해줘" (Analyze this document with AI)
|
|
52
55
|
|
|
53
56
|
## Available Tools
|
|
54
57
|
|
|
55
58
|
| Tool | Description |
|
|
56
59
|
|------|-------------|
|
|
57
|
-
| `
|
|
58
|
-
| `
|
|
59
|
-
| `
|
|
60
|
-
| `
|
|
61
|
-
| `
|
|
60
|
+
| `create_document` | Create a new document (contract, proposal, quotation, resume, report, etc.) — auto-generates PDF |
|
|
61
|
+
| `upload_document` | Upload a PDF or Office file (DOC, DOCX, HWP, XLS, XLSX, PPT, PPTX) |
|
|
62
|
+
| `list_documents` | List documents with optional pagination |
|
|
63
|
+
| `get_document` | Get document details and extracted text |
|
|
64
|
+
| `delete_document` | Delete a document |
|
|
62
65
|
| `list_folders` | List folders |
|
|
63
66
|
| `create_folder` | Create a new folder |
|
|
64
67
|
| `delete_folder` | Delete a folder (optionally with all contents) |
|
|
65
|
-
| `
|
|
66
|
-
| `
|
|
68
|
+
| `search_documents` | Search documents with text query, date filters, and pagination |
|
|
69
|
+
| `analyze_document` | AI-powered document analysis with risk score and insights |
|
|
70
|
+
|
|
71
|
+
## Document Types
|
|
72
|
+
|
|
73
|
+
| Type | Examples |
|
|
74
|
+
|------|----------|
|
|
75
|
+
| `contract` | Service agreements, NDAs, employment contracts |
|
|
76
|
+
| `proposal` | Project proposals, consulting proposals |
|
|
77
|
+
| `quotation` | Price quotes, cost estimates |
|
|
78
|
+
| `plan` | Project plans, strategy documents |
|
|
79
|
+
| `business-plan` | Investor pitch business plans |
|
|
80
|
+
| `report` | Analysis reports, audit reports |
|
|
81
|
+
| `official-letter` | Official letters, notices, requests |
|
|
82
|
+
| `resume` | Resumes, CVs, cover letters |
|
|
83
|
+
| `purchase-order` | Purchase orders, delivery notes |
|
|
84
|
+
| `manual` | SOPs, user manuals, guides |
|
|
67
85
|
|
|
68
86
|
## Workflow
|
|
69
87
|
|
|
70
|
-
1. **AI generates a
|
|
71
|
-
2. **Open the
|
|
72
|
-
3. **
|
|
88
|
+
1. **AI generates a document** → calls `create_document` → PDF is created in AiDocX
|
|
89
|
+
2. **Open the URL** returned by the tool to view, download, or share
|
|
90
|
+
3. **For contracts:** open the signing workspace URL to place signature fields and send to signers
|
|
73
91
|
|
|
74
92
|
## Environment Variables
|
|
75
93
|
|
package/build/index.js
CHANGED
|
@@ -4,16 +4,16 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
4
4
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
5
5
|
import { loadConfig } from "./config.js";
|
|
6
6
|
import { AiDocxClient } from "./api-client.js";
|
|
7
|
-
import { register as
|
|
8
|
-
import { register as
|
|
9
|
-
import { register as
|
|
10
|
-
import { register as
|
|
7
|
+
import { register as registerCreateDocument } from "./tools/create-document.js";
|
|
8
|
+
import { register as registerUploadDocument } from "./tools/upload-document.js";
|
|
9
|
+
import { register as registerListDocuments } from "./tools/list-documents.js";
|
|
10
|
+
import { register as registerGetDocument } from "./tools/get-document.js";
|
|
11
11
|
import { register as registerListFolders } from "./tools/list-folders.js";
|
|
12
12
|
import { register as registerCreateFolder } from "./tools/create-folder.js";
|
|
13
|
-
import { register as
|
|
13
|
+
import { register as registerDeleteDocument } from "./tools/delete-document.js";
|
|
14
14
|
import { register as registerDeleteFolder } from "./tools/delete-folder.js";
|
|
15
|
-
import { register as
|
|
16
|
-
import { register as
|
|
15
|
+
import { register as registerSearchDocuments } from "./tools/search-documents.js";
|
|
16
|
+
import { register as registerAnalyzeDocument } from "./tools/analyze-document.js";
|
|
17
17
|
const require = createRequire(import.meta.url);
|
|
18
18
|
const { version } = require("../package.json");
|
|
19
19
|
async function main() {
|
|
@@ -23,16 +23,16 @@ async function main() {
|
|
|
23
23
|
name: "aidocx",
|
|
24
24
|
version,
|
|
25
25
|
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
registerCreateDocument(server, client);
|
|
27
|
+
registerUploadDocument(server, client);
|
|
28
|
+
registerListDocuments(server, client);
|
|
29
|
+
registerGetDocument(server, client);
|
|
30
30
|
registerListFolders(server, client);
|
|
31
31
|
registerCreateFolder(server, client);
|
|
32
|
-
|
|
32
|
+
registerDeleteDocument(server, client);
|
|
33
33
|
registerDeleteFolder(server, client);
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
registerSearchDocuments(server, client);
|
|
35
|
+
registerAnalyzeDocument(server, client);
|
|
36
36
|
const transport = new StdioServerTransport();
|
|
37
37
|
await server.connect(transport);
|
|
38
38
|
console.error("[AiDocX MCP] Server running on stdio");
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const inputSchema = {
|
|
3
|
+
id: z.string().describe("Document ID to analyze"),
|
|
4
|
+
};
|
|
5
|
+
export function register(server, client) {
|
|
6
|
+
server.registerTool("analyze_document", {
|
|
7
|
+
description: "Analyze a document using AI. For contracts, returns a risk score (0-100), key clauses, " +
|
|
8
|
+
"and missing protections. For other document types, returns a summary and improvement suggestions.\n\n" +
|
|
9
|
+
"NOTE: This operation consumes AI tokens from the user's subscription plan. " +
|
|
10
|
+
"The analysis may take 10-30 seconds depending on document length.",
|
|
11
|
+
inputSchema,
|
|
12
|
+
}, async ({ id }) => {
|
|
13
|
+
try {
|
|
14
|
+
const result = await client.post("/ai/analyze", { id });
|
|
15
|
+
return {
|
|
16
|
+
content: [{
|
|
17
|
+
type: "text",
|
|
18
|
+
text: JSON.stringify({
|
|
19
|
+
success: true,
|
|
20
|
+
documentId: id,
|
|
21
|
+
summary: result.summary,
|
|
22
|
+
riskScore: result.riskScore,
|
|
23
|
+
insights: result.insights,
|
|
24
|
+
tokensUsed: result.tokensUsed,
|
|
25
|
+
}, null, 2),
|
|
26
|
+
}],
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
return {
|
|
31
|
+
content: [{ type: "text", text: `Error: ${error.message}` }],
|
|
32
|
+
isError: true,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const DOCUMENT_TYPES = [
|
|
3
|
+
"contract", "proposal", "quotation", "plan", "business-plan",
|
|
4
|
+
"business-trip-plan", "business-trip-report", "report",
|
|
5
|
+
"official-letter", "resume", "purchase-order", "manual",
|
|
6
|
+
];
|
|
7
|
+
export function register(server, client) {
|
|
8
|
+
server.registerTool("create_document", {
|
|
9
|
+
description: "Create a new document in AiDocX. The content is rendered to a professionally formatted PDF " +
|
|
10
|
+
"(A4, proper margins) and stored in document management.\n\n" +
|
|
11
|
+
"Supported document types:\n" +
|
|
12
|
+
"- contract: Contracts, NDAs, employment agreements, service agreements\n" +
|
|
13
|
+
"- proposal: Project proposals, consulting proposals\n" +
|
|
14
|
+
"- quotation: Price quotes, cost estimates, invoices\n" +
|
|
15
|
+
"- plan: Project plans, strategy documents\n" +
|
|
16
|
+
"- business-plan: Investor pitch business plans, startup plans\n" +
|
|
17
|
+
"- business-trip-plan: Travel plans with itinerary and budget\n" +
|
|
18
|
+
"- business-trip-report: Post-trip reports with outcomes and expenses\n" +
|
|
19
|
+
"- report: Analysis reports, audit reports, due diligence\n" +
|
|
20
|
+
"- official-letter: Official letters, notices, requests\n" +
|
|
21
|
+
"- resume: Resumes, CVs, cover letters\n" +
|
|
22
|
+
"- purchase-order: Purchase orders, delivery notes, invoices\n" +
|
|
23
|
+
"- manual: SOPs, user manuals, guides\n\n" +
|
|
24
|
+
"IMPORTANT: Before calling this tool, you MUST confirm the following with the user:\n" +
|
|
25
|
+
"1. Document type (e.g., contract, quotation, resume, proposal)\n" +
|
|
26
|
+
"2. Key details (parties, terms, items, or sections depending on type)\n" +
|
|
27
|
+
"3. Any special requirements or clauses\n\n" +
|
|
28
|
+
"Generate professional, well-structured HTML appropriate for the document type. " +
|
|
29
|
+
"Do NOT include <html>/<head>/<body> wrapper — only the inner content.\n" +
|
|
30
|
+
"- Contracts: include signature blocks at the bottom\n" +
|
|
31
|
+
"- Quotations: include item tables with totals\n" +
|
|
32
|
+
"- Resumes: include profile, experience, education sections\n" +
|
|
33
|
+
"- Proposals: include executive summary, scope, timeline, pricing",
|
|
34
|
+
inputSchema: {
|
|
35
|
+
name: z.string().describe("Document title"),
|
|
36
|
+
html: z.string().describe("Document body content as HTML"),
|
|
37
|
+
documentType: z.enum(DOCUMENT_TYPES).optional().describe("Document type. Determines formatting and structure. Default: 'contract'"),
|
|
38
|
+
folderId: z.string().optional().describe("Target folder ID"),
|
|
39
|
+
},
|
|
40
|
+
}, async ({ name, html, documentType, folderId }) => {
|
|
41
|
+
try {
|
|
42
|
+
const result = await client.post("/contracts/create-from-html", {
|
|
43
|
+
name, html, folderId,
|
|
44
|
+
...(documentType ? { label: documentType } : {}),
|
|
45
|
+
});
|
|
46
|
+
const viewUrl = `${client.appUrl}/contracts/${result.id}`;
|
|
47
|
+
const signingUrl = `${client.appUrl}/contracts/${result.id}/signing`;
|
|
48
|
+
const isContract = !documentType || documentType === "contract";
|
|
49
|
+
return {
|
|
50
|
+
content: [{
|
|
51
|
+
type: "text",
|
|
52
|
+
text: JSON.stringify({
|
|
53
|
+
success: true,
|
|
54
|
+
documentId: result.id,
|
|
55
|
+
name: result.name,
|
|
56
|
+
documentType: documentType || "contract",
|
|
57
|
+
fileSize: result.fileSize,
|
|
58
|
+
message: `Document "${result.name}" created successfully.`,
|
|
59
|
+
viewUrl,
|
|
60
|
+
...(isContract ? {
|
|
61
|
+
signingWorkspaceUrl: signingUrl,
|
|
62
|
+
nextStep: "Open the signing workspace URL to place signature fields and send to signers.",
|
|
63
|
+
} : {
|
|
64
|
+
nextStep: "Open the view URL to preview, download, or share the document.",
|
|
65
|
+
}),
|
|
66
|
+
}, null, 2),
|
|
67
|
+
}],
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
return {
|
|
72
|
+
content: [{ type: "text", text: `Error: ${error.message}` }],
|
|
73
|
+
isError: true,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const inputSchema = {
|
|
3
|
+
id: z.string().describe("Document ID to delete"),
|
|
4
|
+
};
|
|
5
|
+
export function register(server, client) {
|
|
6
|
+
server.registerTool("delete_document", {
|
|
7
|
+
description: "Delete a document from AiDocX document management. This action is irreversible.\n\n" +
|
|
8
|
+
"IMPORTANT: Always confirm with the user before deleting a document.",
|
|
9
|
+
inputSchema,
|
|
10
|
+
}, async ({ id }) => {
|
|
11
|
+
try {
|
|
12
|
+
await client.delete(`/contracts/${id}`);
|
|
13
|
+
return {
|
|
14
|
+
content: [{
|
|
15
|
+
type: "text",
|
|
16
|
+
text: JSON.stringify({
|
|
17
|
+
success: true,
|
|
18
|
+
message: `Document ${id} has been deleted.`,
|
|
19
|
+
}, null, 2),
|
|
20
|
+
}],
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
return {
|
|
25
|
+
content: [{ type: "text", text: `Error: ${error.message}` }],
|
|
26
|
+
isError: true,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
const inputSchema = {
|
|
3
3
|
id: z.string().describe("Folder ID to delete"),
|
|
4
|
-
recursive: z.boolean().optional().describe("If true, delete the folder and all its contents (subfolders and
|
|
4
|
+
recursive: z.boolean().optional().describe("If true, delete the folder and all its contents (subfolders and documents). " +
|
|
5
5
|
"If false or omitted, the folder must be empty to delete."),
|
|
6
6
|
};
|
|
7
7
|
export function register(server, client) {
|
|
@@ -10,9 +10,7 @@ export function register(server, client) {
|
|
|
10
10
|
"IMPORTANT: Always confirm with the user before deleting. " +
|
|
11
11
|
"Use recursive=true only when the user explicitly wants to delete all contents.",
|
|
12
12
|
inputSchema,
|
|
13
|
-
},
|
|
14
|
-
// @ts-expect-error -- MCP SDK generic recursion with zod v3.25+ optional()
|
|
15
|
-
async ({ id, recursive }) => {
|
|
13
|
+
}, async ({ id, recursive }) => {
|
|
16
14
|
try {
|
|
17
15
|
const params = {};
|
|
18
16
|
if (recursive)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const inputSchema = {
|
|
3
|
+
id: z.string().describe("Document ID"),
|
|
4
|
+
};
|
|
5
|
+
export function register(server, client) {
|
|
6
|
+
server.registerTool("get_document", {
|
|
7
|
+
description: "Get details of a specific document in AiDocX. " +
|
|
8
|
+
"Returns name, type, labels, size, and extracted text content.",
|
|
9
|
+
inputSchema,
|
|
10
|
+
}, async ({ id }) => {
|
|
11
|
+
try {
|
|
12
|
+
const result = await client.get(`/contracts/${id}`);
|
|
13
|
+
const doc = result.contract || result;
|
|
14
|
+
return {
|
|
15
|
+
content: [{
|
|
16
|
+
type: "text",
|
|
17
|
+
text: JSON.stringify({
|
|
18
|
+
id: doc.id, name: doc.name,
|
|
19
|
+
fileName: doc.fileName, fileType: doc.fileType,
|
|
20
|
+
fileSize: doc.fileSize, contentType: doc.contentType,
|
|
21
|
+
folderId: doc.folderId, labels: doc.labels,
|
|
22
|
+
textExtract: doc.textExtract,
|
|
23
|
+
createdAt: doc.createdAt, updatedAt: doc.updatedAt,
|
|
24
|
+
}, null, 2),
|
|
25
|
+
}],
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
return {
|
|
30
|
+
content: [{ type: "text", text: `Error: ${error.message}` }],
|
|
31
|
+
isError: true,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const inputSchema = {
|
|
3
|
+
folderId: z.string().optional().describe("Folder ID to list. Omit for root folder."),
|
|
4
|
+
limit: z.number().optional().describe("Maximum number of documents to return. Default: 50"),
|
|
5
|
+
offset: z.number().optional().describe("Number of documents to skip. Default: 0"),
|
|
6
|
+
};
|
|
7
|
+
export function register(server, client) {
|
|
8
|
+
server.registerTool("list_documents", {
|
|
9
|
+
description: "List documents in the user's AiDocX document management. " +
|
|
10
|
+
"Returns all document types (contracts, proposals, quotations, resumes, reports, etc.). " +
|
|
11
|
+
"Supports pagination.",
|
|
12
|
+
inputSchema,
|
|
13
|
+
}, async ({ folderId, limit, offset }) => {
|
|
14
|
+
try {
|
|
15
|
+
const params = {};
|
|
16
|
+
if (folderId)
|
|
17
|
+
params.folderId = folderId;
|
|
18
|
+
const result = await client.get("/contracts", params);
|
|
19
|
+
const documents = result.contracts || result;
|
|
20
|
+
const all = Array.isArray(documents)
|
|
21
|
+
? documents.map((d) => ({
|
|
22
|
+
id: d.id, name: d.name, labels: d.labels,
|
|
23
|
+
fileType: d.fileType, fileSize: d.fileSize,
|
|
24
|
+
contentType: d.contentType,
|
|
25
|
+
createdAt: d.createdAt, updatedAt: d.updatedAt,
|
|
26
|
+
}))
|
|
27
|
+
: documents;
|
|
28
|
+
const effectiveLimit = limit ?? 50;
|
|
29
|
+
const effectiveOffset = offset ?? 0;
|
|
30
|
+
const paginated = Array.isArray(all)
|
|
31
|
+
? all.slice(effectiveOffset, effectiveOffset + effectiveLimit)
|
|
32
|
+
: all;
|
|
33
|
+
return {
|
|
34
|
+
content: [{
|
|
35
|
+
type: "text",
|
|
36
|
+
text: JSON.stringify({
|
|
37
|
+
total: Array.isArray(all) ? all.length : 0,
|
|
38
|
+
count: Array.isArray(paginated) ? paginated.length : 0,
|
|
39
|
+
documents: paginated,
|
|
40
|
+
pagination: { limit: effectiveLimit, offset: effectiveOffset },
|
|
41
|
+
}, null, 2),
|
|
42
|
+
}],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
return {
|
|
47
|
+
content: [{ type: "text", text: `Error: ${error.message}` }],
|
|
48
|
+
isError: true,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const inputSchema = {
|
|
3
|
+
query: z.string().optional().describe("Search query text. Searches document names and content."),
|
|
4
|
+
sortBy: z.enum(["relevance", "date", "name"]).optional().describe("Sort results by relevance, date, or name. Default: relevance"),
|
|
5
|
+
sortOrder: z.enum(["asc", "desc"]).optional().describe("Sort order. Default: desc"),
|
|
6
|
+
dateFrom: z.string().optional().describe("Filter results from this date (ISO 8601, e.g., '2024-01-01')"),
|
|
7
|
+
dateTo: z.string().optional().describe("Filter results up to this date (ISO 8601)"),
|
|
8
|
+
limit: z.number().optional().describe("Maximum results to return (1-100). Default: 20"),
|
|
9
|
+
offset: z.number().optional().describe("Number of results to skip for pagination. Default: 0"),
|
|
10
|
+
};
|
|
11
|
+
export function register(server, client) {
|
|
12
|
+
server.registerTool("search_documents", {
|
|
13
|
+
description: "Search documents in AiDocX. Searches across all document types " +
|
|
14
|
+
"(contracts, proposals, quotations, resumes, reports, etc.). " +
|
|
15
|
+
"Supports text search, date filtering, and pagination. " +
|
|
16
|
+
"Returns matching documents sorted by relevance by default.",
|
|
17
|
+
inputSchema,
|
|
18
|
+
}, async ({ query, sortBy, sortOrder, dateFrom, dateTo, limit, offset }) => {
|
|
19
|
+
try {
|
|
20
|
+
const params = {};
|
|
21
|
+
if (query)
|
|
22
|
+
params.q = query;
|
|
23
|
+
if (sortBy)
|
|
24
|
+
params.sortBy = sortBy;
|
|
25
|
+
if (sortOrder)
|
|
26
|
+
params.sortOrder = sortOrder;
|
|
27
|
+
if (dateFrom)
|
|
28
|
+
params.dateFrom = dateFrom;
|
|
29
|
+
if (dateTo)
|
|
30
|
+
params.dateTo = dateTo;
|
|
31
|
+
if (limit !== undefined)
|
|
32
|
+
params.limit = String(limit);
|
|
33
|
+
if (offset !== undefined)
|
|
34
|
+
params.offset = String(offset);
|
|
35
|
+
const result = await client.get("/search", params);
|
|
36
|
+
const items = result.results || result;
|
|
37
|
+
return {
|
|
38
|
+
content: [{
|
|
39
|
+
type: "text",
|
|
40
|
+
text: JSON.stringify({
|
|
41
|
+
total: result.total ?? (Array.isArray(items) ? items.length : 0),
|
|
42
|
+
results: Array.isArray(items)
|
|
43
|
+
? items.map((item) => ({
|
|
44
|
+
id: item.id,
|
|
45
|
+
name: item.name,
|
|
46
|
+
type: item.type,
|
|
47
|
+
labels: item.labels,
|
|
48
|
+
fileType: item.fileType,
|
|
49
|
+
fileSize: item.fileSize,
|
|
50
|
+
createdAt: item.createdAt,
|
|
51
|
+
updatedAt: item.updatedAt,
|
|
52
|
+
}))
|
|
53
|
+
: items,
|
|
54
|
+
pagination: {
|
|
55
|
+
limit: limit ?? 20,
|
|
56
|
+
offset: offset ?? 0,
|
|
57
|
+
},
|
|
58
|
+
}, null, 2),
|
|
59
|
+
}],
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
return {
|
|
64
|
+
content: [{ type: "text", text: `Error: ${error.message}` }],
|
|
65
|
+
isError: true,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const inputSchema = {
|
|
3
|
+
fileName: z.string().describe("File name with extension (e.g., 'proposal.pdf', 'resume.docx')"),
|
|
4
|
+
fileBase64: z.string().describe("Base64-encoded file content (max 50MB)"),
|
|
5
|
+
fileType: z.string().describe("MIME type (e.g., 'application/pdf')"),
|
|
6
|
+
folderId: z.string().optional().describe("Target folder ID. Omit for root."),
|
|
7
|
+
};
|
|
8
|
+
export function register(server, client) {
|
|
9
|
+
server.registerTool("upload_document", {
|
|
10
|
+
description: "Upload a PDF or Office document (DOC, DOCX, HWP, XLS, XLSX, PPT, PPTX) to AiDocX. " +
|
|
11
|
+
"Office files are auto-converted to PDF. " +
|
|
12
|
+
"Works for any document type: contracts, proposals, quotations, resumes, reports, etc.",
|
|
13
|
+
inputSchema,
|
|
14
|
+
}, async ({ fileName, fileBase64, fileType, folderId }) => {
|
|
15
|
+
try {
|
|
16
|
+
const result = await client.post("/contracts/upload", {
|
|
17
|
+
file: fileBase64, fileName, fileType, folderId,
|
|
18
|
+
});
|
|
19
|
+
const viewUrl = `${client.appUrl}/contracts/${result.id}`;
|
|
20
|
+
return {
|
|
21
|
+
content: [{
|
|
22
|
+
type: "text",
|
|
23
|
+
text: JSON.stringify({
|
|
24
|
+
success: true,
|
|
25
|
+
documentId: result.id,
|
|
26
|
+
name: result.name,
|
|
27
|
+
fileSize: result.fileSize,
|
|
28
|
+
message: `File "${result.name}" uploaded successfully.`,
|
|
29
|
+
viewUrl,
|
|
30
|
+
nextStep: "Open the view URL to preview, share, or set up e-signatures.",
|
|
31
|
+
}, null, 2),
|
|
32
|
+
}],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
return {
|
|
37
|
+
content: [{ type: "text", text: `Error: ${error.message}` }],
|
|
38
|
+
isError: true,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aidocx-mcp-server",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
3
|
+
"mcpName": "io.github.aidocx/mcp-server",
|
|
4
|
+
"version": "0.4.0",
|
|
5
|
+
"description": "MCP server for AiDocX - Create, upload, and manage documents (contracts, proposals, quotations, resumes, reports) from AI assistants",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"license": "MIT",
|
|
7
8
|
"author": "AiDocX <contact@aidocx.ai> (https://aidocx.ai)",
|
|
@@ -15,6 +16,10 @@
|
|
|
15
16
|
"model-context-protocol",
|
|
16
17
|
"aidocx",
|
|
17
18
|
"contract",
|
|
19
|
+
"proposal",
|
|
20
|
+
"quotation",
|
|
21
|
+
"resume",
|
|
22
|
+
"report",
|
|
18
23
|
"e-signature",
|
|
19
24
|
"document-management",
|
|
20
25
|
"pdf",
|