ConduitMcp (ConduitMCP v0.9.0)

Copy Markdown View Source

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
end

Manual 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: ...
end

Endpoint + 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
end

Core Modules

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.

Functions

protocol_version()

Returns the MCP protocol version supported by this library.