@aikdna/kdna-mcp-server 0.8.6 → 0.8.7
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 +15 -12
- package/bin/operator-binding.mjs +56 -30
- package/bin/read-session.mjs +2 -2
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# KDNA MCP 0.8.
|
|
1
|
+
# KDNA MCP 0.8.7 — local stdio Read adapter
|
|
2
2
|
|
|
3
|
-
This local stdio MCP server (`@aikdna/kdna-mcp-server@0.8.
|
|
3
|
+
This local stdio MCP server (`@aikdna/kdna-mcp-server@0.8.7`) delegates native container `0.6.0` admission and scoped Read operations to the exact CLI `0.47.2` / Core `0.37.13` / Read `0.13.7` graph (`kdna.read/0.7.0-candidate`). Historical MCP `0.5.0`–`0.5.1` and CLI `0.36.x` workspace flows are superseded by this operator-bound native `0.6.0` adapter.
|
|
4
4
|
|
|
5
5
|
## Operator-controlled startup
|
|
6
6
|
|
|
@@ -10,12 +10,13 @@ node /absolute/installed/mcp-server/bin/kdna-mcp.mjs --asset /absolute/selected.
|
|
|
10
10
|
node /absolute/installed/mcp-server/bin/kdna-mcp.mjs --asset /absolute/first.kdna --asset /absolute/second.kdna --allow-read
|
|
11
11
|
# Optional for single password-protected 0.6.0 .kdna files (mode 0600 file or fd >= 3):
|
|
12
12
|
node /absolute/installed/mcp-server/bin/kdna-mcp.mjs --asset /absolute/selected.kdna --allow-read --password-file /absolute/passphrase.txt
|
|
13
|
+
# Mix protected and public files, with a passphrase source scoped to one file:
|
|
14
|
+
node /absolute/installed/mcp-server/bin/kdna-mcp.mjs --asset /absolute/protected.kdna --asset-password-file /absolute/passphrase.txt --asset /absolute/public.kdna --allow-read
|
|
13
15
|
```
|
|
14
16
|
|
|
15
17
|
The **OS process argv**, supplied by an actual local operator or trusted
|
|
16
|
-
launcher, is the sole input-selection/read-permission channel
|
|
17
|
-
|
|
18
|
-
password-protected `0.6.0` `.kdna` files). It is outside
|
|
18
|
+
launcher, is the sole input-selection/read-permission channel, including
|
|
19
|
+
passphrase sources for password-protected files. It is outside
|
|
19
20
|
model-controlled MCP stdin. The Host must not let model tool parameters,
|
|
20
21
|
initialize fields, instructions in an asset or edits to startup configuration
|
|
21
22
|
establish or widen this binding. A Host that lets a model launch arbitrary
|
|
@@ -261,10 +262,12 @@ legacy load/plan-load/Runtime Capsule adaptation are absent.
|
|
|
261
262
|
|
|
262
263
|
This adapter reads native container `0.6.0` `.kdna` assets with `kdna.read/0.7.0-candidate`.
|
|
263
264
|
Public `0.6.0` assets require one or more explicit `--asset /absolute/selected.kdna`
|
|
264
|
-
flags (up to 16) with `--allow-read
|
|
265
|
-
(`kdna.envelope.aead`, `password` entitlement)
|
|
266
|
-
|
|
267
|
-
|
|
265
|
+
flags (up to 16) with `--allow-read`. For each password-protected `0.6.0` asset
|
|
266
|
+
(`kdna.envelope.aead`, `password` entitlement), place `--asset-password-file
|
|
267
|
+
/absolute/passphrase` or `--asset-password-fd <n>` (`n >= 3`) after its
|
|
268
|
+
`--asset` and before the next `--asset`. For a launch with one file,
|
|
269
|
+
`--password-file` and `--password-fd` remain supported. The local CLI receives
|
|
270
|
+
only the credential bound to the file it is opening. Source disclosure
|
|
268
271
|
and revision use the direct CLI (`source-open` / `source-pack`) on the
|
|
269
272
|
unencrypted plaintext source rather than MCP read tools. An unsupported
|
|
270
273
|
container format is not permission to convert it implicitly or read its raw payload.
|
|
@@ -272,7 +275,7 @@ container format is not permission to convert it implicitly or read its raw payl
|
|
|
272
275
|
## Install and test from source
|
|
273
276
|
|
|
274
277
|
For an Agent-led task, begin with the [getting-started guide](https://github.com/aikdna/kdna-skills/blob/main/docs/GETTING_STARTED.md).
|
|
275
|
-
The installer requires Node.js 22 or later, npm, `bash` and `tar`. The
|
|
278
|
+
The installer requires Node.js 22 or later, npm, `bash` and `tar`. The earlier
|
|
276
279
|
CLI 0.47.1 / Core 0.37.12 / Read 0.13.6 graph was exercised with Node.js 22.22.3
|
|
277
280
|
and npm 10.9.8. Earlier companion graphs' runtime checks do not verify this
|
|
278
281
|
one on additional Node versions. The CI matrix is a set of required checks,
|
|
@@ -318,11 +321,11 @@ package-lock.json are excluded. The companion consumer lock is generated from
|
|
|
318
321
|
the checked source graph. The packed-consumer test installs with an empty npm
|
|
319
322
|
cache, then runs the same real stdio boundary suite against the installed bin.
|
|
320
323
|
|
|
321
|
-
Canonical npm publication of `@aikdna/kdna-mcp-server@0.8.
|
|
324
|
+
Canonical npm publication of `@aikdna/kdna-mcp-server@0.8.7` runs exclusively via the GitHub Release workflow (`kdna-mcp-server-0.8.7`) after companion packages (`@aikdna/kdna-core@0.37.13`, `@aikdna/kdna-read@0.13.7`, `@aikdna/kdna-cli@0.47.2`) are published on the official registry. Source and installed process tests do not
|
|
322
325
|
establish named Host adoption, human review, authorship or Creation acceptance.
|
|
323
326
|
|
|
324
327
|
## Native section contract boundary
|
|
325
328
|
|
|
326
|
-
The complete CLI public contract binding is pinned by SHA-256 `
|
|
329
|
+
The complete CLI public contract binding is pinned by SHA-256 `b57b1dffc82f4c8ca6100a462a3d3b07260aa6800b83166ff0431168ad9cc163`. It identifies the native container `0.6.0` and Read `0.7.0-candidate` tuple, exact Core/Read artifacts and route contracts. CLI and Read must resolve the same fixed Core instance; a nested shadow dependency is refused. The adapter delegates native admission and retained section reads to that runtime. Preserve catalog-only status, mandatory closure, native handle origin, diagnostics, absent declarations and explicit empty states. Technical validity, Read and static declarations do not establish live Creation authority, human confirmation or action permission.
|
|
327
330
|
|
|
328
331
|
The public regression corpus is generated from synthetic authored JSON with the fixed CLI. It tests real native containers and one deliberately truncated container; no legacy component-format asset is treated as current native input.
|
package/bin/operator-binding.mjs
CHANGED
|
@@ -10,6 +10,7 @@ export class AdapterError extends Error {
|
|
|
10
10
|
}
|
|
11
11
|
const invalid = () => new AdapterError("MCP_BINDING_INVALID", "The operator-selected local file is unavailable or changed.");
|
|
12
12
|
const invalidPassword = () => new AdapterError("MCP_BINDING_INVALID", "The operator-supplied password source is unavailable or invalid.");
|
|
13
|
+
const invalidArguments = () => new AdapterError("MCP_ARGUMENT_INVALID", "Use --asset /absolute/selected.kdna [--asset-password-file /absolute/passphrase | --asset-password-fd <fd>=3..] [--asset ...] --allow-read, or start without a binding.");
|
|
13
14
|
const sameFile = (a, b) => a.isFile() && b.isFile() && a.dev === b.dev && a.ino === b.ino && a.size === b.size && a.mtimeMs === b.mtimeMs && a.ctimeMs === b.ctimeMs;
|
|
14
15
|
|
|
15
16
|
function stripTrailingNewline(bytes) {
|
|
@@ -104,23 +105,41 @@ function copyAssetFile(selectedPath, destinationPath) {
|
|
|
104
105
|
// Only the local operator/trusted launcher supplies argv, never MCP input.
|
|
105
106
|
export function bindOperatorInput(argv) {
|
|
106
107
|
const selected = [];
|
|
107
|
-
let allowed = false,
|
|
108
|
+
let allowed = false, sharedCredential;
|
|
108
109
|
for (let i = 0; i < argv.length; i++) {
|
|
109
|
-
|
|
110
|
+
const flag = argv[i], value = argv[i + 1];
|
|
111
|
+
if (flag === "--asset" && typeof value === "string" && value.length > 0) {
|
|
110
112
|
if (selected.length >= MAX_BOUND_ASSETS) throw new AdapterError("MCP_ARGUMENT_INVALID", "At most " + MAX_BOUND_ASSETS + " --asset files may be bound in one process.");
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
113
|
+
if (selected.some(asset => asset.path === value)) throw new AdapterError("MCP_ARGUMENT_INVALID", "Duplicate --asset path in operator startup arguments.");
|
|
114
|
+
selected.push({ path: value });
|
|
115
|
+
i++;
|
|
116
|
+
} else if (flag === "--allow-read" && !allowed) {
|
|
117
|
+
allowed = true;
|
|
118
|
+
} else if (["--password-file", "--password-fd", "--asset-password-file", "--asset-password-fd"].includes(flag)) {
|
|
119
|
+
const forAsset = flag.startsWith("--asset-"), asset = selected.at(-1);
|
|
120
|
+
if (forAsset ? !asset || asset.credential : sharedCredential) throw invalidArguments();
|
|
121
|
+
if (typeof value !== "string" || value.length === 0) throw invalidArguments();
|
|
122
|
+
const fd = flag.endsWith("-fd") ? Number(value) : null;
|
|
123
|
+
if (fd !== null && (!/^[1-9][0-9]*$/.test(value) || !Number.isSafeInteger(fd) || fd < 3)) throw invalidArguments();
|
|
124
|
+
const credential = fd === null ? { path: value } : { fd };
|
|
125
|
+
if (forAsset) asset.credential = credential;
|
|
126
|
+
else sharedCredential = credential;
|
|
127
|
+
i++;
|
|
128
|
+
} else {
|
|
129
|
+
throw invalidArguments();
|
|
114
130
|
}
|
|
115
|
-
else if (argv[i] === "--allow-read" && !allowed) allowed = true;
|
|
116
|
-
else if (argv[i] === "--password-file" && passwordFile === undefined && passwordFd === undefined && typeof argv[i + 1] === "string" && argv[i + 1].length > 0) passwordFile = argv[++i];
|
|
117
|
-
else if (argv[i] === "--password-fd" && passwordFd === undefined && passwordFile === undefined && typeof argv[i + 1] === "string" && /^[1-9][0-9]*$/.test(argv[i + 1]) && Number(argv[i + 1]) >= 3 && Number.isSafeInteger(Number(argv[i + 1]))) passwordFd = Number(argv[++i]);
|
|
118
|
-
else throw new AdapterError("MCP_ARGUMENT_INVALID", "Use --asset /absolute/selected.kdna [--asset ...] --allow-read [--password-file /absolute/passphrase | --password-fd <fd>=3..], or start without a binding.");
|
|
119
131
|
}
|
|
120
132
|
if (allowed && selected.length === 0) throw new AdapterError("MCP_ARGUMENT_INVALID", "An operator-selected file is required.");
|
|
121
|
-
|
|
122
|
-
|
|
133
|
+
const boundCredentials = selected.filter(asset => asset.credential);
|
|
134
|
+
if (sharedCredential) {
|
|
135
|
+
if (selected.length !== 1 || boundCredentials.length !== 0) throw invalidArguments();
|
|
136
|
+
selected[0].credential = sharedCredential;
|
|
123
137
|
}
|
|
138
|
+
if (!allowed && (sharedCredential || boundCredentials.length)) throw invalidArguments();
|
|
139
|
+
const descriptors = selected.map(asset => asset.credential?.fd).filter(fd => fd !== undefined);
|
|
140
|
+
if (new Set(descriptors).size !== descriptors.length) throw invalidArguments();
|
|
141
|
+
|
|
142
|
+
const passwordCopies = new Set();
|
|
124
143
|
let directory = null, identity = null, closed = false;
|
|
125
144
|
const binding = {
|
|
126
145
|
state: "unbound", file: null, passwordFile: null, name: null, digest: null, assets: [],
|
|
@@ -132,40 +151,46 @@ export function bindOperatorInput(argv) {
|
|
|
132
151
|
closed = true; this.state = "cancelled"; this.file = null;
|
|
133
152
|
for (const entry of this.assets) { entry.file = null; entry.passwordFile = null; }
|
|
134
153
|
this.assets = [];
|
|
135
|
-
|
|
136
|
-
try {
|
|
137
|
-
const stat = fs.lstatSync(this.passwordFile);
|
|
138
|
-
if (stat.isFile() && !stat.isSymbolicLink()) fs.writeFileSync(this.passwordFile, Buffer.alloc(stat.size, 0));
|
|
139
|
-
} catch { /* cleaned up with directory below */ }
|
|
140
|
-
this.passwordFile = null;
|
|
141
|
-
}
|
|
154
|
+
this.passwordFile = null;
|
|
142
155
|
if (directory !== null) {
|
|
143
156
|
const current = fs.lstatSync(directory);
|
|
144
157
|
if (!current.isDirectory() || current.isSymbolicLink() || current.dev !== identity.dev || current.ino !== identity.ino) throw new AdapterError("MCP_CLEANUP_FAILED", "The private binding directory changed.");
|
|
158
|
+
for (const passwordCopy of passwordCopies) {
|
|
159
|
+
try {
|
|
160
|
+
const stat = fs.lstatSync(passwordCopy);
|
|
161
|
+
if (stat.isFile() && !stat.isSymbolicLink()) fs.writeFileSync(passwordCopy, Buffer.alloc(stat.size, 0));
|
|
162
|
+
} catch { /* removed with the private directory */ }
|
|
163
|
+
}
|
|
145
164
|
fs.rmSync(directory, { recursive: true }); directory = null;
|
|
165
|
+
passwordCopies.clear();
|
|
146
166
|
}
|
|
147
167
|
},
|
|
148
168
|
};
|
|
149
169
|
if (!allowed) return binding;
|
|
150
170
|
try {
|
|
151
|
-
const passphraseBytes = passwordFile !== undefined ? readPasswordFile(passwordFile) : passwordFd !== undefined ? readPasswordFd(passwordFd) : null;
|
|
152
171
|
directory = fs.mkdtempSync(path.join(os.tmpdir(), "kdna-mcp-read-"));
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
if (passphraseBytes !== null) {
|
|
156
|
-
passCopy = path.join(directory, "passphrase");
|
|
157
|
-
fs.writeFileSync(passCopy, passphraseBytes, { flag: "wx", mode: 0o600 });
|
|
158
|
-
passphraseBytes.fill(0);
|
|
159
|
-
binding.passwordFile = passCopy;
|
|
160
|
-
}
|
|
172
|
+
identity = fs.lstatSync(directory);
|
|
173
|
+
fs.chmodSync(directory, 0o700);
|
|
161
174
|
const boundAssets = [];
|
|
162
|
-
for (
|
|
175
|
+
for (const [index, selectedAsset] of selected.entries()) {
|
|
163
176
|
const copy = path.join(directory, selected.length === 1 ? "selected.kdna" : `asset-${index}.kdna`);
|
|
164
|
-
const copied = copyAssetFile(
|
|
177
|
+
const copied = copyAssetFile(selectedAsset.path, copy);
|
|
178
|
+
const credential = selectedAsset.credential;
|
|
179
|
+
let passwordCopy = null;
|
|
180
|
+
if (credential) {
|
|
181
|
+
const passphrase = credential.fd === undefined ? readPasswordFile(credential.path) : readPasswordFd(credential.fd);
|
|
182
|
+
try {
|
|
183
|
+
passwordCopy = path.join(directory, `passphrase-${index}`);
|
|
184
|
+
passwordCopies.add(passwordCopy);
|
|
185
|
+
fs.writeFileSync(passwordCopy, passphrase, { flag: "wx", mode: 0o600 });
|
|
186
|
+
} finally {
|
|
187
|
+
passphrase.fill(0);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
165
190
|
const assetBinding = {
|
|
166
191
|
index,
|
|
167
192
|
file: copy,
|
|
168
|
-
passwordFile:
|
|
193
|
+
passwordFile: passwordCopy,
|
|
169
194
|
name: copied.name,
|
|
170
195
|
digest: copied.digest,
|
|
171
196
|
assertReadable() {
|
|
@@ -178,6 +203,7 @@ export function bindOperatorInput(argv) {
|
|
|
178
203
|
binding.assets = boundAssets;
|
|
179
204
|
if (boundAssets.length === 1) {
|
|
180
205
|
binding.file = boundAssets[0].file;
|
|
206
|
+
binding.passwordFile = boundAssets[0].passwordFile;
|
|
181
207
|
binding.name = boundAssets[0].name;
|
|
182
208
|
binding.digest = boundAssets[0].digest;
|
|
183
209
|
} else {
|
package/bin/read-session.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { AdapterError } from "./operator-binding.mjs";
|
|
|
8
8
|
|
|
9
9
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
10
10
|
export const packageInfo = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8"));
|
|
11
|
-
const versions = { cli: "0.47.
|
|
11
|
+
const versions = { cli: "0.47.2", core: "0.37.13", read: "0.13.7" };
|
|
12
12
|
function localPackage(name) {
|
|
13
13
|
const roots = [path.join(root, "node_modules")];
|
|
14
14
|
if (path.basename(path.dirname(root)) === "@aikdna" && path.basename(path.dirname(path.dirname(root))) === "node_modules") roots.push(path.dirname(path.dirname(root)));
|
|
@@ -26,7 +26,7 @@ const cli = localPackage("cli"), core = localPackage("core"), read = localPackag
|
|
|
26
26
|
const cliEntry = path.resolve(cli.directory, cli.value.bin?.kdna || "");
|
|
27
27
|
const bindingBytes = fs.readFileSync(path.join(cli.directory, "public-contract-binding.json"));
|
|
28
28
|
export const publicBinding = JSON.parse(bindingBytes);
|
|
29
|
-
if (packageInfo.kdna_runtime?.cli !== versions.cli || packageInfo.kdna_runtime?.core !== versions.core || packageInfo.kdna_runtime?.read !== versions.read || createHash("sha256").update(bindingBytes).digest("hex") !== "
|
|
29
|
+
if (packageInfo.kdna_runtime?.cli !== versions.cli || packageInfo.kdna_runtime?.core !== versions.core || packageInfo.kdna_runtime?.read !== versions.read || createHash("sha256").update(bindingBytes).digest("hex") !== "b57b1dffc82f4c8ca6100a462a3d3b07260aa6800b83166ff0431168ad9cc163" || publicBinding.implementation?.version !== versions.cli || publicBinding.tuple?.container !== "0.6.0" || publicBinding.tuple?.read !== "kdna.read/0.7.0-candidate" || publicBinding.accepted_core?.version !== versions.core || publicBinding.accepted_read?.version !== versions.read || packageInfo.kdna_runtime?.read_contract !== "kdna.read/0.7.0-candidate" || !cliEntry.startsWith(cli.directory + path.sep) || !fs.statSync(cliEntry).isFile()) throw new AdapterError("MCP_RUNTIME_INVALID", "The fixed native runtime contract binding is invalid.");
|
|
30
30
|
// Every consumer resolves the same fixed Core/Read instance; nested shadow copies are refused.
|
|
31
31
|
for (const [consumer, dependency] of [[cli, core], [cli, read], [read, core]]) {
|
|
32
32
|
const resolved = createRequire(path.join(consumer.directory, "package.json")).resolve(dependency.value.name + "/package.json");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aikdna/kdna-mcp-server",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.7",
|
|
4
4
|
"description": "Local stdio Read adapter for operator-bound KDNA assets.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"homepage": "https://aikdna.com",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
},
|
|
41
41
|
"license": "Apache-2.0",
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@aikdna/kdna-core": "0.37.
|
|
44
|
-
"@aikdna/kdna-read": "0.13.
|
|
43
|
+
"@aikdna/kdna-core": "0.37.13",
|
|
44
|
+
"@aikdna/kdna-read": "0.13.7",
|
|
45
45
|
"ajv": "8.20.0",
|
|
46
46
|
"ajv-formats": "3.0.1",
|
|
47
47
|
"cbor-x": "1.6.9",
|
|
@@ -51,12 +51,12 @@
|
|
|
51
51
|
"@noble/hashes": "1.8.0",
|
|
52
52
|
"pako": "2.1.0",
|
|
53
53
|
"require-from-string": "2.0.2",
|
|
54
|
-
"@aikdna/kdna-cli": "0.47.
|
|
54
|
+
"@aikdna/kdna-cli": "0.47.2"
|
|
55
55
|
},
|
|
56
56
|
"kdna_runtime": {
|
|
57
|
-
"cli": "0.47.
|
|
58
|
-
"core": "0.37.
|
|
59
|
-
"read": "0.13.
|
|
57
|
+
"cli": "0.47.2",
|
|
58
|
+
"core": "0.37.13",
|
|
59
|
+
"read": "0.13.7",
|
|
60
60
|
"read_contract": "kdna.read/0.7.0-candidate"
|
|
61
61
|
},
|
|
62
62
|
"engines": {
|