Skip to content

Commit 2a4e795

Browse files
committed
fix(server): skip host lookup when device tools omit it
1 parent 5f077f0 commit 2a4e795

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

‎apps/server/src/mcp/McpHttpServer.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ const callSnapshot = (args: Record<string, unknown>) => callTool("preview_snapsh
146146
it.effect.each([
147147
{ input: {}, open: false, message: "No device is open in this thread. Call device_open first." },
148148
{
149-
input: { deviceId: "missing", hostId: "local" },
149+
input: { deviceId: "missing" },
150150
open: false,
151151
message: "Device missing is not open in this thread. Call device_open first.",
152152
},

‎apps/server/src/mcp/toolkits/device/handlers.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,10 @@ const handlers = {
297297
const scope = yield* requireDeviceAccess;
298298
const devices = yield* DeviceService.DeviceService;
299299
const threadId = scope.thread.threadId;
300-
const hostId = yield* resolveHostId((yield* devices.state).hosts, input.hostId);
300+
const hostId =
301+
input.hostId === undefined
302+
? undefined
303+
: yield* resolveHostId((yield* devices.state).hosts, input.hostId);
301304
const target =
302305
input.deviceId === undefined
303306
? (yield* devices.sessionsForThread(threadId)).findLast(
@@ -332,7 +335,10 @@ const handlers = {
332335
const scope = yield* requireDeviceAccess;
333336
const devices = yield* DeviceService.DeviceService;
334337
const deviceId = input.deviceId;
335-
const inputHostId = yield* resolveHostId((yield* devices.state).hosts, input.hostId);
338+
const inputHostId =
339+
input.hostId === undefined
340+
? undefined
341+
: yield* resolveHostId((yield* devices.state).hosts, input.hostId);
336342
const open =
337343
deviceId === undefined
338344
? Option.none()

0 commit comments

Comments
 (0)