@quantakrypto/mcp 0.4.4 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HOSTING.md +15 -1
- package/README.md +22 -1
- package/dist/fsconfig.d.ts +4 -3
- package/dist/fsconfig.d.ts.map +1 -1
- package/dist/fsconfig.js.map +1 -1
- package/dist/http.d.ts +21 -18
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +23 -12
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/protocol.d.ts +3 -6
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js.map +1 -1
- package/dist/resources.d.ts +4 -3
- package/dist/resources.d.ts.map +1 -1
- package/dist/resources.js.map +1 -1
- package/dist/rules.d.ts +2 -1
- package/dist/rules.d.ts.map +1 -1
- package/dist/rules.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +6 -0
- package/dist/server.js.map +1 -1
- package/dist/stdio.d.ts +0 -3
- package/dist/stdio.d.ts.map +1 -1
- package/dist/stdio.js +0 -5
- package/dist/stdio.js.map +1 -1
- package/dist/tools.d.ts +9 -4
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +181 -5
- package/dist/tools.js.map +1 -1
- package/package.json +3 -2
package/dist/protocol.d.ts
CHANGED
|
@@ -17,11 +17,7 @@ export declare const JSONRPC_VERSION: "2.0";
|
|
|
17
17
|
*/
|
|
18
18
|
export declare const MCP_PROTOCOL_VERSION: "2025-06-18";
|
|
19
19
|
/** A JSON-RPC id: string or number per spec (we never originate notifications). */
|
|
20
|
-
|
|
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
|
-
};
|
|
20
|
+
type JsonRpcId = string | number | null;
|
|
25
21
|
/** A JSON-RPC 2.0 request or notification (notifications omit `id`). */
|
|
26
22
|
export interface JsonRpcRequest {
|
|
27
23
|
jsonrpc: typeof JSONRPC_VERSION;
|
|
@@ -37,7 +33,7 @@ export interface JsonRpcSuccess {
|
|
|
37
33
|
result: unknown;
|
|
38
34
|
}
|
|
39
35
|
/** A JSON-RPC error object. */
|
|
40
|
-
|
|
36
|
+
interface JsonRpcErrorObject {
|
|
41
37
|
code: number;
|
|
42
38
|
message: string;
|
|
43
39
|
data?: unknown;
|
|
@@ -121,4 +117,5 @@ export interface ToolDefinition extends ToolDescriptor {
|
|
|
121
117
|
export declare function textResult(...parts: string[]): ToolResult;
|
|
122
118
|
/** Convenience: wrap a string as an error text tool result. */
|
|
123
119
|
export declare function errorResult(text: string): ToolResult;
|
|
120
|
+
export {};
|
|
124
121
|
//# sourceMappingURL=protocol.d.ts.map
|
package/dist/protocol.d.ts.map
CHANGED
|
@@ -1 +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,
|
|
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,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;AAExC,wEAAwE;AACxE,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,eAAe,CAAC;IAChC,gCAAgC;IAChC,EAAE,CAAC,EAAE,SAAS,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MA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.js.map
CHANGED
|
@@ -1 +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;
|
|
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;AAqC1D,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;IACrB,qEAAqE;IACrE,gBAAgB,EAAE,CAAC,KAAK;CAChB,CAAC;AAEX,qFAAqF;AACrF,MAAM,OAAO,QAAS,SAAQ,KAAK;IACxB,IAAI,CAAS;IACb,IAAI,CAAW;IACxB,YAAY,IAAY,EAAE,OAAe,EAAE,IAAc;QACvD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAED,4CAA4C;AAC5C,MAAM,UAAU,WAAW,CAAC,EAAa,EAAE,MAAe;IACxD,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC;AAClD,CAAC;AAED,yCAAyC;AACzC,MAAM,UAAU,WAAW,CACzB,EAAa,EACb,IAAY,EACZ,OAAe,EACf,IAAc;IAEd,MAAM,KAAK,GAAuB,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IACpD,IAAI,IAAI,KAAK,SAAS;QAAE,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;IAC1C,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC;AACjD,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,CAAC,GAAG,KAAgC,CAAC;IAC3C,OAAO,CAAC,CAAC,OAAO,KAAK,eAAe,IAAI,OAAO,CAAC,CAAC,MAAM,KAAK,QAAQ,CAAC;AACvE,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,cAAc,CAAC,GAAmB;IAChD,OAAO,CAAC,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,GAAG,CAAC,EAAE,KAAK,SAAS,CAAC;AAChD,CAAC;AA4DD,6EAA6E;AAC7E,MAAM,UAAU,UAAU,CAAC,GAAG,KAAe;IAC3C,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;AACpE,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC9D,CAAC","sourcesContent":["/**\n * JSON-RPC 2.0 + Model Context Protocol (MCP) wire types.\n *\n * This module is pure type/shape definitions plus a few small helpers for\n * constructing valid JSON-RPC responses and errors. It has no runtime\n * dependencies and no I/O — the transport layers (stdio, http) and the\n * {@link McpServer} build on top of it.\n *\n * Reference: JSON-RPC 2.0 (https://www.jsonrpc.org/specification) and the\n * Model Context Protocol specification (https://modelcontextprotocol.io).\n */\n\n/** The fixed JSON-RPC protocol marker. */\nexport const JSONRPC_VERSION = \"2.0\" as const;\n\n/**\n * MCP protocol revision this server speaks. The `initialize` handshake echoes\n * the client's requested version when we support it, otherwise advertises this.\n */\nexport const MCP_PROTOCOL_VERSION = \"2025-06-18\" as const;\n\n/** A JSON-RPC id: string or number per spec (we never originate notifications). */\ntype JsonRpcId = string | number | null;\n\n/** A JSON-RPC 2.0 request or notification (notifications omit `id`). */\nexport interface JsonRpcRequest {\n jsonrpc: typeof JSONRPC_VERSION;\n /** Absent for notifications. */\n id?: JsonRpcId;\n method: string;\n params?: Record<string, unknown> | unknown[];\n}\n\n/** A successful JSON-RPC response. */\nexport interface JsonRpcSuccess {\n jsonrpc: typeof JSONRPC_VERSION;\n id: JsonRpcId;\n result: unknown;\n}\n\n/** A JSON-RPC error object. */\ninterface JsonRpcErrorObject {\n code: number;\n message: string;\n data?: unknown;\n}\n\n/** A failed JSON-RPC response. */\nexport interface JsonRpcFailure {\n jsonrpc: typeof JSONRPC_VERSION;\n id: JsonRpcId;\n error: JsonRpcErrorObject;\n}\n\nexport type JsonRpcResponse = JsonRpcSuccess | JsonRpcFailure;\n\n/** Standard JSON-RPC 2.0 error codes (plus MCP conventions). */\nexport const ErrorCode = {\n ParseError: -32700,\n InvalidRequest: -32600,\n MethodNotFound: -32601,\n InvalidParams: -32602,\n InternalError: -32603,\n /** MCP: resource not found (`resources/read` for an unknown URI). */\n ResourceNotFound: -32002,\n} as const;\n\n/** An error that carries a JSON-RPC error code, thrown by tool handlers/dispatch. */\nexport class RpcError extends Error {\n readonly code: number;\n readonly data?: unknown;\n constructor(code: number, message: string, data?: unknown) {\n super(message);\n this.name = \"RpcError\";\n this.code = code;\n this.data = data;\n }\n}\n\n/** Build a successful response envelope. */\nexport function makeSuccess(id: JsonRpcId, result: unknown): JsonRpcSuccess {\n return { jsonrpc: JSONRPC_VERSION, id, result };\n}\n\n/** Build a failure response envelope. */\nexport function makeFailure(\n id: JsonRpcId,\n code: number,\n message: string,\n data?: unknown,\n): JsonRpcFailure {\n const error: JsonRpcErrorObject = { code, message };\n if (data !== undefined) error.data = data;\n return { jsonrpc: JSONRPC_VERSION, id, error };\n}\n\n/** Narrow an unknown parsed value to something request-shaped enough to dispatch. */\nexport function isJsonRpcRequestLike(value: unknown): value is JsonRpcRequest {\n if (typeof value !== \"object\" || value === null) return false;\n const v = value as Record<string, unknown>;\n return v.jsonrpc === JSONRPC_VERSION && typeof v.method === \"string\";\n}\n\n/** True when a request is a notification (no `id` field present). */\nexport function isNotification(req: JsonRpcRequest): boolean {\n return !(\"id\" in req) || req.id === undefined;\n}\n\n// ---------------------------------------------------------------------------\n// MCP content + tool shapes\n// ---------------------------------------------------------------------------\n\n/** A single piece of MCP content. We only emit text content in this server. */\nexport interface TextContent {\n type: \"text\";\n text: string;\n}\n\nexport type Content = TextContent;\n\n/** The result envelope returned by a `tools/call`. */\nexport interface ToolResult {\n content: Content[];\n /** True when the tool ran but produced an error result (vs. a protocol error). */\n isError?: boolean;\n}\n\n/** A minimal JSON Schema object describing a tool's input. */\nexport interface JsonSchema {\n type: \"object\";\n properties?: Record<string, unknown>;\n required?: string[];\n additionalProperties?: boolean;\n [key: string]: unknown;\n}\n\n/** The public descriptor of a tool, as returned by `tools/list`. */\nexport interface ToolDescriptor {\n name: string;\n description: string;\n inputSchema: JsonSchema;\n}\n\n/**\n * Per-call context threaded from the transport into a tool handler. Carries the\n * cooperative-cancellation signal so a long-running tool (e.g. a filesystem\n * scan) can be aborted when the transport's request deadline fires, instead of\n * leaking unbounded background work after a 504/timeout.\n */\nexport interface ToolContext {\n /** Fires when the caller's request deadline elapses; abort in-flight work. */\n signal?: AbortSignal;\n}\n\n/** A registered tool: descriptor plus its async handler. */\nexport interface ToolDefinition extends ToolDescriptor {\n /**\n * Executes the tool with already-parsed arguments and an optional per-call\n * {@link ToolContext} (e.g. an `AbortSignal` for the request deadline).\n */\n handler: (\n args: Record<string, unknown>,\n context?: ToolContext,\n ) => Promise<ToolResult> | ToolResult;\n}\n\n/** Convenience: wrap one or more strings as a non-error text tool result. */\nexport function textResult(...parts: string[]): ToolResult {\n return { content: parts.map((text) => ({ type: \"text\", text })) };\n}\n\n/** Convenience: wrap a string as an error text tool result. */\nexport function errorResult(text: string): ToolResult {\n return { content: [{ type: \"text\", text }], isError: true };\n}\n"]}
|
package/dist/resources.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** A resource descriptor for `resources/list`. */
|
|
2
|
-
|
|
2
|
+
interface ResourceDescriptor {
|
|
3
3
|
uri: string;
|
|
4
4
|
name: string;
|
|
5
5
|
description: string;
|
|
@@ -13,7 +13,7 @@ export declare function readResource(uri: string): {
|
|
|
13
13
|
text: string;
|
|
14
14
|
} | null;
|
|
15
15
|
/** A prompt descriptor for `prompts/list`. */
|
|
16
|
-
|
|
16
|
+
interface PromptDescriptor {
|
|
17
17
|
name: string;
|
|
18
18
|
description: string;
|
|
19
19
|
arguments?: {
|
|
@@ -24,7 +24,7 @@ export interface PromptDescriptor {
|
|
|
24
24
|
}
|
|
25
25
|
export declare const PROMPTS: PromptDescriptor[];
|
|
26
26
|
/** A prompt message (MCP `prompts/get` shape). */
|
|
27
|
-
|
|
27
|
+
interface PromptMessage {
|
|
28
28
|
role: "user";
|
|
29
29
|
content: {
|
|
30
30
|
type: "text";
|
|
@@ -36,4 +36,5 @@ export declare function getPrompt(name: string, args: Record<string, unknown>):
|
|
|
36
36
|
description: string;
|
|
37
37
|
messages: PromptMessage[];
|
|
38
38
|
} | null;
|
|
39
|
+
export {};
|
|
39
40
|
//# sourceMappingURL=resources.d.ts.map
|
package/dist/resources.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../src/resources.ts"],"names":[],"mappings":"AAQA,kDAAkD;AAClD,
|
|
1
|
+
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../src/resources.ts"],"names":[],"mappings":"AAQA,kDAAkD;AAClD,UAAU,kBAAkB;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,SAAS,EAAE,kBAAkB,EAczC,CAAC;AAmBF,oEAAoE;AACpE,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAYhG;AAED,8CAA8C;AAC9C,UAAU,gBAAgB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC;CACzE;AAED,eAAO,MAAM,OAAO,EAAE,gBAAgB,EAOrC,CAAC;AAEF,kDAAkD;AAClD,UAAU,aAAa;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CACzC;AAED,0DAA0D;AAC1D,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,aAAa,EAAE,CAAA;CAAE,GAAG,IAAI,CAc3D"}
|
package/dist/resources.js.map
CHANGED
|
@@ -1 +1 @@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;IAE7B,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACpC,MAAM,IAAI,GAAG,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;IAC1E,MAAM,IAAI,GACR,WAAW,IAAI,sEAAsE;QACrF,yBAAyB,IAAI,MAAM;QACnC,sFAAsF;QACtF,uFAAuF;QACvF,0EAA0E;QAC1E,sFAAsF,CAAC;IACzF,OAAO;QACL,WAAW,EAAE,0CAA0C;QACvD,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC;KAC9D,CAAC;AACJ,CAAC","sourcesContent":["/**\n * MCP resources + prompts. Resources expose read-only reference data (the full\n * rule catalog + a migration guide); the prompt gives a client a one-call\n * \"migrate this path\" workflow that drives the deterministic tools. All offline\n * and static — no filesystem, no network, no key.\n */\nimport { defaultRegistry, REMEDIATE_RUBRIC } from \"@quantakrypto/core\";\n\n/** A resource descriptor for `resources/list`. */\
|
|
1
|
+
{"version":3,"file":"resources.js","sourceRoot":"","sources":["../src/resources.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAUvE,MAAM,CAAC,MAAM,SAAS,GAAyB;IAC7C;QACE,GAAG,EAAE,sBAAsB;QAC3B,IAAI,EAAE,2BAA2B;QACjC,WAAW,EACT,gGAAgG;QAClG,QAAQ,EAAE,kBAAkB;KAC7B;IACD;QACE,GAAG,EAAE,gCAAgC;QACrC,IAAI,EAAE,qBAAqB;QAC3B,WAAW,EAAE,kFAAkF;QAC/F,QAAQ,EAAE,eAAe;KAC1B;CACF,CAAC;AAEF,MAAM,eAAe,GAAG;;;;;;;;;;;;;;EActB,gBA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EAAE,CAAC;KAC9D,CAAC;AACJ,CAAC","sourcesContent":["/**\n * MCP resources + prompts. Resources expose read-only reference data (the full\n * rule catalog + a migration guide); the prompt gives a client a one-call\n * \"migrate this path\" workflow that drives the deterministic tools. All offline\n * and static — no filesystem, no network, no key.\n */\nimport { defaultRegistry, REMEDIATE_RUBRIC } from \"@quantakrypto/core\";\n\n/** A resource descriptor for `resources/list`. */\ninterface ResourceDescriptor {\n uri: string;\n name: string;\n description: string;\n mimeType: string;\n}\n\nexport const RESOURCES: ResourceDescriptor[] = [\n {\n uri: \"quantakrypto://rules\",\n name: \"Quantakrypto rule catalog\",\n description:\n \"Every detection rule quantakrypto can emit (id, title, severity, category, HNDL, remediation).\",\n mimeType: \"application/json\",\n },\n {\n uri: \"quantakrypto://guide/migration\",\n name: \"PQC migration guide\",\n description: \"How to migrate quantum-vulnerable cryptography using the quantakrypto MCP tools.\",\n mimeType: \"text/markdown\",\n },\n];\n\nconst MIGRATION_GUIDE = `# Post-Quantum Migration with quantakrypto\n\nA safe, deterministic loop (\"the model proposes, the engine disposes\"):\n\n1. **Inventory** — call \\`scan_path\\` on the target to list quantum-vulnerable findings.\n2. **Triage** — call \\`triage_findings\\` for the bundle, decide an exposure verdict per\n finding, then \\`apply_triage\\` to rank them (harvest-now-decrypt-later first).\n3. **Remediate** — call \\`remediate_findings\\`; for each finding propose the corrected\n full file, then \\`verify_fix\\` on your result. Keep ONLY fixes that clear the finding\n and introduce no new one. Skip any file containing secrets.\n4. Open a **draft** PR for review. Never auto-merge.\n\n## Remediation rubric\n\n${REMEDIATE_RUBRIC}\n`;\n\n/** Read a resource body by URI, or null when the URI is unknown. */\nexport function readResource(uri: string): { uri: string; mimeType: string; text: string } | null {\n if (uri === \"quantakrypto://rules\") {\n return {\n uri,\n mimeType: \"application/json\",\n text: JSON.stringify(defaultRegistry.ruleCatalog(), null, 2),\n };\n }\n if (uri === \"quantakrypto://guide/migration\") {\n return { uri, mimeType: \"text/markdown\", text: MIGRATION_GUIDE };\n }\n return null;\n}\n\n/** A prompt descriptor for `prompts/list`. */\ninterface PromptDescriptor {\n name: string;\n description: string;\n arguments?: { name: string; description: string; required?: boolean }[];\n}\n\nexport const PROMPTS: PromptDescriptor[] = [\n {\n name: \"migrate\",\n description:\n \"Plan and apply a post-quantum migration for a path using the deterministic tools.\",\n arguments: [{ name: \"path\", description: \"Path to scan (default: .)\", required: false }],\n },\n];\n\n/** A prompt message (MCP `prompts/get` shape). */\ninterface PromptMessage {\n role: \"user\";\n content: { type: \"text\"; text: string };\n}\n\n/** Materialize a prompt by name, or null when unknown. */\nexport function getPrompt(\n name: string,\n args: Record<string, unknown>,\n): { description: string; messages: PromptMessage[] } | null {\n if (name !== \"migrate\") return null;\n const path = typeof args.path === \"string\" && args.path ? args.path : \".\";\n const text =\n `Migrate ${path} off quantum-vulnerable cryptography using the quantakrypto tools.\\n` +\n `1) Call scan_path on \"${path}\".\\n` +\n `2) Call triage_findings, decide exposure verdicts, then apply_triage to rank them.\\n` +\n `3) For each finding: call remediate_findings, propose the corrected full file, then\\n` +\n ` verify_fix on your result — keep only fixes that clear the finding.\\n` +\n `Never touch files containing secrets; never auto-merge — open a draft PR for review.`;\n return {\n description: \"Plan and apply a post-quantum migration.\",\n messages: [{ role: \"user\", content: { type: \"text\", text } }],\n };\n}\n"]}
|
package/dist/rules.d.ts
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
*/
|
|
21
21
|
import type { AlgorithmFamily, RuleMeta } from "@quantakrypto/core";
|
|
22
22
|
/** A resolved rule: the detector it belongs to (if any) and its algorithm. */
|
|
23
|
-
|
|
23
|
+
interface ResolvedRule {
|
|
24
24
|
/** The rule id that was looked up (echoed for convenience). */
|
|
25
25
|
ruleId: string;
|
|
26
26
|
/** The detector that emits this rule, when one could be resolved. */
|
|
@@ -50,4 +50,5 @@ export interface ResolvedRule {
|
|
|
50
50
|
export declare function resolveRule(ruleId: string): ResolvedRule;
|
|
51
51
|
/** Exposed for tests: the set of canonical rule ids resolvable via the catalog. */
|
|
52
52
|
export declare const KNOWN_RULE_IDS: readonly string[];
|
|
53
|
+
export {};
|
|
53
54
|
//# sourceMappingURL=rules.d.ts.map
|
package/dist/rules.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../src/rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAY,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9E,8EAA8E;AAC9E,
|
|
1
|
+
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../src/rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAY,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9E,8EAA8E;AAC9E,UAAU,YAAY;IACpB,+DAA+D;IAC/D,MAAM,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,QAAQ,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/C,oEAAoE;IACpE,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,uEAAuE;IACvE,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,iEAAiE;IACjE,GAAG,EAAE,OAAO,GAAG,aAAa,GAAG,QAAQ,GAAG,YAAY,CAAC;CACxD;AAyBD;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAyDxD;AAED,mFAAmF;AACnF,eAAO,MAAM,cAAc,EAAE,SAAS,MAAM,EASxC,CAAC"}
|
package/dist/rules.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules.js","sourceRoot":"","sources":["../src/rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;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G,EAAE,QAAQ;SACd,CAAC;IACJ,CAAC;IAED,iBAAiB;IACjB,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE,CAAC;AAC3C,CAAC;AAED,mFAAmF;AACnF,MAAM,CAAC,MAAM,cAAc,GAAsB,CAAC,GAAG,EAAE;IACrD,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,IAAI,CAAC;QACH,KAAK,MAAM,CAAC,IAAI,eAAe,CAAC,WAAW,EAAE;YAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAChE,CAAC;IAAC,MAAM,CAAC;QACP,qEAAqE;IACvE,CAAC;IACD,GAAG,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IACtC,OAAO,GAAG,CAAC;AACb,CAAC,CAAC,EAAE,CAAC","sourcesContent":["/**\n * Rule resolution for {@link explain_finding}.\n *\n * Core's detectors are coarse-grained: a single {@link Detector} (e.g. the\n * `crypto-libs` detector) emits many distinct `ruleId`s (`forge-rsa-keygen`,\n * `elliptic-ec`, `node-rsa`, …) that do NOT share the detector's `id` as a\n * prefix. The old MCP `explain_finding` matched `ruleId` against `detector.id`\n * by prefix and therefore returned \"no matching detector\" for every real\n * library finding (P0-5).\n *\n * This module resolves a finding's `ruleId` against core's rule catalog\n * ({@link defaultRegistry.ruleCatalog}) — the single source of truth declared by\n * the detectors themselves. There is no hand-curated table to keep in sync: the\n * ruleId → { detector, algorithm } mapping is derived from the catalog at load\n * time, so a new rule added in core is resolvable here the moment it ships. The\n * one non-detector rule (`dep-vulnerable`, produced by the manifest scanner\n * rather than a {@link Detector}) is supplemented explicitly. Unknown rules fall\n * back to a prefix match against the detector id space, then to unresolved.\n * Pure and synchronous — no I/O — so it is directly unit-testable.\n */\n\nimport { defaultRegistry, detectors } from \"@quantakrypto/core\";\nimport type { AlgorithmFamily, Detector, RuleMeta } from \"@quantakrypto/core\";\n\n/** A resolved rule: the detector it belongs to (if any) and its algorithm. */\
|
|
1
|
+
{"version":3,"file":"rules.js","sourceRoot":"","sources":["../src/rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAiBhE;;;;GAIG;AACH,MAAM,WAAW,GAAmD;IAClE,gBAAgB,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE;CAC3C,CAAC;AAEF,mFAAmF;AACnF,SAAS,WAAW;IAClB,MAAM,GAAG,GAAG,IAAI,GAAG,EAAoB,CAAC;IACxC,MAAM,GAAG,GAAG,CAAC,GAAG,EAAE;QAChB,IAAI,CAAC;YACH,OAAO,eAAe,CAAC,GAAG,EAAE,CAAC;QAC/B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC,CAAC,EAAE,CAAC;IACL,KAAK,MAAM,CAAC,IAAI,GAAG;QAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IACtC,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,WAAW,CAAC,MAAc;IACxC,MAAM,EAAE,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;IAEzB,qEAAqE;IACrE,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE;QAClB,IAAI,CAAC;YACH,OAAO,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACrC,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC,CAAC,EAAE,CAAC;IACL,IAAI,KAAK,EAAE,CAAC;QACV,OAAO;YACL,MAAM,EAAE,EAAE;YACV,QAAQ,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE,EAAE,WAAW,EAAE,KAAK,CAAC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AC;QACT,OAAO;YACL,MAAM,EAAE,EAAE;YACV,QAAQ,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE;YACxD,GAAG,EAAE,QAAQ;SACd,CAAC;IACJ,CAAC;IAED,iBAAiB;IACjB,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE,CAAC;AAC3C,CAAC;AAED,mFAAmF;AACnF,MAAM,CAAC,MAAM,cAAc,GAAsB,CAAC,GAAG,EAAE;IACrD,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,IAAI,CAAC;QACH,KAAK,MAAM,CAAC,IAAI,eAAe,CAAC,WAAW,EAAE;YAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAChE,CAAC;IAAC,MAAM,CAAC;QACP,qEAAqE;IACvE,CAAC;IACD,GAAG,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IACtC,OAAO,GAAG,CAAC;AACb,CAAC,CAAC,EAAE,CAAC","sourcesContent":["/**\n * Rule resolution for {@link explain_finding}.\n *\n * Core's detectors are coarse-grained: a single {@link Detector} (e.g. the\n * `crypto-libs` detector) emits many distinct `ruleId`s (`forge-rsa-keygen`,\n * `elliptic-ec`, `node-rsa`, …) that do NOT share the detector's `id` as a\n * prefix. The old MCP `explain_finding` matched `ruleId` against `detector.id`\n * by prefix and therefore returned \"no matching detector\" for every real\n * library finding (P0-5).\n *\n * This module resolves a finding's `ruleId` against core's rule catalog\n * ({@link defaultRegistry.ruleCatalog}) — the single source of truth declared by\n * the detectors themselves. There is no hand-curated table to keep in sync: the\n * ruleId → { detector, algorithm } mapping is derived from the catalog at load\n * time, so a new rule added in core is resolvable here the moment it ships. The\n * one non-detector rule (`dep-vulnerable`, produced by the manifest scanner\n * rather than a {@link Detector}) is supplemented explicitly. Unknown rules fall\n * back to a prefix match against the detector id space, then to unresolved.\n * Pure and synchronous — no I/O — so it is directly unit-testable.\n */\n\nimport { defaultRegistry, detectors } from \"@quantakrypto/core\";\nimport type { AlgorithmFamily, Detector, RuleMeta } from \"@quantakrypto/core\";\n\n/** A resolved rule: the detector it belongs to (if any) and its algorithm. */\ninterface ResolvedRule {\n /** The rule id that was looked up (echoed for convenience). */\n ruleId: string;\n /** The detector that emits this rule, when one could be resolved. */\n detector?: { id: string; description: string };\n /** The classical algorithm family the rule concerns, when known. */\n algorithm?: AlgorithmFamily;\n /** The catalog metadata for the rule, when it is a known core rule. */\n meta?: RuleMeta;\n /** How the match was made — useful for tests and diagnostics. */\n via: \"index\" | \"detector-id\" | \"prefix\" | \"unresolved\";\n}\n\n/**\n * Rules that are NOT emitted by a {@link Detector} and so are absent from the\n * catalog, but are still canonical core ruleIds. Today that is only the\n * dependency-manifest scanner's `dep-vulnerable` rule.\n */\nconst EXTRA_RULES: Record<string, { algorithm: AlgorithmFamily }> = {\n \"dep-vulnerable\": { algorithm: \"unknown\" },\n};\n\n/** Build an id → Detector lookup over the active detector set (registry first). */\nfunction detectorMap(): Map<string, Detector> {\n const map = new Map<string, Detector>();\n const all = (() => {\n try {\n return defaultRegistry.all();\n } catch {\n return detectors;\n }\n })();\n for (const d of all) map.set(d.id, d);\n return map;\n}\n\n/**\n * Resolve a finding's `ruleId` to its detector and algorithm.\n *\n * Resolution order:\n * 1. The core rule catalog — the authoritative path for every detector rule.\n * 2. The {@link EXTRA_RULES} supplement (non-detector rules, e.g. dependencies).\n * 3. Exact detector id (a rule that IS a detector id, e.g. a future 1:1 rule).\n * 4. Prefix against the detector id space (`node-crypto-*`, `pem-*`, …).\n * 5. Unresolved — caller falls back to the algorithm remediation.\n *\n * Pure: depends only on its argument and the static core detector set.\n */\nexport function resolveRule(ruleId: string): ResolvedRule {\n const id = ruleId.trim();\n\n // 1. Catalog — the authoritative path for known core detector rules.\n const entry = (() => {\n try {\n return defaultRegistry.forRule(id);\n } catch {\n return undefined;\n }\n })();\n if (entry) {\n return {\n ruleId: id,\n detector: { id: entry.detector.id, description: entry.detector.description },\n algorithm: entry.rule.algorithm ?? \"unknown\",\n meta: entry.rule,\n via: \"index\",\n };\n }\n\n // 2. Non-detector supplement (dependency scanner, …). `hasOwn` guards against\n // a rule id like `__proto__`/`constructor` resolving to an Object.prototype member.\n const extra = Object.hasOwn(EXTRA_RULES, id) ? EXTRA_RULES[id] : undefined;\n if (extra) {\n return { ruleId: id, algorithm: extra.algorithm, via: \"index\" };\n }\n\n const detectorsById = detectorMap();\n\n // 3. Exact detector id.\n const exact = detectorsById.get(id);\n if (exact) {\n return {\n ruleId: id,\n detector: { id: exact.id, description: exact.description },\n via: \"detector-id\",\n };\n }\n\n // 4. Longest-prefix detector id (e.g. `node-crypto-foo` → `node-crypto`).\n let best: Detector | undefined;\n for (const det of detectorsById.values()) {\n if (id === det.id || id.startsWith(`${det.id}-`)) {\n if (!best || det.id.length > best.id.length) best = det;\n }\n }\n if (best) {\n return {\n ruleId: id,\n detector: { id: best.id, description: best.description },\n via: \"prefix\",\n };\n }\n\n // 5. Unresolved.\n return { ruleId: id, via: \"unresolved\" };\n}\n\n/** Exposed for tests: the set of canonical rule ids resolvable via the catalog. */\nexport const KNOWN_RULE_IDS: readonly string[] = (() => {\n const ids: string[] = [];\n try {\n for (const r of defaultRegistry.ruleCatalog()) ids.push(r.id);\n } catch {\n // ignore — an empty/broken catalog just yields the supplement below.\n }\n ids.push(...Object.keys(EXTRA_RULES));\n return ids;\n})();\n"]}
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAaH,OAAO,KAAK,EAEV,eAAe,EACf,WAAW,EACX,cAAc,EACd,cAAc,EAEf,MAAM,eAAe,CAAC;AAGvB,kEAAkE;AAClE,MAAM,WAAW,UAAU;IACzB,IAAI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AK,CAAqC;IAC3D,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;IAClC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAS;IACvC,mEAAmE;IACnE,OAAO,CAAC,WAAW,CAAS;gBAEhB,OAAO,EAAE,gBAAgB;IAKrC,2EAA2E;IAC3E,YAAY,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI;IAQxC,uEAAuE;IACvE,SAAS,IAAI,cAAc,EAAE;IAM7B,wDAAwD;IACxD,IAAI,aAAa,IAAI,OAAO,CAE3B;IAED;;;;;;;;;OASG;IACG,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IA8BtF,gFAAgF;YAClE,QAAQ;IAgCtB,kEAAkE;IAClE,OAAO,CAAC,eAAe;IAcvB,yEAAyE;IACzE,OAAO,CAAC,YAAY;IAiBpB,qCAAqC;IACrC,OAAO,CAAC,YAAY;IAgBpB,2DAA2D;YAC7C,WAAW;CAuB1B"}
|
package/dist/server.js
CHANGED
|
@@ -104,6 +104,12 @@ export class McpServer {
|
|
|
104
104
|
return this.onToolsCall(req.params, context);
|
|
105
105
|
case "resources/list":
|
|
106
106
|
return { resources: RESOURCES };
|
|
107
|
+
case "resources/templates/list":
|
|
108
|
+
// We advertise the `resources` capability, so spec-compliant clients
|
|
109
|
+
// (and MCP directory health checks) call this during discovery. We
|
|
110
|
+
// expose only fixed-URI resources, no URI templates → empty list, not a
|
|
111
|
+
// -32601 that trips those clients.
|
|
112
|
+
return { resourceTemplates: [] };
|
|
107
113
|
case "resources/read":
|
|
108
114
|
return this.onResourcesRead(req.params);
|
|
109
115
|
case "prompts/list":
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,OAAO,M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M,KAAK,CAAC,EAAE,CAAC;YAClD,MAAM,IAAI,QAAQ,CAAC,SAAS,CAAC,aAAa,EAAE,qCAAqC,CAAC,CAAC;QACrF,CAAC;QACD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAClC,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,QAAQ,CAAC,SAAS,CAAC,aAAa,EAAE,iBAAiB,IAAI,EAAE,CAAC,CAAC;QACvE,CAAC;QACD,IAAI,IAAI,KAAK,SAAS,IAAI,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;YAC7F,MAAM,IAAI,QAAQ,CAAC,SAAS,CAAC,aAAa,EAAE,oCAAoC,CAAC,CAAC;QACpF,CAAC;QACD,MAAM,QAAQ,GAAG,CAAC,IAAI,IAAI,EAAE,CAA4B,CAAC;QACzD,4EAA4E;QAC5E,6EAA6E;QAC7E,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC;CACF","sourcesContent":["/**\n * Transport-agnostic MCP server core.\n *\n * {@link McpServer} owns a tool registry and a single pure entry point,\n * {@link McpServer.handle}, that turns one JSON-RPC message into one JSON-RPC\n * response (or `null` for notifications, which get no reply). It performs no\n * I/O whatsoever — the stdio and http transports feed it parsed messages and\n * serialize whatever it returns. This makes the whole protocol surface\n * unit-testable by calling `handle` directly.\n *\n * The one concession to I/O is that unexpected (non-{@link RpcError}) throws are\n * logged to stderr with full detail and replaced with a generic message in the\n * response, so server internals (paths, ENOENT targets) never reach the remote\n * caller. The wire response remains a pure function of the inputs.\n */\n\nimport process from \"node:process\";\n\nimport {\n ErrorCode,\n MCP_PROTOCOL_VERSION,\n RpcError,\n isJsonRpcRequestLike,\n isNotification,\n makeFailure,\n makeSuccess,\n} from \"./protocol.js\";\nimport type {\n JsonRpcRequest,\n JsonRpcResponse,\n ToolContext,\n ToolDefinition,\n ToolDescriptor,\n ToolResult,\n} from \"./protocol.js\";\nimport { RESOURCES, PROMPTS, readResource, getPrompt } from \"./resources.js\";\n\n/** Identifying info advertised to clients during `initialize`. */\nexport interface ServerInfo {\n name: string;\n version: string;\n}\n\nexport interface McpServerOptions {\n /** Server identity returned in the `initialize` handshake. */\n info: ServerInfo;\n /** Optional human-readable instructions surfaced to the client. */\n instructions?: string;\n}\n\n/**\n * A minimal, spec-faithful MCP server. Register tools with {@link registerTool}\n * and drive it one message at a time with {@link handle}.\n */\nexport class McpServer {\n private readonly tools = new Map<string, ToolDefinition>();\n private readonly info: ServerInfo;\n private readonly instructions?: string;\n /** Set once `initialize` has been received; informational only. */\n private initialized = false;\n\n constructor(options: McpServerOptions) {\n this.info = options.info;\n this.instructions = options.instructions;\n }\n\n /** Register a tool. Throws if a tool with the same name already exists. */\n registerTool(tool: ToolDefinition): this {\n if (this.tools.has(tool.name)) {\n throw new Error(`duplicate tool registration: ${tool.name}`);\n }\n this.tools.set(tool.name, tool);\n return this;\n }\n\n /** The public descriptors of all registered tools (sorted by name). */\n listTools(): ToolDescriptor[] {\n return [...this.tools.values()]\n .map(({ name, description, inputSchema }) => ({ name, description, inputSchema }))\n .sort((a, b) => a.name.localeCompare(b.name));\n }\n\n /** Whether the `initialize` handshake has completed. */\n get isInitialized(): boolean {\n return this.initialized;\n }\n\n /**\n * Process a single JSON-RPC message.\n *\n * @param message An already-parsed JSON value (the transport handles framing\n * and `JSON.parse`). May be malformed; this method validates it.\n * @param context Optional per-call context (e.g. an `AbortSignal` for the\n * transport's request deadline) forwarded to the invoked tool handler.\n * @returns The response to send back, or `null` when no reply is due\n * (notifications, or an unparseable notification-shaped message).\n */\n async handle(message: unknown, context?: ToolContext): Promise<JsonRpcResponse | null> {\n if (!isJsonRpcRequestLike(message)) {\n // Not a valid request object. We can't know its id, so reply with null id.\n return makeFailure(null, ErrorCode.InvalidRequest, \"invalid JSON-RPC request\");\n }\n\n const req = message as JsonRpcRequest;\n const notification = isNotification(req);\n const id = notification ? null : (req.id ?? null);\n\n try {\n const result = await this.dispatch(req, context);\n // Notifications never receive a response, even on success.\n if (notification) return null;\n return makeSuccess(id, result);\n } catch (err) {\n if (notification) return null; // swallow errors from notifications\n if (err instanceof RpcError) {\n // RpcError messages are author-controlled validation strings, safe to return.\n return makeFailure(id, err.code, err.message, err.data);\n }\n // An unexpected throw may carry a server-side detail (a filesystem path, an\n // ENOENT for /etc/shadow, …). Log the detail locally; return a generic\n // message so the remote caller never learns server internals.\n const detail = err instanceof Error ? (err.stack ?? err.message) : String(err);\n process.stderr.write(`quantakrypto MCP: internal error handling request: ${detail}\\n`);\n return makeFailure(id, ErrorCode.InternalError, \"internal error\");\n }\n }\n\n /** Route a request to the right handler. Throws {@link RpcError} on failure. */\n private async dispatch(req: JsonRpcRequest, context?: ToolContext): Promise<unknown> {\n switch (req.method) {\n case \"initialize\":\n return this.onInitialize();\n case \"notifications/initialized\":\n this.initialized = true;\n return {}; // notification → result ignored by handle()\n case \"ping\":\n return {};\n case \"tools/list\":\n return { tools: this.listTools() };\n case \"tools/call\":\n return this.onToolsCall(req.params, context);\n case \"resources/list\":\n return { resources: RESOURCES };\n case \"resources/read\":\n return this.onResourcesRead(req.params);\n case \"prompts/list\":\n return { prompts: PROMPTS };\n case \"prompts/get\":\n return this.onPromptsGet(req.params);\n default:\n throw new RpcError(ErrorCode.MethodNotFound, `method not found: ${req.method}`);\n }\n }\n\n /** `resources/read`: return the body for a known resource URI. */\n private onResourcesRead(params: unknown): unknown {\n if (typeof params !== \"object\" || params === null || Array.isArray(params)) {\n throw new RpcError(ErrorCode.InvalidParams, \"resources/read requires an object params\");\n }\n const uri = (params as { uri?: unknown }).uri;\n if (typeof uri !== \"string\" || uri.length === 0) {\n throw new RpcError(ErrorCode.InvalidParams, \"resources/read requires a 'uri' string\");\n }\n const contents = readResource(uri);\n // MCP spec: unknown resource → -32002 (Resource not found), uri in data.\n if (!contents) throw new RpcError(ErrorCode.ResourceNotFound, \"Resource not found\", { uri });\n return { contents: [contents] };\n }\n\n /** `prompts/get`: materialize a named prompt with optional arguments. */\n private onPromptsGet(params: unknown): unknown {\n if (typeof params !== \"object\" || params === null || Array.isArray(params)) {\n throw new RpcError(ErrorCode.InvalidParams, \"prompts/get requires an object params\");\n }\n const { name, arguments: args } = params as { name?: unknown; arguments?: unknown };\n if (typeof name !== \"string\" || name.length === 0) {\n throw new RpcError(ErrorCode.InvalidParams, \"prompts/get requires a 'name' string\");\n }\n const promptArgs =\n args && typeof args === \"object\" && !Array.isArray(args)\n ? (args as Record<string, unknown>)\n : {};\n const prompt = getPrompt(name, promptArgs);\n if (!prompt) throw new RpcError(ErrorCode.InvalidParams, `unknown prompt: ${name}`);\n return prompt;\n }\n\n /** Build the `initialize` result. */\n private onInitialize(): unknown {\n this.initialized = true;\n const result: Record<string, unknown> = {\n protocolVersion: MCP_PROTOCOL_VERSION,\n capabilities: {\n // Everything we expose is static, so listChanged is false throughout.\n tools: { listChanged: false },\n resources: { listChanged: false },\n prompts: { listChanged: false },\n },\n serverInfo: { name: this.info.name, version: this.info.version },\n };\n if (this.instructions) result.instructions = this.instructions;\n return result;\n }\n\n /** Validate params and execute a tool for `tools/call`. */\n private async onToolsCall(params: unknown, context?: ToolContext): Promise<ToolResult> {\n if (typeof params !== \"object\" || params === null || Array.isArray(params)) {\n throw new RpcError(ErrorCode.InvalidParams, \"tools/call requires an object params\");\n }\n const { name, arguments: args } = params as {\n name?: unknown;\n arguments?: unknown;\n };\n if (typeof name !== \"string\" || name.length === 0) {\n throw new RpcError(ErrorCode.InvalidParams, \"tools/call requires a 'name' string\");\n }\n const tool = this.tools.get(name);\n if (!tool) {\n throw new RpcError(ErrorCode.InvalidParams, `unknown tool: ${name}`);\n }\n if (args !== undefined && (typeof args !== \"object\" || args === null || Array.isArray(args))) {\n throw new RpcError(ErrorCode.InvalidParams, \"tool 'arguments' must be an object\");\n }\n const toolArgs = (args ?? {}) as Record<string, unknown>;\n // Tool-level failures are reported as isError results, not protocol errors,\n // so the model can read and react to them. Only unexpected throws bubble up.\n return tool.handler(toolArgs, context);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,EACL,SAAS,EACT,oBAAoB,EACpB,QAAQ,EACR,oBAAoB,EACpB,cAAc,EACd,WAAW,EACX,WAAW,GACZ,MAAM,eAAe,CAAC;AASvB,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAe7E;;;GAGG;AACH,MAAM,OAAO,SAAS;IACH,KAAK,GAAG,IAAI,GAAG,EAA0B,CAAC;IAC1C,IAAI,CAAa;IACjB,YAAY,CAAU;IACvC,mEAAmE;IAC3D,WAAW,GAAG,KAAK,CAAC;IAE5B,YAAY,OAAyB;QACnC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IAC3C,CAAC;IAED,2EAA2E;IAC3E,YAAY,CAAC,IAAoB;QAC/B,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,gCAAgC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QAC/D,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,uEAAuE;IACvE,SAAS;QACP,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;aAC5B,GAAG,CAAC,CAAC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AA2D;IACnD,KAAK,CAAC,WAAW,CAAC,MAAe,EAAE,OAAqB;QAC9D,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAC3E,MAAM,IAAI,QAAQ,CAAC,SAAS,CAAC,aAAa,EAAE,sCAAsC,CAAC,CAAC;QACtF,CAAC;QACD,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,MAGjC,CAAC;QACF,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAClD,MAAM,IAAI,QAAQ,CAAC,SAAS,CAAC,aAAa,EAAE,qCAAqC,CAAC,CAAC;QACrF,CAAC;QACD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAClC,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,QAAQ,CAAC,SAAS,CAAC,aAAa,EAAE,iBAAiB,IAAI,EAAE,CAAC,CAAC;QACvE,CAAC;QACD,IAAI,IAAI,KAAK,SAAS,IAAI,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;YAC7F,MAAM,IAAI,QAAQ,CAAC,SAAS,CAAC,aAAa,EAAE,oCAAoC,CAAC,CAAC;QACpF,CAAC;QACD,MAAM,QAAQ,GAAG,CAAC,IAAI,IAAI,EAAE,CAA4B,CAAC;QACzD,4EAA4E;QAC5E,6EAA6E;QAC7E,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC;CACF","sourcesContent":["/**\n * Transport-agnostic MCP server core.\n *\n * {@link McpServer} owns a tool registry and a single pure entry point,\n * {@link McpServer.handle}, that turns one JSON-RPC message into one JSON-RPC\n * response (or `null` for notifications, which get no reply). It performs no\n * I/O whatsoever — the stdio and http transports feed it parsed messages and\n * serialize whatever it returns. This makes the whole protocol surface\n * unit-testable by calling `handle` directly.\n *\n * The one concession to I/O is that unexpected (non-{@link RpcError}) throws are\n * logged to stderr with full detail and replaced with a generic message in the\n * response, so server internals (paths, ENOENT targets) never reach the remote\n * caller. The wire response remains a pure function of the inputs.\n */\n\nimport process from \"node:process\";\n\nimport {\n ErrorCode,\n MCP_PROTOCOL_VERSION,\n RpcError,\n isJsonRpcRequestLike,\n isNotification,\n makeFailure,\n makeSuccess,\n} from \"./protocol.js\";\nimport type {\n JsonRpcRequest,\n JsonRpcResponse,\n ToolContext,\n ToolDefinition,\n ToolDescriptor,\n ToolResult,\n} from \"./protocol.js\";\nimport { RESOURCES, PROMPTS, readResource, getPrompt } from \"./resources.js\";\n\n/** Identifying info advertised to clients during `initialize`. */\nexport interface ServerInfo {\n name: string;\n version: string;\n}\n\nexport interface McpServerOptions {\n /** Server identity returned in the `initialize` handshake. */\n info: ServerInfo;\n /** Optional human-readable instructions surfaced to the client. */\n instructions?: string;\n}\n\n/**\n * A minimal, spec-faithful MCP server. Register tools with {@link registerTool}\n * and drive it one message at a time with {@link handle}.\n */\nexport class McpServer {\n private readonly tools = new Map<string, ToolDefinition>();\n private readonly info: ServerInfo;\n private readonly instructions?: string;\n /** Set once `initialize` has been received; informational only. */\n private initialized = false;\n\n constructor(options: McpServerOptions) {\n this.info = options.info;\n this.instructions = options.instructions;\n }\n\n /** Register a tool. Throws if a tool with the same name already exists. */\n registerTool(tool: ToolDefinition): this {\n if (this.tools.has(tool.name)) {\n throw new Error(`duplicate tool registration: ${tool.name}`);\n }\n this.tools.set(tool.name, tool);\n return this;\n }\n\n /** The public descriptors of all registered tools (sorted by name). */\n listTools(): ToolDescriptor[] {\n return [...this.tools.values()]\n .map(({ name, description, inputSchema }) => ({ name, description, inputSchema }))\n .sort((a, b) => a.name.localeCompare(b.name));\n }\n\n /** Whether the `initialize` handshake has completed. */\n get isInitialized(): boolean {\n return this.initialized;\n }\n\n /**\n * Process a single JSON-RPC message.\n *\n * @param message An already-parsed JSON value (the transport handles framing\n * and `JSON.parse`). May be malformed; this method validates it.\n * @param context Optional per-call context (e.g. an `AbortSignal` for the\n * transport's request deadline) forwarded to the invoked tool handler.\n * @returns The response to send back, or `null` when no reply is due\n * (notifications, or an unparseable notification-shaped message).\n */\n async handle(message: unknown, context?: ToolContext): Promise<JsonRpcResponse | null> {\n if (!isJsonRpcRequestLike(message)) {\n // Not a valid request object. We can't know its id, so reply with null id.\n return makeFailure(null, ErrorCode.InvalidRequest, \"invalid JSON-RPC request\");\n }\n\n const req = message as JsonRpcRequest;\n const notification = isNotification(req);\n const id = notification ? null : (req.id ?? null);\n\n try {\n const result = await this.dispatch(req, context);\n // Notifications never receive a response, even on success.\n if (notification) return null;\n return makeSuccess(id, result);\n } catch (err) {\n if (notification) return null; // swallow errors from notifications\n if (err instanceof RpcError) {\n // RpcError messages are author-controlled validation strings, safe to return.\n return makeFailure(id, err.code, err.message, err.data);\n }\n // An unexpected throw may carry a server-side detail (a filesystem path, an\n // ENOENT for /etc/shadow, …). Log the detail locally; return a generic\n // message so the remote caller never learns server internals.\n const detail = err instanceof Error ? (err.stack ?? err.message) : String(err);\n process.stderr.write(`quantakrypto MCP: internal error handling request: ${detail}\\n`);\n return makeFailure(id, ErrorCode.InternalError, \"internal error\");\n }\n }\n\n /** Route a request to the right handler. Throws {@link RpcError} on failure. */\n private async dispatch(req: JsonRpcRequest, context?: ToolContext): Promise<unknown> {\n switch (req.method) {\n case \"initialize\":\n return this.onInitialize();\n case \"notifications/initialized\":\n this.initialized = true;\n return {}; // notification → result ignored by handle()\n case \"ping\":\n return {};\n case \"tools/list\":\n return { tools: this.listTools() };\n case \"tools/call\":\n return this.onToolsCall(req.params, context);\n case \"resources/list\":\n return { resources: RESOURCES };\n case \"resources/templates/list\":\n // We advertise the `resources` capability, so spec-compliant clients\n // (and MCP directory health checks) call this during discovery. We\n // expose only fixed-URI resources, no URI templates → empty list, not a\n // -32601 that trips those clients.\n return { resourceTemplates: [] };\n case \"resources/read\":\n return this.onResourcesRead(req.params);\n case \"prompts/list\":\n return { prompts: PROMPTS };\n case \"prompts/get\":\n return this.onPromptsGet(req.params);\n default:\n throw new RpcError(ErrorCode.MethodNotFound, `method not found: ${req.method}`);\n }\n }\n\n /** `resources/read`: return the body for a known resource URI. */\n private onResourcesRead(params: unknown): unknown {\n if (typeof params !== \"object\" || params === null || Array.isArray(params)) {\n throw new RpcError(ErrorCode.InvalidParams, \"resources/read requires an object params\");\n }\n const uri = (params as { uri?: unknown }).uri;\n if (typeof uri !== \"string\" || uri.length === 0) {\n throw new RpcError(ErrorCode.InvalidParams, \"resources/read requires a 'uri' string\");\n }\n const contents = readResource(uri);\n // MCP spec: unknown resource → -32002 (Resource not found), uri in data.\n if (!contents) throw new RpcError(ErrorCode.ResourceNotFound, \"Resource not found\", { uri });\n return { contents: [contents] };\n }\n\n /** `prompts/get`: materialize a named prompt with optional arguments. */\n private onPromptsGet(params: unknown): unknown {\n if (typeof params !== \"object\" || params === null || Array.isArray(params)) {\n throw new RpcError(ErrorCode.InvalidParams, \"prompts/get requires an object params\");\n }\n const { name, arguments: args } = params as { name?: unknown; arguments?: unknown };\n if (typeof name !== \"string\" || name.length === 0) {\n throw new RpcError(ErrorCode.InvalidParams, \"prompts/get requires a 'name' string\");\n }\n const promptArgs =\n args && typeof args === \"object\" && !Array.isArray(args)\n ? (args as Record<string, unknown>)\n : {};\n const prompt = getPrompt(name, promptArgs);\n if (!prompt) throw new RpcError(ErrorCode.InvalidParams, `unknown prompt: ${name}`);\n return prompt;\n }\n\n /** Build the `initialize` result. */\n private onInitialize(): unknown {\n this.initialized = true;\n const result: Record<string, unknown> = {\n protocolVersion: MCP_PROTOCOL_VERSION,\n capabilities: {\n // Everything we expose is static, so listChanged is false throughout.\n tools: { listChanged: false },\n resources: { listChanged: false },\n prompts: { listChanged: false },\n },\n serverInfo: { name: this.info.name, version: this.info.version },\n };\n if (this.instructions) result.instructions = this.instructions;\n return result;\n }\n\n /** Validate params and execute a tool for `tools/call`. */\n private async onToolsCall(params: unknown, context?: ToolContext): Promise<ToolResult> {\n if (typeof params !== \"object\" || params === null || Array.isArray(params)) {\n throw new RpcError(ErrorCode.InvalidParams, \"tools/call requires an object params\");\n }\n const { name, arguments: args } = params as {\n name?: unknown;\n arguments?: unknown;\n };\n if (typeof name !== \"string\" || name.length === 0) {\n throw new RpcError(ErrorCode.InvalidParams, \"tools/call requires a 'name' string\");\n }\n const tool = this.tools.get(name);\n if (!tool) {\n throw new RpcError(ErrorCode.InvalidParams, `unknown tool: ${name}`);\n }\n if (args !== undefined && (typeof args !== \"object\" || args === null || Array.isArray(args))) {\n throw new RpcError(ErrorCode.InvalidParams, \"tool 'arguments' must be an object\");\n }\n const toolArgs = (args ?? {}) as Record<string, unknown>;\n // Tool-level failures are reported as isError results, not protocol errors,\n // so the model can read and react to them. Only unexpected throws bubble up.\n return tool.handler(toolArgs, context);\n }\n}\n"]}
|
package/dist/stdio.d.ts
CHANGED
|
@@ -12,12 +12,9 @@
|
|
|
12
12
|
* Run as the `quantakrypto-mcp` bin, or `node dist/stdio.js`.
|
|
13
13
|
*/
|
|
14
14
|
import type { McpServer } from "./server.js";
|
|
15
|
-
/** Serialize a value as one newline-terminated JSON line to stdout. */
|
|
16
|
-
declare function writeLine(value: unknown): void;
|
|
17
15
|
/**
|
|
18
16
|
* Attach a line-delimited JSON-RPC loop to the given streams. Exposed (rather
|
|
19
17
|
* than only run on import) so it can be reused or tested with custom streams.
|
|
20
18
|
*/
|
|
21
19
|
export declare function runStdioServer(server: McpServer, input?: NodeJS.ReadableStream, output?: NodeJS.WritableStream): void;
|
|
22
|
-
export { writeLine };
|
|
23
20
|
//# sourceMappingURL=stdio.d.ts.map
|
package/dist/stdio.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stdio.d.ts","sourceRoot":"","sources":["../src/stdio.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;GAWG;AASH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C
|
|
1
|
+
{"version":3,"file":"stdio.d.ts","sourceRoot":"","sources":["../src/stdio.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;GAWG;AASH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,SAAS,EACjB,KAAK,GAAE,MAAM,CAAC,cAA8B,EAC5C,MAAM,GAAE,MAAM,CAAC,cAA+B,GAC7C,IAAI,CAkCN"}
|
package/dist/stdio.js
CHANGED
|
@@ -17,10 +17,6 @@ import { realpathSync } from "node:fs";
|
|
|
17
17
|
import { fileURLToPath } from "node:url";
|
|
18
18
|
import { createQuantakryptoServer } from "./index.js";
|
|
19
19
|
import { ErrorCode, makeFailure } from "./protocol.js";
|
|
20
|
-
/** Serialize a value as one newline-terminated JSON line to stdout. */
|
|
21
|
-
function writeLine(value) {
|
|
22
|
-
process.stdout.write(JSON.stringify(value) + "\n");
|
|
23
|
-
}
|
|
24
20
|
/**
|
|
25
21
|
* Attach a line-delimited JSON-RPC loop to the given streams. Exposed (rather
|
|
26
22
|
* than only run on import) so it can be reused or tested with custom streams.
|
|
@@ -85,5 +81,4 @@ function isMainModule() {
|
|
|
85
81
|
if (isMainModule()) {
|
|
86
82
|
main();
|
|
87
83
|
}
|
|
88
|
-
export { writeLine };
|
|
89
84
|
//# sourceMappingURL=stdio.js.map
|
package/dist/stdio.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stdio.js","sourceRoot":"","sources":["../src/stdio.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,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AAO,YAAY,CAAC,KAAK,CAAC,KAAK,YAAY,CAAC,QAAQ,CAAC,CAAC;IACxD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,KAAK,QAAQ,CAAC;IAC5B,CAAC;AACH,CAAC;AAED,sEAAsE;AACtE,IAAI,YAAY,EAAE,EAAE,CAAC;IACnB,IAAI,EAAE,CAAC;AACT,CAAC","sourcesContent":["#!/usr/bin/env node\n/**\n * quantakrypto-mcp — stdio transport.\n *\n * MCP's stdio transport is newline-delimited JSON: exactly one JSON-RPC 2.0\n * message per line on stdin, one per line on stdout. (This is NOT HTTP-style\n * Content-Length framing.) This module reads stdin line-by-line with\n * {@link node:readline}, hands each parsed message to {@link McpServer.handle},\n * and writes any response back as a single line on stdout. Diagnostics go to\n * stderr so they never corrupt the protocol stream.\n *\n * Run as the `quantakrypto-mcp` bin, or `node dist/stdio.js`.\n */\n\nimport { createInterface } from \"node:readline\";\nimport process from \"node:process\";\nimport { realpathSync } from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { createQuantakryptoServer } from \"./index.js\";\nimport { ErrorCode, makeFailure } from \"./protocol.js\";\nimport type { McpServer } from \"./server.js\";\n\n/**\n * Attach a line-delimited JSON-RPC loop to the given streams. Exposed (rather\n * than only run on import) so it can be reused or tested with custom streams.\n */\nexport function runStdioServer(\n server: McpServer,\n input: NodeJS.ReadableStream = process.stdin,\n output: NodeJS.WritableStream = process.stdout,\n): void {\n const rl = createInterface({ input, crlfDelay: Infinity });\n\n rl.on(\"line\", (raw: string) => {\n const line = raw.trim();\n if (line.length === 0) return; // tolerate blank lines / keepalives\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(line);\n } catch {\n // Parse error: we have no id, so reply with a null-id error per JSON-RPC.\n output.write(JSON.stringify(makeFailure(null, ErrorCode.ParseError, \"parse error\")) + \"\\n\");\n return;\n }\n\n // Process asynchronously; responses are written as they resolve. Ordering\n // within a single client is preserved because handlers here are fast and\n // the event loop drains line events in order.\n void server\n .handle(parsed)\n .then((response) => {\n if (response !== null) output.write(JSON.stringify(response) + \"\\n\");\n })\n .catch((err: unknown) => {\n // Defensive: handle() already catches, but never let a rejection escape.\n const messageText = err instanceof Error ? err.message : String(err);\n process.stderr.write(`quantakrypto-mcp internal error: ${messageText}\\n`);\n });\n });\n\n rl.on(\"close\", () => {\n process.exitCode = 0;\n });\n}\n\n/** Entry point when executed directly (the bin / `node dist/stdio.js`). */\nfunction main(): void {\n const server = createQuantakryptoServer();\n process.stderr.write(`quantakrypto MCP server (stdio) ready\\n`);\n runStdioServer(server);\n}\n\n/**\n * True when this module is the program's entry point. Resolves symlinks so the\n * check also holds when launched via the `quantakrypto-mcp` bin shim in node_modules/.bin.\n */\nfunction isMainModule(): boolean {\n const argv1 = process.argv[1];\n if (!argv1) return false;\n const thisPath = fileURLToPath(import.meta.url);\n try {\n return realpathSync(argv1) === realpathSync(thisPath);\n } catch {\n return argv1 === thisPath;\n }\n}\n\n// Only auto-run when invoked as a script, not when imported by tests.\nif (isMainModule()) {\n main();\n}\n"]}
|
package/dist/tools.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* crash.
|
|
9
9
|
*/
|
|
10
10
|
import type { AlgorithmFamily, ScanOptions, ScanResult } from "@quantakrypto/core";
|
|
11
|
-
import type {
|
|
11
|
+
import type { ToolContext, ToolDefinition, ToolResult } from "./protocol.js";
|
|
12
12
|
/**
|
|
13
13
|
* Map a core failure to a caller-safe message. Cancellation and budget overflows
|
|
14
14
|
* are intentional, expected outcomes — their messages are author-controlled and
|
|
@@ -47,10 +47,17 @@ declare function staticHybridAdvice(algorithm: AlgorithmFamily): string[];
|
|
|
47
47
|
* trusts the local user, always exposes them.
|
|
48
48
|
*/
|
|
49
49
|
export declare const FS_TOOL_NAMES: readonly string[];
|
|
50
|
+
/**
|
|
51
|
+
* Tools that open network connections. On the HTTP transport they are OFF by
|
|
52
|
+
* default — a hosted MCP should not probe arbitrary hosts — but a trusted operator
|
|
53
|
+
* can opt in with QUANTAKRYPTO_MCP_ALLOW_NETWORK=1 (mirroring the FS-tools opt-in).
|
|
54
|
+
* Always available on the local stdio transport, which trusts the local user.
|
|
55
|
+
*/
|
|
56
|
+
export declare const NETWORK_TOOL_NAMES: readonly string[];
|
|
50
57
|
/** All quantakrypto MCP tools, in a stable order. */
|
|
51
58
|
export declare const quantakryptoTools: ToolDefinition[];
|
|
52
59
|
/** The core version these tools are built against (re-exported for diagnostics). */
|
|
53
|
-
export declare const CORE_VERSION = "0.
|
|
60
|
+
export declare const CORE_VERSION = "0.5.0";
|
|
54
61
|
/** Exposed for tests and advanced callers. */
|
|
55
62
|
export declare const __test: {
|
|
56
63
|
normalizeAlgorithm: typeof normalizeAlgorithm;
|
|
@@ -64,7 +71,5 @@ export declare const __test: {
|
|
|
64
71
|
after: string;
|
|
65
72
|
}>>;
|
|
66
73
|
};
|
|
67
|
-
/** Keep the schema type imported and referenced (documentation aid). */
|
|
68
|
-
export type ToolInputSchema = JsonSchema;
|
|
69
74
|
export {};
|
|
70
75
|
//# sourceMappingURL=tools.d.ts.map
|
package/dist/tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAyBH,OAAO,KAAK,EACV,eAAe,EAIf,WAAW,EACX,UAAU,EAGX,MAAM,oBAAoB,CAAC;AAG5B,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAyBH,OAAO,KAAK,EACV,eAAe,EAIf,WAAW,EACX,UAAU,EAGX,MAAM,oBAAoB,CAAC;AAG5B,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAkB7E;;;;;;GAMG;AACH,iBAAS,aAAa,CAAC,KAAK,EAA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