@strixgov/mcp-proxy 0.2.3 → 0.2.5

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.
Files changed (37) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +75 -25
  3. package/examples/controlled-launcher/README.md +33 -0
  4. package/examples/controlled-launcher/acceptance.mjs +337 -0
  5. package/examples/controlled-launcher/agent-client.mjs +18 -0
  6. package/examples/controlled-launcher/approval-relay.mjs +19 -0
  7. package/examples/controlled-launcher/approver.mjs +27 -0
  8. package/examples/controlled-launcher/authorizer.mjs +73 -0
  9. package/examples/controlled-launcher/bridge-client.mjs +8 -0
  10. package/examples/controlled-launcher/destination.mjs +18 -0
  11. package/examples/controlled-launcher/executor.mjs +74 -0
  12. package/examples/controlled-launcher/kernel-authority/acceptance.mjs +627 -0
  13. package/examples/controlled-launcher/kernel-authority/broker.mjs +83 -0
  14. package/examples/controlled-launcher/kernel-authority/derive.mjs +12 -0
  15. package/examples/controlled-launcher/kernel-authority/executor.mjs +105 -0
  16. package/examples/controlled-launcher/kernel-authority/reconcile.mjs +43 -0
  17. package/examples/controlled-launcher/kernel-authority/shim.mjs +38 -0
  18. package/examples/controlled-launcher/kernel-authority/signing-provider.mjs +137 -0
  19. package/examples/controlled-launcher/kernel-authority/strix-approver.mjs +73 -0
  20. package/examples/controlled-launcher/lib.mjs +63 -0
  21. package/examples/controlled-launcher/make-config.mjs +16 -0
  22. package/examples/controlled-launcher/proxy-host.mjs +19 -0
  23. package/examples/controlled-launcher/reconcile.mjs +30 -0
  24. package/examples/controlled-launcher/shim.mjs +32 -0
  25. package/examples/github-reference/README.md +34 -0
  26. package/examples/github-reference/acceptance.mjs +675 -0
  27. package/examples/github-reference/claims-matrix.md +34 -0
  28. package/examples/github-reference/demo-script.md +17 -0
  29. package/examples/github-reference/package-lock.json +1330 -0
  30. package/examples/github-reference/package.json +23 -0
  31. package/examples/github-reference/reuse-inventory.md +24 -0
  32. package/examples/synthetic-server/proxy-config.json +16 -0
  33. package/examples/synthetic-server/quickstart.mjs +98 -0
  34. package/examples/synthetic-server/server.mjs +54 -0
  35. package/package.json +6 -5
  36. package/test/package-contract.test.mjs +12 -0
  37. package/test/synthetic-quickstart.test.mjs +44 -0
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@strixgov/github-mcp-reference-demo",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "description": "Offline GitHub-shaped MCP acceptance demo; never contacts GitHub.",
7
+ "engines": {
8
+ "node": ">=18"
9
+ },
10
+ "scripts": {
11
+ "test": "node acceptance.mjs",
12
+ "demo": "node acceptance.mjs"
13
+ },
14
+ "dependencies": {
15
+ "@modelcontextprotocol/sdk": "1.32.2",
16
+ "@strixgov/capabilities-mcp-common": "0.1.2",
17
+ "@strixgov/guard": "0.2.0",
18
+ "@strixgov/mcp-adapter": "0.1.5",
19
+ "@strixgov/mcp-proxy": "0.2.4",
20
+ "@strixgov/tool-gateway": "0.5.2",
21
+ "@strixgov/verifier": "1.25.0"
22
+ }
23
+ }
@@ -0,0 +1,24 @@
1
+ # Reuse inventory
2
+
3
+ ## Published components exercised
4
+
5
+ | Existing component | Reused contract | Demo use |
6
+ |---|---|---|
7
+ | `@strixgov/guard@0.2.0` | `packForServer`, `buildProxyConfig`, `createApproverKey`, `approveSigned` | Selects the existing GitHub capability pack; writes exact approval requests; signs synthetic reviewer decisions over exact request bytes. |
8
+ | `@strixgov/capabilities-mcp-common@0.1.2` | Existing GitHub classifications | Classifies the read and merge tools; the fixture's unclassified `delete_repository` is denied by default. |
9
+ | `@strixgov/mcp-proxy@0.2.4` | Existing MCP interception and transport path | Intercepts calls over the supported in-memory test transport; no second proxy is added. |
10
+ | `@strixgov/mcp-adapter@0.1.5` | Capability resolution, policy evaluation, approval handling, receipt and outcome production | Used transitively by the published proxy. Its tarball's own `npm test` script fails because the tarball omits `scripts/preflight.mjs`; see the test logs. |
11
+ | `@strixgov/tool-gateway@0.5.2` | Existing policy, approval, storage, receipt, and signing primitives | Supplies the gateway and persisted logs; the harness adds no competing authority or signer. |
12
+ | `@strixgov/verifier@1.25.0` | Published receipt-chain and execution-outcome verification | Verifies signed receipts, receipt-linked outcomes, and tampering. Repository candidate 1.24.2 is unpublished and is not substituted. |
13
+
14
+ ## Existing source examined but not claimed as a published integration
15
+
16
+ The `docs/strategy/specs/execution-plane-phase-a-reference/github-merge-pep.mjs` and its tests implement a reference PEP with exact subject hashing, full head-SHA precondition, and injected single-use authority/revocation/evidence dependencies. It is source-reference-only, has no production callers, and returns unsigned results. Its source tests are not evidence that the published MCP stack or GitHub API executes a merge.
17
+
18
+ The production authority model remains the one to reuse: the first-party `github.pr.merge` capability is currently pending lifecycle and non-executable. `docs/architecture/mcp-mode-3-enforcement-v1.md` describes future signed execution authorization and atomic downstream nonce redemption; the published MCP proxy does not wire that Mode-3 path. The official GitHub MCP `merge_pull_request` shape also lacks the provider-side full-head-SHA precondition required by the PEP.
19
+
20
+ The adapter's `examples/github.mjs` can auto-approve a stub flow and can reach live GitHub when supplied a PAT; it was not run. `scripts/mcp-bundle-smoke.mjs` contains GitHub-related policy but exercises filesystem and `claude.read`, not a GitHub-specific end-to-end flow.
21
+
22
+ ## Integration gap
23
+
24
+ The published Mode-2 signed file approval is exact-request-bound, but it is not equivalent to a durable, atomic, payload-bound Mode-3 execution grant. This demo intentionally does not approve or dispatch a merge, and does not claim the proxy covers direct credentials or alternative routes.
@@ -0,0 +1,16 @@
1
+ {
2
+ "_comment": "Template. quickstart.mjs writes a copy with absolute paths for you. Capabilities are inline, so no companion pack is needed. 'default': 'DENY' means a tool you did not classify does not run. Guard's defaults pause unclassified tools for a person instead.",
3
+ "serverId": "synthetic-notes",
4
+ "upstream": { "command": "node", "args": ["./server.mjs", "--data", "./data"] },
5
+ "capabilities": [
6
+ { "id": "synthetic.read_note", "name": "read_note", "risk": "LOW", "mode": "READ" },
7
+ { "id": "synthetic.write_note", "name": "write_note", "risk": "MEDIUM", "mode": "WRITE" },
8
+ { "id": "synthetic.delete_notes", "name": "delete_notes", "risk": "CRITICAL", "mode": "WRITE" }
9
+ ],
10
+ "policy": {
11
+ "riskOverrides": { "LOW": "ALLOW", "MEDIUM": "APPROVAL_REQUIRED", "CRITICAL": "DENY" },
12
+ "default": "DENY"
13
+ },
14
+ "approval": { "enabled": true, "type": "file", "requestDir": "./approvals", "timeoutMs": 60000, "pollIntervalMs": 100 },
15
+ "storagePath": "./receipts"
16
+ }
@@ -0,0 +1,98 @@
1
+ #!/usr/bin/env node
2
+ // Five-minute, safe walkthrough of the Strix MCP Proxy. Run: node quickstart.mjs
3
+ // It starts the proxy in front of a synthetic server, then shows, in order:
4
+ // 1. a classified read passes 2. a write pauses for a person
5
+ // 3. a human approves it and it runs 4. a second write is refused
6
+ // 5. a call your policy denies never runs 6. the signed receipts it left
7
+ // Everything happens in a temp folder. No real service or credential is involved.
8
+ import fs from "node:fs";
9
+ import os from "node:os";
10
+ import path from "node:path";
11
+ import { fileURLToPath } from "node:url";
12
+ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
13
+ import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
14
+
15
+ const here = path.dirname(fileURLToPath(import.meta.url));
16
+ const proxyBin = path.resolve(here, "../../bin/strix-mcp-proxy.mjs");
17
+ const work = fs.mkdtempSync(path.join(os.tmpdir(), "strix-quickstart-"));
18
+ const dirs = { data: path.join(work, "data"), approvals: path.join(work, "approvals"), receipts: path.join(work, "receipts") };
19
+ const notes = path.join(dirs.data, "notes.txt");
20
+
21
+ const cfg = JSON.parse(fs.readFileSync(path.join(here, "proxy-config.json"), "utf8"));
22
+ delete cfg._comment;
23
+ cfg.upstream.args = [path.join(here, "server.mjs"), "--data", dirs.data];
24
+ cfg.approval.requestDir = dirs.approvals;
25
+ cfg.storagePath = dirs.receipts;
26
+ const configPath = path.join(work, "proxy-config.json");
27
+ fs.writeFileSync(configPath, JSON.stringify(cfg, null, 2));
28
+
29
+ const say = (s) => console.log(s);
30
+ const step = (n, s) => say(`\n[${n}] ${s}`);
31
+ const lines = () => fs.readFileSync(notes, "utf8").trim().split("\n").length;
32
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
33
+
34
+ async function waitForRequest() {
35
+ for (let i = 0; i < 200; i++) {
36
+ const f = fs.existsSync(dirs.approvals) && fs.readdirSync(dirs.approvals).find((x) => x.endsWith(".request.json"));
37
+ if (f) return path.join(dirs.approvals, f);
38
+ await sleep(50);
39
+ }
40
+ throw new Error("no approval request appeared");
41
+ }
42
+ function decide(requestPath, approved) {
43
+ const resp = requestPath.replace(/\.request\.json$/, ".response.json");
44
+ fs.writeFileSync(resp, JSON.stringify({ approved, approvedBy: "you-at-the-keyboard" }));
45
+ }
46
+
47
+ const client = new Client({ name: "quickstart", version: "0.0.1" }, { capabilities: {} });
48
+ await client.connect(new StdioClientTransport({
49
+ command: process.execPath, args: [proxyBin, "--config", configPath], stderr: "ignore",
50
+ }));
51
+ const txt = (r) => r.content?.map((c) => c.text).join("") ?? "";
52
+ // A refused call reaches the client as an MCP error, not a result.
53
+ const attempt = async (p) => { try { return { ok: true, text: txt(await p) }; } catch (e) { return { ok: false, text: String(e.message) }; } };
54
+
55
+ step(1, "Read a note (classified low-risk: passes)");
56
+ say(` result: ${JSON.stringify(txt(await client.callTool({ name: "read_note", arguments: {} })).split("\n")[0])}...`);
57
+
58
+ step(2, "Ask for a write (classified medium: the proxy pauses it for a person)");
59
+ const before = lines();
60
+ const held = client.callTool({ name: "write_note", arguments: { text: "note-3: written after approval" } });
61
+ const req1 = await waitForRequest();
62
+ const asked = JSON.parse(fs.readFileSync(req1, "utf8"));
63
+ say(` waiting on a person. Tool asked for: ${asked.invocation?.capabilityId ?? "(see request file)"}`);
64
+ say(` notes file lines while paused: ${lines()} (was ${before}) -> the write has not run`);
65
+
66
+ step(3, "A person approves; only now does the write run");
67
+ decide(req1, true);
68
+ say(` result: ${txt(await held)}; notes file lines now: ${lines()}`);
69
+
70
+ step(4, "A second write, this time refused by the person");
71
+ const second = client.callTool({ name: "write_note", arguments: { text: "note-4: should never appear" } });
72
+ decide(await waitForRequest(), false);
73
+ const r2 = await attempt(second);
74
+ say(` ran: ${r2.ok}; the client was told: ${r2.text}`);
75
+ say(` notes file lines: ${lines()} (unchanged)`);
76
+
77
+ step(5, "A call your policy denies (classified critical): never runs, no one is asked");
78
+ const r3 = await attempt(client.callTool({ name: "delete_notes", arguments: {} }));
79
+ say(` ran: ${r3.ok}; the client was told: ${r3.text}`);
80
+ say(` notes file still exists: ${fs.existsSync(notes)}`);
81
+
82
+ await client.close();
83
+ await sleep(200);
84
+
85
+ step(6, "The signed receipts the proxy left (allowed and refused alike)");
86
+ const dir = fs.readdirSync(dirs.receipts, { recursive: true }).map(String);
87
+ const rfile = dir.find((f) => f.endsWith("receipts.jsonl"));
88
+ const jwk = dir.find((f) => f.endsWith("public-jwk.json"));
89
+ const recs = fs.readFileSync(path.join(dirs.receipts, rfile), "utf8").trim().split("\n").map((l) => JSON.parse(l));
90
+ for (const r of recs) {
91
+ const p = r.payload ?? r;
92
+ say(` ${String(p.capabilityId ?? p.toolName ?? "?").padEnd(24)} decision=${p.decision ?? p.outcome ?? "?"} signed=${Boolean(r.signature)}`);
93
+ }
94
+ say("\nWhat a receipt is: evidence of the proxy's recorded decision. It does not by itself prove that the");
95
+ say("downstream server executed or delivered the action; step 3's file change is what showed that here.");
96
+ say("\nCheck them offline with a separate package (needs network the first time):");
97
+ say(` npx @strixgov/verifier chain "${path.join(dirs.receipts, rfile)}" --jwks "${path.join(dirs.receipts, jwk)}"`);
98
+ say(`\nEverything is in ${work} (safe to delete).`);
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env node
2
+ // A synthetic stdio MCP server for trying the Strix MCP Proxy safely.
3
+ // It holds a few made-up notes. Nothing here touches a real system: the only
4
+ // side effect is appending a line to a text file inside --data <dir>, so you can
5
+ // see whether a write actually ran. No dependencies; newline-delimited JSON-RPC.
6
+ import fs from "node:fs";
7
+ import path from "node:path";
8
+ import readline from "node:readline";
9
+
10
+ const dataIdx = process.argv.indexOf("--data");
11
+ const dataDir = path.resolve(dataIdx > -1 ? process.argv[dataIdx + 1] : "./synthetic-data");
12
+ fs.mkdirSync(dataDir, { recursive: true });
13
+ const notesFile = path.join(dataDir, "notes.txt");
14
+ if (!fs.existsSync(notesFile)) {
15
+ fs.writeFileSync(notesFile, "note-1: synthetic planning note\nnote-2: synthetic meeting note\n");
16
+ }
17
+
18
+ const tools = [
19
+ { name: "read_note", description: "Read the synthetic notes file.",
20
+ inputSchema: { type: "object", properties: {} } },
21
+ { name: "write_note", description: "Append a line to the synthetic notes file.",
22
+ inputSchema: { type: "object", properties: { text: { type: "string" } }, required: ["text"] } },
23
+ { name: "delete_notes", description: "Delete the synthetic notes file.",
24
+ inputSchema: { type: "object", properties: {} } },
25
+ ];
26
+
27
+ const text = (t, isError = false) => ({ content: [{ type: "text", text: t }], ...(isError ? { isError } : {}) });
28
+
29
+ function call(name, args = {}) {
30
+ if (name === "read_note") return text(fs.readFileSync(notesFile, "utf8"));
31
+ if (name === "write_note") {
32
+ fs.appendFileSync(notesFile, `${String(args.text ?? "")}\n`);
33
+ return text("appended");
34
+ }
35
+ if (name === "delete_notes") { fs.rmSync(notesFile, { force: true }); return text("deleted"); }
36
+ return text(`unknown tool: ${name}`, true);
37
+ }
38
+
39
+ const send = (msg) => process.stdout.write(`${JSON.stringify(msg)}\n`);
40
+ readline.createInterface({ input: process.stdin }).on("line", (line) => {
41
+ let m;
42
+ try { m = JSON.parse(line); } catch { return; }
43
+ if (m.id === undefined) return; // notifications need no reply
44
+ if (m.method === "initialize") {
45
+ return send({ jsonrpc: "2.0", id: m.id, result: {
46
+ protocolVersion: m.params?.protocolVersion ?? "2024-11-05",
47
+ capabilities: { tools: {} }, serverInfo: { name: "strix-synthetic-notes", version: "0.0.1" } } });
48
+ }
49
+ if (m.method === "tools/list") return send({ jsonrpc: "2.0", id: m.id, result: { tools } });
50
+ if (m.method === "tools/call") {
51
+ return send({ jsonrpc: "2.0", id: m.id, result: call(m.params?.name, m.params?.arguments) });
52
+ }
53
+ send({ jsonrpc: "2.0", id: m.id, error: { code: -32601, message: `method not found: ${m.method}` } });
54
+ });
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@strixgov/mcp-proxy",
3
- "version": "0.2.3",
4
- "description": "Strix MCP Proxy — the distribution wedge for governed agent tool execution. Point your MCP client at the proxy instead of the underlying server; every callTool is intercepted, evaluated against policy, and emits a signed Ed25519 receipt. Designed so Mode 3 (capability-enforced) is the v0.2.0 upgrade path, not a rewrite.",
3
+ "mcpName": "io.github.Strixgov/mcp-proxy",
4
+ "version": "0.2.5",
5
+ "description": "Strix MCP Proxy — put an authorization decision in front of the MCP tools an agent uses. Point your MCP client at the proxy instead of the underlying server; every callTool is intercepted, evaluated against policy (reads pass, writes can wait for a person), and produces a signed Ed25519 receipt that verifies offline against the proxy's public key. Source-available (Elastic-2.0).",
5
6
  "license": "Elastic-2.0",
6
7
  "type": "module",
7
8
  "main": "./src/index.mjs",
@@ -16,9 +17,9 @@
16
17
  },
17
18
  "dependencies": {
18
19
  "@modelcontextprotocol/sdk": "^1.0.0",
19
- "@strixgov/capabilities-mcp-common": "^0.1.0",
20
- "@strixgov/mcp-adapter": "^0.1.0",
21
- "@strixgov/tool-gateway": "^0.5.1"
20
+ "@strixgov/capabilities-mcp-common": "0.1.2",
21
+ "@strixgov/mcp-adapter": "0.1.5",
22
+ "@strixgov/tool-gateway": "0.5.2"
22
23
  },
23
24
  "devDependencies": {
24
25
  "zod": "^3.25.76"
@@ -18,3 +18,15 @@ test("every script file the `test` script runs ships in the tarball", () => {
18
18
  assert.ok(covered(rel), `${rel} is used by \`npm test\` but excluded by package.json "files"`);
19
19
  }
20
20
  });
21
+
22
+ test("Strix dependencies are pinned exactly, so Guard's pinned proxy version fixes the whole Strix stack", () => {
23
+ // In this repository they are `workspace:*`, which pnpm publishes as the exact
24
+ // current version; in an installed copy they must already be exact versions.
25
+ // A range here means a new tool-gateway release changes what an existing Guard
26
+ // install runs (finding 1 of the #2810 evidence run).
27
+ const strix = Object.entries(pkg.dependencies).filter(([n]) => n.startsWith("@strixgov/"));
28
+ assert.ok(strix.length >= 3, "expected the Strix runtime dependencies");
29
+ for (const [name, spec] of strix) {
30
+ assert.ok(spec === "workspace:*" || /^\d+\.\d+\.\d+$/.test(spec), `${name} is "${spec}"; pin it exactly (workspace:*)`);
31
+ }
32
+ });
@@ -0,0 +1,44 @@
1
+ import { test } from "node:test";
2
+ import assert from "node:assert/strict";
3
+ import { spawnSync } from "node:child_process";
4
+ import { readFileSync, existsSync } from "node:fs";
5
+ import path from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+
8
+ const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
9
+ const dir = path.join(root, "examples", "synthetic-server");
10
+
11
+ test("synthetic quickstart files ship and the config classifies every server tool", () => {
12
+ for (const f of ["server.mjs", "proxy-config.json", "quickstart.mjs"]) {
13
+ assert.ok(existsSync(path.join(dir, f)), `${f} is missing`);
14
+ }
15
+ const cfg = JSON.parse(readFileSync(path.join(dir, "proxy-config.json"), "utf8"));
16
+ const names = cfg.capabilities.map((c) => c.name).sort();
17
+ assert.deepEqual(names, ["delete_notes", "read_note", "write_note"]);
18
+ assert.equal(cfg.policy.default, "DENY");
19
+ });
20
+
21
+ test("quickstart: read passes, write waits and then runs only after approval, refusals never run, receipts are signed", () => {
22
+ const r = spawnSync(process.execPath, [path.join(dir, "quickstart.mjs")], { encoding: "utf8", timeout: 60_000 });
23
+ assert.equal(r.status, 0, `quickstart exited ${r.status}\n${r.stdout}\n${r.stderr}`);
24
+ const out = r.stdout;
25
+ // The write had not run while it waited for a person.
26
+ assert.match(out, /notes file lines while paused: 2 \(was 2\) -> the write has not run/);
27
+ // It ran only after approval.
28
+ assert.match(out, /result: appended; notes file lines now: 3/);
29
+ // A person's refusal and a policy denial both leave the file untouched.
30
+ assert.match(out, /ran: false; the client was told: .*write_note.* denied/);
31
+ assert.match(out, /notes file lines: 3 \(unchanged\)/);
32
+ assert.match(out, /ran: false; the client was told: .*delete_notes.* denied/);
33
+ assert.match(out, /notes file still exists: true/);
34
+ // Four receipts, in order, all signed.
35
+ const rec = [...out.matchAll(/^\s+(synthetic\.\w+)\s+decision=(\w+)\s+signed=(\w+)/gm)].map((m) => m.slice(1));
36
+ assert.deepEqual(rec, [
37
+ ["synthetic.read_note", "ALLOW", "true"],
38
+ ["synthetic.write_note", "ALLOW", "true"],
39
+ ["synthetic.write_note", "DENY", "true"],
40
+ ["synthetic.delete_notes", "DENY", "true"],
41
+ ]);
42
+ // The proof boundary is stated on screen.
43
+ assert.match(out, /does not by itself prove that the\s+downstream server executed/);
44
+ });