Skip to content

Add timeout and AbortSignal to client.callTool in realtimeMcpTools.ts #1102

Description

@coderabbitai

Summary

The client.callTool invocation in src/lib/voice/livekit/realtimeMcpTools.ts (around line 183) lacks a bounded timeout and AbortSignal. A stalled MCP server will hang the realtime voice turn indefinitely, delaying or omitting the tool-result event.

Proposed Fix

Pass a third RequestOptions argument to client.callTool (supported by @modelcontextprotocol/sdk):

const result = await client.callTool(
  { name: mcpTool.name, arguments: args ?? {} },
  undefined,          // use the default result schema
  { timeout: 30_000 } // 30 s hard cap per tool call
);

Optionally, thread an AbortSignal for cancellability when the user interrupts:

{ timeout: 30_000, signal: someAbortController.signal }

Alternatively, apply the withTimeout pattern already used in src/lib/mcp/toolDiscoveryService.ts.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions