ConduitMCP - Elixir implementation of the Model Context Protocol (MCP).
ConduitMCP provides a framework for building MCP servers that expose tools, resources, and prompts to LLM applications. The library implements the MCP specification version 2025-11-25 with support for both modern Streamable HTTP and legacy SSE transports.
Three Ways to Build
DSL Mode — declarative macros, everything in one module:
defmodule MyApp.MCPServer do
use ConduitMcp.Server
tool "greet", "Greet someone" do
param :name, :string, "Name", required: true
handle fn _conn, %{"name" => name} -> text("Hello, #{name}!") end
end
endManual Mode — raw callbacks with full control:
defmodule MyApp.MCPServer do
use ConduitMcp.Server, dsl: false
@impl true
def handle_list_tools(_conn), do: {:ok, %{"tools" => [...]}}
@impl true
def handle_call_tool(_conn, "greet", %{"name" => name}), do: ...
endEndpoint + Component Mode — each tool as its own module:
defmodule MyApp.Greet do
use ConduitMcp.Component, type: :tool, description: "Greet someone"
schema do
field :name, :string, "Name", required: true
end
@impl true
def execute(%{name: name}, _conn), do: text("Hello, #{name}!")
end
defmodule MyApp.MCPServer do
use ConduitMcp.Endpoint, name: "My App", version: "1.0.0"
component MyApp.Greet
endCore Modules
ConduitMcp.Server- Behaviour for DSL and manual mode serversConduitMcp.Endpoint- Aggregates component modules into a serverConduitMcp.Component- Behaviour for individual tool/resource/prompt modulesConduitMcp.Protocol- JSON-RPC 2.0 and MCP message typesConduitMcp.Handler- Request routing and method dispatchConduitMcp.Errors- Standard JSON-RPC and MCP error codesConduitMcp.Transport.StreamableHTTP- Modern HTTP transport (recommended)ConduitMcp.Transport.SSE- Server-Sent Events transport (legacy)
Running a Server
children = [
{Bandit,
plug: {ConduitMcp.Transport.StreamableHTTP,
server_module: MyApp.MCPServer},
port: 4000}
]Resources
Summary
Functions
Returns the MCP protocol version supported by this library.