Skip to content

V2: Redesign HTTP client lifecycle management with MCPClient/Client approach #1773

@felixweinberger

Description

@felixweinberger

Context

Following discussion in #1177, @Kludex raised concerns about the current API approach for HTTP client handling.

Problem

The current pattern of accepting an HTTP client directly may not be the cleanest long-term approach. While many LLM providers do this, there are concerns about API sustainability.

Proposed Direction

Create an MCPClient/Client class that manages the lifecycle of the HTTP client internally, rather than accepting it as a parameter. This is similar to how Starlette's TestClient works.

Key points from @Kludex:

  • The SDK should manage HTTP client lifecycle internally
  • Could use composition (not necessarily inheritance)
  • Reference implementation: Starlette's TestClient pattern
  • Allow passing configuration parameters rather than the client itself

cc @Kludex @maxisbey


Reference: #1177


Update: This is being addressed as part of #1728 (ergonomic test client). We're creating a unified Client class that handles both in-memory testing and HTTP production use cases.

Metadata

Metadata

Labels

enhancementRequest for a new feature that's not currently supportedv2Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions