Skip to content

ClientSession.initialize gets stuck if the MCP server process exits #428

Description

@evilsocket

Describe the bug

I'm using the brave_search MCP server which exits(1) if BRAVE_API_KEY is not set. https://github.com/modelcontextprotocol/servers/blob/main/src/brave-search/index.ts#L85

This causes ClientSession.initialize to get stuck forever.

To Reproduce

Steps to reproduce the behavior:

Use brave_search without setting BRAVE_API_KEY.

Expected behavior

When the process of an stdio_client exits an exception should be raised.

Screenshots

From this client implementation https://github.com/evilsocket/nerve/blob/main/nerve/tools/mcp/client.py

Image

Activity

  1. changed the title [-]ClientSession.initialize gets stuck if server process exits[/-] [+]ClientSession.initialize gets stuck if the MCP server process exits[/+] on Apr 4, 2025
  2. evilsocket commented on Apr 4, 2025

    @evilsocket
    Author

    ( i'm aware there's a read_timeout argument, but imo failure in initialization and especially if the process dies should be handled with its own check )

  3. mroch commented on Apr 14, 2025

    @mroch
    Contributor

    I think this is a duplicate of #332

  4. evilsocket commented on Apr 14, 2025

    @evilsocket
    Author

    @mroch yep totally, apologies somehow i couldn't find it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions