AgentSea.MCP (agentsea_mcp v0.1.0)

Copy Markdown

Model Context Protocol integration: connect to an MCP server and expose its tools to an AgentSea agent.

Example

# `transport` is any (method, params) -> {:ok, result} | {:error, reason}
{:ok, client} =
  AgentSea.MCP.connect({AgentSea.MCP.Transport.Function, transport})

tools = AgentSea.MCP.to_tool_specs(client)
# add `tools` to an AgentSea.Agent's config — the model can now call them

Summary

Functions

Start an MCP client for a {transport_module, ref}.

Connect to an MCP server over Streamable HTTP. url is the server endpoint; :headers and :adapter are forwarded to the transport. Returns {:ok, client}.

Connect to an MCP server subprocess over stdio. command is [executable | args] (e.g. ["node", "server.js"]). Returns {:ok, client}.

Adapt the server's tools into AgentSea.Tool.Spec values an agent can use. Each spec's run calls the tool through the client.

Functions

connect(transport, opts \\ [])

@spec connect({module(), term()}, keyword()) :: GenServer.on_start()

Start an MCP client for a {transport_module, ref}.

connect_http(url, opts \\ [])

@spec connect_http(
  String.t(),
  keyword()
) :: GenServer.on_start()

Connect to an MCP server over Streamable HTTP. url is the server endpoint; :headers and :adapter are forwarded to the transport. Returns {:ok, client}.

connect_stdio(command, opts \\ [])

@spec connect_stdio(
  [String.t()],
  keyword()
) :: GenServer.on_start()

Connect to an MCP server subprocess over stdio. command is [executable | args] (e.g. ["node", "server.js"]). Returns {:ok, client}.

to_tool_specs(client)

@spec to_tool_specs(GenServer.server()) :: [AgentSea.Tool.Spec.t()]

Adapt the server's tools into AgentSea.Tool.Spec values an agent can use. Each spec's run calls the tool through the client.