Skip to content

feat(client): AgentClient.from_mcp_client() factory for in-process MCP transport #291

@bokelley

Description

@bokelley

Context

JS client v5.19.0 added AgentClient.fromMCPClient() — a static factory that takes a pre-connected @modelcontextprotocol/sdk Client instance instead of a URL-based agent config. This lets compliance test fleets wire a full AgentClient against an InMemoryTransport pair without standing up a loopback HTTP server.

Python client has no equivalent today: ADCPClient / MCPAdapter always construct their own MCP client from a URL/headers config. Compliance tests that want to exercise the full client path against an in-process server have to either:

  • Spin up an HTTP loopback (slow + flaky)
  • Mock the adapter (defeats the purpose of integration coverage)

Proposal

Add ADCPClient.from_mcp_client(client, *, agent_id=None) (or equivalent on MCPAdapter) that wraps a pre-connected mcp.client.session.ClientSession. Keep semantics identical to the JS factory:

  • MCP only. No A2A equivalent yet (matches JS — JS notes that for A2A, run on a loopback). Don't try to model in-process A2A in this issue.
  • Caller owns the lifecycle of the wrapped client (no double-close).
  • All existing client surface (skills, signing, validation hooks) works unchanged through the factory path.

Out of scope

  • In-process A2A bridge (separate problem, separate issue if/when it matters)
  • Refactoring MCPAdapter internals beyond what's needed to accept an injected session

References

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions