ADK.MCP.Client (ADK v0.0.1-alpha.1)

Copy Markdown View Source

MCP (Model Context Protocol) client over stdio transport.

Launches an MCP server as a subprocess, performs JSON-RPC initialization, and exposes list_tools/1 and call_tool/3 for protocol interaction.

Examples

{:ok, client} = ADK.MCP.Client.start_link(command: "npx", args: ["-y", "@modelcontextprotocol/server-everything"])
{:ok, tools} = ADK.MCP.Client.list_tools(client)
{:ok, result} = ADK.MCP.Client.call_tool(client, "echo", %{"message" => "hello"})

Summary

Functions

Call a tool on the MCP server.

Returns a specification to start this module under a supervisor.

Stop the client and terminate the subprocess.

List tools available on the MCP server.

Get server info from the initialization response.

Types

start_opt()

@type start_opt() ::
  {:command, String.t()}
  | {:args, [String.t()]}
  | {:env, [{String.t(), String.t()}]}
  | {:name, GenServer.name()}
  | {:timeout, pos_integer()}

Functions

call_tool(client, tool_name, arguments \\ %{})

@spec call_tool(GenServer.server(), String.t(), map()) ::
  {:ok, map()} | {:error, term()}

Call a tool on the MCP server.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

close(client)

@spec close(GenServer.server()) :: :ok

Stop the client and terminate the subprocess.

list_tools(client)

@spec list_tools(GenServer.server()) :: {:ok, [map()]} | {:error, term()}

List tools available on the MCP server.

server_info(client)

@spec server_info(GenServer.server()) :: {:ok, map()} | {:error, term()}

Get server info from the initialization response.

start_link(opts)

@spec start_link([start_opt()]) :: GenServer.on_start()