Skip to content

Add timeout and retry options for connect() #2

@ctonneslan

Description

@ctonneslan

Add configurable timeout and automatic retry logic to connect().

Currently if a server is slow to respond or temporarily unavailable, the connection just fails. We should support:

const server = await connect("http://localhost:3000/mcp", {
  timeout: 10000,     // 10 second timeout
  retries: 3,         // retry up to 3 times
  retryDelay: 1000,   // 1 second between retries
});

Implementation notes:

  • Wrap the transport connection in a timeout using AbortController
  • On failure, retry with exponential backoff up to retries times
  • Throw a clear error message after all retries are exhausted

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions