annotation ActionController::MCP

Overview

configures how a route, or every route in a controller, is exposed by the optional MCP server (see ActionController::MCPServer)

tools with ui: or visibility: :card are root: true unless annotated root: false, as hosts only render cards for, and let cards call, the tools in their tool list. Icons are added with @[AC::Icon]

a method level annotation overrides the controller level annotation The nearest annotated controller supplies defaults for inherited and newly declared actions; a child controller annotation replaces those defaults.

@[AC::MCP(hide: true)]
class Internal < AC::Base
  # exposed even though the rest of the controller is hidden
  @[AC::MCP(hide: false)]
  @[AC::Route::GET("/status")]
  def status : String
    "ok"
  end
end

class Widgets < AC::Base
  # summarise a widget for the user
  @[AC::MCP(prompt: true)]
  def summarise(
    @[AC::Param::Info(description: "the widget to summarise")]
    id : Int64,
  ) : String
    "Summarise the widget: #{Widget.find(id).to_json}"
  end
end

Defined in:

action-controller/router/builder.cr