ExMCP.Server.DSL (ex_mcp v1.0.0-rc.1)

View Source

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

  tool "echo", "Echo back the input" do
    param :message, :string, required: true

    run fn %{message: message}, _state ->
      {:ok, %{text: message}}
    end
  end
end

Summary

Functions

annotations(annotations)

(macro)

arg(name, opts \\ [])

(macro)

description(description)

(macro)

execution(execution)

(macro)

handle(handler)

(macro)

icons(icons)

(macro)

input_schema(schema)

(macro)

meta(meta)

(macro)

mime_type(mime_type)

(macro)

name(name)

(macro)

output_schema(schema)

(macro)

param(name, type, opts \\ [])

(macro)

prompt(name, description \\ nil, list)

(macro)

Defines a prompt with a co-located renderer.

read(handler)

(macro)

render(handler)

(macro)

resource(uri, description \\ nil, list)

(macro)

Defines a static resource with a co-located read handler.

resource_template(uri_template, description \\ nil, list)

(macro)

Defines a resource template with a co-located read handler.

run(handler)

(macro)

size(size)

(macro)

title(title)

(macro)

tool(name, description \\ nil, list)

(macro)

Defines a tool with a co-located handler.