CodexWrapper.Commands.Mcp (CodexWrapper v0.4.0)

Copy Markdown View Source

MCP (Model Context Protocol) server management commands.

Wraps codex mcp list|get|add|remove|login|logout.

Summary

Functions

Add an MCP server.

Get details for a specific MCP server.

List configured MCP servers.

Authenticate with an MCP server over OAuth.

Deauthenticate an MCP server.

Remove an MCP server.

Functions

add(config, name, atom, opts)

@spec add(CodexWrapper.Config.t(), String.t(), :stdio | :http, keyword()) ::
  {:ok, String.t()} | {:error, term()}

Add an MCP server.

Stdio transport

Mcp.add(config, "my-server", :stdio, command: "npx", args: ["-y", "server"], env: %{"KEY" => "val"})

HTTP transport

Mcp.add(config, "my-server", :http, url: "http://localhost:8080")

OAuth

:oauth_client_id and :oauth_resource are accepted on both transports; the CLI does not restrict them to one. They configure the OAuth exchange that login/3 later performs.

Mcp.add(config, "remote", :http,
  url: "https://example.com/mcp",
  oauth_client_id: "codex-cli",
  oauth_resource: "https://example.com"
)

Options

  • :oauth_client_id - OAuth client identifier for this server
  • :oauth_resource - OAuth resource parameter to include during login

get(config, name, opts \\ [])

@spec get(CodexWrapper.Config.t(), String.t(), keyword()) ::
  {:ok, term()} | {:error, term()}

Get details for a specific MCP server.

Options

  • :json - Return JSON output (boolean)

list(config, opts \\ [])

@spec list(
  CodexWrapper.Config.t(),
  keyword()
) :: {:ok, term()} | {:error, term()}

List configured MCP servers.

Options

  • :json - Return JSON output (boolean)

login(config, name, opts \\ [])

@spec login(CodexWrapper.Config.t(), String.t(), keyword()) ::
  {:ok, String.t()} | {:error, term()}

Authenticate with an MCP server over OAuth.

Mcp.login(config, "remote")
Mcp.login(config, "remote", scopes: ["read", "write"])

Options

  • :scopes - OAuth scopes to request, as a list or an already-joined comma-separated string

logout(config, name)

@spec logout(CodexWrapper.Config.t(), String.t()) ::
  {:ok, String.t()} | {:error, term()}

Deauthenticate an MCP server.

remove(config, name)

@spec remove(CodexWrapper.Config.t(), String.t()) ::
  {:ok, String.t()} | {:error, term()}

Remove an MCP server.