ExMCP.Server (ex_mcp v0.1.0)

View Source

MCP server implementation.

This module handles the protocol layer for MCP servers, delegating the actual functionality to a handler module that implements the ExMCP.Server.Handler behaviour.

Example

defmodule MyHandler do
  use ExMCP.Server.Handler

  @impl true
  def handle_initialize(_params, state) do
    {:ok, %{
      server_info: %{name: "my-server", version: "1.0.0"},
      capabilities: %{tools: %{}}
    }, state}
  end

  # ... implement other callbacks ...
end

# Start server on stdio
{:ok, server} = ExMCP.Server.start_link(
  handler: MyHandler,
  transport: :stdio
)

Summary

Functions

Returns a specification to start this module under a supervisor.

Starts an MCP server.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(opts)

Starts an MCP server.

Options

  • :handler - Module implementing ExMCP.Server.Handler behaviour (required)
  • :transport - Transport type (:stdio, :sse, or module)
  • :handler_args - Arguments passed to handler's init/1 callback
  • :name - GenServer name (optional)

Transport-specific options are passed through.