Prompt DSL for defining MCP prompt templates.
Prompts are reusable templates that generate messages based on provided arguments. They enable structured, parameterized interactions with LLM clients.
Examples
defmodule MyApp.MCP do
use Ectomancer, name: "my-app", version: "1.0.0"
prompt :analyze_churn do
description "Analyze user churn over a time period"
argument :days, :integer, required: true, description: "Days to look back"
argument :threshold, :float, default: 0.05, description: "Churn threshold"
messages fn args ->
[
%{
role: "user",
content: %{
type: "text",
text: "Using the list_users tool, analyze churn over the last #{args.days} days with threshold #{args.threshold}..."
}
}
]
end
end
prompt :summarize_reports do
description "Summarize recent reports"
argument :report_type, :string, required: true,
description: "Type of report",
enum: ["sales", "inventory", "employee"]
messages fn args ->
report_type = Map.get(args, "report_type", "sales")
[
%{
role: "system",
content: %{
type: "text",
text: "You are a report analyst. Summarize the #{report_type} reports."
}
},
%{
role: "user",
content: %{
type: "text",
text: "Provide a concise summary of the latest #{report_type} reports."
}
}
]
end
end
endDSL Functions
description/1— Human-readable description of the promptargument/3— Define an argument with name, type, and options:required— Whether the argument is required (default:false):description— Description of the argument:default— Default value if not provided:enum— List of allowed values
messages/1— Callbackfn args -> [...] endthat returns a list of message maps Each message is%{role: "user"|"assistant"|"system", content: %{type: "text", text: "..."}}
Arguments
Arguments support the following types: :string, :integer, :float, :boolean,
:list, :map, and arrays ({:array, inner_type}).
Arguments with required: true will be validated by Anubis MCP before calling
the messages callback. Missing required arguments will return a protocol error.
Response Format
The messages callback should return a list of message maps. Each message must have:
:role— One of"user","assistant", or"system":content— A map with:type("text") and:text(the message content)
The generated module wraps these messages in an Anubis.Server.Response struct
with type: :prompt for proper MCP protocol encoding.
Summary
Functions
Defines a new prompt within an Ectomancer module.
Functions
Defines a new prompt within an Ectomancer module.
Example
prompt :analyze_churn do
description "Analyze user churn over a time period"
argument :days, :integer, required: true, description: "Days to look back"
messages fn args ->
[
%{
role: "user",
content: %{
type: "text",
text: "Analyze churn over the last #{args["days"]} days"
}
}
]
end
end