Skip to content

Commit aabc19f

Browse files
BobDickinsonCopilot
andcommitted
mcpi: close CI coverage/build gaps found after typecheck fix unblocked them
The previous commit fixed verify:typecheck-coverage, which unblocked two CI jobs that had never run to completion on this branch before: the per-file branch-coverage gate and the externalized-dependency check. Coverage (clients/mcpi, >=90% branches per file): - server.ts, format-human.ts, and mcp.ts had branch coverage below the 90% gate. The gaps traced to two features added this session that had thin or subprocess-only test coverage: sessions/show's enrichment fields (era, serverInfo, capabilities, supportedVersions, instructions) and the --era flag (previously untested at all). - Added in-process tests (server.handle()/callDaemon() against a daemon constructed directly in the test file) instead of runMcp() subprocess calls, since subprocess code isn't visible to coverage instrumentation. Covers sessions/show's absent-field fallback paths and full success path, the --era auto/invalid-value paths, and the mcp.ts positional sessionArg fallback for sessions/show. Build gate (verify:bundle-externals): - mcpi's tsup entry is named mcp-bin.js (multi-entry config), not index.js like web/cli/tui, so the script's hardcoded index.js existence check reported "build/index.js is missing" for mcpi even after a real build. Added a per-client `entry` override (defaults to index.js) so mcpi's real entry file is checked. - Once buildable, the scan found @modelcontextprotocol/ext-apps (a root runtime dependency reachable through cli's noExternal reach-in) had been inlined into mcpi's bundle instead of staying external. cli and tui already list it as external; added the same entry to mcpi's tsup config. npm run validate and npm run coverage both pass cleanly at the repo root after these changes. Co-authored-by: Copilot <[email protected]>
1 parent 54d00b9 commit aabc19f

6 files changed

Lines changed: 75 additions & 4 deletions

File tree

‎clients/mcpi/__tests__/daemon-coverage.test.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ describe("daemon coverage", () => {
6161
});
6262
expect(badUse.ok).toBe(false);
6363

64+
// sessions/show with no `params` at all exercises the `request.params ??
65+
// {}` fallback; with no active session it still fails, same shape as
66+
// sessions/use above.
67+
const badShow = await server.handle({ id: "2b", op: "sessions/show" });
68+
expect(badShow.ok).toBe(false);
69+
6470
const unknown = await server.handle({
6571
id: "3",
6672
op: "nope" as never,
@@ -582,6 +588,20 @@ describe("daemon coverage", () => {
582588
expect(used.ok).toBe(true);
583589
expect(server.registry.idleRemainingMs()).toBeNull();
584590

591+
// sessions/show over the same live session — exercises the full case
592+
// body (serverInfo/protocolVersion/protocolEra/capabilities lookups)
593+
// in-process, where coverage instrumentation can see it.
594+
const shown = await server.handle({
595+
id: "s2",
596+
op: "sessions/show",
597+
params: { name: "s" },
598+
});
599+
expect(shown.ok).toBe(true);
600+
if (shown.ok) {
601+
const result = shown.result as { protocolVersion?: string };
602+
expect(result.protocolVersion).toBeTruthy();
603+
}
604+
585605
await new Promise<void>((resolve, reject) => {
586606
const socket = new net.Socket();
587607
socket.on("error", reject);

‎clients/mcpi/__tests__/format-session.test.ts‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,32 @@ describe("format-human", () => {
339339
expect(
340340
formatSessionInfoHuman({ name: "a", isMru: true, serverIdentity: "id" }),
341341
).toContain("Session `@a`");
342+
// sessions/show enrichment: era without a protocolVersion, serverInfo
343+
// without a version, empty capabilities, an empty/non-array
344+
// supportedVersions, and blank instructions each take the "nothing to
345+
// append" branch rather than the populated one exercised elsewhere.
346+
expect(
347+
formatSessionInfoHuman({
348+
name: "a",
349+
protocolEra: "legacy",
350+
serverInfo: { name: "demo" },
351+
capabilities: {},
352+
supportedVersions: [],
353+
instructions: "",
354+
}),
355+
).toMatch(/Era: legacy\nServer info: demo\nCapabilities: \(none\)/);
356+
expect(
357+
formatSessionInfoHuman({
358+
name: "a",
359+
protocolEra: undefined,
360+
protocolVersion: "2025-11-25",
361+
serverInfo: { name: "demo", version: "1.2.3" },
362+
supportedVersions: ["2025-11-25", "2025-06-18"],
363+
instructions: "Say hi.",
364+
}),
365+
).toMatch(
366+
/Era: unknown \(2025-11-25\)[\s\S]*demo v1\.2\.3[\s\S]*Supported versions: 2025-11-25, 2025-06-18[\s\S]*Instructions: Say hi\./,
367+
);
342368

343369
expect(
344370
formatAppInfoListHuman([

‎clients/mcpi/__tests__/mcp-coverage.test.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ describe("mcp.ts coverage", () => {
260260
"COV_FLAG=1",
261261
"--connect-timeout",
262262
"15000",
263+
"--era",
264+
"auto",
263265
"--format",
264266
"json",
265267
command,
@@ -269,6 +271,14 @@ describe("mcp.ts coverage", () => {
269271
);
270272
expectCliSuccess(adHoc);
271273

274+
// Invalid --era is rejected before any connection is attempted.
275+
const badEra = await runMcp(
276+
["connect", "--era", "bogus", "--format", "json", command, ...args],
277+
{ env: e, timeout: 20000 },
278+
);
279+
expectCliFailure(badEra);
280+
expect(badEra.stderr).toMatch(/Invalid --era/);
281+
272282
await runMcp(["disconnect", "--session", "opts", "--format", "json"], {
273283
env: e,
274284
});

‎clients/mcpi/__tests__/mcp-session.test.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,14 @@ describe("mcp session CLI", () => {
199199
expect(shownBody.protocolVersion).toBeTruthy();
200200
expect(shownBody.protocolEra).toBeTruthy();
201201

202+
// `sessions/show <name>` (positional, no `@name`/--session) exercises
203+
// the opts.session-absent fallback to the command's own argument.
204+
const shownByArg = await runMcp(
205+
["sessions/show", "test-stdio", "--format", "json"],
206+
{ env: e, timeout: 20000 },
207+
);
208+
expectCliSuccess(shownByArg);
209+
202210
await runMcp(
203211
["disconnect", "--session", "test-stdio", "--format", "json"],
204212
{

‎clients/mcpi/tsup.config.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export default defineConfig({
2626
"@napi-rs/keyring",
2727
"@modelcontextprotocol/client",
2828
"@modelcontextprotocol/core",
29+
"@modelcontextprotocol/ext-apps",
2930
"commander",
3031
"pino",
3132
"open",

‎scripts/verify-bundle-externals.mjs‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,12 @@ const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
3434

3535
/**
3636
* Clients that ship a tsup bundle, with the config to read `external` from and
37-
* the build directory to inspect. `clients/launcher` is plain `tsc` — it emits
38-
* no bundle and inlines nothing — so it has nothing to check.
37+
* the build directory to inspect. `entry` names the file whose presence
38+
* proves a build actually ran; it defaults to `index.js` (what web/cli/tui
39+
* each name their single tsup entry) and is overridden only when a client's
40+
* tsup config uses a different entry name, like mcpi's multi-entry `mcp-bin`.
41+
* `clients/launcher` is plain `tsc` — it emits no bundle and inlines nothing —
42+
* so it has nothing to check.
3943
*/
4044
export const BUNDLED_CLIENTS = [
4145
{
@@ -57,6 +61,7 @@ export const BUNDLED_CLIENTS = [
5761
name: "mcpi",
5862
config: "clients/mcpi/tsup.config.ts",
5963
build: "clients/mcpi/build",
64+
entry: "mcp-bin.js",
6065
},
6166
];
6267

@@ -210,10 +215,11 @@ function main() {
210215
);
211216
for (const client of BUNDLED_CLIENTS) {
212217
const buildDir = join(repoRoot, client.build);
213-
const entry = join(buildDir, "index.js");
218+
const entryName = client.entry ?? "index.js";
219+
const entry = join(buildDir, entryName);
214220
if (!existsSync(entry)) {
215221
failures.push(
216-
`${client.name}: ${client.build}/index.js is missing — run \`npm run build\` first.`,
222+
`${client.name}: ${client.build}/${entryName} is missing — run \`npm run build\` first.`,
217223
);
218224
continue;
219225
}

0 commit comments

Comments
 (0)