@signdocs-brasil/mcp-server 0.1.0 → 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 +64 -3
- package/dist/bin/http.d.ts +2 -0
- package/dist/bin/http.js +35 -0
- package/dist/bin/http.js.map +1 -0
- package/dist/bin/stdio.js +2 -1
- package/dist/bin/stdio.js.map +1 -1
- package/dist/client.d.ts +50 -0
- package/dist/client.js +71 -0
- package/dist/client.js.map +1 -1
- package/dist/http/server.d.ts +29 -29
- package/dist/http/server.js +213 -36
- package/dist/http/server.js.map +1 -1
- package/dist/server.d.ts +7 -5
- package/dist/server.js +13 -12
- package/dist/server.js.map +1 -1
- package/dist/tools/documents.d.ts +2 -1
- package/dist/tools/documents.js +3 -4
- package/dist/tools/documents.js.map +1 -1
- package/dist/tools/envelopes.d.ts +2 -1
- package/dist/tools/envelopes.js +6 -6
- package/dist/tools/envelopes.js.map +1 -1
- package/dist/tools/evidence.d.ts +2 -1
- package/dist/tools/evidence.js +2 -3
- package/dist/tools/evidence.js.map +1 -1
- package/dist/tools/signingSessions.d.ts +2 -1
- package/dist/tools/signingSessions.js +8 -8
- package/dist/tools/signingSessions.js.map +1 -1
- package/dist/tools/transactions.d.ts +2 -1
- package/dist/tools/transactions.js +4 -5
- package/dist/tools/transactions.js.map +1 -1
- package/dist/tools/verify.d.ts +2 -1
- package/dist/tools/verify.js +5 -7
- package/dist/tools/verify.js.map +1 -1
- package/dist/tools/webhooks.d.ts +2 -1
- package/dist/tools/webhooks.js +5 -6
- package/dist/tools/webhooks.js.map +1 -1
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -105,6 +105,63 @@ The server exposes grounding resources the model can read on demand:
|
|
|
105
105
|
- `signdocs://policy-profiles` — valid `policyProfile` values and CUSTOM steps
|
|
106
106
|
- `signdocs://webhook-events` — all subscribable event types
|
|
107
107
|
|
|
108
|
+
## Remote HTTP transport (multi-tenant)
|
|
109
|
+
|
|
110
|
+
The same tools are also served over **Streamable HTTP** so a single deployment
|
|
111
|
+
can serve many AI agents/tenants — each authenticates per session with its own
|
|
112
|
+
SignDocs credentials (no shared secret baked into the server).
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
npm run start:http # or: signdocs-mcp-http (listens on PORT, default 3000)
|
|
116
|
+
# or containerized:
|
|
117
|
+
docker build -t signdocs-mcp . && docker run -p 3000:3000 signdocs-mcp
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**Endpoint:** `POST /mcp` (Streamable HTTP). Auth is required on the MCP
|
|
121
|
+
`initialize` request, via the `Authorization` header:
|
|
122
|
+
|
|
123
|
+
- `Authorization: Bearer <token>` — a SignDocs OAuth2 access token (from
|
|
124
|
+
`/oauth2/token`), passed straight through to the API.
|
|
125
|
+
- `Authorization: Basic base64(clientId:clientSecret)` — the server runs the
|
|
126
|
+
`client_credentials` exchange for you.
|
|
127
|
+
|
|
128
|
+
Pick the environment per session with `X-SignDocs-Environment: hml|production`
|
|
129
|
+
(defaults to the server's configured default).
|
|
130
|
+
|
|
131
|
+
The server behaves as an **OAuth 2.0 Resource Server**: it serves
|
|
132
|
+
`GET /.well-known/oauth-protected-resource` (RFC 9728, pointing at the SignDocs
|
|
133
|
+
authorization server) and answers an unauthenticated `initialize` with `401` +
|
|
134
|
+
`WWW-Authenticate`. The SignDocs API remains the authoritative token validator.
|
|
135
|
+
`GET /healthz` is an unauthenticated health probe.
|
|
136
|
+
|
|
137
|
+
Example client config (Bearer):
|
|
138
|
+
|
|
139
|
+
```json
|
|
140
|
+
{
|
|
141
|
+
"mcpServers": {
|
|
142
|
+
"signdocs-remote": {
|
|
143
|
+
"type": "http",
|
|
144
|
+
"url": "https://your-host.example/mcp",
|
|
145
|
+
"headers": {
|
|
146
|
+
"Authorization": "Bearer <signdocs_access_token>",
|
|
147
|
+
"X-SignDocs-Environment": "hml"
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
**Server env vars:** `PORT`, `HOST`, `SIGNDOCS_ENVIRONMENT` (default env),
|
|
155
|
+
`MCP_PUBLIC_URL` (for resource metadata behind a proxy), `MCP_CORS_ORIGIN`,
|
|
156
|
+
`MCP_DNS_REBINDING_PROTECTION=true` + `MCP_ALLOWED_HOSTS` / `MCP_ALLOWED_ORIGINS`
|
|
157
|
+
(recommended in production).
|
|
158
|
+
|
|
159
|
+
> Sessions are held in process memory, so run a single instance or use sticky
|
|
160
|
+
> routing. For multi-instance/serverless, front it with sticky sessions or swap
|
|
161
|
+
> the session map for a shared store + EventStore (resumability). Deploying onto
|
|
162
|
+
> the existing `external-api` Lambda + API Gateway as a NestedStack is the
|
|
163
|
+
> intended production path.
|
|
164
|
+
|
|
108
165
|
## Development
|
|
109
166
|
|
|
110
167
|
```bash
|
|
@@ -116,6 +173,10 @@ npm run inspect # build + launch MCP Inspector against the stdio server
|
|
|
116
173
|
|
|
117
174
|
## Roadmap
|
|
118
175
|
|
|
119
|
-
- **v0.1
|
|
120
|
-
- **
|
|
121
|
-
|
|
176
|
+
- **v0.1:** local stdio server, full tool catalog, env credentials.
|
|
177
|
+
- **v0.2 (this release):** remote Streamable-HTTP transport with per-session,
|
|
178
|
+
per-tenant auth (Bearer passthrough or Basic client-credentials) and OAuth
|
|
179
|
+
Resource Server discovery. Tool layer is shared between both transports.
|
|
180
|
+
- **Next:** deploy the HTTP transport onto `external-api` (Lambda + API Gateway
|
|
181
|
+
NestedStack); optional edge JWT validation + shared-store sessions for
|
|
182
|
+
horizontal scale.
|
package/dist/bin/http.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createHttpServer } from '../http/server.js';
|
|
3
|
+
import { resolveEnvironment } from '../client.js';
|
|
4
|
+
/**
|
|
5
|
+
* Remote HTTP entrypoint. Unlike the stdio server, credentials are NOT read
|
|
6
|
+
* from env — each request carries its own (Bearer token or Basic client
|
|
7
|
+
* credentials), so one deployment serves many tenants.
|
|
8
|
+
*/
|
|
9
|
+
function envDefault() {
|
|
10
|
+
try {
|
|
11
|
+
return resolveEnvironment(process.env.SIGNDOCS_ENVIRONMENT);
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return 'hml';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const port = Number(process.env.PORT ?? 3000);
|
|
18
|
+
const host = process.env.HOST ?? '0.0.0.0';
|
|
19
|
+
const server = createHttpServer({
|
|
20
|
+
defaultEnvironment: envDefault(),
|
|
21
|
+
corsOrigin: process.env.MCP_CORS_ORIGIN,
|
|
22
|
+
publicUrl: process.env.MCP_PUBLIC_URL,
|
|
23
|
+
enableDnsRebindingProtection: process.env.MCP_DNS_REBINDING_PROTECTION === 'true',
|
|
24
|
+
allowedHosts: process.env.MCP_ALLOWED_HOSTS?.split(',').map((h) => h.trim()).filter(Boolean),
|
|
25
|
+
allowedOrigins: process.env.MCP_ALLOWED_ORIGINS?.split(',').map((o) => o.trim()).filter(Boolean),
|
|
26
|
+
});
|
|
27
|
+
server.listen(port, host, () => {
|
|
28
|
+
process.stderr.write(`[signdocs-mcp-http] listening on http://${host}:${port}/mcp (default env: ${envDefault()})\n`);
|
|
29
|
+
});
|
|
30
|
+
for (const sig of ['SIGINT', 'SIGTERM']) {
|
|
31
|
+
process.on(sig, () => {
|
|
32
|
+
server.close(() => process.exit(0));
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/bin/http.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAoB,MAAM,cAAc,CAAC;AAEpE;;;;GAIG;AACH,SAAS,UAAU;IACjB,IAAI,CAAC;QACH,OAAO,kBAAkB,CAAC,OA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EAAE;QACnB,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/bin/stdio.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
3
3
|
import { createServer } from '../server.js';
|
|
4
|
+
import { getStdioContext } from '../client.js';
|
|
4
5
|
/**
|
|
5
6
|
* stdio entrypoint. AI clients (Claude Desktop/Code, Cursor, …) launch this
|
|
6
7
|
* binary and speak MCP over stdin/stdout. NEVER write to stdout here — it is
|
|
7
8
|
* the protocol channel; diagnostics go to stderr.
|
|
8
9
|
*/
|
|
9
10
|
async function main() {
|
|
10
|
-
const server = createServer();
|
|
11
|
+
const server = createServer(getStdioContext());
|
|
11
12
|
const transport = new StdioServerTransport();
|
|
12
13
|
await server.connect(transport);
|
|
13
14
|
process.stderr.write('[signdocs-mcp] server started on stdio\n');
|
package/dist/bin/stdio.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stdio.js","sourceRoot":"","sources":["../../src/bin/stdio.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"stdio.js","sourceRoot":"","sources":["../../src/bin/stdio.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C;;;;GAIG;AACH,KAAK,UAAU,IAAI;IACjB,MAAM,MAAM,GAAG,YAAY,CAAC,eAAe,EAAE,CAAC,CAAC;IAC/C,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAC;AACnE,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,yBAAyB,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACjH,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SignDocsBrasilClient } from '@signdocs-brasil/api';
|
|
2
|
+
import type { TokenCache, CachedToken } from '@signdocs-brasil/api';
|
|
2
3
|
/**
|
|
3
4
|
* Thin wrapper that turns environment variables into a configured
|
|
4
5
|
* {@link SignDocsBrasilClient}. The official SDK owns the OAuth2
|
|
@@ -33,3 +34,52 @@ export declare function resetClientCache(): void;
|
|
|
33
34
|
* link — it must carry the one-time embed token (`clientSecret`) as `?cs=`.
|
|
34
35
|
*/
|
|
35
36
|
export declare function buildSigningUrl(url: string, clientSecret: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* What every tool handler needs to talk to SignDocs. In the stdio server this
|
|
39
|
+
* is built once from env; in the remote HTTP server it is built per-request so
|
|
40
|
+
* each tenant is fully isolated (no shared client/token across requests).
|
|
41
|
+
*/
|
|
42
|
+
export interface ToolContext {
|
|
43
|
+
client: SignDocsBrasilClient;
|
|
44
|
+
environment: Environment;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A {@link TokenCache} pre-seeded with a caller-supplied access token. The SDK's
|
|
48
|
+
* AuthHandler checks the cache before exchanging credentials, so seeding it makes
|
|
49
|
+
* the SDK use the presented bearer directly and never call `/oauth2/token`.
|
|
50
|
+
* The SignDocs API remains the real validator — an invalid/expired token yields
|
|
51
|
+
* a 401 from the API, surfaced to the caller.
|
|
52
|
+
*/
|
|
53
|
+
export declare class StaticTokenCache implements TokenCache {
|
|
54
|
+
private readonly token;
|
|
55
|
+
constructor(accessToken: string, ttlMs?: number);
|
|
56
|
+
get(): CachedToken | null;
|
|
57
|
+
set(): void;
|
|
58
|
+
delete(): void;
|
|
59
|
+
}
|
|
60
|
+
export type BuildClientOptions = {
|
|
61
|
+
mode: 'credentials';
|
|
62
|
+
clientId: string;
|
|
63
|
+
clientSecret: string;
|
|
64
|
+
environment: Environment;
|
|
65
|
+
baseUrlOverride?: string;
|
|
66
|
+
scopes?: string[];
|
|
67
|
+
} | {
|
|
68
|
+
mode: 'bearer';
|
|
69
|
+
bearer: string;
|
|
70
|
+
environment: Environment;
|
|
71
|
+
baseUrlOverride?: string;
|
|
72
|
+
scopes?: string[];
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Build a fresh, request-scoped SDK client. `credentials` mode lets the SDK run
|
|
76
|
+
* the OAuth2 client_credentials exchange; `bearer` mode passes a pre-issued
|
|
77
|
+
* access token straight through via {@link StaticTokenCache}.
|
|
78
|
+
*/
|
|
79
|
+
export declare function buildClient(opts: BuildClientOptions): SignDocsBrasilClient;
|
|
80
|
+
/**
|
|
81
|
+
* Build the tool context for the stdio server from environment variables.
|
|
82
|
+
* Credentials are resolved lazily (on first API call); the environment is read
|
|
83
|
+
* eagerly but does not require credentials.
|
|
84
|
+
*/
|
|
85
|
+
export declare function getStdioContext(env?: NodeJS.ProcessEnv): ToolContext;
|
package/dist/client.js
CHANGED
|
@@ -77,4 +77,75 @@ export function resetClientCache() {
|
|
|
77
77
|
export function buildSigningUrl(url, clientSecret) {
|
|
78
78
|
return `${url}?cs=${encodeURIComponent(clientSecret)}`;
|
|
79
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* A {@link TokenCache} pre-seeded with a caller-supplied access token. The SDK's
|
|
82
|
+
* AuthHandler checks the cache before exchanging credentials, so seeding it makes
|
|
83
|
+
* the SDK use the presented bearer directly and never call `/oauth2/token`.
|
|
84
|
+
* The SignDocs API remains the real validator — an invalid/expired token yields
|
|
85
|
+
* a 401 from the API, surfaced to the caller.
|
|
86
|
+
*/
|
|
87
|
+
export class StaticTokenCache {
|
|
88
|
+
token;
|
|
89
|
+
constructor(accessToken, ttlMs = 60 * 60 * 1000) {
|
|
90
|
+
this.token = { accessToken, expiresAt: Date.now() + ttlMs };
|
|
91
|
+
}
|
|
92
|
+
get() {
|
|
93
|
+
return this.token;
|
|
94
|
+
}
|
|
95
|
+
set() {
|
|
96
|
+
/* no-op: the token is fixed for this request */
|
|
97
|
+
}
|
|
98
|
+
delete() {
|
|
99
|
+
/* no-op */
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Build a fresh, request-scoped SDK client. `credentials` mode lets the SDK run
|
|
104
|
+
* the OAuth2 client_credentials exchange; `bearer` mode passes a pre-issued
|
|
105
|
+
* access token straight through via {@link StaticTokenCache}.
|
|
106
|
+
*/
|
|
107
|
+
export function buildClient(opts) {
|
|
108
|
+
const baseUrl = getBaseUrl(opts.environment, opts.baseUrlOverride);
|
|
109
|
+
const scopes = opts.scopes ?? DEFAULT_SCOPES;
|
|
110
|
+
if (opts.mode === 'bearer') {
|
|
111
|
+
return new SignDocsBrasilClient({
|
|
112
|
+
clientId: 'mcp-bearer-passthrough',
|
|
113
|
+
clientSecret: 'unused', // never used: the token cache short-circuits exchange
|
|
114
|
+
baseUrl,
|
|
115
|
+
scopes,
|
|
116
|
+
tokenCache: new StaticTokenCache(opts.bearer),
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
return new SignDocsBrasilClient({
|
|
120
|
+
clientId: opts.clientId,
|
|
121
|
+
clientSecret: opts.clientSecret,
|
|
122
|
+
baseUrl,
|
|
123
|
+
scopes,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* A client proxy that defers construction until first use, so the stdio server
|
|
128
|
+
* can start and list tools/resources even with no credentials — a missing-cred
|
|
129
|
+
* error surfaces only when a tool actually calls the API.
|
|
130
|
+
*/
|
|
131
|
+
function lazyClient(factory) {
|
|
132
|
+
let instance;
|
|
133
|
+
return new Proxy({}, {
|
|
134
|
+
get(_target, prop, receiver) {
|
|
135
|
+
instance ??= factory();
|
|
136
|
+
return Reflect.get(instance, prop, receiver);
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Build the tool context for the stdio server from environment variables.
|
|
142
|
+
* Credentials are resolved lazily (on first API call); the environment is read
|
|
143
|
+
* eagerly but does not require credentials.
|
|
144
|
+
*/
|
|
145
|
+
export function getStdioContext(env = process.env) {
|
|
146
|
+
return {
|
|
147
|
+
client: lazyClient(() => getClient(env)),
|
|
148
|
+
environment: resolveEnvironment(env.SIGNDOCS_ENVIRONMENT),
|
|
149
|
+
};
|
|
150
|
+
}
|
|
80
151
|
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAY5D,MAAM,SAAS,GAAgC;IAC7C,UAAU,EAAE,6BAA6B;IACzC,uDAAuD;IACvD,GAAG,EAAE,iCAAiC;CACvC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,mBAAmB;IACnB,oBAAoB;IACpB,aAAa;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CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,MAAyB,OAAO,CAAC,GAAG;IAClE,OAAO;QACL,MAAM,EAAE,UAAU,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QACxC,WAAW,EAAE,kBAAkB,CAAC,GAAG,CAAC,oBAAoB,CAAC;KAC1D,CAAC;AACJ,CAAC"}
|
package/dist/http/server.d.ts
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
+
import { type Server } from 'node:http';
|
|
2
|
+
import { type Environment } from '../client.js';
|
|
1
3
|
/**
|
|
2
|
-
* Phase 2 — remote Streamable-HTTP transport (
|
|
4
|
+
* Phase 2 — remote Streamable-HTTP transport (stateful sessions).
|
|
3
5
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
+
* One deployment serves many tenants. A session is established on the MCP
|
|
7
|
+
* `initialize` request, which MUST carry credentials:
|
|
8
|
+
* - `Authorization: Bearer <token>` → a SignDocs OAuth2 access token, passed through.
|
|
9
|
+
* - `Authorization: Basic <base64(clientId:clientSecret)>` → server runs client_credentials.
|
|
10
|
+
* Environment via `X-SignDocs-Environment: hml|production` (default = server default).
|
|
6
11
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* await server.connect(transport);
|
|
12
|
-
* // node:http handler → transport.handleRequest(req, res, body)
|
|
12
|
+
* The tenant's SDK client is bound to that session; follow-up requests are routed
|
|
13
|
+
* by the `Mcp-Session-Id` header. Acts as an OAuth Resource Server: advertises the
|
|
14
|
+
* SignDocs authorization server (RFC 9728) and challenges unauthenticated initialize
|
|
15
|
+
* requests with WWW-Authenticate. The SignDocs API is the real token validator.
|
|
13
16
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* hosted server serves many tenants. The MCP server should act as an
|
|
18
|
-
* OAuth Resource Server: each connecting AI presents its own SignDocs
|
|
19
|
-
* bearer token (issued by the existing /oauth2/token AS). Validate it with
|
|
20
|
-
* the same ES256/KMS verifier external-api uses (auth-middleware.ts) and
|
|
21
|
-
* build a PER-REQUEST SDK client scoped to that tenant — do NOT reuse the
|
|
22
|
-
* process-wide getClient() singleton, which would cross tenant boundaries.
|
|
23
|
-
*
|
|
24
|
-
* 2. DEPLOYMENT. Reuse the external-api Lambda + API Gateway pattern via a new
|
|
25
|
-
* NestedStack (the Core stack is at the CFN 500-resource limit — follow the
|
|
26
|
-
* EnvelopeHandlersStack precedent), or a small container behind the same WAF.
|
|
27
|
-
*
|
|
28
|
-
* 3. SESSION MODE. Stateless (sessionIdGenerator: undefined) fits serverless;
|
|
29
|
-
* confirm against the MCP spec version current at build time, plus DCR /
|
|
30
|
-
* protected-resource metadata discovery needs.
|
|
31
|
-
*
|
|
32
|
-
* Intentionally not wired up yet so the v0.1 stdio package stays dependency-light.
|
|
17
|
+
* Sessions live in process memory, so a single instance (or sticky routing) is
|
|
18
|
+
* assumed. For multi-instance/serverless, front with sticky sessions or swap this
|
|
19
|
+
* map for a shared store + an EventStore for resumability.
|
|
33
20
|
*/
|
|
34
|
-
export
|
|
21
|
+
export interface HttpServerOptions {
|
|
22
|
+
/** Environment when a request doesn't specify one. Default 'hml'. */
|
|
23
|
+
defaultEnvironment?: Environment;
|
|
24
|
+
/** CORS Access-Control-Allow-Origin. Default '*'. */
|
|
25
|
+
corsOrigin?: string;
|
|
26
|
+
/** Public base URL for resource metadata (e.g. https://mcp.signdocs.com.br). Derived from the request if unset. */
|
|
27
|
+
publicUrl?: string;
|
|
28
|
+
/** DNS-rebinding protection — enable in production and pair with allowedHosts/Origins. Default false. */
|
|
29
|
+
enableDnsRebindingProtection?: boolean;
|
|
30
|
+
allowedHosts?: string[];
|
|
31
|
+
allowedOrigins?: string[];
|
|
32
|
+
}
|
|
33
|
+
/** Build (but do not start) the remote HTTP MCP server. Call `.listen(port)`. */
|
|
34
|
+
export declare function createHttpServer(options?: HttpServerOptions): Server;
|
package/dist/http/server.js
CHANGED
|
@@ -1,38 +1,215 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
1
|
+
import { createServer as createNodeHttpServer, } from 'node:http';
|
|
2
|
+
import { randomUUID } from 'node:crypto';
|
|
3
|
+
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
4
|
+
import { isInitializeRequest } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
+
import { createServer as createMcpServer } from '../server.js';
|
|
6
|
+
import { buildClient, getBaseUrl, resolveEnvironment, DEFAULT_SCOPES, } from '../client.js';
|
|
7
|
+
function applyCors(res, opts) {
|
|
8
|
+
res.setHeader('Access-Control-Allow-Origin', opts.corsOrigin);
|
|
9
|
+
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, DELETE, OPTIONS');
|
|
10
|
+
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization, Mcp-Session-Id, Mcp-Protocol-Version, X-SignDocs-Environment');
|
|
11
|
+
res.setHeader('Access-Control-Expose-Headers', 'Mcp-Session-Id, WWW-Authenticate');
|
|
12
|
+
}
|
|
13
|
+
function sendJson(res, status, body, extra) {
|
|
14
|
+
res.writeHead(status, { 'Content-Type': 'application/json', ...extra });
|
|
15
|
+
res.end(JSON.stringify(body));
|
|
16
|
+
}
|
|
17
|
+
function publicBase(req, opts) {
|
|
18
|
+
if (opts.publicUrl)
|
|
19
|
+
return opts.publicUrl.replace(/\/$/, '');
|
|
20
|
+
const fwd = req.headers['x-forwarded-proto'];
|
|
21
|
+
const proto = (Array.isArray(fwd) ? fwd[0] : fwd)?.split(',')[0] ?? 'http';
|
|
22
|
+
const host = req.headers.host ?? 'localhost';
|
|
23
|
+
return `${proto}://${host}`;
|
|
24
|
+
}
|
|
25
|
+
function headerValue(req, name) {
|
|
26
|
+
const raw = req.headers[name];
|
|
27
|
+
return Array.isArray(raw) ? raw[0] : raw;
|
|
28
|
+
}
|
|
29
|
+
function extractAuth(req) {
|
|
30
|
+
const header = req.headers.authorization;
|
|
31
|
+
if (!header)
|
|
32
|
+
return null;
|
|
33
|
+
const space = header.indexOf(' ');
|
|
34
|
+
if (space < 0)
|
|
35
|
+
return null;
|
|
36
|
+
const scheme = header.slice(0, space).toLowerCase();
|
|
37
|
+
const value = header.slice(space + 1).trim();
|
|
38
|
+
if (!value)
|
|
39
|
+
return null;
|
|
40
|
+
if (scheme === 'bearer')
|
|
41
|
+
return { mode: 'bearer', bearer: value };
|
|
42
|
+
if (scheme === 'basic') {
|
|
43
|
+
const decoded = Buffer.from(value, 'base64').toString('utf8');
|
|
44
|
+
const sep = decoded.indexOf(':');
|
|
45
|
+
if (sep < 0)
|
|
46
|
+
return null;
|
|
47
|
+
return { mode: 'credentials', clientId: decoded.slice(0, sep), clientSecret: decoded.slice(sep + 1) };
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
function requestEnvironment(req, fallback) {
|
|
52
|
+
const value = headerValue(req, 'x-signdocs-environment');
|
|
53
|
+
if (value && value.trim()) {
|
|
54
|
+
try {
|
|
55
|
+
return resolveEnvironment(value);
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
/* ignore invalid header, use fallback */
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return fallback;
|
|
62
|
+
}
|
|
63
|
+
function protectedResourceMetadata(req, opts) {
|
|
64
|
+
return {
|
|
65
|
+
resource: `${publicBase(req, opts)}/mcp`,
|
|
66
|
+
authorization_servers: [getBaseUrl(opts.defaultEnvironment)],
|
|
67
|
+
scopes_supported: DEFAULT_SCOPES,
|
|
68
|
+
bearer_methods_supported: ['header'],
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function challenge(req, res, opts) {
|
|
72
|
+
res.setHeader('WWW-Authenticate', `Bearer resource_metadata="${publicBase(req, opts)}/.well-known/oauth-protected-resource"`);
|
|
73
|
+
sendJson(res, 401, {
|
|
74
|
+
error: 'unauthorized',
|
|
75
|
+
error_description: 'Provide a SignDocs OAuth2 access token (Authorization: Bearer <token>) or client ' +
|
|
76
|
+
'credentials (Authorization: Basic base64(clientId:clientSecret)) on the initialize request.',
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function readBody(req) {
|
|
80
|
+
return new Promise((resolve, reject) => {
|
|
81
|
+
const chunks = [];
|
|
82
|
+
req.on('data', (c) => chunks.push(c));
|
|
83
|
+
req.on('end', () => {
|
|
84
|
+
const raw = Buffer.concat(chunks).toString('utf8');
|
|
85
|
+
if (!raw)
|
|
86
|
+
return resolve(undefined);
|
|
87
|
+
try {
|
|
88
|
+
resolve(JSON.parse(raw));
|
|
89
|
+
}
|
|
90
|
+
catch (err) {
|
|
91
|
+
reject(err);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
req.on('error', reject);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
async function startSession(req, res, opts, sessions, body) {
|
|
98
|
+
const auth = extractAuth(req);
|
|
99
|
+
if (!auth) {
|
|
100
|
+
challenge(req, res, opts);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const environment = requestEnvironment(req, opts.defaultEnvironment);
|
|
104
|
+
const client = auth.mode === 'bearer'
|
|
105
|
+
? buildClient({ mode: 'bearer', bearer: auth.bearer, environment })
|
|
106
|
+
: buildClient({ mode: 'credentials', clientId: auth.clientId, clientSecret: auth.clientSecret, environment });
|
|
107
|
+
const ctx = { client, environment };
|
|
108
|
+
const server = createMcpServer(ctx);
|
|
109
|
+
const transport = new StreamableHTTPServerTransport({
|
|
110
|
+
sessionIdGenerator: () => randomUUID(),
|
|
111
|
+
enableJsonResponse: true,
|
|
112
|
+
enableDnsRebindingProtection: opts.enableDnsRebindingProtection ?? false,
|
|
113
|
+
...(opts.allowedHosts ? { allowedHosts: opts.allowedHosts } : {}),
|
|
114
|
+
...(opts.allowedOrigins ? { allowedOrigins: opts.allowedOrigins } : {}),
|
|
115
|
+
onsessioninitialized: (sid) => {
|
|
116
|
+
sessions.set(sid, { transport, server });
|
|
117
|
+
},
|
|
118
|
+
onsessionclosed: (sid) => {
|
|
119
|
+
sessions.delete(sid);
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
transport.onclose = () => {
|
|
123
|
+
if (transport.sessionId)
|
|
124
|
+
sessions.delete(transport.sessionId);
|
|
125
|
+
};
|
|
126
|
+
await server.connect(transport);
|
|
127
|
+
await transport.handleRequest(req, res, body);
|
|
128
|
+
}
|
|
129
|
+
async function handlePost(req, res, opts, sessions) {
|
|
130
|
+
let body;
|
|
131
|
+
try {
|
|
132
|
+
body = await readBody(req);
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
sendJson(res, 400, { error: 'invalid_json', error_description: 'Request body is not valid JSON.' });
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const sessionId = headerValue(req, 'mcp-session-id');
|
|
139
|
+
const existing = sessionId ? sessions.get(sessionId) : undefined;
|
|
140
|
+
if (existing) {
|
|
141
|
+
await existing.transport.handleRequest(req, res, body);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if (isInitializeRequest(body)) {
|
|
145
|
+
await startSession(req, res, opts, sessions, body);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
sendJson(res, 400, {
|
|
149
|
+
error: 'invalid_session',
|
|
150
|
+
error_description: 'Missing or unknown Mcp-Session-Id. Send an initialize request first.',
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
async function handle(req, res, opts, sessions) {
|
|
154
|
+
applyCors(res, opts);
|
|
155
|
+
const method = req.method ?? 'GET';
|
|
156
|
+
if (method === 'OPTIONS') {
|
|
157
|
+
res.writeHead(204);
|
|
158
|
+
res.end();
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const path = new URL(req.url ?? '/', 'http://localhost').pathname;
|
|
162
|
+
if (method === 'GET' && path === '/healthz') {
|
|
163
|
+
sendJson(res, 200, { status: 'ok', transport: 'streamable-http', sessions: sessions.size });
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (method === 'GET' && path === '/.well-known/oauth-protected-resource') {
|
|
167
|
+
sendJson(res, 200, protectedResourceMetadata(req, opts));
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if (path !== '/mcp') {
|
|
171
|
+
sendJson(res, 404, { error: 'not_found' });
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
if (method === 'POST') {
|
|
175
|
+
await handlePost(req, res, opts, sessions);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
// GET (SSE stream) and DELETE (session teardown) require an established session.
|
|
179
|
+
if (method === 'GET' || method === 'DELETE') {
|
|
180
|
+
const sessionId = headerValue(req, 'mcp-session-id');
|
|
181
|
+
const session = sessionId ? sessions.get(sessionId) : undefined;
|
|
182
|
+
if (!session) {
|
|
183
|
+
sendJson(res, 400, { error: 'invalid_session', error_description: 'Unknown or missing Mcp-Session-Id.' });
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
await session.transport.handleRequest(req, res);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
sendJson(res, 405, { error: 'method_not_allowed' }, { Allow: 'GET, POST, DELETE, OPTIONS' });
|
|
190
|
+
}
|
|
191
|
+
/** Build (but do not start) the remote HTTP MCP server. Call `.listen(port)`. */
|
|
192
|
+
export function createHttpServer(options = {}) {
|
|
193
|
+
const opts = {
|
|
194
|
+
...options,
|
|
195
|
+
defaultEnvironment: options.defaultEnvironment ?? 'hml',
|
|
196
|
+
corsOrigin: options.corsOrigin ?? '*',
|
|
197
|
+
};
|
|
198
|
+
const sessions = new Map();
|
|
199
|
+
return createNodeHttpServer((req, res) => {
|
|
200
|
+
handle(req, res, opts, sessions).catch((err) => {
|
|
201
|
+
try {
|
|
202
|
+
if (!res.headersSent) {
|
|
203
|
+
sendJson(res, 500, { error: 'internal_error', message: err instanceof Error ? err.message : String(err) });
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
res.end();
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
catch {
|
|
210
|
+
/* response already torn down */
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
});
|
|
37
214
|
}
|
|
38
215
|
//# sourceMappingURL=server.js.map
|
package/dist/http/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/http/server.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/http/server.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,IAAI,oBAAoB,GAIrC,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AACnG,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAEzE,OAAO,EAAE,YAAY,IAAI,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EACL,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,cAAc,GAGf,MAAM,cAAc,CAAC;AAgDtB,SAAS,SAAS,CAAC,GAAmB,EAAE,IAAqB;IAC3D,GAAG,CAAC,SA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E,EAAE,KAAK,EAAE,oBAAoB,EAAE,EAAE,EAAE,KAAK,EAAE,4BAA4B,EAAE,CAAC,CAAC;AAC/F,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,gBAAgB,CAAC,UAA6B,EAAE;IAC9D,MAAM,IAAI,GAAoB;QAC5B,GAAG,OAAO;QACV,kBAAkB,EAAE,OAAO,CAAC,kBAAkB,IAAI,KAAK;QACvD,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,GAAG;KACtC,CAAC;IACF,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAmB,CAAC;IAC5C,OAAO,oBAAoB,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACvC,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YAC7C,IAAI,CAAC;gBACH,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;oBACrB,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBAC7G,CAAC;qBAAM,CAAC;oBACN,GAAG,CAAC,GAAG,EAAE,CAAC;gBACZ,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,gCAAgC;YAClC,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/server.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { ToolContext } from './client.js';
|
|
2
3
|
export declare const SERVER_NAME = "signdocs-brasil";
|
|
3
|
-
export declare const SERVER_VERSION = "0.
|
|
4
|
+
export declare const SERVER_VERSION = "0.2.0";
|
|
4
5
|
/**
|
|
5
|
-
* Build a fully-wired MCP server
|
|
6
|
-
*
|
|
7
|
-
* (http/server.ts)
|
|
6
|
+
* Build a fully-wired MCP server bound to a request/session-scoped
|
|
7
|
+
* {@link ToolContext}. Transport-agnostic: stdio (bin/stdio.ts) builds one
|
|
8
|
+
* context from env; the HTTP transport (http/server.ts) builds one per request
|
|
9
|
+
* so tenants stay isolated.
|
|
8
10
|
*/
|
|
9
|
-
export declare function createServer(): McpServer;
|
|
11
|
+
export declare function createServer(ctx: ToolContext): McpServer;
|
package/dist/server.js
CHANGED
|
@@ -8,7 +8,7 @@ import { registerVerifyTools } from './tools/verify.js';
|
|
|
8
8
|
import { registerWebhookTools } from './tools/webhooks.js';
|
|
9
9
|
import { registerResources } from './resources.js';
|
|
10
10
|
export const SERVER_NAME = 'signdocs-brasil';
|
|
11
|
-
export const SERVER_VERSION = '0.
|
|
11
|
+
export const SERVER_VERSION = '0.2.0';
|
|
12
12
|
const INSTRUCTIONS = `SignDocs Brasil electronic-signature API.
|
|
13
13
|
|
|
14
14
|
Use signing sessions for single-signer flows and envelopes for multi-signer
|
|
@@ -19,19 +19,20 @@ Tools whose names start with create_, add_, cancel_, delete_, or verify_document
|
|
|
19
19
|
take real, quota-consuming, and often legally-binding actions — confirm with the
|
|
20
20
|
human before invoking them. All other tools are read-only or non-binding.`;
|
|
21
21
|
/**
|
|
22
|
-
* Build a fully-wired MCP server
|
|
23
|
-
*
|
|
24
|
-
* (http/server.ts)
|
|
22
|
+
* Build a fully-wired MCP server bound to a request/session-scoped
|
|
23
|
+
* {@link ToolContext}. Transport-agnostic: stdio (bin/stdio.ts) builds one
|
|
24
|
+
* context from env; the HTTP transport (http/server.ts) builds one per request
|
|
25
|
+
* so tenants stay isolated.
|
|
25
26
|
*/
|
|
26
|
-
export function createServer() {
|
|
27
|
+
export function createServer(ctx) {
|
|
27
28
|
const server = new McpServer({ name: SERVER_NAME, version: SERVER_VERSION }, { instructions: INSTRUCTIONS });
|
|
28
|
-
registerSigningSessionTools(server);
|
|
29
|
-
registerEnvelopeTools(server);
|
|
30
|
-
registerDocumentTools(server);
|
|
31
|
-
registerTransactionTools(server);
|
|
32
|
-
registerEvidenceTools(server);
|
|
33
|
-
registerVerifyTools(server);
|
|
34
|
-
registerWebhookTools(server);
|
|
29
|
+
registerSigningSessionTools(server, ctx);
|
|
30
|
+
registerEnvelopeTools(server, ctx);
|
|
31
|
+
registerDocumentTools(server, ctx);
|
|
32
|
+
registerTransactionTools(server, ctx);
|
|
33
|
+
registerEvidenceTools(server, ctx);
|
|
34
|
+
registerVerifyTools(server, ctx);
|
|
35
|
+
registerWebhookTools(server, ctx);
|
|
35
36
|
registerResources(server);
|
|
36
37
|
return server;
|
|
37
38
|
}
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MAAM,CAAC,MAAM,WAAW,GAAG,iBAAiB,CAAC;AAC7C,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC;AAEtC,MAAM,YAAY,GAAG;;;;;;;;0EAQqD,CAAC;AAE3E;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,GAAgB;IAC3C,MAAM,MAAM,GAAG,IAAI,SAAS,CAC1B,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,EAAE,EAC9C,EAAE,YAAY,EAAE,YAAY,EAAE,CAC/B,CAAC;IAEF,2BAA2B,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACzC,qBAAqB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACnC,qBAAqB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACnC,wBAAwB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACtC,qBAAqB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACnC,mBAAmB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACjC,oBAAoB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAClC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAE1B,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
|
|
2
|
+
import type { ToolContext } from '../client.js';
|
|
3
|
+
export declare function registerDocumentTools(server: McpServer, ctx: ToolContext): void;
|
package/dist/tools/documents.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { getClient } from '../client.js';
|
|
2
1
|
import { READ_ONLY, WRITE_SAFE } from '../annotations.js';
|
|
3
2
|
import { run } from './helpers.js';
|
|
4
3
|
import { uploadDocumentShape, transactionIdShape } from '../schemas.js';
|
|
5
|
-
export function registerDocumentTools(server) {
|
|
4
|
+
export function registerDocumentTools(server, ctx) {
|
|
6
5
|
server.registerTool('upload_document', {
|
|
7
6
|
title: 'Upload document',
|
|
8
7
|
description: 'Upload a base64-encoded PDF to an existing transaction (≤10MB inline; use presign for larger).',
|
|
9
8
|
inputSchema: uploadDocumentShape,
|
|
10
9
|
annotations: WRITE_SAFE,
|
|
11
|
-
}, async (args) => run(() =>
|
|
10
|
+
}, async (args) => run(() => ctx.client.documents.upload(args.transactionId, {
|
|
12
11
|
content: args.documentBase64,
|
|
13
12
|
...(args.filename ? { filename: args.filename } : {}),
|
|
14
13
|
})));
|
|
@@ -17,6 +16,6 @@ export function registerDocumentTools(server) {
|
|
|
17
16
|
description: 'Get presigned download URLs for a transaction’s document and signed artifacts.',
|
|
18
17
|
inputSchema: transactionIdShape,
|
|
19
18
|
annotations: READ_ONLY,
|
|
20
|
-
}, async (args) => run(() =>
|
|
19
|
+
}, async (args) => run(() => ctx.client.documents.download(args.transactionId)));
|
|
21
20
|
}
|
|
22
21
|
//# sourceMappingURL=documents.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documents.js","sourceRoot":"","sources":["../../src/tools/documents.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"documents.js","sourceRoot":"","sources":["../../src/tools/documents.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAExE,MAAM,UAAU,qBAAqB,CAAC,MAAiB,EAAE,GAAgB;IACvE,MAAM,CAAC,YAAY,CACjB,iBAAiB,EACjB;QACE,KAAK,EAAE,iBAAiB;QACxB,WAAW,EAAE,gGAAgG;QAC7G,WAAW,EAAE,mBAAmB;QAChC,WAAW,EAAE,UAAU;KACxB,EACD,KAAK,EAAE,IAAI,EAAE,EAAE,CACb,GAAG,CAAC,GAAG,EAAE,CACP,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE;QAC9C,OAAO,EAAE,IAAI,CAAC,cAAc;QAC5B,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACtD,CAAC,CACH,CACJ,CAAC;IAEF,MAAM,CAAC,YAAY,CACjB,mBAAmB,EACnB;QACE,KAAK,EAAE,mBAAmB;QAC1B,WAAW,EAAE,gFAAgF;QAC7F,WAAW,EAAE,kBAAkB;QAC/B,WAAW,EAAE,SAAS;KACvB,EACD,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAC7E,CAAC;AACJ,CAAC"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
|
|
2
|
+
import type { ToolContext } from '../client.js';
|
|
3
|
+
export declare function registerEnvelopeTools(server: McpServer, ctx: ToolContext): void;
|
package/dist/tools/envelopes.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { buildSigningUrl } from '../client.js';
|
|
2
2
|
import { CONFIRM_WARNING, DESTRUCTIVE, READ_ONLY } from '../annotations.js';
|
|
3
3
|
import { run, idempotencyKey } from './helpers.js';
|
|
4
4
|
import { createEnvelopeShape, envelopeIdShape, addEnvelopeSessionShape } from '../schemas.js';
|
|
5
|
-
export function registerEnvelopeTools(server) {
|
|
5
|
+
export function registerEnvelopeTools(server, ctx) {
|
|
6
6
|
server.registerTool('create_envelope', {
|
|
7
7
|
title: 'Create envelope',
|
|
8
8
|
description: CONFIRM_WARNING +
|
|
@@ -22,14 +22,14 @@ export function registerEnvelopeTools(server) {
|
|
|
22
22
|
...(args.expiresInMinutes ? { expiresInMinutes: args.expiresInMinutes } : {}),
|
|
23
23
|
...(args.owner ? { owner: args.owner } : {}),
|
|
24
24
|
};
|
|
25
|
-
return
|
|
25
|
+
return ctx.client.envelopes.create(req, idempotencyKey(args.idempotencyKey));
|
|
26
26
|
}));
|
|
27
27
|
server.registerTool('get_envelope', {
|
|
28
28
|
title: 'Get envelope',
|
|
29
29
|
description: 'Get envelope details including per-signer session summaries and completion counts.',
|
|
30
30
|
inputSchema: envelopeIdShape,
|
|
31
31
|
annotations: READ_ONLY,
|
|
32
|
-
}, async (args) => run(() =>
|
|
32
|
+
}, async (args) => run(() => ctx.client.envelopes.get(args.envelopeId)));
|
|
33
33
|
server.registerTool('add_session_to_envelope', {
|
|
34
34
|
title: 'Add signer to envelope',
|
|
35
35
|
description: CONFIRM_WARNING +
|
|
@@ -46,7 +46,7 @@ export function registerEnvelopeTools(server) {
|
|
|
46
46
|
...(args.cancelUrl ? { cancelUrl: args.cancelUrl } : {}),
|
|
47
47
|
...(args.metadata ? { metadata: args.metadata } : {}),
|
|
48
48
|
};
|
|
49
|
-
const session = await
|
|
49
|
+
const session = await ctx.client.envelopes.addSession(args.envelopeId, req);
|
|
50
50
|
return { ...session, signingUrl: buildSigningUrl(session.url, session.clientSecret) };
|
|
51
51
|
}));
|
|
52
52
|
server.registerTool('get_envelope_combined_stamp', {
|
|
@@ -54,6 +54,6 @@ export function registerEnvelopeTools(server) {
|
|
|
54
54
|
description: 'Generate the combined stamped PDF (all signers) for a COMPLETED envelope and return a download URL.',
|
|
55
55
|
inputSchema: envelopeIdShape,
|
|
56
56
|
annotations: READ_ONLY,
|
|
57
|
-
}, async (args) => run(() =>
|
|
57
|
+
}, async (args) => run(() => ctx.client.envelopes.combinedStamp(args.envelopeId)));
|
|
58
58
|
}
|
|
59
59
|
//# sourceMappingURL=envelopes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envelopes.js","sourceRoot":"","sources":["../../src/tools/envelopes.ts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ol/sdk/server/mcp.js';
|
|
2
|
-
|
|
2
|
+
import type { ToolContext } from '../client.js';
|
|
3
|
+
export declare function registerEvidenceTools(server: McpServer, ctx: ToolContext): void;
|
package/dist/tools/evidence.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { getClient } from '../client.js';
|
|
2
1
|
import { READ_ONLY } from '../annotations.js';
|
|
3
2
|
import { run } from './helpers.js';
|
|
4
3
|
import { transactionIdShape } from '../schemas.js';
|
|
5
|
-
export function registerEvidenceTools(server) {
|
|
4
|
+
export function registerEvidenceTools(server, ctx) {
|
|
6
5
|
server.registerTool('get_evidence', {
|
|
7
6
|
title: 'Get evidence',
|
|
8
7
|
description: 'Retrieve the cryptographic evidence (hashes, step proofs, evidenceId) for a completed transaction.',
|
|
9
8
|
inputSchema: transactionIdShape,
|
|
10
9
|
annotations: READ_ONLY,
|
|
11
|
-
}, async (args) => run(() =>
|
|
10
|
+
}, async (args) => run(() => ctx.client.evidence.get(args.transactionId)));
|
|
12
11
|
}
|
|
13
12
|
//# sourceMappingURL=evidence.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evidence.js","sourceRoot":"","sources":["../../src/tools/evidence.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"evidence.js","sourceRoot":"","sources":["../../src/tools/evidence.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,MAAM,UAAU,qBAAqB,CAAC,MAAiB,EAAE,GAAgB;IACvE,MAAM,CAAC,YAAY,CACjB,cAAc,EACd;QACE,KAAK,EAAE,cAAc;QACrB,WAAW,EACT,oGAAoG;QACtG,WAAW,EAAE,kBAAkB;QAC/B,WAAW,EAAE,SAAS;KACvB,EACD,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CACvE,CAAC;AACJ,CAAC"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
|
|
2
|
+
import type { ToolContext } from '../client.js';
|
|
3
|
+
export declare function registerSigningSessionTools(server: McpServer, ctx: ToolContext): void;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { buildSigningUrl } from '../client.js';
|
|
2
2
|
import { CONFIRM_WARNING, DESTRUCTIVE, READ_ONLY, WRITE_SAFE } from '../annotations.js';
|
|
3
3
|
import { run, idempotencyKey } from './helpers.js';
|
|
4
4
|
import { createSigningSessionShape, sessionIdShape, listSigningSessionsShape, resendOtpShape, } from '../schemas.js';
|
|
5
|
-
export function registerSigningSessionTools(server) {
|
|
5
|
+
export function registerSigningSessionTools(server, ctx) {
|
|
6
6
|
server.registerTool('create_signing_session', {
|
|
7
7
|
title: 'Create signing session',
|
|
8
8
|
description: CONFIRM_WARNING +
|
|
@@ -29,7 +29,7 @@ export function registerSigningSessionTools(server) {
|
|
|
29
29
|
...(args.expiresInMinutes ? { expiresInMinutes: args.expiresInMinutes } : {}),
|
|
30
30
|
...(args.owner ? { owner: args.owner } : {}),
|
|
31
31
|
};
|
|
32
|
-
const session = await
|
|
32
|
+
const session = await ctx.client.signingSessions.create(req, idempotencyKey(args.idempotencyKey));
|
|
33
33
|
return { ...session, signingUrl: buildSigningUrl(session.url, session.clientSecret) };
|
|
34
34
|
}));
|
|
35
35
|
server.registerTool('get_signing_session_status', {
|
|
@@ -37,19 +37,19 @@ export function registerSigningSessionTools(server) {
|
|
|
37
37
|
description: 'Poll the current status of a signing session (ACTIVE/COMPLETED/CANCELLED/EXPIRED/FAILED).',
|
|
38
38
|
inputSchema: sessionIdShape,
|
|
39
39
|
annotations: READ_ONLY,
|
|
40
|
-
}, async (args) => run(() =>
|
|
40
|
+
}, async (args) => run(() => ctx.client.signingSessions.getStatus(args.sessionId)));
|
|
41
41
|
server.registerTool('get_signing_session', {
|
|
42
42
|
title: 'Get signing session details',
|
|
43
43
|
description: 'Get full bootstrap data for a signing session (signer, steps, document, appearance).',
|
|
44
44
|
inputSchema: sessionIdShape,
|
|
45
45
|
annotations: READ_ONLY,
|
|
46
|
-
}, async (args) => run(() =>
|
|
46
|
+
}, async (args) => run(() => ctx.client.signingSessions.get(args.sessionId)));
|
|
47
47
|
server.registerTool('list_signing_sessions', {
|
|
48
48
|
title: 'List signing sessions',
|
|
49
49
|
description: 'List signing sessions filtered by status, with cursor pagination.',
|
|
50
50
|
inputSchema: listSigningSessionsShape,
|
|
51
51
|
annotations: READ_ONLY,
|
|
52
|
-
}, async (args) => run(() =>
|
|
52
|
+
}, async (args) => run(() => ctx.client.signingSessions.list({
|
|
53
53
|
status: args.status,
|
|
54
54
|
...(args.limit !== undefined ? { limit: args.limit } : {}),
|
|
55
55
|
...(args.cursor ? { cursor: args.cursor } : {}),
|
|
@@ -59,12 +59,12 @@ export function registerSigningSessionTools(server) {
|
|
|
59
59
|
description: CONFIRM_WARNING + 'Cancel an active signing session. This cannot be undone.',
|
|
60
60
|
inputSchema: sessionIdShape,
|
|
61
61
|
annotations: DESTRUCTIVE,
|
|
62
|
-
}, async (args) => run(() =>
|
|
62
|
+
}, async (args) => run(() => ctx.client.signingSessions.cancel(args.sessionId)));
|
|
63
63
|
server.registerTool('resend_signing_session_otp', {
|
|
64
64
|
title: 'Resend signing session OTP',
|
|
65
65
|
description: 'Resend the OTP challenge for a signing session, optionally over a specific channel (email/sms).',
|
|
66
66
|
inputSchema: resendOtpShape,
|
|
67
67
|
annotations: WRITE_SAFE,
|
|
68
|
-
}, async (args) => run(() =>
|
|
68
|
+
}, async (args) => run(() => ctx.client.signingSessions.resendOtp(args.sessionId, args.channel ? { channel: args.channel } : undefined)));
|
|
69
69
|
}
|
|
70
70
|
//# sourceMappingURL=signingSessions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signingSessions.js","sourceRoot":"","sources":["../../src/tools/signingSessions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"signingSessions.js","sourceRoot":"","sources":["../../src/tools/signingSessions.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACxF,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EACL,yBAAyB,EACzB,cAAc,EACd,wBAAwB,EACxB,cAAc,GACf,MAAM,eAAe,CAAC;AAEvB,MAAM,UAAU,2BAA2B,CAAC,MAAiB,EAAE,GAAgB;IAC7E,MAAM,CAAC,YAAY,CACjB,wBAAwB,EACxB;QACE,KAAK,EAAE,wBAAwB;QAC/B,WAAW,EACT,eAAe;YACf,6FAA6F;YAC7F,uFAAuF;QACzF,WAAW,EAAE,yBAAyB;QACtC,WAAW,EAAE,WAAW;KACzB,EACD,KAAK,EAAE,IAAI,EAAE,EAAE,CACb,GAAG,CAAC,KAAK,IAAI,EAAE;QACb,MAAM,GAAG,GAAgC;YACvC,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,MAAM,EAAE;gBACN,OAAO,EAAE,IAAI,CAAC,aAAa;gBAC3B,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC/D;YACD,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,GAAG,CAAC,IAAI,CAAC,cAAc;gBACrB,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,cAAc,E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AAC,EAAE,CAAC;KAChD,CAAC,CACH,CACJ,CAAC;IAEF,MAAM,CAAC,YAAY,CACjB,wBAAwB,EACxB;QACE,KAAK,EAAE,wBAAwB;QAC/B,WAAW,EAAE,eAAe,GAAG,0DAA0D;QACzF,WAAW,EAAE,cAAc;QAC3B,WAAW,EAAE,WAAW;KACzB,EACD,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAC7E,CAAC;IAEF,MAAM,CAAC,YAAY,CACjB,4BAA4B,EAC5B;QACE,KAAK,EAAE,4BAA4B;QACnC,WAAW,EAAE,iGAAiG;QAC9G,WAAW,EAAE,cAAc;QAC3B,WAAW,EAAE,UAAU;KACxB,EACD,KAAK,EAAE,IAAI,EAAE,EAAE,CACb,GAAG,CAAC,GAAG,EAAE,CACP,GAAG,CAAC,MAAM,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAC3G,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
|
|
2
|
+
import type { ToolContext } from '../client.js';
|
|
3
|
+
export declare function registerTransactionTools(server: McpServer, ctx: ToolContext): void;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { getClient } from '../client.js';
|
|
2
1
|
import { CONFIRM_WARNING, DESTRUCTIVE, READ_ONLY } from '../annotations.js';
|
|
3
2
|
import { run } from './helpers.js';
|
|
4
3
|
import { listTransactionsShape, transactionIdShape } from '../schemas.js';
|
|
5
|
-
export function registerTransactionTools(server) {
|
|
4
|
+
export function registerTransactionTools(server, ctx) {
|
|
6
5
|
server.registerTool('list_transactions', {
|
|
7
6
|
title: 'List / find transactions',
|
|
8
7
|
description: 'Search transactions by status, signer external ID, document group, or date range (cursor pagination). ' +
|
|
@@ -19,19 +18,19 @@ export function registerTransactionTools(server) {
|
|
|
19
18
|
...(args.startDate ? { startDate: args.startDate } : {}),
|
|
20
19
|
...(args.endDate ? { endDate: args.endDate } : {}),
|
|
21
20
|
};
|
|
22
|
-
return run(() =>
|
|
21
|
+
return run(() => ctx.client.transactions.list(params));
|
|
23
22
|
});
|
|
24
23
|
server.registerTool('get_transaction', {
|
|
25
24
|
title: 'Get transaction',
|
|
26
25
|
description: 'Get full details of a single transaction, including its steps and results.',
|
|
27
26
|
inputSchema: transactionIdShape,
|
|
28
27
|
annotations: READ_ONLY,
|
|
29
|
-
}, async (args) => run(() =>
|
|
28
|
+
}, async (args) => run(() => ctx.client.transactions.get(args.transactionId)));
|
|
30
29
|
server.registerTool('cancel_transaction', {
|
|
31
30
|
title: 'Cancel transaction',
|
|
32
31
|
description: CONFIRM_WARNING + 'Cancel a low-level transaction. This cannot be undone.',
|
|
33
32
|
inputSchema: transactionIdShape,
|
|
34
33
|
annotations: DESTRUCTIVE,
|
|
35
|
-
}, async (args) => run(() =>
|
|
34
|
+
}, async (args) => run(() => ctx.client.transactions.cancel(args.transactionId)));
|
|
36
35
|
}
|
|
37
36
|
//# sourceMappingURL=transactions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transactions.js","sourceRoot":"","sources":["../../src/tools/transactions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transactions.js","sourceRoot":"","sources":["../../src/tools/transactions.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MA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GAAG,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACzD,CAAC,CACF,CAAC;IAEF,MAAM,CAAC,YAAY,CACjB,iBAAiB,EACjB;QACE,KAAK,EAAE,iBAAiB;QACxB,WAAW,EAAE,4EAA4E;QACzF,WAAW,EAAE,kBAAkB;QAC/B,WAAW,EAAE,SAAS;KACvB,EACD,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAC3E,CAAC;IAEF,MAAM,CAAC,YAAY,CACjB,oBAAoB,EACpB;QACE,KAAK,EAAE,oBAAoB;QAC3B,WAAW,EAAE,eAAe,GAAG,wDAAwD;QACvF,WAAW,EAAE,kBAAkB;QAC/B,WAAW,EAAE,WAAW;KACzB,EACD,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAC9E,CAAC;AACJ,CAAC"}
|
package/dist/tools/verify.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
|
|
2
|
+
import type { ToolContext } from '../client.js';
|
|
3
|
+
export declare function registerVerifyTools(server: McpServer, ctx: ToolContext): void;
|
package/dist/tools/verify.js
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
import { getClient, getResolvedEnv } from '../client.js';
|
|
2
1
|
import { CONFIRM_WARNING, DESTRUCTIVE, READ_ONLY } from '../annotations.js';
|
|
3
2
|
import { run, errorContent } from './helpers.js';
|
|
4
3
|
import { verifyEvidenceShape, verifyEnvelopeShape, verifyDocumentShape } from '../schemas.js';
|
|
5
|
-
export function registerVerifyTools(server) {
|
|
4
|
+
export function registerVerifyTools(server, ctx) {
|
|
6
5
|
server.registerTool('verify_evidence', {
|
|
7
6
|
title: 'Verify evidence (public)',
|
|
8
7
|
description: 'Publicly verify a completed signature by its evidenceId. Returns status, document/evidence hashes, ' +
|
|
9
8
|
'steps and signer display info. No authentication needed.',
|
|
10
9
|
inputSchema: verifyEvidenceShape,
|
|
11
10
|
annotations: READ_ONLY,
|
|
12
|
-
}, async (args) => run(() =>
|
|
11
|
+
}, async (args) => run(() => ctx.client.verification.verify(args.evidenceId)));
|
|
13
12
|
server.registerTool('verify_envelope', {
|
|
14
13
|
title: 'Verify envelope (public)',
|
|
15
14
|
description: 'Publicly verify all signers of an envelope and get consolidated download URLs.',
|
|
16
15
|
inputSchema: verifyEnvelopeShape,
|
|
17
16
|
annotations: READ_ONLY,
|
|
18
|
-
}, async (args) => run(() =>
|
|
17
|
+
}, async (args) => run(() => ctx.client.verification.verifyEnvelope(args.envelopeId)));
|
|
19
18
|
server.registerTool('verify_document', {
|
|
20
19
|
title: 'Verify document signatures',
|
|
21
20
|
description: CONFIRM_WARNING +
|
|
@@ -25,12 +24,11 @@ export function registerVerifyTools(server) {
|
|
|
25
24
|
inputSchema: verifyDocumentShape,
|
|
26
25
|
annotations: DESTRUCTIVE,
|
|
27
26
|
}, async (args) => {
|
|
28
|
-
|
|
29
|
-
if (env.environment !== 'production') {
|
|
27
|
+
if (ctx.environment !== 'production') {
|
|
30
28
|
return errorContent(new Error('verify_document is PRODUCTION-only — the signature-detection backend is not provisioned in HML. ' +
|
|
31
29
|
'Set SIGNDOCS_ENVIRONMENT=production with a production credential to use it.'));
|
|
32
30
|
}
|
|
33
|
-
return run(() =>
|
|
31
|
+
return run(() => ctx.client.verification.verifyDocument({
|
|
34
32
|
content: args.documentBase64,
|
|
35
33
|
...(args.filename ? { filename: args.filename } : {}),
|
|
36
34
|
}));
|
package/dist/tools/verify.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify.js","sourceRoot":"","sources":["../../src/tools/verify.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"verify.js","sourceRoot":"","sources":["../../src/tools/verify.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAE9F,MAAM,UAAU,mBAAmB,CAAC,MAAiB,EAAE,GAAgB;IACrE,MAAM,CAAC,YAAY,CACjB,iBAAiB,EACjB;QACE,KAAK,EAAE,0BAA0B;QACjC,WAAW,EACT,qGAAqG;YACrG,0DAA0D;QAC5D,WAAW,EAAE,mBAAmB;QAChC,WAAW,EAAE,SAAS;KACvB,EACD,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAC3E,CAAC;IAEF,MAAM,CAAC,YAAY,CACjB,iBAAiB,EACjB;QACE,KAAK,EAAE,0BAA0B;QACjC,WAAW,EAAE,gFAAgF;QAC7F,WAAW,EAAE,mBAAmB;QAChC,WAAW,EAAE,SAAS;KACvB,EACD,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CACnF,CAAC;IAEF,MAAM,CAAC,YAAY,CACjB,iBAAiB,EACjB;QACE,KAAK,EAAE,4BAA4B;QACnC,WAAW,EACT,eAAe;YACf,sEAAsE;YACtE,kGAAkG;YAClG,uBAAuB;QACzB,WAAW,EAAE,mBAAmB;QAChC,WAAW,EAAE,WAAW;KACzB,EACD,KAAK,EAAE,IAAI,EAAE,EAAE;QACb,IAAI,GAAG,CAAC,WAAW,KAAK,YAAY,EAAE,CAAC;YACrC,OAAO,YAAY,CACjB,IAAI,KAAK,CACP,kGAAkG;gBAChG,6EAA6E,CAChF,CACF,CAAC;QACJ,CAAC;QACD,OAAO,GAAG,CAAC,GAAG,EAAE,CACd,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,cAAc,CAAC;YACrC,OAAO,EAAE,IAAI,CAAC,cAAc;YAC5B,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACtD,CAAC,CACH,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
|
package/dist/tools/webhooks.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
|
|
2
|
+
import type { ToolContext } from '../client.js';
|
|
3
|
+
export declare function registerWebhookTools(server: McpServer, ctx: ToolContext): void;
|
package/dist/tools/webhooks.js
CHANGED
|
@@ -1,28 +1,27 @@
|
|
|
1
|
-
import { getClient } from '../client.js';
|
|
2
1
|
import { CONFIRM_WARNING, DESTRUCTIVE, READ_ONLY, WRITE_SAFE } from '../annotations.js';
|
|
3
2
|
import { run } from './helpers.js';
|
|
4
3
|
import { registerWebhookShape, webhookIdShape } from '../schemas.js';
|
|
5
|
-
export function registerWebhookTools(server) {
|
|
4
|
+
export function registerWebhookTools(server, ctx) {
|
|
6
5
|
server.registerTool('register_webhook', {
|
|
7
6
|
title: 'Register webhook',
|
|
8
7
|
description: 'Register an HTTPS endpoint to receive event notifications. The response returns a signing secret ' +
|
|
9
8
|
'— store it to verify the HMAC-SHA256 signature on incoming payloads.',
|
|
10
9
|
inputSchema: registerWebhookShape,
|
|
11
10
|
annotations: WRITE_SAFE,
|
|
12
|
-
}, async (args) => run(() =>
|
|
11
|
+
}, async (args) => run(() => ctx.client.webhooks.register({ url: args.url, events: args.events })));
|
|
13
12
|
server.registerTool('list_webhooks', {
|
|
14
13
|
title: 'List webhooks',
|
|
15
14
|
description: 'List all registered webhooks for the tenant.',
|
|
16
15
|
inputSchema: {},
|
|
17
16
|
annotations: READ_ONLY,
|
|
18
|
-
}, async () => run(() =>
|
|
17
|
+
}, async () => run(() => ctx.client.webhooks.list()));
|
|
19
18
|
server.registerTool('delete_webhook', {
|
|
20
19
|
title: 'Delete webhook',
|
|
21
20
|
description: CONFIRM_WARNING + 'Delete a registered webhook. Event delivery to it stops immediately.',
|
|
22
21
|
inputSchema: webhookIdShape,
|
|
23
22
|
annotations: DESTRUCTIVE,
|
|
24
23
|
}, async (args) => run(async () => {
|
|
25
|
-
await
|
|
24
|
+
await ctx.client.webhooks.delete(args.webhookId);
|
|
26
25
|
return { webhookId: args.webhookId, deleted: true };
|
|
27
26
|
}));
|
|
28
27
|
server.registerTool('test_webhook', {
|
|
@@ -30,6 +29,6 @@ export function registerWebhookTools(server) {
|
|
|
30
29
|
description: 'Send a sample payload to a registered webhook and return the delivery result.',
|
|
31
30
|
inputSchema: webhookIdShape,
|
|
32
31
|
annotations: WRITE_SAFE,
|
|
33
|
-
}, async (args) => run(() =>
|
|
32
|
+
}, async (args) => run(() => ctx.client.webhooks.test(args.webhookId)));
|
|
34
33
|
}
|
|
35
34
|
//# sourceMappingURL=webhooks.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../../src/tools/webhooks.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../../src/tools/webhooks.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACxF,OAAO,EAAE,GAAG,EA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C;IAEF,MAAM,CAAC,YAAY,CACjB,cAAc,EACd;QACE,KAAK,EAAE,cAAc;QACrB,WAAW,EAAE,+EAA+E;QAC5F,WAAW,EAAE,cAAc;QAC3B,WAAW,EAAE,UAAU;KACxB,EACD,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CACpE,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@signdocs-brasil/mcp-server",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Model Context Protocol (MCP) server for the SignDocs Brasil e-signature API — lets AI agents create signing sessions, manage envelopes, verify documents and more.",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Model Context Protocol (MCP) server for the SignDocs Brasil e-signature API — lets AI agents create signing sessions, manage envelopes, verify documents and more. Local stdio + remote HTTP transports.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=18"
|
|
9
9
|
},
|
|
10
10
|
"bin": {
|
|
11
|
-
"signdocs-mcp": "dist/bin/stdio.js"
|
|
11
|
+
"signdocs-mcp": "dist/bin/stdio.js",
|
|
12
|
+
"signdocs-mcp-http": "dist/bin/http.js"
|
|
12
13
|
},
|
|
13
14
|
"main": "dist/server.js",
|
|
14
15
|
"types": "dist/server.d.ts",
|
|
@@ -18,12 +19,13 @@
|
|
|
18
19
|
"LICENSE"
|
|
19
20
|
],
|
|
20
21
|
"scripts": {
|
|
21
|
-
"build": "tsc -p tsconfig.json && chmod +x dist/bin/stdio.js",
|
|
22
|
+
"build": "tsc -p tsconfig.json && chmod +x dist/bin/stdio.js dist/bin/http.js",
|
|
22
23
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
23
24
|
"test": "vitest run",
|
|
24
25
|
"test:watch": "vitest",
|
|
25
26
|
"inspect": "npm run build && npx @modelcontextprotocol/inspector node dist/bin/stdio.js",
|
|
26
27
|
"start": "node dist/bin/stdio.js",
|
|
28
|
+
"start:http": "node dist/bin/http.js",
|
|
27
29
|
"prepublishOnly": "npm run build && npm test"
|
|
28
30
|
},
|
|
29
31
|
"keywords": [
|