Packages

A generic MCP server behaviour for the latest protocol version with a suite of components to build tools, resources and prompts.

Current section

Files

Jump to
gen_mcp lib gen_mcp.ex
Raw

lib/gen_mcp.ex

defmodule GenMCP do
alias GenMCP.MCP
alias GenMCP.Mux.Channel
def supported_protocol_versions do
["2025-06-18"]
end
require(Elixir.GenMCP.MCP.ModMap).require_all()
@type state :: term
@callback init(session_id :: String.t(), term) :: {:ok, state} | {:stop, term}
@type request :: MCP.InitializeRequest.t()
@type result :: MCP.InitializeResult.t()
@type notification :: MCP.InitializedNotification.t()
@type server_reply :: {:result, result} | :stream | {:error, term}
@callback handle_request(request, Channel.chan_info(), state) ::
{:reply, server_reply, state} | {:stop, reason :: term, server_reply, state}
@callback handle_notification(notification, state) :: {:noreply, state}
@callback handle_info(term, state) :: {:noreply, state}
end