adk_mcp_client (erlang_adk v0.10.0)

View Source

Bounded MCP client for legacy stdio/Streamable HTTP and the explicit stateless 2026-07-28 Streamable HTTP era.

Each connection is an independent OTP worker. When erlang_adk is running, workers are temporary children of adk_mcp_client_sup; callers are never linked to remote MCP process failures.

Summary

Functions

Start a bounded FIFO pool of independently managed MCP clients.

Issue a negotiated method while keeping protocol metadata internal.

Build an adk_tool_executor-compatible call. Invocation context is not forwarded to the remote server, preventing scoped state or credential references from becoming MCP arguments accidentally.

Return MCP tools in the provider-facing adk_tool schema shape. This callback follows adk_toolset's list contract; discovery failure raises a bounded error which adk_toolset converts to toolset_unavailable rather than silently creating an agent with no remote tools.

Types

options/0

-type options() :: map().

Functions

close(Client)

-spec close(pid()) -> ok.

close_pool(Pool)

-spec close_pool(pid()) -> ok.

code_change(OldVersion, State, Extra)

complete(Client, Reference, Argument)

-spec complete(pid(), map(), map()) -> {ok, map()} | {error, term()}.

connect(Transport, Target)

-spec connect(binary(), binary()) -> {ok, pid()} | {error, term()}.

connect(Transport, Target, Options)

-spec connect(binary(), binary(), options()) -> {ok, pid()} | {error, term()}.

connect_pool(Transport, Target, Options)

-spec connect_pool(binary(), binary(), map()) -> {ok, pid()} | {error, term()}.

Start a bounded FIFO pool of independently managed MCP clients.

create_message(Client, Params)

-spec create_message(pid(), map()) -> {ok, map()} | {error, term()}.

elicit(Client, Params)

-spec elicit(pid(), map()) -> {ok, map()} | {error, term()}.

execute_tool(Client, ToolName, Args)

-spec execute_tool(pid(), binary(), map()) -> {ok, map()} | {error, term()}.

format_status(Status)

get_prompt(Client, Name, Arguments)

-spec get_prompt(pid(), binary(), map()) -> {ok, map()} | {error, term()}.

handle_call(Request, From, State)

handle_cast(Message, State)

handle_info(Info, State)

init(_)

list_prompts(Client)

-spec list_prompts(pid()) -> {ok, [map()]} | {error, term()}.

list_prompts(Client, Cursor)

-spec list_prompts(pid(), undefined | binary()) -> {ok, map()} | {error, term()}.

list_resources(Client)

-spec list_resources(pid()) -> {ok, [map()]} | {error, term()}.

list_resources(Client, Cursor)

-spec list_resources(pid(), undefined | binary()) -> {ok, map()} | {error, term()}.

list_roots(Client)

-spec list_roots(pid()) -> {ok, map()} | {error, term()}.

list_tools(Client)

-spec list_tools(pid()) -> {ok, [map()]} | {error, term()}.

list_tools(Client, Cursor)

-spec list_tools(pid(), undefined | binary()) -> {ok, map()} | {error, term()}.

read_resource(Client, Uri)

-spec read_resource(pid(), binary()) -> {ok, map()} | {error, term()}.

request(Client, Method, Params)

-spec request(pid(), binary(), map()) -> {ok, map()} | {error, term()}.

Issue a negotiated method while keeping protocol metadata internal.

resolved_call(Client, Name, Args, Context)

-spec resolved_call(pid(), binary(), map(), map()) -> {ok, map()} | {error, term()}.

Build an adk_tool_executor-compatible call. Invocation context is not forwarded to the remote server, preventing scoped state or credential references from becoming MCP arguments accidentally.

schemas(Client)

-spec schemas(pid()) -> [map()].

Return MCP tools in the provider-facing adk_tool schema shape. This callback follows adk_toolset's list contract; discovery failure raises a bounded error which adk_toolset converts to toolset_unavailable rather than silently creating an agent with no remote tools.

server_info(Client)

-spec server_info(pid()) -> {ok, map()} | {error, term()}.

set_log_level(Client, Level)

-spec set_log_level(pid(), binary()) -> {ok, map()} | {error, term()}.

start_link(Init)

-spec start_link(term()) -> gen_server:start_ret().

subscribe(Client, Notifications)

-spec subscribe(pid(), map()) -> {ok, map()} | {error, term()}.

subscribe_resource(Client, Uri)

-spec subscribe_resource(pid(), binary()) -> {ok, map()} | {error, term()}.

terminate(Reason, State)

unsubscribe_resource(Client, Uri)

-spec unsubscribe_resource(pid(), binary()) -> {ok, map()} | {error, term()}.

with_client(Pool, Class, Fun, Timeout)

-spec with_client(pid(), read_only | mutation, fun((pid()) -> term()), pos_integer()) -> term().