Condukt.MCP.Client (Condukt v1.4.1)

Copy Markdown View Source

GenServer that owns the protocol state for a single MCP server connection.

The process spawns the configured transport, performs the initialize / notifications/initialized / tools/list handshake, and then services synchronous tool calls from callers.

In normal use, callers do not interact with this module directly: Condukt.MCP.start_all/2 builds a list of clients and turns each server's tools into Condukt.Tool.Inline specs ready to drop into an agent or workflow tool list. Use start_link/2 directly when you need finer control.

Summary

Functions

Calls a tool on the connected server. The result is the raw content block returned by the server, normalized into a single string when the server returns text-only content. Errors include both transport errors and isError: true tool responses.

Returns a specification to start this module under a supervisor.

Returns the serverInfo block returned by the server during the initialize handshake.

Starts a client and blocks the caller until the connection is ready or fails.

Stops the client and closes the underlying transport.

Returns the cached tools/list descriptors discovered during initialization.

Functions

call_tool(client, name, args, opts \\ [])

Calls a tool on the connected server. The result is the raw content block returned by the server, normalized into a single string when the server returns text-only content. Errors include both transport errors and isError: true tool responses.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

server_info(client)

Returns the serverInfo block returned by the server during the initialize handshake.

start_link(server, opts \\ [])

Starts a client and blocks the caller until the connection is ready or fails.

Options:

  • :name - register the GenServer under a name
  • :fetch_env - injection point for env-backed auth/secret refs (testing)
  • :token_request - injection point for the OAuth token endpoint (testing)
  • :sse_request / :http_request - injection points for the HTTP transports (testing)

stop(client)

Stops the client and closes the underlying transport.

tools(client)

Returns the cached tools/list descriptors discovered during initialization.