Programmatic builder for .mcp.json configuration files.
Builds the JSON structure that the Claude CLI expects for MCP server configuration, then writes it to disk or returns it as a string.
Usage
ClaudeWrapper.McpConfig.new()
|> ClaudeWrapper.McpConfig.add_stdio("my-server", "npx", ["-y", "my-mcp-server"],
env: %{"API_KEY" => "sk-..."}
)
|> ClaudeWrapper.McpConfig.add_sse("remote", "https://example.com/mcp")
|> ClaudeWrapper.McpConfig.write!("/path/to/project/.mcp.json")Format
The generated JSON follows the Claude CLI's expected format:
{
"mcpServers": {
"server-name": {
"type": "stdio",
"command": "npx",
"args": ["-y", "server-pkg"],
"env": {"KEY": "value"}
}
}
}
Summary
Functions
Add an SSE-based MCP server.
Add a stdio-based MCP server.
Parse from a decoded JSON map.
Get a server definition by name.
Create a new empty MCP config.
Read and parse an existing .mcp.json file.
Remove a server by name.
List server names.
Encode to the JSON string the CLI expects.
Write the config to a file.
Types
Functions
Add an SSE-based MCP server.
Options
:env- Map of environment variables
Add a stdio-based MCP server.
Options
:env- Map of environment variables
Parse from a decoded JSON map.
Get a server definition by name.
@spec new() :: t()
Create a new empty MCP config.
Read and parse an existing .mcp.json file.
Remove a server by name.
List server names.
Encode to the JSON string the CLI expects.
Write the config to a file.