Claudio.MCP.ServerConfig (Claudio v0.5.0)

View Source

Structured configuration for MCP servers passed to the Anthropic Messages API.

The Anthropic API supports a server-side MCP connector where Claude connects to MCP servers on your behalf. This module provides a typed builder for those server configurations.

Example

alias Claudio.MCP.ServerConfig

server = ServerConfig.new("my_server", "https://mcp.example.com/sse")
|> ServerConfig.set_auth_token("bearer-token-here")
|> ServerConfig.allow_tools(["search_*", "fetch_data"])

request = Request.new("claude-sonnet-4-5-20250929")
|> Request.add_mcp_server(server)

Summary

Functions

Sets which tools are allowed from this MCP server.

Creates a new MCP server configuration.

Sets the authorization token for authenticating with the MCP server.

Converts the server configuration to a map suitable for the API payload.

Types

t()

@type t() :: %Claudio.MCP.ServerConfig{
  authorization_token: String.t() | nil,
  name: String.t(),
  tool_configuration: map() | nil,
  type: String.t(),
  url: String.t()
}

Functions

allow_tools(config, patterns)

@spec allow_tools(t(), [String.t()]) :: t()

Sets which tools are allowed from this MCP server.

Accepts a list of tool name patterns (supports glob-style matching).

Example

ServerConfig.new("my_server", "https://mcp.example.com")
|> ServerConfig.allow_tools(["search_*", "fetch_data"])

new(name, url)

@spec new(String.t(), String.t()) :: t()

Creates a new MCP server configuration.

Parameters

  • name - Human-readable server name
  • url - The server's HTTP URL

Example

ServerConfig.new("my_server", "https://mcp.example.com/sse")

set_auth_token(config, token)

@spec set_auth_token(t(), String.t()) :: t()

Sets the authorization token for authenticating with the MCP server.

Example

ServerConfig.new("my_server", "https://mcp.example.com")
|> ServerConfig.set_auth_token("my-bearer-token")

to_map(config)

@spec to_map(t()) :: map()

Converts the server configuration to a map suitable for the API payload.