@quantakrypto/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/HOSTING.md +184 -0
- package/README.md +227 -0
- package/dist/http.d.ts +120 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +339 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -0
- package/dist/protocol.d.ts +109 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +68 -0
- package/dist/protocol.js.map +1 -0
- package/dist/rules.d.ts +48 -0
- package/dist/rules.d.ts.map +1 -0
- package/dist/rules.js +143 -0
- package/dist/rules.js.map +1 -0
- package/dist/server.d.ts +56 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +132 -0
- package/dist/server.js.map +1 -0
- package/dist/stdio.d.ts +23 -0
- package/dist/stdio.d.ts.map +1 -0
- package/dist/stdio.js +89 -0
- package/dist/stdio.js.map +1 -0
- package/dist/tools.d.ts +38 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +421 -0
- package/dist/tools.js.map +1 -0
- package/examples/README.md +36 -0
- package/examples/transcript.jsonl +13 -0
- package/package.json +47 -0
package/dist/http.js
ADDED
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* quantakrypto MCP — hostable HTTP transport (Streamable-HTTP-style JSON-RPC).
|
|
4
|
+
*
|
|
5
|
+
* A zero-dependency {@link node:http} server that exposes the same
|
|
6
|
+
* {@link McpServer} over HTTP so the quantakrypto MCP can run as a remote service:
|
|
7
|
+
*
|
|
8
|
+
* POST /mcp — body is a single JSON-RPC 2.0 message; the JSON-RPC
|
|
9
|
+
* response is returned as the 200 response body
|
|
10
|
+
* (`application/json`). Notifications get HTTP 202 with no body.
|
|
11
|
+
* GET /health — liveness probe, returns `{ status: "ok", ... }`.
|
|
12
|
+
*
|
|
13
|
+
* This is the minimal-but-working core of the MCP Streamable HTTP transport.
|
|
14
|
+
* The full spec also supports an SSE response (`text/event-stream`) for
|
|
15
|
+
* server-initiated messages; this server speaks the JSON request/response half,
|
|
16
|
+
* which is sufficient for stateless tool calls. See HOSTING.md for the
|
|
17
|
+
* production design (auth, multi-tenant sessions, rate limiting, scaling).
|
|
18
|
+
*
|
|
19
|
+
* SAFE-BY-DEFAULT POSTURE (P0-1). Unlike the stdio transport — which trusts the
|
|
20
|
+
* local user and stays fully featured — the HTTP transport is hardened because a
|
|
21
|
+
* hosted endpoint is reachable by untrusted peers:
|
|
22
|
+
*
|
|
23
|
+
* - Binds to 127.0.0.1 by default (NOT 0.0.0.0). Override with QUANTAKRYPTO_MCP_HOST.
|
|
24
|
+
* - Bearer-token auth: when QUANTAKRYPTO_MCP_TOKEN is set, every /mcp request must
|
|
25
|
+
* send `Authorization: Bearer <token>` (else 401). Binding to a non-loopback
|
|
26
|
+
* host WITHOUT a token is refused at startup (it would be an open relay).
|
|
27
|
+
* - The filesystem tools (scan_path, inventory_crypto, generate_cbom) read
|
|
28
|
+
* arbitrary server paths and are DISABLED over HTTP unless QUANTAKRYPTO_MCP_ALLOW_FS=1
|
|
29
|
+
* (security audit Q-01). The knowledge tools (explain_finding, suggest_hybrid,
|
|
30
|
+
* list_rules) are always available. Gating is enforced by registering only the
|
|
31
|
+
* permitted tools, so tools/list and tools/call both reflect it.
|
|
32
|
+
* - Per-request timeout (QUANTAKRYPTO_MCP_TIMEOUT_MS) and a response-size cap
|
|
33
|
+
* (QUANTAKRYPTO_MCP_MAX_RESPONSE_BYTES), in addition to the 1 MiB request-body cap.
|
|
34
|
+
*
|
|
35
|
+
* Run with `node dist/http.js` (PORT/QUANTAKRYPTO_MCP_* from env).
|
|
36
|
+
*/
|
|
37
|
+
import { createServer } from "node:http";
|
|
38
|
+
import { randomUUID } from "node:crypto";
|
|
39
|
+
import { realpathSync } from "node:fs";
|
|
40
|
+
import { fileURLToPath } from "node:url";
|
|
41
|
+
import process from "node:process";
|
|
42
|
+
import { createQuantakryptoServer } from "./index.js";
|
|
43
|
+
import { ErrorCode, makeFailure } from "./protocol.js";
|
|
44
|
+
import { quantakryptoTools, FS_TOOL_NAMES } from "./tools.js";
|
|
45
|
+
/** Header carrying the MCP session id (per the Streamable HTTP transport). */
|
|
46
|
+
export const SESSION_HEADER = "mcp-session-id";
|
|
47
|
+
/** Maximum accepted request body size (1 MiB) — a basic abuse guard. */
|
|
48
|
+
const MAX_BODY_BYTES = 1024 * 1024;
|
|
49
|
+
/** Default per-request tool-execution deadline (ms). */
|
|
50
|
+
const DEFAULT_TIMEOUT_MS = 30_000;
|
|
51
|
+
/** Default cap on the serialized response body (4 MiB). */
|
|
52
|
+
const DEFAULT_MAX_RESPONSE_BYTES = 4 * 1024 * 1024;
|
|
53
|
+
/** Loopback hosts that are safe to bind without authentication. */
|
|
54
|
+
const LOOPBACK_HOSTS = new Set(["127.0.0.1", "::1", "localhost"]);
|
|
55
|
+
/**
|
|
56
|
+
* Resolve the HTTP transport config from env + explicit overrides. Pure: does
|
|
57
|
+
* no I/O and never reads `process` directly. Overrides win over env.
|
|
58
|
+
*/
|
|
59
|
+
export function resolveHttpConfig(env, options = {}) {
|
|
60
|
+
const host = options.host ?? env.QUANTAKRYPTO_MCP_HOST ?? env.HOST ?? "127.0.0.1";
|
|
61
|
+
const port = options.port ?? toInt(env.PORT, 3000);
|
|
62
|
+
const token = (options.token ?? env.QUANTAKRYPTO_MCP_TOKEN ?? "").trim();
|
|
63
|
+
const allowFs = options.allowFs ??
|
|
64
|
+
(env.QUANTAKRYPTO_MCP_ALLOW_FS === "1" || env.QUANTAKRYPTO_MCP_ALLOW_FS === "true");
|
|
65
|
+
const timeoutMs = options.timeoutMs ?? toInt(env.QUANTAKRYPTO_MCP_TIMEOUT_MS, DEFAULT_TIMEOUT_MS);
|
|
66
|
+
const maxResponseBytes = options.maxResponseBytes ??
|
|
67
|
+
toInt(env.QUANTAKRYPTO_MCP_MAX_RESPONSE_BYTES, DEFAULT_MAX_RESPONSE_BYTES);
|
|
68
|
+
return {
|
|
69
|
+
host,
|
|
70
|
+
port,
|
|
71
|
+
token,
|
|
72
|
+
allowFs,
|
|
73
|
+
timeoutMs,
|
|
74
|
+
maxResponseBytes,
|
|
75
|
+
loopback: isLoopbackHost(host),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/** Parse a positive integer from an env string, falling back on bad input. */
|
|
79
|
+
function toInt(value, fallback) {
|
|
80
|
+
if (value === undefined)
|
|
81
|
+
return fallback;
|
|
82
|
+
const n = Number(value);
|
|
83
|
+
return Number.isFinite(n) && n > 0 ? Math.floor(n) : fallback;
|
|
84
|
+
}
|
|
85
|
+
/** True when binding to `host` keeps the server private to this machine. */
|
|
86
|
+
export function isLoopbackHost(host) {
|
|
87
|
+
return LOOPBACK_HOSTS.has(host.trim().toLowerCase());
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Decide whether a non-loopback bind is permitted. A server reachable from the
|
|
91
|
+
* network MUST require auth; binding wide-open without a token would be an open,
|
|
92
|
+
* unauthenticated arbitrary-tool relay. Pure decision used at startup.
|
|
93
|
+
*/
|
|
94
|
+
export function startupDecision(config) {
|
|
95
|
+
if (!config.loopback && config.token.length === 0) {
|
|
96
|
+
return {
|
|
97
|
+
ok: false,
|
|
98
|
+
reason: `refusing to bind to non-loopback host "${config.host}" without a token. ` +
|
|
99
|
+
`Set QUANTAKRYPTO_MCP_TOKEN to require Bearer auth, or bind to 127.0.0.1.`,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
return { ok: true };
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Decide whether a request is authorized given the configured token and the
|
|
106
|
+
* incoming Authorization header. When no token is configured, all requests are
|
|
107
|
+
* allowed (the loopback / trusted-edge case). Pure and testable.
|
|
108
|
+
*/
|
|
109
|
+
export function authorizeRequest(token, authorizationHeader) {
|
|
110
|
+
if (token.length === 0)
|
|
111
|
+
return { authorized: true };
|
|
112
|
+
const header = (authorizationHeader ?? "").trim();
|
|
113
|
+
const match = /^Bearer\s+(.+)$/i.exec(header);
|
|
114
|
+
const presented = match?.[1]?.trim();
|
|
115
|
+
if (!presented) {
|
|
116
|
+
return { authorized: false, status: 401, message: "missing bearer token" };
|
|
117
|
+
}
|
|
118
|
+
if (!timingSafeEqualStr(presented, token)) {
|
|
119
|
+
return { authorized: false, status: 401, message: "invalid bearer token" };
|
|
120
|
+
}
|
|
121
|
+
return { authorized: true };
|
|
122
|
+
}
|
|
123
|
+
/** Constant-time-ish string compare (length-independent short-circuit guarded). */
|
|
124
|
+
function timingSafeEqualStr(a, b) {
|
|
125
|
+
if (a.length !== b.length)
|
|
126
|
+
return false;
|
|
127
|
+
let diff = 0;
|
|
128
|
+
for (let i = 0; i < a.length; i += 1)
|
|
129
|
+
diff |= a.charCodeAt(i) ^ b.charCodeAt(i);
|
|
130
|
+
return diff === 0;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Select the tools to expose over HTTP for a given policy. The knowledge tools
|
|
134
|
+
* are always returned; the filesystem tools are included only when
|
|
135
|
+
* `allowFs` is true. Pure function of its inputs — the single source of truth
|
|
136
|
+
* for HTTP tool gating, so tools/list and tools/call stay consistent.
|
|
137
|
+
*/
|
|
138
|
+
export function gateHttpTools(tools, allowFs) {
|
|
139
|
+
const fsNames = new Set(FS_TOOL_NAMES);
|
|
140
|
+
return tools.filter((t) => allowFs || !fsNames.has(t.name));
|
|
141
|
+
}
|
|
142
|
+
/* -------------------------------------------------------------------------- */
|
|
143
|
+
/* HTTP plumbing */
|
|
144
|
+
/* -------------------------------------------------------------------------- */
|
|
145
|
+
/** Read a request body fully, enforcing the size cap. Resolves to the raw string. */
|
|
146
|
+
function readBody(req) {
|
|
147
|
+
return new Promise((resolve, reject) => {
|
|
148
|
+
let size = 0;
|
|
149
|
+
const chunks = [];
|
|
150
|
+
req.on("data", (chunk) => {
|
|
151
|
+
size += chunk.length;
|
|
152
|
+
if (size > MAX_BODY_BYTES) {
|
|
153
|
+
reject(new Error("request body too large"));
|
|
154
|
+
req.destroy();
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
chunks.push(chunk);
|
|
158
|
+
});
|
|
159
|
+
req.on("end", () => resolve(Buffer.concat(chunks).toString("utf8")));
|
|
160
|
+
req.on("error", reject);
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
/** Write a JSON response with the given status and optional extra headers. */
|
|
164
|
+
function sendJson(res, status, body, headers = {}) {
|
|
165
|
+
const payload = JSON.stringify(body);
|
|
166
|
+
res.writeHead(status, {
|
|
167
|
+
"content-type": "application/json; charset=utf-8",
|
|
168
|
+
"content-length": Buffer.byteLength(payload).toString(),
|
|
169
|
+
...headers,
|
|
170
|
+
});
|
|
171
|
+
res.end(payload);
|
|
172
|
+
}
|
|
173
|
+
/** Race a handler against a deadline; rejects with a timeout error if exceeded. */
|
|
174
|
+
function withTimeout(promise, ms) {
|
|
175
|
+
if (!(ms > 0))
|
|
176
|
+
return promise;
|
|
177
|
+
return new Promise((resolve, reject) => {
|
|
178
|
+
const timer = setTimeout(() => reject(new Error("request timed out")), ms);
|
|
179
|
+
timer.unref?.();
|
|
180
|
+
promise.then((value) => {
|
|
181
|
+
clearTimeout(timer);
|
|
182
|
+
resolve(value);
|
|
183
|
+
}, (err) => {
|
|
184
|
+
clearTimeout(timer);
|
|
185
|
+
reject(err instanceof Error ? err : new Error(String(err)));
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Build (but do not start) the HTTP server wrapping an {@link McpServer}.
|
|
191
|
+
* Exposed for testing and for embedding in a larger process. The `config`
|
|
192
|
+
* carries the resolved auth / timeout / response-cap policy.
|
|
193
|
+
*/
|
|
194
|
+
export function createHttpServer(server, config) {
|
|
195
|
+
return createServer((req, res) => {
|
|
196
|
+
void handleRequest(server, config, req, res).catch((err) => {
|
|
197
|
+
const messageText = err instanceof Error ? err.message : String(err);
|
|
198
|
+
if (!res.headersSent) {
|
|
199
|
+
sendJson(res, 500, makeFailure(null, ErrorCode.InternalError, messageText));
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
res.end();
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
/** Route and handle a single HTTP request. */
|
|
208
|
+
async function handleRequest(server, config, req, res) {
|
|
209
|
+
const url = req.url ?? "/";
|
|
210
|
+
const method = req.method ?? "GET";
|
|
211
|
+
const path = url.split("?")[0];
|
|
212
|
+
if (method === "GET" && path === "/health") {
|
|
213
|
+
sendJson(res, 200, { status: "ok", server: "quantakrypto", transport: "http" });
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
if (path === "/mcp") {
|
|
217
|
+
if (method !== "POST") {
|
|
218
|
+
// The full transport also allows GET for an SSE stream; we don't here.
|
|
219
|
+
sendJson(res, 405, makeFailure(null, ErrorCode.InvalidRequest, "method not allowed"), {
|
|
220
|
+
allow: "POST",
|
|
221
|
+
});
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
// Authenticate BEFORE reading the body or dispatching (Q-02).
|
|
225
|
+
const auth = authorizeRequest(config.token, req.headers.authorization);
|
|
226
|
+
if (!auth.authorized) {
|
|
227
|
+
sendJson(res, auth.status ?? 401, makeFailure(null, ErrorCode.InvalidRequest, auth.message ?? "unauthorized"), { "www-authenticate": "Bearer" });
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
await handleMcpPost(server, config, req, res);
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
sendJson(res, 404, makeFailure(null, ErrorCode.MethodNotFound, "not found"));
|
|
234
|
+
}
|
|
235
|
+
/** Handle `POST /mcp`: parse one JSON-RPC message, dispatch, return the result. */
|
|
236
|
+
async function handleMcpPost(server, config, req, res) {
|
|
237
|
+
// Session handling (stateless here): echo a provided session id, else mint one.
|
|
238
|
+
// A production server would look this up in a session store — see HOSTING.md.
|
|
239
|
+
const incomingSession = req.headers[SESSION_HEADER];
|
|
240
|
+
const sessionId = (Array.isArray(incomingSession) ? incomingSession[0] : incomingSession) ?? randomUUID();
|
|
241
|
+
const sessionHeaders = { [SESSION_HEADER]: sessionId };
|
|
242
|
+
let raw;
|
|
243
|
+
try {
|
|
244
|
+
raw = await readBody(req);
|
|
245
|
+
}
|
|
246
|
+
catch (err) {
|
|
247
|
+
const messageText = err instanceof Error ? err.message : String(err);
|
|
248
|
+
sendJson(res, 413, makeFailure(null, ErrorCode.InvalidRequest, messageText), sessionHeaders);
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
let parsed;
|
|
252
|
+
try {
|
|
253
|
+
parsed = JSON.parse(raw);
|
|
254
|
+
}
|
|
255
|
+
catch {
|
|
256
|
+
sendJson(res, 400, makeFailure(null, ErrorCode.ParseError, "parse error"), sessionHeaders);
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
let response;
|
|
260
|
+
try {
|
|
261
|
+
response = await withTimeout(server.handle(parsed), config.timeoutMs);
|
|
262
|
+
}
|
|
263
|
+
catch (err) {
|
|
264
|
+
const messageText = err instanceof Error ? err.message : String(err);
|
|
265
|
+
sendJson(res, 504, makeFailure(null, ErrorCode.InternalError, messageText), sessionHeaders);
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
if (response === null) {
|
|
269
|
+
// Notification — acknowledge with 202 and no body.
|
|
270
|
+
res.writeHead(202, sessionHeaders);
|
|
271
|
+
res.end();
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
// Enforce the response-size cap (Q-03): never stream back an unbounded body.
|
|
275
|
+
const serialized = JSON.stringify(response);
|
|
276
|
+
if (Buffer.byteLength(serialized) > config.maxResponseBytes) {
|
|
277
|
+
sendJson(res, 500, makeFailure(null, ErrorCode.InternalError, "response too large"), sessionHeaders);
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
sendJson(res, 200, response, sessionHeaders);
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Build the HTTP-facing {@link McpServer}: the same server used over stdio but
|
|
284
|
+
* with the filesystem tools gated per policy. Exposed for tests.
|
|
285
|
+
*/
|
|
286
|
+
export function createHttpMcpServer(config) {
|
|
287
|
+
return createQuantakryptoServer({ tools: gateHttpTools(quantakryptoTools, config.allowFs) });
|
|
288
|
+
}
|
|
289
|
+
/** Start the HTTP server, resolving once it is listening. */
|
|
290
|
+
export function startHttpServer(options = {}) {
|
|
291
|
+
const config = resolveHttpConfig(process.env, options);
|
|
292
|
+
const decision = startupDecision(config);
|
|
293
|
+
if (!decision.ok) {
|
|
294
|
+
return Promise.reject(new Error(decision.reason ?? "refusing to start"));
|
|
295
|
+
}
|
|
296
|
+
if (!config.loopback) {
|
|
297
|
+
process.stderr.write(`quantakrypto MCP (http): WARNING binding to non-loopback host ${config.host}; ` +
|
|
298
|
+
`Bearer auth is required and active.\n`);
|
|
299
|
+
}
|
|
300
|
+
const mcp = createHttpMcpServer(config);
|
|
301
|
+
const httpServer = createHttpServer(mcp, config);
|
|
302
|
+
return new Promise((resolve) => {
|
|
303
|
+
httpServer.listen(config.port, config.host, () => {
|
|
304
|
+
const auth = config.token ? "bearer-auth" : "no-auth";
|
|
305
|
+
const fs = config.allowFs ? "fs-tools:on" : "fs-tools:off";
|
|
306
|
+
process.stderr.write(`quantakrypto MCP server (http) listening on http://${config.host}:${config.port} ` +
|
|
307
|
+
`[${auth}, ${fs}]\n`);
|
|
308
|
+
process.stderr.write(` POST http://${config.host}:${config.port}/mcp ` +
|
|
309
|
+
`GET http://${config.host}:${config.port}/health\n`);
|
|
310
|
+
resolve(httpServer);
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
/** Entry point when run directly. */
|
|
315
|
+
function main() {
|
|
316
|
+
startHttpServer().catch((err) => {
|
|
317
|
+
const messageText = err instanceof Error ? err.message : String(err);
|
|
318
|
+
process.stderr.write(`quantakrypto MCP (http) failed to start: ${messageText}\n`);
|
|
319
|
+
process.exitCode = 1;
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
/** True when this module is the program's entry point (handles symlinks). */
|
|
323
|
+
function isMainModule() {
|
|
324
|
+
const argv1 = process.argv[1];
|
|
325
|
+
if (!argv1)
|
|
326
|
+
return false;
|
|
327
|
+
const thisPath = fileURLToPath(import.meta.url);
|
|
328
|
+
try {
|
|
329
|
+
return realpathSync(argv1) === realpathSync(thisPath);
|
|
330
|
+
}
|
|
331
|
+
catch {
|
|
332
|
+
return argv1 === thisPath;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
// Only auto-run when invoked as a script, not when imported by tests.
|
|
336
|
+
if (isMainModule()) {
|
|
337
|
+
main();
|
|
338
|
+
}
|
|
339
|
+
//# sourceMappingURL=http.js.map
|
package/dist/http.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEvD,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG9D,8EAA8E;AAC9E,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAE/C,wEAAwE;AACxE,MAAM,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link McpServer}, the quantakrypto tool set, and a
|
|
5
|
+
* {@link createQuantakryptoServer} factory that wires them together. Transports
|
|
6
|
+
* (stdio, http) consume the factory; tests drive the server's `handle` method
|
|
7
|
+
* directly.
|
|
8
|
+
*/
|
|
9
|
+
import { McpServer } from "./server.js";
|
|
10
|
+
import { quantakryptoTools } from "./tools.js";
|
|
11
|
+
export { McpServer } from "./server.js";
|
|
12
|
+
export type { McpServerOptions, ServerInfo } from "./server.js";
|
|
13
|
+
export { quantakryptoTools, CORE_VERSION } from "./tools.js";
|
|
14
|
+
export { MCP_PROTOCOL_VERSION, JSONRPC_VERSION, ErrorCode, RpcError, textResult, errorResult, } from "./protocol.js";
|
|
15
|
+
export type { JsonRpcRequest, JsonRpcResponse, JsonRpcSuccess, JsonRpcFailure, ToolDefinition, ToolDescriptor, ToolResult, Content, TextContent, JsonSchema, } from "./protocol.js";
|
|
16
|
+
/** The MCP server name advertised to clients. */
|
|
17
|
+
export declare const SERVER_NAME = "quantakrypto";
|
|
18
|
+
/** The version reported by the server (kept in sync with @quantakrypto/core). */
|
|
19
|
+
export declare const SERVER_VERSION = "0.1.0";
|
|
20
|
+
export interface CreateServerOptions {
|
|
21
|
+
/** Override the advertised server version (defaults to @quantakrypto/core VERSION). */
|
|
22
|
+
version?: string;
|
|
23
|
+
/** Override or extend the registered tool set (defaults to all quantakrypto tools). */
|
|
24
|
+
tools?: typeof quantakryptoTools;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Create a fully-wired quantakrypto {@link McpServer} with all tools registered.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const server = createQuantakryptoServer();
|
|
32
|
+
* const res = await server.handle({ jsonrpc: "2.0", id: 1, method: "tools/list" });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function createQuantakryptoServer(options?: CreateServerOptions): McpServer;
|
|
36
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,SAAS,EACT,QAAQ,EACR,UAAU,EACV,WAAW,GACZ,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,cAAc,EACd,eAAe,EACf,cAAc,EACd,cAAc,EACd,cAAc,EACd,cAAc,EACd,UAAU,EACV,OAAO,EACP,WAAW,EACX,UAAU,GACX,MAAM,eAAe,CAAC;AAEvB,iDAAiD;AACjD,eAAO,MAAM,WAAW,iBAAiB,CAAC;AAE1C,iFAAiF;AACjF,eAAO,MAAM,cAAc,UAAU,CAAC;AAEtC,MAAM,WAAW,mBAAmB;IAClC,uFAAuF;IACvF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uFAAuF;IACvF,KAAK,CAAC,EAAE,OAAO,iBAAiB,CAAC;CAClC;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,GAAE,mBAAwB,GAAG,SAAS,CAarF"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @quantakrypto/mcp — public API.
|
|
3
|
+
*
|
|
4
|
+
* Exports the transport-agnostic {@link McpServer}, the quantakrypto tool set, and a
|
|
5
|
+
* {@link createQuantakryptoServer} factory that wires them together. Transports
|
|
6
|
+
* (stdio, http) consume the factory; tests drive the server's `handle` method
|
|
7
|
+
* directly.
|
|
8
|
+
*/
|
|
9
|
+
import { VERSION } from "@quantakrypto/core";
|
|
10
|
+
import { McpServer } from "./server.js";
|
|
11
|
+
import { quantakryptoTools } from "./tools.js";
|
|
12
|
+
export { McpServer } from "./server.js";
|
|
13
|
+
export { quantakryptoTools, CORE_VERSION } from "./tools.js";
|
|
14
|
+
export { MCP_PROTOCOL_VERSION, JSONRPC_VERSION, ErrorCode, RpcError, textResult, errorResult, } from "./protocol.js";
|
|
15
|
+
/** The MCP server name advertised to clients. */
|
|
16
|
+
export const SERVER_NAME = "quantakrypto";
|
|
17
|
+
/** The version reported by the server (kept in sync with @quantakrypto/core). */
|
|
18
|
+
export const SERVER_VERSION = VERSION;
|
|
19
|
+
/**
|
|
20
|
+
* Create a fully-wired quantakrypto {@link McpServer} with all tools registered.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* const server = createQuantakryptoServer();
|
|
25
|
+
* const res = await server.handle({ jsonrpc: "2.0", id: 1, method: "tools/list" });
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export function createQuantakryptoServer(options = {}) {
|
|
29
|
+
const server = new McpServer({
|
|
30
|
+
info: { name: SERVER_NAME, version: options.version ?? SERVER_VERSION },
|
|
31
|
+
instructions: "quantakrypto checks code for quantum-vulnerable cryptography and recommends " +
|
|
32
|
+
"post-quantum (NIST PQC) migrations. Use scan_path / inventory_crypto to " +
|
|
33
|
+
"assess a path, list_rules to see detectors, and explain_finding / " +
|
|
34
|
+
"suggest_hybrid for remediation guidance.",
|
|
35
|
+
});
|
|
36
|
+
for (const tool of options.tools ?? quantakryptoTools) {
|
|
37
|
+
server.registerTool(tool);
|
|
38
|
+
}
|
|
39
|
+
return server;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,SAAS,EACT,QAAQ,EACR,UAAU,EACV,WAAW,GACZ,MAAM,eAAe,CAAC;AAcvB,iDAAiD;AACjD,MAAM,CAAC,MAAM,WAAW,GAAG,cAAc,CAAC;AAE1C,iFAAiF;AACjF,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC;AAStC;;;;;;;;GAQG;AACH,MAAM,UAAU,wBAAwB,CAAC,UAA+B,EAAE;IACxE,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;QAC3B,IAAI,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,cAAc,EAAE;QACvE,YAAY,EACV,8EAA8E;YAC9E,0EAA0E;YAC1E,oEAAoE;YACpE,0CAA0C;KAC7C,CAAC,CAAC;IACH,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,KAAK,IAAI,iBAAiB,EAAE,CAAC;QACtD,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON-RPC 2.0 + Model Context Protocol (MCP) wire types.
|
|
3
|
+
*
|
|
4
|
+
* This module is pure type/shape definitions plus a few small helpers for
|
|
5
|
+
* constructing valid JSON-RPC responses and errors. It has no runtime
|
|
6
|
+
* dependencies and no I/O — the transport layers (stdio, http) and the
|
|
7
|
+
* {@link McpServer} build on top of it.
|
|
8
|
+
*
|
|
9
|
+
* Reference: JSON-RPC 2.0 (https://www.jsonrpc.org/specification) and the
|
|
10
|
+
* Model Context Protocol specification (https://modelcontextprotocol.io).
|
|
11
|
+
*/
|
|
12
|
+
/** The fixed JSON-RPC protocol marker. */
|
|
13
|
+
export declare const JSONRPC_VERSION: "2.0";
|
|
14
|
+
/**
|
|
15
|
+
* MCP protocol revision this server speaks. The `initialize` handshake echoes
|
|
16
|
+
* the client's requested version when we support it, otherwise advertises this.
|
|
17
|
+
*/
|
|
18
|
+
export declare const MCP_PROTOCOL_VERSION: "2025-06-18";
|
|
19
|
+
/** A JSON-RPC id: string or number per spec (we never originate notifications). */
|
|
20
|
+
export type JsonRpcId = string | number | null;
|
|
21
|
+
/** Any JSON value. Kept structural rather than `any` for strict mode. */
|
|
22
|
+
export type JsonValue = null | boolean | number | string | JsonValue[] | {
|
|
23
|
+
[key: string]: JsonValue;
|
|
24
|
+
};
|
|
25
|
+
/** A JSON-RPC 2.0 request or notification (notifications omit `id`). */
|
|
26
|
+
export interface JsonRpcRequest {
|
|
27
|
+
jsonrpc: typeof JSONRPC_VERSION;
|
|
28
|
+
/** Absent for notifications. */
|
|
29
|
+
id?: JsonRpcId;
|
|
30
|
+
method: string;
|
|
31
|
+
params?: Record<string, unknown> | unknown[];
|
|
32
|
+
}
|
|
33
|
+
/** A successful JSON-RPC response. */
|
|
34
|
+
export interface JsonRpcSuccess {
|
|
35
|
+
jsonrpc: typeof JSONRPC_VERSION;
|
|
36
|
+
id: JsonRpcId;
|
|
37
|
+
result: unknown;
|
|
38
|
+
}
|
|
39
|
+
/** A JSON-RPC error object. */
|
|
40
|
+
export interface JsonRpcErrorObject {
|
|
41
|
+
code: number;
|
|
42
|
+
message: string;
|
|
43
|
+
data?: unknown;
|
|
44
|
+
}
|
|
45
|
+
/** A failed JSON-RPC response. */
|
|
46
|
+
export interface JsonRpcFailure {
|
|
47
|
+
jsonrpc: typeof JSONRPC_VERSION;
|
|
48
|
+
id: JsonRpcId;
|
|
49
|
+
error: JsonRpcErrorObject;
|
|
50
|
+
}
|
|
51
|
+
export type JsonRpcResponse = JsonRpcSuccess | JsonRpcFailure;
|
|
52
|
+
/** Standard JSON-RPC 2.0 error codes (plus MCP conventions). */
|
|
53
|
+
export declare const ErrorCode: {
|
|
54
|
+
readonly ParseError: -32700;
|
|
55
|
+
readonly InvalidRequest: -32600;
|
|
56
|
+
readonly MethodNotFound: -32601;
|
|
57
|
+
readonly InvalidParams: -32602;
|
|
58
|
+
readonly InternalError: -32603;
|
|
59
|
+
};
|
|
60
|
+
/** An error that carries a JSON-RPC error code, thrown by tool handlers/dispatch. */
|
|
61
|
+
export declare class RpcError extends Error {
|
|
62
|
+
readonly code: number;
|
|
63
|
+
readonly data?: unknown;
|
|
64
|
+
constructor(code: number, message: string, data?: unknown);
|
|
65
|
+
}
|
|
66
|
+
/** Build a successful response envelope. */
|
|
67
|
+
export declare function makeSuccess(id: JsonRpcId, result: unknown): JsonRpcSuccess;
|
|
68
|
+
/** Build a failure response envelope. */
|
|
69
|
+
export declare function makeFailure(id: JsonRpcId, code: number, message: string, data?: unknown): JsonRpcFailure;
|
|
70
|
+
/** Narrow an unknown parsed value to something request-shaped enough to dispatch. */
|
|
71
|
+
export declare function isJsonRpcRequestLike(value: unknown): value is JsonRpcRequest;
|
|
72
|
+
/** True when a request is a notification (no `id` field present). */
|
|
73
|
+
export declare function isNotification(req: JsonRpcRequest): boolean;
|
|
74
|
+
/** A single piece of MCP content. We only emit text content in this server. */
|
|
75
|
+
export interface TextContent {
|
|
76
|
+
type: "text";
|
|
77
|
+
text: string;
|
|
78
|
+
}
|
|
79
|
+
export type Content = TextContent;
|
|
80
|
+
/** The result envelope returned by a `tools/call`. */
|
|
81
|
+
export interface ToolResult {
|
|
82
|
+
content: Content[];
|
|
83
|
+
/** True when the tool ran but produced an error result (vs. a protocol error). */
|
|
84
|
+
isError?: boolean;
|
|
85
|
+
}
|
|
86
|
+
/** A minimal JSON Schema object describing a tool's input. */
|
|
87
|
+
export interface JsonSchema {
|
|
88
|
+
type: "object";
|
|
89
|
+
properties?: Record<string, unknown>;
|
|
90
|
+
required?: string[];
|
|
91
|
+
additionalProperties?: boolean;
|
|
92
|
+
[key: string]: unknown;
|
|
93
|
+
}
|
|
94
|
+
/** The public descriptor of a tool, as returned by `tools/list`. */
|
|
95
|
+
export interface ToolDescriptor {
|
|
96
|
+
name: string;
|
|
97
|
+
description: string;
|
|
98
|
+
inputSchema: JsonSchema;
|
|
99
|
+
}
|
|
100
|
+
/** A registered tool: descriptor plus its async handler. */
|
|
101
|
+
export interface ToolDefinition extends ToolDescriptor {
|
|
102
|
+
/** Executes the tool with already-parsed arguments. */
|
|
103
|
+
handler: (args: Record<string, unknown>) => Promise<ToolResult> | ToolResult;
|
|
104
|
+
}
|
|
105
|
+
/** Convenience: wrap one or more strings as a non-error text tool result. */
|
|
106
|
+
export declare function textResult(...parts: string[]): ToolResult;
|
|
107
|
+
/** Convenience: wrap a string as an error text tool result. */
|
|
108
|
+
export declare function errorResult(text: string): ToolResult;
|
|
109
|
+
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,0CAA0C;AAC1C,eAAO,MAAM,eAAe,EAAG,KAAc,CAAC;AAE9C;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAG,YAAqB,CAAC;AAE1D,mFAAmF;AACnF,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;AAE/C,yEAAyE;AACzE,MAAM,MAAM,SAAS,GACjB,IAAI,GACJ,OAAO,GACP,MAAM,GACN,MAAM,GACN,SAAS,EAAE,GACX;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAEjC,wEAAwE;AACxE,MAAM,WAAW,cAAc;IAC7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,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON-RPC 2.0 + Model Context Protocol (MCP) wire types.
|
|
3
|
+
*
|
|
4
|
+
* This module is pure type/shape definitions plus a few small helpers for
|
|
5
|
+
* constructing valid JSON-RPC responses and errors. It has no runtime
|
|
6
|
+
* dependencies and no I/O — the transport layers (stdio, http) and the
|
|
7
|
+
* {@link McpServer} build on top of it.
|
|
8
|
+
*
|
|
9
|
+
* Reference: JSON-RPC 2.0 (https://www.jsonrpc.org/specification) and the
|
|
10
|
+
* Model Context Protocol specification (https://modelcontextprotocol.io).
|
|
11
|
+
*/
|
|
12
|
+
/** The fixed JSON-RPC protocol marker. */
|
|
13
|
+
export const JSONRPC_VERSION = "2.0";
|
|
14
|
+
/**
|
|
15
|
+
* MCP protocol revision this server speaks. The `initialize` handshake echoes
|
|
16
|
+
* the client's requested version when we support it, otherwise advertises this.
|
|
17
|
+
*/
|
|
18
|
+
export const MCP_PROTOCOL_VERSION = "2025-06-18";
|
|
19
|
+
/** Standard JSON-RPC 2.0 error codes (plus MCP conventions). */
|
|
20
|
+
export const ErrorCode = {
|
|
21
|
+
ParseError: -32700,
|
|
22
|
+
InvalidRequest: -32600,
|
|
23
|
+
MethodNotFound: -32601,
|
|
24
|
+
InvalidParams: -32602,
|
|
25
|
+
InternalError: -32603,
|
|
26
|
+
};
|
|
27
|
+
/** An error that carries a JSON-RPC error code, thrown by tool handlers/dispatch. */
|
|
28
|
+
export class RpcError extends Error {
|
|
29
|
+
code;
|
|
30
|
+
data;
|
|
31
|
+
constructor(code, message, data) {
|
|
32
|
+
super(message);
|
|
33
|
+
this.name = "RpcError";
|
|
34
|
+
this.code = code;
|
|
35
|
+
this.data = data;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/** Build a successful response envelope. */
|
|
39
|
+
export function makeSuccess(id, result) {
|
|
40
|
+
return { jsonrpc: JSONRPC_VERSION, id, result };
|
|
41
|
+
}
|
|
42
|
+
/** Build a failure response envelope. */
|
|
43
|
+
export function makeFailure(id, code, message, data) {
|
|
44
|
+
const error = { code, message };
|
|
45
|
+
if (data !== undefined)
|
|
46
|
+
error.data = data;
|
|
47
|
+
return { jsonrpc: JSONRPC_VERSION, id, error };
|
|
48
|
+
}
|
|
49
|
+
/** Narrow an unknown parsed value to something request-shaped enough to dispatch. */
|
|
50
|
+
export function isJsonRpcRequestLike(value) {
|
|
51
|
+
if (typeof value !== "object" || value === null)
|
|
52
|
+
return false;
|
|
53
|
+
const v = value;
|
|
54
|
+
return v.jsonrpc === JSONRPC_VERSION && typeof v.method === "string";
|
|
55
|
+
}
|
|
56
|
+
/** True when a request is a notification (no `id` field present). */
|
|
57
|
+
export function isNotification(req) {
|
|
58
|
+
return !("id" in req) || req.id === undefined;
|
|
59
|
+
}
|
|
60
|
+
/** Convenience: wrap one or more strings as a non-error text tool result. */
|
|
61
|
+
export function textResult(...parts) {
|
|
62
|
+
return { content: parts.map((text) => ({ type: "text", text })) };
|
|
63
|
+
}
|
|
64
|
+
/** Convenience: wrap a string as an error text tool result. */
|
|
65
|
+
export function errorResult(text) {
|
|
66
|
+
return { content: [{ type: "text", text }], isError: true };
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,0CAA0C;AAC1C,MAAM,CAAC,MAAM,eAAe,GAAG,KAAc,CAAC;AAE9C;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,YAAqB,CAAC;AA8C1D,gEAAgE;AAChE,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,UAAU,EAAE,CAAC,KAAK;IAClB,cAAc,EAAE,CAAC,KAAK;IACtB,cAAc,EAAE,CAAC,KAAK;IACtB,aAAa,EAAE,CAAC,KAAK;IACrB,aAAa,EAAE,CAAC,KAAK;CACb,CAA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