Skip to content

[BUG] Indefinite Hang on MCP Tool Execution #691

@sysprime10001

Description

@sysprime10001

Project

cortex

Description

The Cortex CLI does not enforce the global timeout configuration when awaiting responses from Model Context Protocol (MCP) tools. If a connected MCP server hangs or takes longer than the configured timeout to return a tool result, the main CLI process blocks indefinitely waiting for the response.

Error Message

There is no error message; the CLI enters a non-responsive state with a loading spinner that spins indefinitely until manually terminated.

Debug Logs

System Information

## Operating System
  OS: Windows 11

## Hardware
  CPU: Intel(R) Xeon(R) E-2388G CPU @ 3.20GHz (16 cores)
  RAM: 125 GB

## Build Environment
  Rust: rustc 1.92.0 (ded5c06cf 2025-12-08)
  Target: x86_64

## Additional Context
This behavior indicates a missing `tokio::time::timeout` wrapper around the MCP client's request handling logic. The issue is strictly reproducible and violates the expected fault-tolerance specification of the application. It represents a critical reliability flaw in the integration of third-party MCP servers.

Screenshots

No response

Steps to Reproduce

  1. Configure cortex with a strict timeout using cortex config set timeout 5.
  2. Connect a custom MCP server that implements a tool with an intentional 20-second delay (e.g., a sleep function).
  3. Start a chat session and instruct the agent to invoke this specific tool.
  4. Observe the CLI behavior after 5 seconds have passed.

Expected Behavior

The tool execution should be aborted after the configured 5-second timeout, returning a timeout error to the agent context so it can handle the failure gracefully.

Actual Behavior

The CLI ignores the global timeout setting for MCP transport layers, causing the application to hang until the external tool finishes or the user kills the process.

Additional Context

This behavior indicates a missing tokio::time::timeout wrapper around the MCP client's request handling logic. The issue is strictly reproducible and violates the expected fault-tolerance specification of the application. It represents a critical reliability flaw in the integration of third-party MCP servers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions