OpenResponses.MCP.Connection (OpenResponses v0.1.1)

View Source

Connection to a Model Context Protocol (MCP) server.

One Connection process is started per MCP server per request. It fetches the server's tool list on startup and proxies tool calls on behalf of the agentic loop.

Usage

Per-request MCP servers are specified in the API request body:

{
  "model": "gpt-4o",
  "tools": [{"type": "mcp", "server_url": "https://my-mcp.example.com"}],
  "input": [{"role": "user", "content": "Search for recent news"}]
}

Pre-configured servers available to all requests can be set in config:

config :open_responses, :mcp_servers, [
  %{
    name: "docs",
    url: "https://docs-mcp.example.com",
    headers: [{"authorization", "Bearer #{System.get_env("MCP_TOKEN")}"}]
  }
]

See the MCP Integration guide for the full protocol and authentication details.

Summary

Functions

Returns a specification to start this module under a supervisor.

Functions

call_tool(pid, name, arguments)

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

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

list_tools(pid)

@spec list_tools(pid()) :: {:ok, list()} | {:error, term()}

start_link(opts)

@spec start_link(keyword()) :: GenServer.on_start()