Skip to content

Commit 72f65bb

Browse files
committed
chore: keep mcp config out of command contracts
1 parent 4e7c612 commit 72f65bb

3 files changed

Lines changed: 21 additions & 5 deletions

File tree

src/commands/command-input.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,6 @@ function commonProperties(): Record<string, JsonSchema> {
584584
type: 'string',
585585
description: 'Android serial allowlist used for device resolution.',
586586
},
587-
stateDir: { type: 'string', description: 'Agent-device state directory.' },
588587
daemonBaseUrl: { type: 'string', description: 'Remote daemon base URL.' },
589588
daemonAuthToken: { type: 'string', description: 'Remote daemon auth token.' },
590589
tenant: { type: 'string', description: 'Remote tenant identifier.' },

src/mcp/__tests__/command-tools.test.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import assert from 'node:assert/strict';
22
import { test } from 'vitest';
33
import type { AgentDeviceClient } from '../../client-types.ts';
4-
import { createCommandToolExecutor } from '../command-tools.ts';
4+
import { createCommandToolExecutor, listCommandTools } from '../command-tools.ts';
55

66
test('MCP command tool executor hides client creation behind an execution adapter', async () => {
77
const client = {} as AgentDeviceClient;
@@ -31,3 +31,10 @@ test('MCP command tool executor hides client creation behind an execution adapte
3131
assert.deepEqual(result.structuredContent, { name: 'devices', ok: true });
3232
assert.match(result.content[0]?.text ?? '', /"name": "devices"/);
3333
});
34+
35+
test('MCP tool schemas add MCP client config fields at the MCP boundary', () => {
36+
const devicesTool = listCommandTools().find((tool) => tool.name === 'devices');
37+
38+
assert.ok(devicesTool);
39+
assert.ok('stateDir' in (devicesTool.inputSchema.properties ?? {}));
40+
});

src/mcp/command-tools.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
} from '../commands/command-surface.ts';
99
import type { JsonSchema } from '../commands/command-contract.ts';
1010

11-
export type ToolResult = {
11+
type ToolResult = {
1212
isError: boolean;
1313
structuredContent?: unknown;
1414
content: Array<{ type: 'text'; text: string }>;
@@ -19,7 +19,7 @@ type CommandToolExecutorDeps = {
1919
runCommand: (client: AgentDeviceClient, name: CommandName, input: unknown) => Promise<unknown>;
2020
};
2121

22-
export type CommandToolExecutor = {
22+
type CommandToolExecutor = {
2323
execute: (name: string, input: unknown) => Promise<ToolResult>;
2424
};
2525

@@ -31,7 +31,7 @@ export function listCommandTools(): Array<{
3131
return listMcpToolDefinitions().map((definition) => ({
3232
name: definition.name,
3333
description: definition.description,
34-
inputSchema: definition.inputSchema,
34+
inputSchema: withMcpConfigSchema(definition.inputSchema),
3535
}));
3636
}
3737

@@ -75,6 +75,16 @@ function stripClientConfigFields(input: unknown): unknown {
7575
return commandInput;
7676
}
7777

78+
function withMcpConfigSchema(schema: JsonSchema): JsonSchema {
79+
return {
80+
...schema,
81+
properties: {
82+
...schema.properties,
83+
stateDir: { type: 'string', description: 'Agent-device state directory.' },
84+
},
85+
};
86+
}
87+
7888
function renderToolText(value: unknown): string {
7989
return typeof value === 'string' ? value : JSON.stringify(value, null, 2);
8090
}

0 commit comments

Comments
 (0)