Skip to content

Commit 658f822

Browse files
authored
fix: encode the mcp subcommand in server.json package arguments (#2275)
* fix: encode the mcp subcommand in server.json package arguments A registry-format launcher (e.g. one consuming /.well-known/mcp.json or the MCP registry entry) starts the server from the package descriptor only; without the positional "mcp" argument it runs the bare CLI instead of the stdio MCP server (bin.ts only starts the MCP server for the mcp subcommand). Enforce the argument in scripts/sync-mcp-metadata.mjs so sync and the CI/prepack checks (check:mcp-metadata) keep server.json correct, and regenerate server.json. * test: own the registry launch-argument invariant; add changelog entry - scripts/__tests__/mcp-metadata.test.ts asserts the checked-in server.json's agent-device npm package entry declares the exact fixed positional mcp argument (and stays stdio-only), so a missing or wrong argument fails the unit lane in both directions. Wired into the unit-core project include list. - Changelog: user-visible release fix under Unreleased.
1 parent 33084c7 commit 658f822

5 files changed

Lines changed: 66 additions & 3 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@
1818
writing `airplane_mode_on` and broadcasting `ACTION_AIRPLANE_MODE_CHANGED` — a broadcast Android
1919
refuses for non-system callers, so the old path failed *after* writing the setting and left the
2020
device reporting airplane mode with the network still up (#2223). The response now reports the
21-
`airplaneMode` the connectivity service holds after the change, and an Android build that does not
22-
expose that command is refused with `UNSUPPORTED_OPERATION` before anything is written.
21+
`airplaneMode` the connectivity service holds after the change, and an Android build that does not
22+
expose that command is refused with `UNSUPPORTED_OPERATION` before anything is written.
23+
- Fixed: the MCP registry entry (`server.json`) now declares the fixed `mcp` subcommand via
24+
`packageArguments`, so a registry-format launcher — the MCP Registry or the website's
25+
`/.well-known/mcp.json` discovery manifest — starts the stdio MCP server. Previously it ran
26+
`agent-device` with no subcommand, i.e. the bare CLI (#2275).
2327
- Breaking (0.21): iOS Appium/WebDriver snapshots now expose engine-owned acquisition facts and
2428
typed fidelity warnings. The SDK snapshot `truncated` field is optional when Appium cannot report
2529
hierarchy completeness; regular snapshots fail closed without valid viewport evidence, while
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* Guard for the registry-format launch argument.
3+
*
4+
* The MCP registry entry (and the website's `/.well-known/mcp.json` discovery manifest) tell a
5+
* launcher how to start the server: the npm package, the stdio transport, and
6+
* `packageArguments`. Without the fixed `mcp` positional argument, a client that honors the
7+
* manifest runs `agent-device` with no subcommand — the bare CLI — instead of the stdio MCP
8+
* server (`src/bin.ts` only starts the server for the `mcp` subcommand).
9+
*
10+
* `check:mcp-metadata` compares the file against a regeneration, which proves the corrected file
11+
* is self-consistent; this test owns the invariant directly against the checked-in file and fails
12+
* in both directions — a missing argument and a wrong one.
13+
*/
14+
import assert from 'node:assert/strict';
15+
import { readFile } from 'node:fs/promises';
16+
import { join } from 'node:path';
17+
import { test } from 'vitest';
18+
19+
const ROOT = join(import.meta.dirname, '..', '..');
20+
21+
const EXPECTED_MCP_PACKAGE_ARGUMENTS = [{ type: 'positional', value: 'mcp' }];
22+
23+
type ServerPackage = {
24+
registryType?: string;
25+
identifier?: string;
26+
transport?: { type?: string };
27+
packageArguments?: unknown;
28+
};
29+
30+
test('the published registry entry starts the MCP server, not the bare CLI', async () => {
31+
const pkg = JSON.parse(await readFile(join(ROOT, 'package.json'), 'utf8')) as {
32+
name: string;
33+
};
34+
const server = JSON.parse(await readFile(join(ROOT, 'server.json'), 'utf8')) as {
35+
packages?: ServerPackage[];
36+
};
37+
38+
const entry = (server.packages ?? []).find((candidate) => candidate.identifier === pkg.name);
39+
assert.ok(entry, `server.json must describe the ${pkg.name} npm package`);
40+
assert.equal(entry.registryType, 'npm');
41+
assert.deepEqual(entry.transport, { type: 'stdio' });
42+
43+
assert.deepEqual(
44+
entry.packageArguments,
45+
EXPECTED_MCP_PACKAGE_ARGUMENTS,
46+
'registry-format launchers must start the stdio MCP server; without the fixed mcp subcommand they run the bare CLI',
47+
);
48+
});

‎scripts/sync-mcp-metadata.mjs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const server = readJson(serverPath);
1212
const expectedName = pkg.mcpName;
1313
const expectedVersion = pkg.version;
1414
const registryDescriptionMaxLength = 100;
15+
const mcpPackageArguments = [{ type: 'positional', value: 'mcp' }];
1516

1617
if (typeof expectedName !== 'string' || expectedName.length === 0) {
1718
fail('package.json must define mcpName.');
@@ -32,6 +33,7 @@ if (Array.isArray(server.packages)) {
3233
for (const packageEntry of server.packages) {
3334
if (packageEntry?.identifier === pkg.name) {
3435
packageEntry.version = expectedVersion;
36+
packageEntry.packageArguments = mcpPackageArguments;
3537
}
3638
}
3739
}

‎server.json‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@
1515
"version": "0.20.11-dev",
1616
"transport": {
1717
"type": "stdio"
18-
}
18+
},
19+
"packageArguments": [
20+
{
21+
"type": "positional",
22+
"value": "mcp"
23+
}
24+
]
1925
}
2026
]
2127
}

‎vitest.config.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ export default defineConfig({
147147
// Publish preparation spawns only fixture-owned scripts and proves both Android
148148
// helper families are rebuilt through the shared release/size-report owner.
149149
'scripts/__tests__/prepare-publish-assets.test.ts',
150+
// Parse-only guard on the checked-in registry entry: the npm package must declare
151+
// the fixed mcp subcommand, or registry-format launchers run the bare CLI.
152+
'scripts/__tests__/mcp-metadata.test.ts',
150153
'scripts/ios-snapshot-benchmark/*.test.ts',
151154
'scripts/ios-ax-bridge-spike/*.test.ts',
152155
// Parses CI configuration only, so this action guard needs no device or subprocess lane.

0 commit comments

Comments
 (0)