Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ env_vars = ["PROOFLINE_TOKEN"]

Create a personal token in the Proofline console for the organization you want to use. The token selects the organization, so no organization ID is needed. Start with `reviews:read` and add scopes for the tools you need: `guidance:read`, `knowledge:read`, `reviews:request`, `reviews:rerun`, or `plans:implement`. The server enforces each tool's scopes and repository access.

The default server URL is `https://proofline.sh`. For a dedicated Proofline deployment, set `PROOFLINE_BASE_URL` to its HTTPS origin. The package never opens a browser or stores credentials.
The default server URL is `https://proofline.sh`. An empty `PROOFLINE_BASE_URL` counts as unset. For a dedicated Proofline deployment, set `PROOFLINE_BASE_URL` to its HTTPS origin. Run `npx -y @proofline/mcp --check` to verify configuration without starting the stdio loop. The package never opens a browser or stores credentials.

## Tools and results

Expand Down
16 changes: 13 additions & 3 deletions scripts/packed-smoke.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,22 @@ import { tmpdir } from "node:os";
import { resolve, join } from "node:path";

const temporary = mkdtempSync(join(tmpdir(), "proofline-mcp-pack-"));
const npm = process.platform === "win32" ? "npm.cmd" : "npm";
function runNpm(args) {
const execPath = process.env.npm_execpath;
if (execPath) {
execFileSync(process.execPath, [execPath, ...args], { stdio: "inherit" });
return;
}
execFileSync("npm", args, {
stdio: "inherit",
shell: process.platform === "win32",
});
}
try {
execFileSync(npm, ["pack", "--ignore-scripts", "--pack-destination", temporary], { stdio: "inherit" });
runNpm(["pack", "--ignore-scripts", "--pack-destination", temporary]);
const archive = readdirSync(temporary).find((name) => name.endsWith(".tgz"));
if (!archive) throw new Error("npm pack produced no archive");
execFileSync(npm, ["install", "--prefix", temporary, "--ignore-scripts", "--no-audit", "--no-fund", join(temporary, archive)], { stdio: "inherit" });
runNpm(["install", "--prefix", temporary, "--ignore-scripts", "--no-audit", "--no-fund", join(temporary, archive)]);
const binary = join(temporary, "node_modules", "@proofline", "mcp", "src", "cli.js");
execFileSync(process.execPath, ["--test", resolve("tests/bridge.test.js")], {
stdio: "inherit", env: { ...process.env, PROOFLINE_MCP_TEST_BIN: binary },
Expand Down
20 changes: 15 additions & 5 deletions src/bridge.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { once } from "node:events";
import { readFileSync } from "node:fs";

export const VERSION = JSON.parse(
readFileSync(new URL("../package.json", import.meta.url), "utf8"),
).version;
export const PROTOCOL = "2025-11-25";
const REQUEST_LIMIT = 8192;
const RESPONSE_LIMIT = 8 * 1024 * 1024;
Expand All @@ -20,14 +24,17 @@ export function configuration(env) {
if (!token || /[\s\x00-\x1f\x7f]/u.test(token)) {
throw new BridgeError("configuration: set PROOFLINE_TOKEN");
}
const raw = env.PROOFLINE_BASE_URL ?? "https://proofline.sh";
const raw = env.PROOFLINE_BASE_URL || "https://proofline.sh";
let origin;
try { origin = new URL(raw); } catch { throw new BridgeError("configuration: invalid origin"); }
const loopback =
origin.hostname === "localhost" ||
origin.hostname === "[::1]" ||
/^127\.\d+\.\d+\.\d+$/.test(origin.hostname);
if (raw !== raw.trim() || origin.username || origin.password || origin.search || origin.hash ||
origin.pathname !== "/" ||
!(origin.protocol === "https:" || (origin.protocol === "http:" &&
["127.0.0.1", "[::1]"].includes(origin.hostname)))) {
throw new BridgeError("configuration: require an HTTPS origin or loopback IP");
!(origin.protocol === "https:" || (origin.protocol === "http:" && loopback))) {
throw new BridgeError("configuration: require an HTTPS origin or loopback HTTP origin");
}
return { token, origin: origin.origin };
}
Expand All @@ -42,7 +49,9 @@ async function* frames(input) {
if (pending.length + end > REQUEST_LIMIT) throw new BridgeError("input", -32600);
pending = Buffer.concat([pending, bytes.subarray(0, end)]);
if (newline === -1) break;
yield pending;
const isBlank =
pending.length === 0 || (pending.length === 1 && pending[0] === 13);
if (!isBlank) yield pending;
pending = Buffer.alloc(0);
bytes = bytes.subarray(newline + 1);
}
Expand All @@ -66,6 +75,7 @@ async function post(frame, config, protocol, notification) {
"Content-Type": "application/json",
Accept: "application/json, text/event-stream",
Origin: config.origin,
"User-Agent": `proofline-mcp/${VERSION}`,
...(protocol ? { "MCP-Protocol-Version": protocol } : {}),
},
body: frame,
Expand Down
23 changes: 17 additions & 6 deletions src/cli.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
#!/usr/bin/env node
import { readFileSync } from "node:fs";
import { bridge, configuration } from "./bridge.js";
import { VERSION, bridge, configuration } from "./bridge.js";

const args = process.argv.slice(2);
if (args.length === 1 && args[0] === "--help") {
console.log("Usage: proofline-mcp\n\nSet PROOFLINE_TOKEN to a scoped Proofline token.\nOptional: PROOFLINE_BASE_URL (default https://proofline.sh).\nReads MCP JSON-RPC from stdin and writes responses to stdout.\nRequires Node.js 22 or later.");
console.log("Usage: proofline-mcp [--check | --help | --version]\n\nSet PROOFLINE_TOKEN to a scoped Proofline token.\nOptional: PROOFLINE_BASE_URL (default https://proofline.sh).\nReads MCP JSON-RPC from stdin and writes responses to stdout.\nRequires Node.js 22 or later.");
} else if (args.length === 1 && args[0] === "--version") {
console.log(JSON.parse(readFileSync(new URL("../package.json", import.meta.url))).version);
console.log(VERSION);
} else if (args.length === 1 && args[0] === "--check") {
try {
const config = configuration(process.env);
console.log(`Proofline MCP configuration valid (${config.origin}).`);
} catch (error) {
console.error(error instanceof Error ? error.message : "Invalid configuration.");
process.exitCode = 1;
}
} else if (args.length) {
console.error("Unknown arguments. Run proofline-mcp --help.");
process.exitCode = 1;
Expand All @@ -15,8 +22,12 @@ if (args.length === 1 && args[0] === "--help") {
const config = configuration(process.env);
process.exitCode = await bridge(process.stdin, process.stdout, process.stderr, config);
process.stdin.destroy();
} catch {
console.error("Proofline MCP configuration invalid. Set PROOFLINE_TOKEN and use an HTTPS origin for PROOFLINE_BASE_URL.");
} catch (error) {
console.error(
error instanceof Error
? error.message
: "Proofline MCP configuration invalid. Set PROOFLINE_TOKEN and use an HTTPS origin for PROOFLINE_BASE_URL.",
);
process.exitCode = 1;
}
}
55 changes: 55 additions & 0 deletions tests/bridge.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,58 @@ test("pre-initialize probes are answered without ending the session", async (t)
assert.deepEqual(outcome.responses[3], { jsonrpc: "2.0", id: 3, result: tools });
assert.deepEqual(fixture.requests.map((request) => request.method), ["initialize", "notifications/initialized", "tools/list"]);
});

test("empty PROOFLINE_BASE_URL counts as unset, localhost loopback and blank lines work, and --check reports safe config status", async (t) => {
const { configuration } = await import("../src/bridge.js");
assert.equal(configuration({ PROOFLINE_TOKEN: token, PROOFLINE_BASE_URL: "" }).origin, "https://proofline.sh");
assert.equal(configuration({ PROOFLINE_TOKEN: token, PROOFLINE_BASE_URL: "http://localhost:8080" }).origin, "http://localhost:8080");
assert.equal(configuration({ PROOFLINE_TOKEN: token, PROOFLINE_BASE_URL: "http://127.0.0.2:9000" }).origin, "http://127.0.0.2:9000");

const tools = { tools: [] };
const headers = [];
const srv = createServer(async (request, response) => {
headers.push(request.headers["user-agent"]);
let raw = "";
for await (const chunk of request) raw += chunk;
const body = JSON.parse(raw);
if (body.method === "initialize") return json(response, { jsonrpc: "2.0", id: body.id, result: { protocolVersion: protocol, capabilities: { tools: {} } } });
if (body.method === "notifications/initialized") { response.writeHead(202); return response.end(); }
json(response, { jsonrpc: "2.0", id: body.id, result: tools });
});
srv.listen(0, "127.0.0.1");
await once(srv, "listening");
t.after(() => { srv.closeAllConnections(); srv.close(); });
const localOrigin = `http://localhost:${srv.address().port}`;

const rawInput = `${JSON.stringify(initialize)}\n\r\n${JSON.stringify(notification)}\n\n${JSON.stringify({ jsonrpc: "2.0", id: 3, method: "tools/list" })}\r\n`;
const outcome = await run(localOrigin, rawInput);
assert.equal(outcome.code, 0);
assert.equal(outcome.stderr, "");
assert.deepEqual(outcome.responses.map((r) => r.id), ["init", 3]);
assert.ok(headers.every((ua) => typeof ua === "string" && ua.startsWith("proofline-mcp/")));

for (const args of [["--check"]]) {
const okChild = spawn(process.execPath, [binary, ...args], {
env: { ...process.env, PROOFLINE_TOKEN: token, PROOFLINE_BASE_URL: "" },
stdio: ["ignore", "pipe", "pipe"],
});
let out = "", err = "";
okChild.stdout.on("data", (c) => { out += c; });
okChild.stderr.on("data", (c) => { err += c; });
const [code] = await once(okChild, "close");
assert.equal(code, 0);
assert.match(out, /https:\/\/proofline\.sh/);
assert.equal(err, "");
assert.ok(!out.includes(token));

const badChild = spawn(process.execPath, [binary, ...args], {
env: { ...process.env, PROOFLINE_TOKEN: "", PROOFLINE_BASE_URL: "http://example.com" },
stdio: ["ignore", "pipe", "pipe"],
});
let badErr = "";
badChild.stderr.on("data", (c) => { badErr += c; });
const [badCode] = await once(badChild, "close");
assert.equal(badCode, 1);
assert.match(badErr, /PROOFLINE_TOKEN/);
}
});