Skip to content

annotation ActionController::MCP #

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

  • hide: true excludes the route(s) from the MCP toolboxes
  • root: true always lists the tool(s) or prompt(s), without opening the toolbox
  • prompt: true exposes a method as an MCP prompt (not as a HTTP route). The method must return String or Array(AC::PromptMessage)

a method level annotation overrides the controller level annotation

@[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