@signatrust/mcp-server 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +110 -0
- package/dist/errors.d.ts +20 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +87 -0
- package/dist/errors.js.map +1 -0
- package/dist/handlers.d.ts +316 -0
- package/dist/handlers.d.ts.map +1 -0
- package/dist/handlers.js +389 -0
- package/dist/handlers.js.map +1 -0
- package/dist/server.d.ts +16 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +90 -0
- package/dist/server.js.map +1 -0
- package/dist/vendor/signatrust-sdk/api-client.d.ts +77 -0
- package/dist/vendor/signatrust-sdk/api-client.d.ts.map +1 -0
- package/dist/vendor/signatrust-sdk/api-client.js +130 -0
- package/dist/vendor/signatrust-sdk/api-client.js.map +1 -0
- package/dist/vendor/signatrust-sdk/index.d.ts +3 -0
- package/dist/vendor/signatrust-sdk/index.d.ts.map +1 -0
- package/dist/vendor/signatrust-sdk/index.js +3 -0
- package/dist/vendor/signatrust-sdk/index.js.map +1 -0
- package/dist/vendor/signatrust-sdk/types.d.ts +170 -0
- package/dist/vendor/signatrust-sdk/types.d.ts.map +1 -0
- package/dist/vendor/signatrust-sdk/types.js +10 -0
- package/dist/vendor/signatrust-sdk/types.js.map +1 -0
- package/manifest.json +51 -0
- package/package.json +56 -0
package/dist/handlers.js
ADDED
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool definitions and handlers.
|
|
3
|
+
*
|
|
4
|
+
* The SignaTrust client is injected rather than instantiated at module level
|
|
5
|
+
* so handlers are straightforward to unit test.
|
|
6
|
+
*/
|
|
7
|
+
import { readFile, stat } from "node:fs/promises";
|
|
8
|
+
import { basename, extname } from "node:path";
|
|
9
|
+
// =============================================================================
|
|
10
|
+
// Tool Definitions
|
|
11
|
+
// =============================================================================
|
|
12
|
+
export const TOOLS = [
|
|
13
|
+
{
|
|
14
|
+
name: "list_envelopes",
|
|
15
|
+
description: "List signature envelopes with optional status filter and pagination. " +
|
|
16
|
+
"Returns envelope summaries including signers, documents, and blockchain " +
|
|
17
|
+
"anchoring status.",
|
|
18
|
+
inputSchema: {
|
|
19
|
+
type: "object",
|
|
20
|
+
properties: {
|
|
21
|
+
status: {
|
|
22
|
+
type: "string",
|
|
23
|
+
enum: ["DRAFT", "SENT", "NEEDS_SIGNATURE", "COMPLETED", "VOIDED", "DECLINED"],
|
|
24
|
+
description: "Filter by envelope status",
|
|
25
|
+
},
|
|
26
|
+
page: {
|
|
27
|
+
type: "number",
|
|
28
|
+
description: "Page number (1-indexed)",
|
|
29
|
+
minimum: 1,
|
|
30
|
+
},
|
|
31
|
+
limit: {
|
|
32
|
+
type: "number",
|
|
33
|
+
enum: [10, 25, 50],
|
|
34
|
+
description: "Results per page (default: 10)",
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
annotations: {
|
|
39
|
+
title: "List Envelopes",
|
|
40
|
+
readOnlyHint: true,
|
|
41
|
+
destructiveHint: false,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "get_envelope",
|
|
46
|
+
description: "Get full details of a specific envelope including all signers, " +
|
|
47
|
+
"documents, status, security level, and blockchain anchoring info.",
|
|
48
|
+
inputSchema: {
|
|
49
|
+
type: "object",
|
|
50
|
+
properties: {
|
|
51
|
+
id: {
|
|
52
|
+
type: "string",
|
|
53
|
+
description: "Envelope ID",
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
required: ["id"],
|
|
57
|
+
},
|
|
58
|
+
annotations: {
|
|
59
|
+
title: "Get Envelope Details",
|
|
60
|
+
readOnlyHint: true,
|
|
61
|
+
destructiveHint: false,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: "create_envelope",
|
|
66
|
+
description: "Create and send a new envelope for signing. Requires a name, at least " +
|
|
67
|
+
"one signer, and at least one document (pass document IDs from " +
|
|
68
|
+
"upload_document, or pass a templateId to create from a template). " +
|
|
69
|
+
"Signers are notified via their chosen delivery method. Use " +
|
|
70
|
+
"securityLevel to match the legal weight required: STANDARD for routine/" +
|
|
71
|
+
"internal approvals; VERIFIED (adds SMS/email OTP) for employment, " +
|
|
72
|
+
"vendor, or healthcare consent; CERTIFIED (adds WebAuthn biometric + " +
|
|
73
|
+
"device binding) for real estate, high-value, or regulatory signings.",
|
|
74
|
+
inputSchema: {
|
|
75
|
+
type: "object",
|
|
76
|
+
properties: {
|
|
77
|
+
name: {
|
|
78
|
+
type: "string",
|
|
79
|
+
description: "Envelope name/title shown to signers (max 256 chars)",
|
|
80
|
+
maxLength: 256,
|
|
81
|
+
},
|
|
82
|
+
securityLevel: {
|
|
83
|
+
type: "string",
|
|
84
|
+
enum: ["STANDARD", "VERIFIED", "CERTIFIED"],
|
|
85
|
+
description: "Signing ceremony tier. STANDARD = bearer-token only (default, " +
|
|
86
|
+
"legally weakest — vulnerable to link-forwarding disputes). " +
|
|
87
|
+
"VERIFIED = STANDARD + SMS/email OTP (defeats link forwarding; " +
|
|
88
|
+
"suitable for employment contracts, vendor agreements, healthcare " +
|
|
89
|
+
"consent). CERTIFIED = VERIFIED + WebAuthn biometric on a " +
|
|
90
|
+
"device-bound credential (near-unrepudiable; suitable for real " +
|
|
91
|
+
"estate, high-value transactions, regulated industries). All " +
|
|
92
|
+
"tiers are included on every plan.",
|
|
93
|
+
},
|
|
94
|
+
signers: {
|
|
95
|
+
type: "array",
|
|
96
|
+
description: "List of signers for this envelope",
|
|
97
|
+
items: {
|
|
98
|
+
type: "object",
|
|
99
|
+
properties: {
|
|
100
|
+
name: {
|
|
101
|
+
type: "string",
|
|
102
|
+
description: "Signer's full name",
|
|
103
|
+
},
|
|
104
|
+
email: {
|
|
105
|
+
type: "string",
|
|
106
|
+
description: "Signer's email address (required unless phone is provided)",
|
|
107
|
+
},
|
|
108
|
+
phone: {
|
|
109
|
+
type: "string",
|
|
110
|
+
description: "Signer's phone number for SMS delivery (required unless " +
|
|
111
|
+
"email is provided)",
|
|
112
|
+
},
|
|
113
|
+
role: {
|
|
114
|
+
type: "string",
|
|
115
|
+
enum: ["SIGNER", "OBSERVER"],
|
|
116
|
+
description: "SIGNER must sign, OBSERVER can only view (default: SIGNER)",
|
|
117
|
+
},
|
|
118
|
+
routingOrder: {
|
|
119
|
+
type: "number",
|
|
120
|
+
description: "Signing order (1 = first, 2 = second, ...)",
|
|
121
|
+
minimum: 1,
|
|
122
|
+
},
|
|
123
|
+
deliveryMethod: {
|
|
124
|
+
type: "string",
|
|
125
|
+
enum: ["EMAIL", "SMS", "BOTH"],
|
|
126
|
+
description: "How to notify signer (default: EMAIL)",
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
required: ["name"],
|
|
130
|
+
},
|
|
131
|
+
minItems: 1,
|
|
132
|
+
},
|
|
133
|
+
documentIds: {
|
|
134
|
+
type: "array",
|
|
135
|
+
description: "IDs of documents to include. Use upload_document to create a " +
|
|
136
|
+
"document first. Either documentIds or templateId is required.",
|
|
137
|
+
items: { type: "string" },
|
|
138
|
+
},
|
|
139
|
+
templateId: {
|
|
140
|
+
type: "string",
|
|
141
|
+
description: "Template ID to create the envelope from. When set, the backend " +
|
|
142
|
+
"copies the template's document server-side — you do not need to " +
|
|
143
|
+
"supply documentIds. Either documentIds or templateId is required.",
|
|
144
|
+
},
|
|
145
|
+
message: {
|
|
146
|
+
type: "string",
|
|
147
|
+
description: "Optional message included in the signing notification",
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
required: ["signers"],
|
|
151
|
+
},
|
|
152
|
+
annotations: {
|
|
153
|
+
title: "Create Envelope",
|
|
154
|
+
readOnlyHint: false,
|
|
155
|
+
destructiveHint: false,
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
name: "list_templates",
|
|
160
|
+
description: "List available document templates. Templates provide pre-configured " +
|
|
161
|
+
"documents with defined signer roles and form-field placement.",
|
|
162
|
+
inputSchema: {
|
|
163
|
+
type: "object",
|
|
164
|
+
properties: {
|
|
165
|
+
includeSystem: {
|
|
166
|
+
type: "boolean",
|
|
167
|
+
description: "Include system-provided templates alongside user templates " +
|
|
168
|
+
"(default: true)",
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
annotations: {
|
|
173
|
+
title: "List Templates",
|
|
174
|
+
readOnlyHint: true,
|
|
175
|
+
destructiveHint: false,
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
name: "upload_document",
|
|
180
|
+
description: "Upload a local file to SignaTrust and return a document ID suitable " +
|
|
181
|
+
"for passing to create_envelope. Reads the file from disk, requests a " +
|
|
182
|
+
"pre-signed S3 upload URL, streams the bytes, and returns metadata. " +
|
|
183
|
+
"Supported: PDF (recommended), DOCX, images. Max size is enforced by " +
|
|
184
|
+
"your plan's limits.",
|
|
185
|
+
inputSchema: {
|
|
186
|
+
type: "object",
|
|
187
|
+
properties: {
|
|
188
|
+
filePath: {
|
|
189
|
+
type: "string",
|
|
190
|
+
description: "Absolute path to the file on the local filesystem",
|
|
191
|
+
},
|
|
192
|
+
name: {
|
|
193
|
+
type: "string",
|
|
194
|
+
description: "Display name for the document (default: the file's basename)",
|
|
195
|
+
},
|
|
196
|
+
contentType: {
|
|
197
|
+
type: "string",
|
|
198
|
+
description: "MIME type (default: inferred from the file extension — .pdf, " +
|
|
199
|
+
".docx, .png, .jpg, .jpeg are recognised)",
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
required: ["filePath"],
|
|
203
|
+
},
|
|
204
|
+
annotations: {
|
|
205
|
+
title: "Upload Document",
|
|
206
|
+
readOnlyHint: false,
|
|
207
|
+
destructiveHint: false,
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
name: "analyze_document",
|
|
212
|
+
description: "Run AI contract analysis (Google Gemini) on a completed envelope's " +
|
|
213
|
+
"document. Returns a structured report covering risk assessment, " +
|
|
214
|
+
"flagged clauses, and overall sentiment (SAFE / CAUTION / RISKY). " +
|
|
215
|
+
"Plan-gated: free accounts receive a 403; upgrade to Pro Lite or above " +
|
|
216
|
+
"to use this. Surface the 403 message to the user rather than retrying.",
|
|
217
|
+
inputSchema: {
|
|
218
|
+
type: "object",
|
|
219
|
+
properties: {
|
|
220
|
+
envelopeId: {
|
|
221
|
+
type: "string",
|
|
222
|
+
description: "Envelope ID to analyze",
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
required: ["envelopeId"],
|
|
226
|
+
},
|
|
227
|
+
annotations: {
|
|
228
|
+
title: "Analyze Document (AI)",
|
|
229
|
+
readOnlyHint: true,
|
|
230
|
+
destructiveHint: false,
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
name: "void_envelope",
|
|
235
|
+
description: "Void (cancel) an in-progress envelope. The envelope's status becomes " +
|
|
236
|
+
"VOIDED, all signers receive a cancellation notice, and the void is " +
|
|
237
|
+
"recorded in the audit trail. Use this when the sender needs to cancel " +
|
|
238
|
+
"a contract that has already been sent to signers. Fails if the envelope " +
|
|
239
|
+
"is already COMPLETED or already VOIDED — use get_envelope first to " +
|
|
240
|
+
"check status. After voiding, the envelope can be deleted via the " +
|
|
241
|
+
"dashboard or DELETE /api/v1/envelopes/{id}.",
|
|
242
|
+
inputSchema: {
|
|
243
|
+
type: "object",
|
|
244
|
+
properties: {
|
|
245
|
+
id: {
|
|
246
|
+
type: "string",
|
|
247
|
+
description: "Envelope ID to void",
|
|
248
|
+
},
|
|
249
|
+
reason: {
|
|
250
|
+
type: "string",
|
|
251
|
+
description: "Optional reason for voiding — included in the cancellation " +
|
|
252
|
+
"notice sent to signers, the audit event, and the webhook payload. " +
|
|
253
|
+
"Recommend providing one so signers understand why.",
|
|
254
|
+
maxLength: 500,
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
required: ["id"],
|
|
258
|
+
},
|
|
259
|
+
annotations: {
|
|
260
|
+
title: "Void Envelope",
|
|
261
|
+
readOnlyHint: false,
|
|
262
|
+
destructiveHint: true,
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
name: "verify_blockchain",
|
|
267
|
+
description: "Verify a completed envelope's Solana anchor. Returns the composite " +
|
|
268
|
+
"hash (SHA-256 binding the final PDF, signer metadata, and the " +
|
|
269
|
+
"hash-chained audit trail), the file hash, the Solana transaction ID, " +
|
|
270
|
+
"and an explorer URL. Because the composite hash is anchored to " +
|
|
271
|
+
"Solana, any modification to the document, signer records, or audit " +
|
|
272
|
+
"trail breaks the hash chain and fails verification. This is the " +
|
|
273
|
+
"proof that makes the envelope independently verifiable without " +
|
|
274
|
+
"SignaTrust.",
|
|
275
|
+
inputSchema: {
|
|
276
|
+
type: "object",
|
|
277
|
+
properties: {
|
|
278
|
+
envelopeId: {
|
|
279
|
+
type: "string",
|
|
280
|
+
description: "Envelope ID to verify",
|
|
281
|
+
},
|
|
282
|
+
},
|
|
283
|
+
required: ["envelopeId"],
|
|
284
|
+
},
|
|
285
|
+
annotations: {
|
|
286
|
+
title: "Verify Blockchain Anchor",
|
|
287
|
+
readOnlyHint: true,
|
|
288
|
+
destructiveHint: false,
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
];
|
|
292
|
+
function success(data) {
|
|
293
|
+
return {
|
|
294
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
const EXTENSION_MIME = {
|
|
298
|
+
".pdf": "application/pdf",
|
|
299
|
+
".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
300
|
+
".doc": "application/msword",
|
|
301
|
+
".png": "image/png",
|
|
302
|
+
".jpg": "image/jpeg",
|
|
303
|
+
".jpeg": "image/jpeg",
|
|
304
|
+
".txt": "text/plain",
|
|
305
|
+
};
|
|
306
|
+
function inferContentType(filePath) {
|
|
307
|
+
const ext = extname(filePath).toLowerCase();
|
|
308
|
+
return EXTENSION_MIME[ext] ?? "application/octet-stream";
|
|
309
|
+
}
|
|
310
|
+
// =============================================================================
|
|
311
|
+
// Handler
|
|
312
|
+
// =============================================================================
|
|
313
|
+
export async function handleTool(client, name, args) {
|
|
314
|
+
switch (name) {
|
|
315
|
+
case "list_envelopes": {
|
|
316
|
+
const result = await client.listEnvelopes({
|
|
317
|
+
status: args.status,
|
|
318
|
+
page: args.page,
|
|
319
|
+
limit: args.limit,
|
|
320
|
+
});
|
|
321
|
+
return success(result);
|
|
322
|
+
}
|
|
323
|
+
case "get_envelope": {
|
|
324
|
+
const result = await client.getEnvelope(args.id);
|
|
325
|
+
return success(result);
|
|
326
|
+
}
|
|
327
|
+
case "create_envelope": {
|
|
328
|
+
const result = await client.createEnvelope({
|
|
329
|
+
name: args.name,
|
|
330
|
+
signers: args.signers,
|
|
331
|
+
documentIds: args.documentIds,
|
|
332
|
+
templateId: args.templateId,
|
|
333
|
+
message: args.message,
|
|
334
|
+
securityLevel: args.securityLevel,
|
|
335
|
+
});
|
|
336
|
+
return success(result);
|
|
337
|
+
}
|
|
338
|
+
case "list_templates": {
|
|
339
|
+
const result = await client.listTemplates({
|
|
340
|
+
includeSystem: args.includeSystem,
|
|
341
|
+
});
|
|
342
|
+
return success(result);
|
|
343
|
+
}
|
|
344
|
+
case "upload_document": {
|
|
345
|
+
const filePath = args.filePath;
|
|
346
|
+
const stats = await stat(filePath);
|
|
347
|
+
const bytes = await readFile(filePath);
|
|
348
|
+
const displayName = args.name ?? basename(filePath);
|
|
349
|
+
const contentType = args.contentType ?? inferContentType(filePath);
|
|
350
|
+
const uploaded = await client.requestDocumentUpload({
|
|
351
|
+
name: displayName,
|
|
352
|
+
contentType,
|
|
353
|
+
size: stats.size,
|
|
354
|
+
});
|
|
355
|
+
await client.putBytesToUploadUrl(uploaded.uploadUrl, bytes, contentType);
|
|
356
|
+
return success({
|
|
357
|
+
id: uploaded.id,
|
|
358
|
+
name: uploaded.name,
|
|
359
|
+
contentType: uploaded.contentType,
|
|
360
|
+
size: uploaded.size,
|
|
361
|
+
hash: uploaded.hash,
|
|
362
|
+
createdAt: uploaded.createdAt,
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
case "analyze_document": {
|
|
366
|
+
const result = await client.analyzeEnvelope(args.envelopeId);
|
|
367
|
+
return success(result);
|
|
368
|
+
}
|
|
369
|
+
case "void_envelope": {
|
|
370
|
+
const result = await client.voidEnvelope(args.id, args.reason);
|
|
371
|
+
return success(result);
|
|
372
|
+
}
|
|
373
|
+
case "verify_blockchain": {
|
|
374
|
+
const result = await client.verifyBlockchain(args.envelopeId);
|
|
375
|
+
return success(result);
|
|
376
|
+
}
|
|
377
|
+
default:
|
|
378
|
+
return {
|
|
379
|
+
content: [
|
|
380
|
+
{
|
|
381
|
+
type: "text",
|
|
382
|
+
text: `Unknown tool: ${name}. Use list_tools to see available tools.`,
|
|
383
|
+
},
|
|
384
|
+
],
|
|
385
|
+
isError: true,
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
//# sourceMappingURL=handlers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handlers.js","sourceRoot":"","sources":["../src/handlers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAO9C,gFAAgF;AAChF,mBAAmB;AACnB,gFAAgF;AAEhF,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB;QACE,IAAI,EAAE,gBAAgB;QACtB,WAAW,EACT,uEAAuE;YACvE,0EAA0E;YAC1E,mBAAmB;QACrB,WAAW,EAAE;YACX,IAAI,EAAE,QAAiB;YACvB,UAAU,EAAE;gBACV,MAAM,EAAE;oBACN,IAAI,EAAE,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server enabling AI assistants to interact with the
|
|
6
|
+
* SignaTrust document signing API. Supports envelope management, templates,
|
|
7
|
+
* blockchain verification, and more.
|
|
8
|
+
*
|
|
9
|
+
* Setup:
|
|
10
|
+
* SIGNATRUST_API_KEY=sk_live_xxx npx @signatrust/mcp-server
|
|
11
|
+
*
|
|
12
|
+
* Or add to claude_desktop_config.json:
|
|
13
|
+
* { "mcpServers": { "signatrust": { "command": "npx", "args": ["-y", "@signatrust/mcp-server"], "env": { "SIGNATRUST_API_KEY": "sk_live_xxx" } } } }
|
|
14
|
+
*/
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;GAYG"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* SignaTrust MCP Server
|
|
4
|
+
*
|
|
5
|
+
* Model Context Protocol server enabling AI assistants to interact with the
|
|
6
|
+
* SignaTrust document signing API. Supports envelope management, templates,
|
|
7
|
+
* blockchain verification, and more.
|
|
8
|
+
*
|
|
9
|
+
* Setup:
|
|
10
|
+
* SIGNATRUST_API_KEY=sk_live_xxx npx @signatrust/mcp-server
|
|
11
|
+
*
|
|
12
|
+
* Or add to claude_desktop_config.json:
|
|
13
|
+
* { "mcpServers": { "signatrust": { "command": "npx", "args": ["-y", "@signatrust/mcp-server"], "env": { "SIGNATRUST_API_KEY": "sk_live_xxx" } } } }
|
|
14
|
+
*/
|
|
15
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
16
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
17
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
18
|
+
import { SignaTrustClient, ApiError } from "./vendor/signatrust-sdk/index.js";
|
|
19
|
+
import { formatApiError } from "./errors.js";
|
|
20
|
+
import { TOOLS, handleTool } from "./handlers.js";
|
|
21
|
+
// =============================================================================
|
|
22
|
+
// Configuration
|
|
23
|
+
// =============================================================================
|
|
24
|
+
const API_KEY = process.env.SIGNATRUST_API_KEY;
|
|
25
|
+
const API_URL = process.env.SIGNATRUST_API_URL || "https://app.signatrust.io";
|
|
26
|
+
const VERCEL_PROTECTION_BYPASS = process.env.VERCEL_PROTECTION_BYPASS;
|
|
27
|
+
if (!API_KEY) {
|
|
28
|
+
console.error("Error: SIGNATRUST_API_KEY environment variable is required.\n" +
|
|
29
|
+
"Get your API key at https://app.signatrust.io/settings/api-keys");
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
// Staging is fronted by Vercel's deployment protection. Forwarding the bypass
|
|
33
|
+
// header lets harness runs and staging smoke tests reach the application.
|
|
34
|
+
// In production the env var is unset, so nothing is forwarded.
|
|
35
|
+
// Note: do NOT also send x-vercel-set-bypass-cookie — that triggers a
|
|
36
|
+
// redirect loop under node's fetch because cookies aren't persisted across
|
|
37
|
+
// the follow-up request.
|
|
38
|
+
const extraHeaders = {};
|
|
39
|
+
if (VERCEL_PROTECTION_BYPASS) {
|
|
40
|
+
extraHeaders["x-vercel-protection-bypass"] = VERCEL_PROTECTION_BYPASS;
|
|
41
|
+
}
|
|
42
|
+
const client = new SignaTrustClient({
|
|
43
|
+
apiKey: API_KEY,
|
|
44
|
+
baseUrl: API_URL,
|
|
45
|
+
extraHeaders,
|
|
46
|
+
});
|
|
47
|
+
// =============================================================================
|
|
48
|
+
// Server Setup
|
|
49
|
+
// =============================================================================
|
|
50
|
+
const server = new Server({
|
|
51
|
+
name: "signatrust",
|
|
52
|
+
version: "0.1.0",
|
|
53
|
+
}, {
|
|
54
|
+
capabilities: {
|
|
55
|
+
tools: {},
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
59
|
+
return { tools: TOOLS };
|
|
60
|
+
});
|
|
61
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
62
|
+
const { name } = request.params;
|
|
63
|
+
const args = (request.params.arguments ?? {});
|
|
64
|
+
try {
|
|
65
|
+
return await handleTool(client, name, args);
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
if (error instanceof ApiError) {
|
|
69
|
+
return formatApiError(error.status, error.body, error.retryAfter);
|
|
70
|
+
}
|
|
71
|
+
const message = error instanceof Error ? error.message : "An unexpected error occurred";
|
|
72
|
+
return {
|
|
73
|
+
content: [{ type: "text", text: message }],
|
|
74
|
+
isError: true,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
// =============================================================================
|
|
79
|
+
// Start
|
|
80
|
+
// =============================================================================
|
|
81
|
+
async function main() {
|
|
82
|
+
const transport = new StdioServerTransport();
|
|
83
|
+
await server.connect(transport);
|
|
84
|
+
console.error("SignaTrust MCP server running on stdio");
|
|
85
|
+
}
|
|
86
|
+
main().catch((error) => {
|
|
87
|
+
console.error("Fatal error:", error);
|
|
88
|
+
process.exit(1);
|
|
89
|
+
});
|
|
90
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,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native fetch() (Node 18+)
|
|
5
|
+
* with API key authentication via x-api-key header. All methods return typed
|
|
6
|
+
* responses or throw ApiError on non-2xx status.
|
|
7
|
+
*/
|
|
8
|
+
import type { EnvelopeDetail, CreateEnvelopeInput, TemplateResponse, VerificationResponse, AnalysisResponse, DocumentUploadResponse, PaginatedResponse, ProblemDetails } from "./types.js";
|
|
9
|
+
export interface ClientConfig {
|
|
10
|
+
apiKey: string;
|
|
11
|
+
baseUrl: string;
|
|
12
|
+
/**
|
|
13
|
+
* Optional extra headers added to every API request. Useful for
|
|
14
|
+
* preview/staging deployments gated by a platform auth layer (e.g.
|
|
15
|
+
* Vercel's protection bypass). Never used in production.
|
|
16
|
+
*/
|
|
17
|
+
extraHeaders?: Record<string, string>;
|
|
18
|
+
}
|
|
19
|
+
export interface ApiResponse<T> {
|
|
20
|
+
ok: boolean;
|
|
21
|
+
status: number;
|
|
22
|
+
data: T;
|
|
23
|
+
retryAfter?: string | null;
|
|
24
|
+
}
|
|
25
|
+
export declare class ApiError extends Error {
|
|
26
|
+
status: number;
|
|
27
|
+
body: ProblemDetails | string | null;
|
|
28
|
+
retryAfter?: string | null | undefined;
|
|
29
|
+
constructor(status: number, body: ProblemDetails | string | null, retryAfter?: string | null | undefined);
|
|
30
|
+
}
|
|
31
|
+
export declare class SignaTrustClient {
|
|
32
|
+
private apiKey;
|
|
33
|
+
private baseUrl;
|
|
34
|
+
private extraHeaders;
|
|
35
|
+
constructor(config: ClientConfig);
|
|
36
|
+
private request;
|
|
37
|
+
listEnvelopes(params?: {
|
|
38
|
+
status?: string;
|
|
39
|
+
page?: number;
|
|
40
|
+
limit?: number;
|
|
41
|
+
}): Promise<PaginatedResponse<EnvelopeDetail>>;
|
|
42
|
+
getEnvelope(id: string): Promise<EnvelopeDetail>;
|
|
43
|
+
createEnvelope(input: CreateEnvelopeInput): Promise<EnvelopeDetail>;
|
|
44
|
+
listTemplates(params?: {
|
|
45
|
+
includeSystem?: boolean;
|
|
46
|
+
}): Promise<TemplateResponse[]>;
|
|
47
|
+
/**
|
|
48
|
+
* Request a pre-signed upload URL for a new document.
|
|
49
|
+
* After this returns, PUT the file bytes to `uploadUrl` with the given
|
|
50
|
+
* Content-Type header, then use the returned `id` when creating an envelope.
|
|
51
|
+
*/
|
|
52
|
+
requestDocumentUpload(input: {
|
|
53
|
+
name: string;
|
|
54
|
+
contentType: string;
|
|
55
|
+
size: number;
|
|
56
|
+
}): Promise<DocumentUploadResponse>;
|
|
57
|
+
/**
|
|
58
|
+
* Upload file bytes to a pre-signed S3 URL obtained from requestDocumentUpload.
|
|
59
|
+
* Does not use the API key — the pre-signed URL carries its own auth.
|
|
60
|
+
*/
|
|
61
|
+
putBytesToUploadUrl(uploadUrl: string, bytes: Uint8Array, contentType: string): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Void an in-progress envelope. Sets status to VOIDED, notifies signers
|
|
64
|
+
* with a cancellation notice, writes an ENVELOPE_VOIDED audit event, and
|
|
65
|
+
* dispatches an `envelope.voided` webhook.
|
|
66
|
+
*
|
|
67
|
+
* Fails with 400 if the envelope is already COMPLETED or already VOIDED.
|
|
68
|
+
*/
|
|
69
|
+
voidEnvelope(envelopeId: string, reason?: string): Promise<EnvelopeDetail>;
|
|
70
|
+
verifyBlockchain(envelopeId: string): Promise<VerificationResponse>;
|
|
71
|
+
/**
|
|
72
|
+
* Trigger AI contract analysis on an envelope's document.
|
|
73
|
+
* Plan-gated: Free plan returns 403.
|
|
74
|
+
*/
|
|
75
|
+
analyzeEnvelope(envelopeId: string): Promise<AnalysisResponse>;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=api-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../../../src/vendor/signatrust-sdk/api-client.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,E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