Modern DSL for defining MCP server primitives next to their handlers.
Use this module with ExMCP.Server.Handler:
defmodule MyServer do
use ExMCP.Server.Handler
use ExMCP.Server.DSL, name: "my-server", version: "1.0.0"
tool "echo", "Echo back the input" do
param :message, :string, required: true
param :tags, {:array, :string}, default: []
run fn %{message: message}, state ->
{:ok, message, state}
end
end
endParam types include :string, :integer, :number, :boolean,
:object/:map, and {:array, item_type}. Bare :array is rejected at
compile time.
Invalid declarations fail at compile time with file/line and fix hints (missing handlers, duplicate names, wrong instructions per kind, etc.).
Inside DSL modules, ToolResult is an alias for ExMCP.Server.DSL.Result.
See the project DSL guide for full details.
Summary
Functions
Defines a prompt with a co-located renderer.
Defines a static resource with a co-located read handler.
Defines a resource template with a co-located read handler.
Defines a tool with a co-located handler.
Functions
Defines a prompt with a co-located renderer.
Defines a static resource with a co-located read handler.
Defines a resource template with a co-located read handler.
Defines a tool with a co-located handler.