@canveo/mcp 0.1.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/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 - 2026-08-31
4
+
5
+ - Publish-ready npm package `@canveo/mcp` (stdio MCP server for any MCP client).
6
+ - Keep `canveo-cursor-mcp` as a CLI alias for existing local configs.
7
+ - Add MIT license, CI, and a tagged GitHub Release workflow for `npm publish`.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Canveo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,109 @@
1
+ # @canveo/mcp
2
+
3
+ Canveo’s [Model Context Protocol](https://modelcontextprotocol.io/) server. It is a **local stdio process**, not an AWS service. Any MCP client can spawn it; it then calls the existing Canveo API (`cvback`) with a Personal Access Token.
4
+
5
+ ## What it does
6
+
7
+ | Tool | Purpose |
8
+ | --- | --- |
9
+ | `canveo.listPlaybooks` | List playbooks for the authenticated org |
10
+ | `canveo.reviewDoc` | Upload a local `.docx`, run compliance assessment, write redlined `.docx` + assessment JSON |
11
+
12
+ The server does not host contracts. Upload, analysis, and export run on Canveo’s existing API (already deployed on AWS). This package only needs to be published to **npm**.
13
+
14
+ ## Install / run
15
+
16
+ Requires Node 20+.
17
+
18
+ ```bash
19
+ npx -y @canveo/mcp
20
+ ```
21
+
22
+ Or, after `npm i -g @canveo/mcp`:
23
+
24
+ ```bash
25
+ canveo-mcp
26
+ ```
27
+
28
+ `canveo-cursor-mcp` is the same binary (compat alias).
29
+
30
+ ## Environment
31
+
32
+ | Variable | Required | Example |
33
+ | --- | --- | --- |
34
+ | `CANVEO_API_URL` | yes | `https://api.canveo.net/api` |
35
+ | `CANVEO_PAT` | yes | PAT from Canveo **Settings → Personal access tokens** |
36
+ | `CANVEO_WEB_URL` | no | `https://app.canveo.net` (used for agreement deep links) |
37
+ | `CANVEO_OUTPUT_DIR` | no | `canveo-output` |
38
+
39
+ Never commit the PAT.
40
+
41
+ ## Client config
42
+
43
+ Cursor, Claude Desktop, VS Code Copilot, and other MCP hosts all use the same shape: spawn this package and pass env.
44
+
45
+ ### Cursor (plugin)
46
+
47
+ The `canveo-cursor-plugin` repo ships `.mcp.json` that runs `npx -y @canveo/mcp`.
48
+
49
+ ### Cursor / Claude Desktop / other stdio clients
50
+
51
+ ```json
52
+ {
53
+ "mcpServers": {
54
+ "canveo": {
55
+ "command": "npx",
56
+ "args": ["-y", "@canveo/mcp"],
57
+ "env": {
58
+ "CANVEO_API_URL": "https://api.canveo.net/api",
59
+ "CANVEO_PAT": "cvpat_...",
60
+ "CANVEO_WEB_URL": "https://app.canveo.net"
61
+ }
62
+ }
63
+ }
64
+ }
65
+ ```
66
+
67
+ Local development (unpublished):
68
+
69
+ ```json
70
+ {
71
+ "mcpServers": {
72
+ "canveo": {
73
+ "command": "node",
74
+ "args": ["/absolute/path/to/canveo-mcp/index.js"],
75
+ "env": {
76
+ "CANVEO_API_URL": "https://api.canveo.net/api",
77
+ "CANVEO_PAT": "cvpat_..."
78
+ }
79
+ }
80
+ }
81
+ }
82
+ ```
83
+
84
+ ## Publish to npm (maintainers)
85
+
86
+ This is **not** a Terraform/ECS deploy.
87
+
88
+ 1. Create the public npm org/scope `@canveo` if it does not exist.
89
+ 2. Add repo secret `NPM_TOKEN` (Automation token with publish rights on `@canveo`).
90
+ 3. Bump `version` in `package.json`.
91
+ 4. Create a GitHub Release tagged `v0.1.0` (must match `package.json`). The **Publish npm** workflow runs `npm publish --access public`.
92
+
93
+ Manual fallback:
94
+
95
+ ```bash
96
+ npm login
97
+ npm test
98
+ npm publish --access public
99
+ ```
100
+
101
+ ## Development
102
+
103
+ ```bash
104
+ npm ci
105
+ npm test
106
+ npm run pack:check
107
+ ```
108
+
109
+ Related: `cvback` (API), `canveo-cursor-plugin` (Cursor wrapper), `cv` (web app).
package/index.js ADDED
@@ -0,0 +1,321 @@
1
+ #!/usr/bin/env node
2
+ import fs from "node:fs/promises";
3
+ import { readFileSync } from "node:fs";
4
+ import path from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
7
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
8
+ import {
9
+ CallToolRequestSchema,
10
+ ListToolsRequestSchema,
11
+ } from "@modelcontextprotocol/sdk/types.js";
12
+
13
+ const packageJson = JSON.parse(
14
+ readFileSync(new URL("./package.json", import.meta.url), "utf8")
15
+ );
16
+ const SERVER_NAME = "canveo-mcp";
17
+ const SERVER_VERSION = packageJson.version;
18
+
19
+ const API_URL = process.env.CANVEO_API_URL || "";
20
+ const API_TOKEN = process.env.CANVEO_PAT || "";
21
+ const WEB_URL = process.env.CANVEO_WEB_URL || "";
22
+ const DEFAULT_OUTPUT_DIR = process.env.CANVEO_OUTPUT_DIR || "canveo-output";
23
+ const POLL_INTERVAL_MS = Number(process.env.CANVEO_POLL_INTERVAL_MS || 2000);
24
+ const POLL_TIMEOUT_MS = Number(process.env.CANVEO_POLL_TIMEOUT_MS || 600000);
25
+
26
+ /**
27
+ * @param {string} route
28
+ * @param {RequestInit} [options]
29
+ */
30
+ async function canveoApi(route, options = {}) {
31
+ const url = `${API_URL.replace(/\/$/, "")}/${route.replace(/^\//, "")}`;
32
+ const headers = {
33
+ Authorization: `Bearer ${API_TOKEN}`,
34
+ ...(options.body ? { "Content-Type": "application/json" } : {}),
35
+ ...(options.headers || {}),
36
+ };
37
+
38
+ const response = await fetch(url, { ...options, headers });
39
+ const payload = await response.json().catch(() => null);
40
+ if (!response.ok) {
41
+ throw new Error(
42
+ `Canveo API error (${response.status}) on ${route}: ${
43
+ payload?.message || response.statusText
44
+ }`
45
+ );
46
+ }
47
+ return payload;
48
+ }
49
+
50
+ /**
51
+ * @param {string} uploadUrl
52
+ * @param {Buffer} fileBuffer
53
+ * @param {string} contentType
54
+ */
55
+ async function uploadFileToSignedUrl(uploadUrl, fileBuffer, contentType) {
56
+ const response = await fetch(uploadUrl, {
57
+ method: "PUT",
58
+ headers: { "Content-Type": contentType },
59
+ body: fileBuffer,
60
+ });
61
+ if (!response.ok) {
62
+ throw new Error(`Signed URL upload failed (${response.status}).`);
63
+ }
64
+ }
65
+
66
+ /**
67
+ * @param {string} url
68
+ */
69
+ async function downloadBuffer(url) {
70
+ const response = await fetch(url);
71
+ if (!response.ok) {
72
+ throw new Error(`Failed to download file (${response.status}).`);
73
+ }
74
+ const arr = await response.arrayBuffer();
75
+ return Buffer.from(arr);
76
+ }
77
+
78
+ /**
79
+ * @param {string} originalVersionId
80
+ * @param {Record<string, unknown> | null} reviewOptions
81
+ */
82
+ async function startAnalysis(originalVersionId, reviewOptions = null) {
83
+ const payload = {
84
+ extractMetadata: true,
85
+ topicsAndPropertiesTagging: true,
86
+ complianceAssessment: true,
87
+ reviewOptions:
88
+ reviewOptions && typeof reviewOptions === "object" ? reviewOptions : null,
89
+ };
90
+ const result = await canveoApi(`/agrv/${originalVersionId}/analyze`, {
91
+ method: "POST",
92
+ body: JSON.stringify(payload),
93
+ });
94
+ return result?.data?.id || result?.data?.jobId || null;
95
+ }
96
+
97
+ /**
98
+ * @param {string} jobId
99
+ */
100
+ async function waitForAnalysis(jobId) {
101
+ const started = Date.now();
102
+ while (Date.now() - started < POLL_TIMEOUT_MS) {
103
+ const status = await canveoApi(`/analysis-jobs/status/${jobId}`, {
104
+ method: "GET",
105
+ });
106
+ const data = status?.data || {};
107
+ if (data.status === "finished") {
108
+ return data?.versions?.finalVersionId || data?.versions?.workingVersionId;
109
+ }
110
+ if (data.status === "error" || data.status === "cancelled") {
111
+ throw new Error(`Analysis job ended with status "${data.status}".`);
112
+ }
113
+ await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
114
+ }
115
+ throw new Error("Timed out waiting for analysis job completion.");
116
+ }
117
+
118
+ /**
119
+ * @param {string} filePath
120
+ * @param {string | undefined} playbookId
121
+ * @param {Record<string, unknown>} options
122
+ * @param {string | undefined} outputDir
123
+ */
124
+ async function reviewDoc(filePath, playbookId, options, outputDir) {
125
+ const absolutePath = path.resolve(filePath);
126
+ const inputName = path.basename(absolutePath);
127
+ const outputBase = inputName.replace(/\.[^.]+$/, "");
128
+ const resolvedOutputDir = path.resolve(outputDir || DEFAULT_OUTPUT_DIR);
129
+ await fs.mkdir(resolvedOutputDir, { recursive: true });
130
+
131
+ const fileBuffer = await fs.readFile(absolutePath);
132
+ const contentType =
133
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
134
+
135
+ const signedUpload = await canveoApi("/upload/signedUrl", {
136
+ method: "POST",
137
+ body: JSON.stringify({
138
+ contentType,
139
+ bucketAlias: "documents",
140
+ }),
141
+ });
142
+ const uploadData = signedUpload?.data || {};
143
+ await uploadFileToSignedUrl(uploadData.uploadSignedUrl, fileBuffer, contentType);
144
+
145
+ const created = await canveoApi("/cursor/review-doc", {
146
+ method: "POST",
147
+ body: JSON.stringify({
148
+ sourceS3Key: uploadData.key,
149
+ fileName: inputName,
150
+ playbookId: playbookId || undefined,
151
+ options: options || {},
152
+ }),
153
+ });
154
+ const agreementId = created?.data?.agreementId || null;
155
+ const originalVersionId = created?.data?.originalVersionId || null;
156
+ if (!originalVersionId) {
157
+ throw new Error("No originalVersionId returned by /cursor/review-doc.");
158
+ }
159
+
160
+ const jobId = await startAnalysis(originalVersionId, options);
161
+ if (!jobId) {
162
+ throw new Error("No jobId returned when starting analysis.");
163
+ }
164
+
165
+ const finalVersionId = await waitForAnalysis(String(jobId));
166
+ if (!finalVersionId) {
167
+ throw new Error("No finalVersionId found for completed analysis job.");
168
+ }
169
+
170
+ const exportData = await canveoApi(
171
+ `/cursor/review-doc/export/${finalVersionId}`,
172
+ {
173
+ method: "GET",
174
+ }
175
+ );
176
+ const downloadUrl = exportData?.data?.downloadUrl;
177
+ if (!downloadUrl) {
178
+ throw new Error("No downloadUrl returned by export endpoint.");
179
+ }
180
+
181
+ const docBuffer = await downloadBuffer(downloadUrl);
182
+ const outputDocxPath = path.join(resolvedOutputDir, `${outputBase}-redlined.docx`);
183
+ await fs.writeFile(outputDocxPath, docBuffer);
184
+
185
+ const assessment = await canveoApi(
186
+ `/compliance-assessments/version/${finalVersionId}`,
187
+ {
188
+ method: "GET",
189
+ }
190
+ );
191
+ const outputJsonPath = path.join(
192
+ resolvedOutputDir,
193
+ `${outputBase}-assessment.json`
194
+ );
195
+ await fs.writeFile(outputJsonPath, JSON.stringify(assessment?.data || {}, null, 2));
196
+
197
+ return {
198
+ outputDocxPath,
199
+ outputJsonPath,
200
+ agreementId,
201
+ finalVersionId,
202
+ agreementUrl:
203
+ WEB_URL && agreementId
204
+ ? `${WEB_URL.replace(/\/$/, "")}/agreements/${agreementId}`
205
+ : null,
206
+ };
207
+ }
208
+
209
+ export async function startMcpServer() {
210
+ if (!API_URL || !API_TOKEN) {
211
+ throw new Error(
212
+ "Missing CANVEO_API_URL or CANVEO_PAT environment variables."
213
+ );
214
+ }
215
+
216
+ const server = new Server(
217
+ {
218
+ name: SERVER_NAME,
219
+ version: SERVER_VERSION,
220
+ },
221
+ {
222
+ capabilities: {
223
+ tools: {},
224
+ },
225
+ }
226
+ );
227
+
228
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({
229
+ tools: [
230
+ {
231
+ name: "canveo.listPlaybooks",
232
+ description: "List active Canveo playbooks for the current organization.",
233
+ inputSchema: { type: "object", properties: {} },
234
+ },
235
+ {
236
+ name: "canveo.reviewDoc",
237
+ description:
238
+ "Upload a local .docx, run compliance assessment, and save redlined .docx + assessment JSON locally.",
239
+ inputSchema: {
240
+ type: "object",
241
+ properties: {
242
+ filePath: { type: "string" },
243
+ playbookId: { type: "string" },
244
+ options: { type: "object" },
245
+ outputDir: { type: "string" },
246
+ },
247
+ required: ["filePath"],
248
+ },
249
+ },
250
+ ],
251
+ }));
252
+
253
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
254
+ const { name, arguments: args = {} } = request.params;
255
+
256
+ if (name === "canveo.listPlaybooks") {
257
+ const data = await canveoApi("/playbook", { method: "GET" });
258
+ const playbooks = Array.isArray(data?.data) ? data.data : [];
259
+
260
+ const enriched = await Promise.all(
261
+ playbooks.map(async (playbook) => {
262
+ const id = playbook?._id;
263
+ if (!id) return playbook;
264
+ try {
265
+ const latest = await canveoApi(`/playbook/${id}/versions/latest`, {
266
+ method: "GET",
267
+ });
268
+ return {
269
+ ...playbook,
270
+ latestVersion: latest?.data || null,
271
+ };
272
+ } catch {
273
+ return playbook;
274
+ }
275
+ })
276
+ );
277
+ return {
278
+ content: [
279
+ { type: "text", text: JSON.stringify(enriched, null, 2) },
280
+ ],
281
+ };
282
+ }
283
+
284
+ if (name === "canveo.reviewDoc") {
285
+ const result = await reviewDoc(
286
+ String(args.filePath),
287
+ typeof args.playbookId === "string" ? args.playbookId : undefined,
288
+ typeof args.options === "object" && args.options ? args.options : {},
289
+ typeof args.outputDir === "string" ? args.outputDir : undefined
290
+ );
291
+ return {
292
+ content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
293
+ };
294
+ }
295
+
296
+ throw new Error(`Unknown tool: ${name}`);
297
+ });
298
+
299
+ const transport = new StdioServerTransport();
300
+ await server.connect(transport);
301
+
302
+ const currentFile = fileURLToPath(import.meta.url);
303
+ if (process.env.CANVEO_MCP_DEBUG === "true") {
304
+ console.error(`Canveo MCP started from ${currentFile}`);
305
+ }
306
+ }
307
+
308
+ const isDirectRun =
309
+ Boolean(process.argv[1]) &&
310
+ path.resolve(process.argv[1]) === fileURLToPath(import.meta.url);
311
+
312
+ if (isDirectRun) {
313
+ try {
314
+ await startMcpServer();
315
+ } catch (error) {
316
+ console.error(error instanceof Error ? error.message : error);
317
+ process.exit(1);
318
+ }
319
+ }
320
+
321
+ export { reviewDoc, waitForAnalysis, startAnalysis, SERVER_NAME, SERVER_VERSION };
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@canveo/mcp",
3
+ "version": "0.1.0",
4
+ "description": "Canveo Model Context Protocol server for contract review, creation, sending, and signing. Works with any MCP client (Cursor, Claude Desktop, VS Code, and others).",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "Canveo",
8
+ "keywords": [
9
+ "mcp",
10
+ "model-context-protocol",
11
+ "canveo",
12
+ "contracts",
13
+ "compliance",
14
+ "review"
15
+ ],
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/getcanveo/canveo-mcp.git"
19
+ },
20
+ "homepage": "https://github.com/getcanveo/canveo-mcp#readme",
21
+ "bugs": {
22
+ "url": "https://github.com/getcanveo/canveo-mcp/issues"
23
+ },
24
+ "engines": {
25
+ "node": ">=20"
26
+ },
27
+ "bin": {
28
+ "canveo-mcp": "./index.js",
29
+ "canveo-cursor-mcp": "./index.js"
30
+ },
31
+ "main": "index.js",
32
+ "files": [
33
+ "index.js",
34
+ "README.md",
35
+ "LICENSE",
36
+ "CHANGELOG.md"
37
+ ],
38
+ "publishConfig": {
39
+ "access": "public"
40
+ },
41
+ "scripts": {
42
+ "start": "node index.js",
43
+ "test": "vitest --run",
44
+ "pack:check": "npm pack --dry-run"
45
+ },
46
+ "dependencies": {
47
+ "@modelcontextprotocol/sdk": "^1.17.5"
48
+ },
49
+ "devDependencies": {
50
+ "vitest": "^3.0.7"
51
+ }
52
+ }