Skip to content

Commit c81772a

Browse files
committed
test(mcp): pin the operator session lock on every MCP tool
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016qAu53rMak1bXMuR5U2gF4
1 parent 4ca194a commit c81772a

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

‎src/mcp/__tests__/command-tools-session-lock.test.ts‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import assert from 'node:assert/strict';
22
import { afterEach, test, vi } from 'vitest';
33
import type { AgentDeviceClientConfig } from '@agent-device/contracts/client';
44
import type { AgentDeviceClient } from '@agent-device/command-surface';
5+
import { listMcpExposedCommandNames } from '@agent-device/command-registry/registry';
56
import { createCommandToolExecutor } from '../command-tools.ts';
67

78
afterEach(() => {
@@ -28,10 +29,24 @@ async function clientConfigFor(input: Record<string, unknown>): Promise<AgentDev
2829
test('AGENT_DEVICE_SESSION_LOCK sets the lock policy of every tool call', async () => {
2930
vi.stubEnv('AGENT_DEVICE_SESSION', 'qa');
3031
vi.stubEnv('AGENT_DEVICE_SESSION_LOCK', 'strip');
32+
const policies = new Map<string, unknown>();
33+
let current = '';
34+
const executor = createCommandToolExecutor({
35+
createClient: (config) => {
36+
policies.set(current, config.lockPolicy);
37+
return {} as AgentDeviceClient;
38+
},
39+
runCommand: async () => ({ ok: true }),
40+
});
3141

32-
const config = await clientConfigFor({});
42+
// Every tool, including ones such as `test` and `devices` that declare few flags of their own.
43+
for (const name of listMcpExposedCommandNames()) {
44+
current = name;
45+
await executor.execute(name, {});
46+
}
3347

34-
assert.equal(config.lockPolicy, 'strip');
48+
assert.equal(policies.size, listMcpExposedCommandNames().length);
49+
for (const [name, policy] of policies) assert.equal(policy, 'strip', name);
3550
});
3651

3752
test('AGENT_DEVICE_SESSION turns on the reject lock bound to AGENT_DEVICE_PLATFORM', async () => {

0 commit comments

Comments
 (0)