@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.
- package/CHANGELOG.md +34 -0
- package/README.md +75 -25
- package/examples/controlled-launcher/README.md +33 -0
- package/examples/controlled-launcher/acceptance.mjs +337 -0
- package/examples/controlled-launcher/agent-client.mjs +18 -0
- package/examples/controlled-launcher/approval-relay.mjs +19 -0
- package/examples/controlled-launcher/approver.mjs +27 -0
- package/examples/controlled-launcher/authorizer.mjs +73 -0
- package/examples/controlled-launcher/bridge-client.mjs +8 -0
- package/examples/controlled-launcher/destination.mjs +18 -0
- package/examples/controlled-launcher/executor.mjs +74 -0
- package/examples/controlled-launcher/kernel-authority/acceptance.mjs +627 -0
- package/examples/controlled-launcher/kernel-authority/broker.mjs +83 -0
- package/examples/controlled-launcher/kernel-authority/derive.mjs +12 -0
- package/examples/controlled-launcher/kernel-authority/executor.mjs +105 -0
- package/examples/controlled-launcher/kernel-authority/reconcile.mjs +43 -0
- package/examples/controlled-launcher/kernel-authority/shim.mjs +38 -0
- package/examples/controlled-launcher/kernel-authority/signing-provider.mjs +137 -0
- package/examples/controlled-launcher/kernel-authority/strix-approver.mjs +73 -0
- package/examples/controlled-launcher/lib.mjs +63 -0
- package/examples/controlled-launcher/make-config.mjs +16 -0
- package/examples/controlled-launcher/proxy-host.mjs +19 -0
- package/examples/controlled-launcher/reconcile.mjs +30 -0
- package/examples/controlled-launcher/shim.mjs +32 -0
- package/examples/github-reference/README.md +34 -0
- package/examples/github-reference/acceptance.mjs +675 -0
- package/examples/github-reference/claims-matrix.md +34 -0
- package/examples/github-reference/demo-script.md +17 -0
- package/examples/github-reference/package-lock.json +1330 -0
- package/examples/github-reference/package.json +23 -0
- package/examples/github-reference/reuse-inventory.md +24 -0
- package/examples/synthetic-server/proxy-config.json +16 -0
- package/examples/synthetic-server/quickstart.mjs +98 -0
- package/examples/synthetic-server/server.mjs +54 -0
- package/package.json +6 -5
- package/test/package-contract.test.mjs +12 -0
- package/test/synthetic-quickstart.test.mjs +44 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Independent observer (separate OS identity, read-only credential). Reconciles executor-reported outcomes
|
|
3
|
+
// against destination state. Reports each attempt separately; it never infers success from a receipt.
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import crypto from "node:crypto";
|
|
7
|
+
import { canonicalizeJSON } from "./lib.mjs";
|
|
8
|
+
const [stateDir, destUrl, out] = process.argv.slice(2);
|
|
9
|
+
const jl = (f) => (fs.existsSync(f) ? fs.readFileSync(f, "utf8").trim().split("\n").filter(Boolean).map(JSON.parse) : []);
|
|
10
|
+
const jwk = JSON.parse(fs.readFileSync(path.join(stateDir, "outcome-jwks.json"), "utf8")).keys[0];
|
|
11
|
+
const pub = crypto.createPublicKey({ key: jwk, format: "jwk" });
|
|
12
|
+
const attempts = jl(path.join(stateDir, "attempts.jsonl")), outcomes = jl(path.join(stateDir, "outcomes.jsonl"));
|
|
13
|
+
const r = await fetch(destUrl + "/repos/synthetic/fixture/branches", { headers: { authorization: "Bearer " + process.env.OBSERVER_TOKEN } });
|
|
14
|
+
const observed = (await r.json()).branches ?? [];
|
|
15
|
+
const rows = [];
|
|
16
|
+
for (const a of attempts.filter((x) => x.state === "STARTED")) {
|
|
17
|
+
const o = outcomes.filter((x) => x.attemptId === a.attemptId).at(-1);
|
|
18
|
+
let sigOk = null;
|
|
19
|
+
if (o) { const { signingKeyId, signature, ...payload } = o; sigOk = crypto.verify(null, Buffer.from(canonicalizeJSON(payload), "utf8"), pub, Buffer.from(signature, "base64url")); }
|
|
20
|
+
const present = observed.includes(a.ref);
|
|
21
|
+
const reported = o?.status ?? "NO_OUTCOME_RECORDED";
|
|
22
|
+
let verdict;
|
|
23
|
+
if (reported === "SUCCEEDED") verdict = present ? "RECONCILED_CONSISTENT" : "INCONSISTENT_REPORTED_SUCCESS_NOT_OBSERVED";
|
|
24
|
+
else if (reported === "UNKNOWN" || reported === "NO_OUTCOME_RECORDED") verdict = present ? "RESOLVED_BY_OBSERVATION_EXECUTED" : "RESOLVED_BY_OBSERVATION_NOT_EXECUTED";
|
|
25
|
+
else verdict = present ? "INCONSISTENT_REPORTED_FAILURE_BUT_OBSERVED" : "RECONCILED_CONSISTENT";
|
|
26
|
+
rows.push({ attemptId: a.attemptId, authorizationId: a.authorizationId, ref: a.ref, executorReported: reported, outcomeSignatureValid: sigOk, destinationObservedRefPresent: present, verdict });
|
|
27
|
+
}
|
|
28
|
+
const unattributed = observed.filter((b) => b !== "main" && !attempts.some((a) => a.ref === b));
|
|
29
|
+
fs.writeFileSync(out, JSON.stringify({ observedAt: new Date().toISOString(), observedBranches: observed, attempts: rows, destinationBranchesWithNoAttemptRecord: unattributed }, null, 1));
|
|
30
|
+
console.log(JSON.stringify({ attempts: rows.length, inconsistent: rows.filter((x) => x.verdict.startsWith("INCONSISTENT")).length, unattributed }));
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Credential-free MCP upstream used by the published proxy. Holds NO downstream credential and NO signing key.
|
|
3
|
+
// For writes it claims a token for the exact payload from the authorizer and forwards to the executor.
|
|
4
|
+
// If it is subverted it can only ask the executor, which still requires a valid exact-payload token.
|
|
5
|
+
import readline from "node:readline";
|
|
6
|
+
import { call, payloadHash } from "./lib.mjs";
|
|
7
|
+
const [execSock, claimSock] = process.argv.slice(2);
|
|
8
|
+
const tools = [
|
|
9
|
+
{ name: "get_file_contents", description: "Read repository contents (synthetic).", inputSchema: { type: "object", properties: {} } },
|
|
10
|
+
{ name: "list_branches", description: "List branches.", inputSchema: { type: "object", properties: {} } },
|
|
11
|
+
{ name: "create_branch", description: "Create a branch.", inputSchema: { type: "object", properties: { owner: { type: "string" }, repo: { type: "string" }, branch: { type: "string" }, from_branch: { type: "string" } }, required: ["owner", "repo", "branch"] } },
|
|
12
|
+
{ name: "merge_pull_request", description: "Merge a pull request.", inputSchema: { type: "object", properties: { owner: { type: "string" }, repo: { type: "string" }, pull_number: { type: "number" } }, required: ["owner", "repo", "pull_number"] } },
|
|
13
|
+
];
|
|
14
|
+
const send = (m) => process.stdout.write(JSON.stringify(m) + "\n");
|
|
15
|
+
const text = (t, isError = false) => ({ content: [{ type: "text", text: t }], ...(isError ? { isError } : {}) });
|
|
16
|
+
async function toolCall(name, args = {}) {
|
|
17
|
+
let token;
|
|
18
|
+
if (name === "create_branch") {
|
|
19
|
+
const c = await call(claimSock, { op: "claim", payloadHash: payloadHash(args), capabilityId: "mcp.github.create_branch" }).catch((e) => ({ ok: false, error: String(e.message) }));
|
|
20
|
+
token = c.ok ? c.token : undefined;
|
|
21
|
+
}
|
|
22
|
+
const r = await call(execSock, { tool: name, args, token }).catch((e) => ({ ok: false, error: "EXECUTOR_UNREACHABLE", detail: e.message }));
|
|
23
|
+
return r.ok ? { content: r.content, ...(r.isError ? { isError: true } : {}) } : text(`refused: ${r.error}${r.detail ? " (" + r.detail + ")" : ""}`, true);
|
|
24
|
+
}
|
|
25
|
+
readline.createInterface({ input: process.stdin }).on("line", async (line) => {
|
|
26
|
+
let m; try { m = JSON.parse(line); } catch { return; }
|
|
27
|
+
if (m.id === undefined) return;
|
|
28
|
+
if (m.method === "initialize") return send({ jsonrpc: "2.0", id: m.id, result: { protocolVersion: m.params?.protocolVersion ?? "2024-11-05", capabilities: { tools: {} }, serverInfo: { name: "controlled-launcher-shim", version: "0.0.1" } } });
|
|
29
|
+
if (m.method === "tools/list") return send({ jsonrpc: "2.0", id: m.id, result: { tools } });
|
|
30
|
+
if (m.method === "tools/call") return send({ jsonrpc: "2.0", id: m.id, result: await toolCall(m.params?.name, m.params?.arguments) });
|
|
31
|
+
send({ jsonrpc: "2.0", id: m.id, error: { code: -32601, message: "method not found" } });
|
|
32
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# GitHub MCP reference demo — local fixture only
|
|
2
|
+
|
|
3
|
+
This demo composes the published Guard configuration surface, GitHub capability pack, MCP proxy, MCP adapter, tool gateway, and offline verifier against an in-memory MCP server. It never starts the GitHub MCP server, never reads a PAT, and never contacts GitHub. Its fixture data and `create_branch` outcomes are synthetic and must not be presented as GitHub activity.
|
|
4
|
+
|
|
5
|
+
The run demonstrates safe reads, a denied merge with zero downstream calls, a held/denied merge approval request, exact signed file approvals for harmless fixture writes, default-deny behavior for an unclassified destructive tool, persistence across proxy restart, independent receipt verification, and tamper detection. It also explicitly records that direct calls to an unwrapped upstream are outside the proxy's coverage.
|
|
6
|
+
|
|
7
|
+
## Run in a fresh consumer outside the repository
|
|
8
|
+
|
|
9
|
+
From a shell with Node.js 18 or newer and npm:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
REPO=/path/to/strix-platform
|
|
13
|
+
CONSUMER="$(mktemp -d)"
|
|
14
|
+
cp "$REPO/packages/strixgov-mcp-proxy/examples/github-reference/package.json" \
|
|
15
|
+
"$REPO/packages/strixgov-mcp-proxy/examples/github-reference/acceptance.mjs" \
|
|
16
|
+
"$CONSUMER/"
|
|
17
|
+
cp "$REPO/packages/strixgov-mcp-proxy/examples/github-reference/package-lock.json" "$CONSUMER/"
|
|
18
|
+
mkdir -p "$REPO/docs/evidence/github-mcp-reference-demo/run"
|
|
19
|
+
cd "$CONSUMER"
|
|
20
|
+
npm ci --ignore-scripts
|
|
21
|
+
STRIX_EVIDENCE_DIR="$REPO/docs/evidence/github-mcp-reference-demo/run" npm test
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
`npm ci` installs the exact versions in the lockfile. The run writes sanitized scenario results, published package versions, policy and capability revisions, exact approval requests and signed responses, consumption status, signed proxy receipts and execution outcomes, the public verification JWK, fixture invocation/outcome logs, independent verifier output/exit codes, and SHA-256 sums under `STRIX_EVIDENCE_DIR`. Private keys and the temporary Guard approver key stay under a temporary OS directory and are deleted after the run. The actual run should be performed from a temporary consumer, not by installing into the repository workspace.
|
|
25
|
+
|
|
26
|
+
The generated JSONL receipt chain is verified by the installed `@strixgov/verifier@1.25.0` artifact. Its tampered copy must fail verification. Versions are pinned in package.json and package-lock.json; the runner prints the installed version it actually used.
|
|
27
|
+
|
|
28
|
+
## What this demo does not establish
|
|
29
|
+
|
|
30
|
+
It is not an end-to-end GitHub integration or a production merge exercise. The published proxy is Mode 1/2: it enforces policy and signed file approvals, but it does not enforce the Mode-3 execution authorization token. The existing `github.pr.merge` PEP is reference-only and has no production caller; the official MCP `merge_pull_request` tool shape lacks a provider-side atomic head-SHA precondition. Therefore this harness intentionally does not approve or execute a merge and marks the exact-merge acceptance path blocked. The PEP's passing source tests are not substituted for a published, signed, integrated execution path.
|
|
31
|
+
|
|
32
|
+
A proxy receipt is interception evidence for a governed request. A fixture handler log and signed `SUCCEEDED` outcome are evidence only of a synthetic local fixture operation. Neither is evidence that GitHub executed a mutation. A valid signature proves integrity under the included local public key, not independent trust in the key's origin or in the business outcome.
|
|
33
|
+
|
|
34
|
+
See [the claims matrix](claims-matrix.md), [reuse inventory](reuse-inventory.md), and [limited two-minute talk track](demo-script.md) for safe external wording and the remaining blockers. The external artifact audit is at `docs/evidence/github-mcp-reference-demo/audit-notes.md`.
|