From ef69801a1cc968172c62ff88af3c8cdf6342f6e7 Mon Sep 17 00:00:00 2001 From: VrtxOmega <272921586+VrtxOmega@users.noreply.github.com> Date: Wed, 7 Oct 2026 10:25:45 -0500 Subject: [PATCH] Keep source MCP launch output protocol-only --- README.md | 2 +- docs/MCP.md | 6 +++++- src/core/mcp-submission.mjs | 2 +- test/mcp.test.mjs | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 78b71c4..9b27336 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Current public state: - Published on npm: [`premature-contribution-firewall`](https://www.npmjs.com/package/premature-contribution-firewall) with the `pcf` CLI, including `lifecycle`, and the `pcf-mcp` stdio server bin. - Published on the GitHub Marketplace as a read-only Action with two modes: `workflow_dispatch` queue artifact and `pull_request` PR gate (step-summary verdict, optional `fail-on` blocking, no GitHub writes). -- MCP server: `pcf-mcp` / `npm run mcp` exposes default-safe agent tools for scout, policy, repro, diff-shape, lane status/resume, evidence drafts, fixed local lane storage, and registry-readiness self-audit. Current release gates install the actual tarball and exercise its CLI/MCP command shims before publish. See [docs/MCP.md](docs/MCP.md). +- MCP server: `pcf-mcp` / `npm run --silent mcp` exposes default-safe agent tools for scout, policy, repro, diff-shape, lane status/resume, evidence drafts, fixed local lane storage, and registry-readiness self-audit. Current release gates install the actual tarball and exercise its CLI/MCP command shims before publish. See [docs/MCP.md](docs/MCP.md). - Contributor preflight: `pcf preflight` checks a draft PR or patch before submission, with a stable exit-code contract for hooks and CI. - Public contribution replay: [actual signals, misses, and source-versus-npm differences](docs/examples/public-contributions/README.md), with frozen public inputs and an offline runner. - Initial release post: [v0.1.0 read-only maintainer queue pilot](docs/RELEASE_POST_V0_1_0.md). diff --git a/docs/MCP.md b/docs/MCP.md index 642ad0d..5d20f17 100644 --- a/docs/MCP.md +++ b/docs/MCP.md @@ -33,9 +33,13 @@ Published v0.2.0 does not contain this validation. See the Run it from a source checkout: ```bash -npm run mcp +npm run --silent mcp ``` +Keep `--silent` when a client launches through npm: it suppresses npm's lifecycle +banners so stdout contains only MCP messages. The server can also be launched +directly with `node src/mcp/server.mjs` from the checkout root. + Smoke-check the stdio server before wiring an agent: ```bash diff --git a/src/core/mcp-submission.mjs b/src/core/mcp-submission.mjs index 44f2415..eee047d 100644 --- a/src/core/mcp-submission.mjs +++ b/src/core/mcp-submission.mjs @@ -145,7 +145,7 @@ export function buildMcpServerCard({ packageInfo, tools, resources, prompts }) { }, install: { npmPackage: packageInfo.name, - localCommand: "npm run mcp", + localCommand: "npm run --silent mcp", smokeCommand: "npm run mcp:smoke", clientConfig: { command: "npx", diff --git a/test/mcp.test.mjs b/test/mcp.test.mjs index 02698b2..d599334 100644 --- a/test/mcp.test.mjs +++ b/test/mcp.test.mjs @@ -97,6 +97,39 @@ test("submission readiness and server card expose registry-safe MCP posture", as assert.ok(card.submissionNotes.some((note) => /Glama/.test(note))); }); +test("server card source launch keeps stdout limited to MCP responses", { + skip: !process.env.npm_execpath && "Run with npm test to exercise the advertised npm launch" +}, async () => { + const card = JSON.parse((await readPcfMcpResource("pcf://mcp/server-card")).text); + const [command, ...args] = card.install.localCommand.split(/\s+/); + assert.equal(command, "npm"); + const requests = [ + { jsonrpc: "2.0", id: 1, method: "initialize", params: { protocolVersion: "2025-06-18" } }, + { jsonrpc: "2.0", id: 2, method: "ping", params: {} } + ]; + // Windows environment keys are case-insensitive. Remove every spelling so an + // inherited silent setting cannot hide lifecycle banners in the regression. + const launchEnv = Object.fromEntries(Object.entries(process.env) + .filter(([key]) => key.toLowerCase() !== "npm_config_loglevel")); + launchEnv.npm_config_loglevel = "notice"; + const launch = spawnSync(process.execPath, [process.env.npm_execpath, ...args], { + cwd: repoRoot, + env: launchEnv, + input: requests.map((request) => JSON.stringify(request)).join("\n") + "\n", + encoding: "utf8", + timeout: 15_000, + windowsHide: true + }); + assert.ifError(launch.error); + assert.equal(launch.status, 0, launch.stderr); + const responses = launch.stdout.trim().split(/\r?\n/).map((line) => JSON.parse(line)); + assert.equal(responses.length, requests.length); + assert.ok(responses.every((response) => response.jsonrpc === "2.0" && !response.error)); + assert.deepEqual(responses.map((response) => response.id), [1, 2]); + assert.equal(responses[0].result.serverInfo.name, card.packageName); + assert.deepEqual(responses[1].result, {}); +}); + test("scout ranks supplied contributor candidates without network collection", async () => { const scout = await callPcfMcpTool("pcf_scout", { generatedAt: "2026-06-11T20:00:00Z",