@sebastienrousseau/crypto-mcp 0.0.8 → 0.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +75 -22
- package/dist/protocol.d.ts +18 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +63 -0
- package/dist/server.d.ts +1 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +16 -14
- package/dist/tools/annotations.d.ts +6 -0
- package/dist/tools/annotations.d.ts.map +1 -0
- package/dist/tools/annotations.js +68 -0
- package/dist/tools/definitions.d.ts +3 -0
- package/dist/tools/definitions.d.ts.map +1 -1
- package/dist/tools/definitions.js +220 -128
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +33 -6
- package/dist/tools/kem.d.ts +8 -0
- package/dist/tools/kem.d.ts.map +1 -0
- package/dist/tools/kem.js +156 -0
- package/dist/tools/keyimport.d.ts +5 -0
- package/dist/tools/keyimport.d.ts.map +1 -0
- package/dist/tools/keyimport.js +207 -0
- package/dist/tools/keys.d.ts +9 -0
- package/dist/tools/keys.d.ts.map +1 -1
- package/dist/tools/keys.js +92 -42
- package/dist/tools/keystore.d.ts +25 -0
- package/dist/tools/keystore.d.ts.map +1 -0
- package/dist/tools/keystore.js +84 -0
- package/dist/tools/kms.d.ts +1 -0
- package/dist/tools/kms.d.ts.map +1 -1
- package/dist/tools/kms.js +28 -18
- package/dist/tools/result.d.ts +0 -1
- package/dist/tools/result.d.ts.map +1 -1
- package/dist/tools/result.js +0 -8
- package/dist/tools/schema-helpers.d.ts +12 -0
- package/dist/tools/schema-helpers.d.ts.map +1 -0
- package/dist/tools/schema-helpers.js +38 -0
- package/dist/tools/signing.d.ts.map +1 -1
- package/dist/tools/signing.js +118 -32
- package/dist/tools/stream-definitions.d.ts +3 -0
- package/dist/tools/stream-definitions.d.ts.map +1 -0
- package/dist/tools/stream-definitions.js +122 -0
- package/dist/tools/stream.d.ts +6 -0
- package/dist/tools/stream.d.ts.map +1 -0
- package/dist/tools/stream.js +97 -0
- package/dist/tools/symmetric.d.ts +1 -0
- package/dist/tools/symmetric.d.ts.map +1 -1
- package/dist/tools/symmetric.js +22 -8
- package/dist/tools/validate.d.ts +3 -0
- package/dist/tools/validate.d.ts.map +1 -0
- package/dist/tools/validate.js +76 -0
- package/dist/types.d.ts +19 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +19 -17
|
@@ -1,9 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TOOLS = exports.HASH_ALGORITHMS = exports.EC_CURVES = exports.RSA_MODULUS_LENGTHS = exports.KEY_TYPES = void 0;
|
|
4
|
-
|
|
3
|
+
exports.TOOLS = exports.HASH_ALGORITHMS = exports.MAX_KEY_FILE_BYTES = exports.KEY_DIR_ENV = exports.EC_CURVES = exports.RSA_MODULUS_LENGTHS = exports.ML_KEM_LEVELS = exports.KEY_TYPES = void 0;
|
|
4
|
+
const keystore_1 = require("./keystore");
|
|
5
|
+
const annotations_1 = require("./annotations");
|
|
6
|
+
const stream_definitions_1 = require("./stream-definitions");
|
|
7
|
+
const schema_helpers_1 = require("./schema-helpers");
|
|
8
|
+
exports.KEY_TYPES = [
|
|
9
|
+
"rsa",
|
|
10
|
+
"ecc",
|
|
11
|
+
"ed25519",
|
|
12
|
+
"x25519",
|
|
13
|
+
"ml-kem-512",
|
|
14
|
+
"ml-kem-768",
|
|
15
|
+
"ml-kem-1024",
|
|
16
|
+
"ml-dsa-44",
|
|
17
|
+
"ml-dsa-65",
|
|
18
|
+
"ml-dsa-87",
|
|
19
|
+
"symmetric-256",
|
|
20
|
+
"hmac-sha256",
|
|
21
|
+
];
|
|
22
|
+
exports.ML_KEM_LEVELS = [512, 768, 1024];
|
|
5
23
|
exports.RSA_MODULUS_LENGTHS = [2048, 3072, 4096];
|
|
6
24
|
exports.EC_CURVES = ["prime256v1", "secp384r1", "secp256k1"];
|
|
25
|
+
exports.KEY_DIR_ENV = "CRYPTO_MCP_KEY_DIR";
|
|
26
|
+
exports.MAX_KEY_FILE_BYTES = 65_536;
|
|
27
|
+
const MAX_KEY_PATH_LENGTH = 512;
|
|
28
|
+
const RAW_KEY_KINDS = ["symmetric-256", "hmac-sha256"];
|
|
7
29
|
exports.HASH_ALGORITHMS = [
|
|
8
30
|
"sha256",
|
|
9
31
|
"sha384",
|
|
@@ -11,133 +33,230 @@ exports.HASH_ALGORITHMS = [
|
|
|
11
33
|
"sha3-256",
|
|
12
34
|
"blake2b512",
|
|
13
35
|
];
|
|
14
|
-
|
|
36
|
+
const AEAD_ALGORITHMS = ["aes-256-gcm", "chacha20-poly1305"];
|
|
37
|
+
const KMS_PROVIDERS = ["aws", "gcp", "azure", "vault", "local"];
|
|
38
|
+
const KMS_PROVIDER = (0, schema_helpers_1.oneOf)("KMS provider ('aws', 'gcp', 'azure', 'vault', or 'local'). Only 'local' (random, in-process key material that does not survive a restart) is configured; the others return an error.", KMS_PROVIDERS);
|
|
39
|
+
const KEK_LABEL = {
|
|
40
|
+
type: "string",
|
|
41
|
+
description: "Label of the Key Encryption Key (KEK). It names the key; it is never used to derive it.",
|
|
42
|
+
minLength: 1,
|
|
43
|
+
maxLength: 256,
|
|
44
|
+
};
|
|
45
|
+
const KEY_TOOLS = [
|
|
15
46
|
{
|
|
16
47
|
name: "crypto_generate_key",
|
|
17
|
-
description:
|
|
48
|
+
description: `Generate a key inside the server: a classical (RSA, ECC, Ed25519) or post-quantum (ML-KEM 512/768/1024 FIPS 203, ML-DSA 44/65/87 FIPS 204) keypair, a 256-bit symmetric key, or an HMAC-SHA256 key. Returns a keyHandle and, for keypairs, the public key. ${schema_helpers_1.HANDLE_NOTE}`,
|
|
18
49
|
inputSchema: {
|
|
19
50
|
type: "object",
|
|
51
|
+
additionalProperties: false,
|
|
20
52
|
properties: {
|
|
21
|
-
type:
|
|
22
|
-
type: "string",
|
|
23
|
-
description: "Key algorithm: 'rsa', 'ecc', 'ed25519', or 'ml-kem-768'.",
|
|
24
|
-
enum: exports.KEY_TYPES,
|
|
25
|
-
},
|
|
53
|
+
type: (0, schema_helpers_1.oneOf)("Key type: 'rsa', 'ecc', 'ed25519', 'x25519', 'ml-kem-512', 'ml-kem-768', 'ml-kem-1024', 'ml-dsa-44', 'ml-dsa-65', 'ml-dsa-87', 'symmetric-256', or 'hmac-sha256'.", exports.KEY_TYPES),
|
|
26
54
|
modulusLength: {
|
|
27
|
-
type: "
|
|
55
|
+
type: "integer",
|
|
28
56
|
description: "Modulus length for RSA (2048, 3072, 4096). Default is 2048.",
|
|
57
|
+
enum: exports.RSA_MODULUS_LENGTHS,
|
|
29
58
|
},
|
|
30
|
-
curve:
|
|
31
|
-
type: "string",
|
|
32
|
-
description: "Elliptic curve: 'prime256v1' (P-256), 'secp384r1' (P-384), or 'secp256k1'.",
|
|
33
|
-
enum: exports.EC_CURVES,
|
|
34
|
-
},
|
|
59
|
+
curve: (0, schema_helpers_1.oneOf)("Elliptic curve for 'ecc': 'prime256v1' (P-256), 'secp384r1' (P-384), or 'secp256k1'. Default is 'prime256v1'.", exports.EC_CURVES),
|
|
35
60
|
},
|
|
36
61
|
required: ["type"],
|
|
37
62
|
},
|
|
38
63
|
},
|
|
39
64
|
{
|
|
40
|
-
name: "
|
|
41
|
-
description:
|
|
65
|
+
name: "crypto_key_list",
|
|
66
|
+
description: `List the key handles this server holds, with each key's type and public metadata. At most ${keystore_1.MAX_KEYS} keys are held; beyond that the least recently used key is destroyed.`,
|
|
67
|
+
inputSchema: {
|
|
68
|
+
type: "object",
|
|
69
|
+
additionalProperties: false,
|
|
70
|
+
properties: {},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: "crypto_key_destroy",
|
|
75
|
+
description: "Destroy a key: overwrite its secret bytes where the runtime allows and invalidate its handle.",
|
|
76
|
+
inputSchema: {
|
|
77
|
+
type: "object",
|
|
78
|
+
additionalProperties: false,
|
|
79
|
+
properties: { keyHandle: (0, schema_helpers_1.keyHandle)("Handle of the key to destroy.") },
|
|
80
|
+
required: ["keyHandle"],
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: "crypto_key_import",
|
|
85
|
+
description: `Import an existing key from a file in the directory the server operator set in ${exports.KEY_DIR_ENV} (disabled when it is unset). Reads an unencrypted PKCS#8 PEM private key (Ed25519, RSA 2048/3072/4096, ECDSA P-256/P-384/secp256k1; the type comes from the key) or a raw 32-byte key, as 32 binary bytes or 64 hex digits, imported as 'symmetric-256' (default) or 'hmac-sha256'. Files over ${exports.MAX_KEY_FILE_BYTES} bytes are refused. The key bytes never pass through the conversation. ${schema_helpers_1.HANDLE_NOTE}`,
|
|
42
86
|
inputSchema: {
|
|
43
87
|
type: "object",
|
|
88
|
+
additionalProperties: false,
|
|
44
89
|
properties: {
|
|
45
|
-
|
|
46
|
-
type: "string",
|
|
47
|
-
description: "Plaintext string to encrypt.",
|
|
48
|
-
},
|
|
49
|
-
algorithm: {
|
|
90
|
+
path: {
|
|
50
91
|
type: "string",
|
|
51
|
-
description:
|
|
52
|
-
|
|
92
|
+
description: `Path of the key file, relative to ${exports.KEY_DIR_ENV}. Absolute paths, '..' segments and symlinks that lead outside the directory are refused.`,
|
|
93
|
+
minLength: 1,
|
|
94
|
+
maxLength: MAX_KEY_PATH_LENGTH,
|
|
53
95
|
},
|
|
54
|
-
key:
|
|
96
|
+
kind: (0, schema_helpers_1.oneOf)("For a raw 32-byte key only: 'symmetric-256' (crypto_encrypt, crypto_decrypt, crypto_kms_wrap; default) or 'hmac-sha256' (crypto_sign, crypto_verify).", RAW_KEY_KINDS),
|
|
97
|
+
},
|
|
98
|
+
required: ["path"],
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: "crypto_inspect_key",
|
|
103
|
+
description: "Inspect and parse PEM certificate, public key, or OpenPGP armored block.",
|
|
104
|
+
inputSchema: {
|
|
105
|
+
type: "object",
|
|
106
|
+
additionalProperties: false,
|
|
107
|
+
properties: {
|
|
108
|
+
keyData: {
|
|
55
109
|
type: "string",
|
|
56
|
-
description: "
|
|
110
|
+
description: "PEM or armored key string.",
|
|
111
|
+
maxLength: schema_helpers_1.MAX_KEY_LENGTH,
|
|
57
112
|
},
|
|
58
113
|
},
|
|
114
|
+
required: ["keyData"],
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
];
|
|
118
|
+
const CIPHER_TOOLS = [
|
|
119
|
+
{
|
|
120
|
+
name: "crypto_encrypt",
|
|
121
|
+
description: `Encrypt plaintext with authenticated encryption (AES-256-GCM or ChaCha20-Poly1305) under a symmetric-256 key handle. Without keyHandle, a new key is generated and its handle returned. ${schema_helpers_1.HANDLE_NOTE}`,
|
|
122
|
+
inputSchema: {
|
|
123
|
+
type: "object",
|
|
124
|
+
additionalProperties: false,
|
|
125
|
+
properties: {
|
|
126
|
+
plaintext: (0, schema_helpers_1.text)("Plaintext string to encrypt."),
|
|
127
|
+
algorithm: (0, schema_helpers_1.oneOf)("Encryption algorithm ('aes-256-gcm' or 'chacha20-poly1305'). Default is 'aes-256-gcm'.", AEAD_ALGORITHMS),
|
|
128
|
+
keyHandle: (0, schema_helpers_1.keyHandle)("Handle of a symmetric-256 key. If omitted, a new key is generated."),
|
|
129
|
+
},
|
|
59
130
|
required: ["plaintext"],
|
|
60
131
|
},
|
|
61
132
|
},
|
|
62
133
|
{
|
|
63
134
|
name: "crypto_decrypt",
|
|
64
|
-
description: "Decrypt
|
|
135
|
+
description: "Decrypt and authenticate an AES-256-GCM or ChaCha20-Poly1305 ciphertext with a symmetric-256 key handle.",
|
|
65
136
|
inputSchema: {
|
|
66
137
|
type: "object",
|
|
138
|
+
additionalProperties: false,
|
|
67
139
|
properties: {
|
|
68
|
-
ciphertext:
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
140
|
+
ciphertext: (0, schema_helpers_1.hex)("Hex-encoded ciphertext.", 2 * schema_helpers_1.MAX_TEXT_LENGTH, true),
|
|
141
|
+
algorithm: (0, schema_helpers_1.oneOf)("Algorithm used for encryption ('aes-256-gcm' or 'chacha20-poly1305'). Default is 'aes-256-gcm'.", AEAD_ALGORITHMS),
|
|
142
|
+
keyHandle: (0, schema_helpers_1.keyHandle)("Handle of the symmetric-256 key."),
|
|
143
|
+
iv: (0, schema_helpers_1.hex)("Hex-encoded 96-bit nonce (24 hex characters).", 24),
|
|
144
|
+
authTag: (0, schema_helpers_1.hex)("Hex-encoded 128-bit authentication tag.", 32),
|
|
145
|
+
},
|
|
146
|
+
required: ["ciphertext", "keyHandle", "iv", "authTag"],
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: "crypto_kem_encapsulate",
|
|
151
|
+
description: `Encapsulate a shared secret to an ML-KEM (FIPS 203) public key (512, 768, 1024). Returns the KEM ciphertext for the recipient and a symmetric-256 keyHandle for the shared secret, usable with crypto_encrypt. ${schema_helpers_1.HANDLE_NOTE}`,
|
|
152
|
+
inputSchema: {
|
|
153
|
+
type: "object",
|
|
154
|
+
additionalProperties: false,
|
|
155
|
+
properties: {
|
|
156
|
+
publicKey: (0, schema_helpers_1.hex)("Hex-encoded ML-KEM public key (1600, 2368, or 3136 hex characters).", 3136, true),
|
|
157
|
+
level: {
|
|
158
|
+
type: "integer",
|
|
159
|
+
description: "ML-KEM security level (512, 768, or 1024). Default is 768.",
|
|
160
|
+
enum: exports.ML_KEM_LEVELS,
|
|
76
161
|
},
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
162
|
+
},
|
|
163
|
+
required: ["publicKey"],
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
name: "crypto_kem_decapsulate",
|
|
168
|
+
description: `Recover an ML-KEM shared secret with an ml-kem key handle (512, 768, 1024). Returns a symmetric-256 keyHandle for the shared secret. ${schema_helpers_1.HANDLE_NOTE}`,
|
|
169
|
+
inputSchema: {
|
|
170
|
+
type: "object",
|
|
171
|
+
additionalProperties: false,
|
|
172
|
+
properties: {
|
|
173
|
+
keyHandle: (0, schema_helpers_1.keyHandle)("Handle of the ml-kem key."),
|
|
174
|
+
ciphertext: (0, schema_helpers_1.hex)("Hex-encoded ML-KEM ciphertext (1536, 2176, or 3136 hex characters).", 3136, true),
|
|
175
|
+
level: {
|
|
176
|
+
type: "integer",
|
|
177
|
+
description: "ML-KEM security level (512, 768, or 1024). Default is inferred from key or 768.",
|
|
178
|
+
enum: exports.ML_KEM_LEVELS,
|
|
80
179
|
},
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
180
|
+
},
|
|
181
|
+
required: ["keyHandle", "ciphertext"],
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
name: "crypto_hybrid_kem_encapsulate",
|
|
186
|
+
description: `Encapsulate a shared secret using Post-Quantum Hybrid KEM (X25519 + ML-KEM, RFC 9180/10024). Returns the classical ephemeral public key, ML-KEM ciphertext, and a symmetric-256 keyHandle for the combined shared secret. ${schema_helpers_1.HANDLE_NOTE}`,
|
|
187
|
+
inputSchema: {
|
|
188
|
+
type: "object",
|
|
189
|
+
additionalProperties: false,
|
|
190
|
+
properties: {
|
|
191
|
+
x25519PublicKey: (0, schema_helpers_1.hex)("Hex-encoded recipient X25519 public key (64 hex characters).", schema_helpers_1.X25519_PUBLIC_KEY_HEX),
|
|
192
|
+
mlKemPublicKey: (0, schema_helpers_1.hex)("Hex-encoded recipient ML-KEM public key (1600, 2368, or 3136 hex characters).", 3136, true),
|
|
193
|
+
level: {
|
|
194
|
+
type: "integer",
|
|
195
|
+
description: "ML-KEM security level (512, 768, or 1024). Default is 768.",
|
|
196
|
+
enum: exports.ML_KEM_LEVELS,
|
|
84
197
|
},
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
198
|
+
},
|
|
199
|
+
required: ["x25519PublicKey", "mlKemPublicKey"],
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
name: "crypto_hybrid_kem_decapsulate",
|
|
204
|
+
description: `Recover a Post-Quantum Hybrid KEM shared secret (X25519 + ML-KEM) using server-held x25519 and ml-kem key handles. Returns a symmetric-256 keyHandle for the combined shared secret. ${schema_helpers_1.HANDLE_NOTE}`,
|
|
205
|
+
inputSchema: {
|
|
206
|
+
type: "object",
|
|
207
|
+
additionalProperties: false,
|
|
208
|
+
properties: {
|
|
209
|
+
x25519KeyHandle: (0, schema_helpers_1.keyHandle)("Handle of the recipient X25519 key."),
|
|
210
|
+
mlKemKeyHandle: (0, schema_helpers_1.keyHandle)("Handle of the recipient ML-KEM key."),
|
|
211
|
+
x25519EphemeralPublic: (0, schema_helpers_1.hex)("Hex-encoded sender ephemeral X25519 public key (64 hex characters).", schema_helpers_1.X25519_PUBLIC_KEY_HEX),
|
|
212
|
+
mlKemCiphertext: (0, schema_helpers_1.hex)("Hex-encoded ML-KEM ciphertext (1536, 2176, or 3136 hex characters).", 3136, true),
|
|
213
|
+
level: {
|
|
214
|
+
type: "integer",
|
|
215
|
+
description: "ML-KEM security level (512, 768, or 1024). Default is inferred from key or 768.",
|
|
216
|
+
enum: exports.ML_KEM_LEVELS,
|
|
88
217
|
},
|
|
89
218
|
},
|
|
90
|
-
required: [
|
|
219
|
+
required: [
|
|
220
|
+
"x25519KeyHandle",
|
|
221
|
+
"mlKemKeyHandle",
|
|
222
|
+
"x25519EphemeralPublic",
|
|
223
|
+
"mlKemCiphertext",
|
|
224
|
+
],
|
|
91
225
|
},
|
|
92
226
|
},
|
|
227
|
+
];
|
|
228
|
+
const SIGNATURE_TOOLS = [
|
|
93
229
|
{
|
|
94
230
|
name: "crypto_sign",
|
|
95
|
-
description: "
|
|
231
|
+
description: "Sign data with a key handle. The algorithm follows the key: Ed25519, RSASSA-PSS (SHA-256), ECDSA (SHA-256; SHA-384 on P-384), ML-DSA (44, 65, 87, FIPS 204), or HMAC-SHA256.",
|
|
96
232
|
inputSchema: {
|
|
97
233
|
type: "object",
|
|
234
|
+
additionalProperties: false,
|
|
98
235
|
properties: {
|
|
99
|
-
data:
|
|
100
|
-
|
|
101
|
-
description: "Data string to sign.",
|
|
102
|
-
},
|
|
103
|
-
algorithm: {
|
|
104
|
-
type: "string",
|
|
105
|
-
description: "Signing algorithm ('ed25519', 'rsa-pss', or 'hmac-sha256').",
|
|
106
|
-
enum: ["ed25519", "rsa-pss", "hmac-sha256"],
|
|
107
|
-
},
|
|
108
|
-
privateKey: {
|
|
109
|
-
type: "string",
|
|
110
|
-
description: "Private key in PEM format or secret key for HMAC.",
|
|
111
|
-
},
|
|
236
|
+
data: (0, schema_helpers_1.text)("Data string to sign."),
|
|
237
|
+
keyHandle: (0, schema_helpers_1.keyHandle)("Handle of an ed25519, rsa, ecc, ml-dsa, or hmac-sha256 key."),
|
|
112
238
|
},
|
|
113
|
-
required: ["data", "
|
|
239
|
+
required: ["data", "keyHandle"],
|
|
114
240
|
},
|
|
115
241
|
},
|
|
116
242
|
{
|
|
117
243
|
name: "crypto_verify",
|
|
118
|
-
description: "Verify
|
|
244
|
+
description: "Verify a signature against a public key (SPKI PEM or ML-DSA hex) or a key handle (also HMAC-SHA256). Pass exactly one of publicKey or keyHandle.",
|
|
119
245
|
inputSchema: {
|
|
120
246
|
type: "object",
|
|
247
|
+
additionalProperties: false,
|
|
121
248
|
properties: {
|
|
122
|
-
data:
|
|
123
|
-
|
|
124
|
-
description: "Original data string.",
|
|
125
|
-
},
|
|
126
|
-
signature: {
|
|
127
|
-
type: "string",
|
|
128
|
-
description: "Hex-encoded signature.",
|
|
129
|
-
},
|
|
130
|
-
algorithm: {
|
|
131
|
-
type: "string",
|
|
132
|
-
description: "Signing algorithm ('ed25519', 'rsa-pss', or 'hmac-sha256').",
|
|
133
|
-
enum: ["ed25519", "rsa-pss", "hmac-sha256"],
|
|
134
|
-
},
|
|
249
|
+
data: (0, schema_helpers_1.text)("Original data string."),
|
|
250
|
+
signature: (0, schema_helpers_1.hex)("Hex-encoded signature.", schema_helpers_1.MAX_KEY_LENGTH, true),
|
|
135
251
|
publicKey: {
|
|
136
252
|
type: "string",
|
|
137
|
-
description: "Public key in PEM format or
|
|
253
|
+
description: "Public key in SPKI PEM format or ML-DSA hex format. Private keys are refused.",
|
|
254
|
+
minLength: 1,
|
|
255
|
+
maxLength: schema_helpers_1.MAX_KEY_LENGTH,
|
|
138
256
|
},
|
|
257
|
+
keyHandle: (0, schema_helpers_1.keyHandle)("Handle of an ed25519, rsa, ecc, ml-dsa, or hmac-sha256 key."),
|
|
139
258
|
},
|
|
140
|
-
required: ["data", "signature"
|
|
259
|
+
required: ["data", "signature"],
|
|
141
260
|
},
|
|
142
261
|
},
|
|
143
262
|
{
|
|
@@ -145,93 +264,66 @@ exports.TOOLS = [
|
|
|
145
264
|
description: "Compute cryptographic digest (SHA-256, SHA-384, SHA-512, SHA3-256, BLAKE2b512).",
|
|
146
265
|
inputSchema: {
|
|
147
266
|
type: "object",
|
|
267
|
+
additionalProperties: false,
|
|
148
268
|
properties: {
|
|
149
|
-
data:
|
|
150
|
-
|
|
151
|
-
description: "Data string to hash.",
|
|
152
|
-
},
|
|
153
|
-
algorithm: {
|
|
154
|
-
type: "string",
|
|
155
|
-
description: "Hash algorithm.",
|
|
156
|
-
enum: exports.HASH_ALGORITHMS,
|
|
157
|
-
},
|
|
269
|
+
data: (0, schema_helpers_1.text)("Data string to hash."),
|
|
270
|
+
algorithm: (0, schema_helpers_1.oneOf)("Hash algorithm.", exports.HASH_ALGORITHMS),
|
|
158
271
|
},
|
|
159
272
|
required: ["data"],
|
|
160
273
|
},
|
|
161
274
|
},
|
|
275
|
+
];
|
|
276
|
+
const KMS_AND_AUDIT_TOOLS = [
|
|
162
277
|
{
|
|
163
278
|
name: "crypto_kms_wrap",
|
|
164
|
-
description: "Wrap
|
|
279
|
+
description: "Wrap the Data Encryption Key (DEK) a symmetric-256 key handle refers to under a Key Encryption Key held by a KMS provider. Only the 'local' provider is configured.",
|
|
165
280
|
inputSchema: {
|
|
166
281
|
type: "object",
|
|
282
|
+
additionalProperties: false,
|
|
167
283
|
properties: {
|
|
168
|
-
provider:
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
enum: ["aws", "gcp", "azure", "vault", "local"],
|
|
172
|
-
},
|
|
173
|
-
keyId: {
|
|
174
|
-
type: "string",
|
|
175
|
-
description: "Label of the Key Encryption Key (KEK). It names the key; it is never used to derive it.",
|
|
176
|
-
},
|
|
177
|
-
dek: {
|
|
178
|
-
type: "string",
|
|
179
|
-
description: "Hex-encoded 256-bit Data Encryption Key to wrap.",
|
|
180
|
-
},
|
|
284
|
+
provider: KMS_PROVIDER,
|
|
285
|
+
keyId: KEK_LABEL,
|
|
286
|
+
keyHandle: (0, schema_helpers_1.keyHandle)("Handle of the symmetric-256 DEK to wrap."),
|
|
181
287
|
},
|
|
182
|
-
required: ["provider", "keyId", "
|
|
288
|
+
required: ["provider", "keyId", "keyHandle"],
|
|
183
289
|
},
|
|
184
290
|
},
|
|
185
291
|
{
|
|
186
292
|
name: "crypto_kms_unwrap",
|
|
187
|
-
description:
|
|
293
|
+
description: `Unwrap a DEK previously wrapped by crypto_kms_wrap in this server process into a symmetric-256 key handle. Only the 'local' provider is configured. ${schema_helpers_1.HANDLE_NOTE}`,
|
|
188
294
|
inputSchema: {
|
|
189
295
|
type: "object",
|
|
296
|
+
additionalProperties: false,
|
|
190
297
|
properties: {
|
|
191
|
-
provider:
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
enum: ["aws", "gcp", "azure", "vault", "local"],
|
|
195
|
-
},
|
|
196
|
-
keyId: {
|
|
197
|
-
type: "string",
|
|
198
|
-
description: "Key Encryption Key (KEK) identifier.",
|
|
199
|
-
},
|
|
200
|
-
wrappedKey: {
|
|
201
|
-
type: "string",
|
|
202
|
-
description: "Hex-encoded wrapped key payload.",
|
|
203
|
-
},
|
|
298
|
+
provider: KMS_PROVIDER,
|
|
299
|
+
keyId: KEK_LABEL,
|
|
300
|
+
wrappedKey: (0, schema_helpers_1.hex)("Hex-encoded wrapped key payload.", 1024, true),
|
|
204
301
|
},
|
|
205
302
|
required: ["provider", "keyId", "wrappedKey"],
|
|
206
303
|
},
|
|
207
304
|
},
|
|
208
|
-
{
|
|
209
|
-
name: "crypto_inspect_key",
|
|
210
|
-
description: "Inspect and parse PEM certificate, public key, or OpenPGP armored block.",
|
|
211
|
-
inputSchema: {
|
|
212
|
-
type: "object",
|
|
213
|
-
properties: {
|
|
214
|
-
keyData: {
|
|
215
|
-
type: "string",
|
|
216
|
-
description: "PEM or armored key string.",
|
|
217
|
-
},
|
|
218
|
-
},
|
|
219
|
-
required: ["keyData"],
|
|
220
|
-
},
|
|
221
|
-
},
|
|
222
305
|
{
|
|
223
306
|
name: "crypto_audit_cbom",
|
|
224
307
|
description: "Generate a Cryptographic Bill of Materials (CBOM) inventory from cryptographic identifiers.",
|
|
225
308
|
inputSchema: {
|
|
226
309
|
type: "object",
|
|
310
|
+
additionalProperties: false,
|
|
227
311
|
properties: {
|
|
228
312
|
algorithms: {
|
|
229
313
|
type: "string",
|
|
230
314
|
description: "Comma-separated list of algorithm names to evaluate (e.g. 'RSA-2048,AES-256-GCM,ML-KEM-768,SHA-1').",
|
|
315
|
+
maxLength: 4096,
|
|
231
316
|
},
|
|
232
317
|
},
|
|
233
318
|
required: ["algorithms"],
|
|
234
319
|
},
|
|
235
320
|
},
|
|
236
321
|
];
|
|
322
|
+
exports.TOOLS = [
|
|
323
|
+
...KEY_TOOLS,
|
|
324
|
+
...CIPHER_TOOLS,
|
|
325
|
+
...stream_definitions_1.STREAM_TOOLS,
|
|
326
|
+
...SIGNATURE_TOOLS,
|
|
327
|
+
...KMS_AND_AUDIT_TOOLS,
|
|
328
|
+
].map((tool) => ({ ...tool, ...(0, annotations_1.annotationsFor)(tool.name) }));
|
|
237
329
|
//# sourceMappingURL=definitions.js.map
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MCPCallToolResult } from "../types";
|
|
2
2
|
export { TOOLS } from "./definitions";
|
|
3
|
+
export { validateArguments } from "./validate";
|
|
3
4
|
export declare function executeTool(name: string, args?: Record<string, unknown>): Promise<MCPCallToolResult>;
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAsB,MAAM,UAAU,CAAC;AAyBjE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAgD/C,wBAAsB,WAAW,CAC/B,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GACjC,OAAO,CAAC,iBAAiB,CAAC,CAU5B"}
|
package/dist/tools/index.js
CHANGED
|
@@ -1,19 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TOOLS = void 0;
|
|
3
|
+
exports.validateArguments = exports.TOOLS = void 0;
|
|
4
4
|
exports.executeTool = executeTool;
|
|
5
5
|
const cbom_1 = require("./cbom");
|
|
6
|
+
const definitions_1 = require("./definitions");
|
|
7
|
+
const keyimport_1 = require("./keyimport");
|
|
8
|
+
const kem_1 = require("./kem");
|
|
6
9
|
const keys_1 = require("./keys");
|
|
7
10
|
const kms_1 = require("./kms");
|
|
8
11
|
const result_1 = require("./result");
|
|
9
12
|
const signing_1 = require("./signing");
|
|
13
|
+
const stream_1 = require("./stream");
|
|
10
14
|
const symmetric_1 = require("./symmetric");
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
const validate_1 = require("./validate");
|
|
16
|
+
var definitions_2 = require("./definitions");
|
|
17
|
+
Object.defineProperty(exports, "TOOLS", { enumerable: true, get: function () { return definitions_2.TOOLS; } });
|
|
18
|
+
var validate_2 = require("./validate");
|
|
19
|
+
Object.defineProperty(exports, "validateArguments", { enumerable: true, get: function () { return validate_2.validateArguments; } });
|
|
13
20
|
const HANDLERS = {
|
|
14
21
|
crypto_generate_key: keys_1.generateKey,
|
|
22
|
+
crypto_key_list: keys_1.listKeys,
|
|
23
|
+
crypto_key_destroy: keys_1.destroyKey,
|
|
24
|
+
crypto_key_import: keyimport_1.importKey,
|
|
25
|
+
crypto_kem_encapsulate: kem_1.kemEncapsulate,
|
|
26
|
+
crypto_kem_decapsulate: kem_1.kemDecapsulate,
|
|
27
|
+
crypto_hybrid_kem_encapsulate: kem_1.hybridKemEncapsulateHandler,
|
|
28
|
+
crypto_hybrid_kem_decapsulate: kem_1.hybridKemDecapsulateHandler,
|
|
29
|
+
crypto_hybrid_kem_multi_encapsulate: kem_1.hybridKemMultiEncapsulateHandler,
|
|
30
|
+
crypto_hybrid_kem_multi_decapsulate: kem_1.hybridKemMultiDecapsulateHandler,
|
|
15
31
|
crypto_encrypt: symmetric_1.encrypt,
|
|
16
32
|
crypto_decrypt: symmetric_1.decrypt,
|
|
33
|
+
crypto_stream_encrypt: stream_1.streamEncrypt,
|
|
34
|
+
crypto_stream_decrypt: stream_1.streamDecrypt,
|
|
35
|
+
crypto_stream_multi_encrypt: stream_1.streamMultiEncrypt,
|
|
36
|
+
crypto_stream_multi_decrypt: stream_1.streamMultiDecrypt,
|
|
17
37
|
crypto_sign: signing_1.sign,
|
|
18
38
|
crypto_verify: signing_1.verify,
|
|
19
39
|
crypto_hash: signing_1.hash,
|
|
@@ -22,12 +42,19 @@ const HANDLERS = {
|
|
|
22
42
|
crypto_inspect_key: keys_1.inspectKey,
|
|
23
43
|
crypto_audit_cbom: cbom_1.auditCbom,
|
|
24
44
|
};
|
|
45
|
+
const REGISTRY = new Map(definitions_1.TOOLS.map((tool) => [
|
|
46
|
+
tool.name,
|
|
47
|
+
{ schema: tool.inputSchema, handler: HANDLERS[tool.name] },
|
|
48
|
+
]));
|
|
25
49
|
async function executeTool(name, args = {}) {
|
|
26
|
-
const
|
|
27
|
-
if (!
|
|
50
|
+
const tool = REGISTRY.get(name);
|
|
51
|
+
if (!tool)
|
|
28
52
|
return (0, result_1.errorResult)(`Unknown tool name: ${name}`);
|
|
53
|
+
const problem = (0, validate_1.validateArguments)(tool.schema, args);
|
|
54
|
+
if (problem)
|
|
55
|
+
return (0, result_1.errorResult)(`Invalid arguments for ${name}: ${problem}`);
|
|
29
56
|
try {
|
|
30
|
-
return await handler(args);
|
|
57
|
+
return await tool.handler(args);
|
|
31
58
|
}
|
|
32
59
|
catch (err) {
|
|
33
60
|
return (0, result_1.errorResult)(`Tool error (${name}): ${err.message}`);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ToolHandler } from "./result";
|
|
2
|
+
export declare const kemEncapsulate: ToolHandler;
|
|
3
|
+
export declare const kemDecapsulate: ToolHandler;
|
|
4
|
+
export declare const hybridKemEncapsulateHandler: ToolHandler;
|
|
5
|
+
export declare const hybridKemDecapsulateHandler: ToolHandler;
|
|
6
|
+
export declare const hybridKemMultiEncapsulateHandler: ToolHandler;
|
|
7
|
+
export declare const hybridKemMultiDecapsulateHandler: ToolHandler;
|
|
8
|
+
//# sourceMappingURL=kem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kem.d.ts","sourceRoot":"","sources":["../../src/tools/kem.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAc,MAAM,UAAU,CAAC;AA2BnD,eAAO,MAAM,cAAc,EAAE,WAa5B,CAAC;AAGF,eAAO,MAAM,cAAc,EAAE,WAoB5B,CAAC;AAGF,eAAO,MAAM,2BAA2B,EAAE,WAoBzC,CAAC;AAGF,eAAO,MAAM,2BAA2B,EAAE,WAuBzC,CAAC;AAmBF,eAAO,MAAM,gCAAgC,EAAE,WAoC9C,CAAC;AAgEF,eAAO,MAAM,gCAAgC,EAAE,WAqB9C,CAAC"}
|