class

ActionController::MCPServer::Invoker

Inherits Reference < Object

dispatches tool calls and prompts to the application routes in-process

Constructors

new(route_handler : Router::RouteHandler, prompt_handler : Router::RouteHandler = Router::RouteHandler.new)

prompts are internal routes, not accessible via HTTP

Source

Instance methods

call(tool : Tool, arguments : Hash(String, JSON::Any), origin : HTTP::Request, bound : Hash(String, String) = {} of String => String) : String

runs the route and returns a CallToolResult JSON string.

raises Unauthorized if authentication is enabled and the route responds with a 401

bound path params, from an endpoint URL, take precedence over the arguments

Source
call_long_running(tool : Tool, arguments : Hash(String, JSON::Any), origin : HTTP::Request, bound : Hash(String, String) = {} of String => String) : String | StreamedResult

runs a long running route, its response is spooled to disk and streamed as the CallToolResult. A String result is an error

raises Unauthorized if authentication is enabled and the route responds with a 401

Source
dispatch(request : HTTP::Request, handler : Router::RouteHandler = @route_handler) : HTTP::Client::Response

runs the request through the application routes in-process

Source
dispatch_spooled(request : HTTP::Request, max_bytes : Int64 | Nil) : Spooled

runs the route, writing its response to a temporary file

Source
forwarded_headers(origin : HTTP::Request) : HTTP::Headers

the credential headers copied from the MCP request

Source
get_prompt(prompt : Prompt, arguments : Hash(String, JSON::Any), origin : HTTP::Request, bound : Hash(String, String) = {} of String => String) : String

renders the prompt and returns a GetPromptResult JSON string

raises RPCError if the prompt can't be rendered and Unauthorized if authentication is enabled and the prompt responds with a 401

Source
instructions(path : String, origin : HTTP::Request, bound : Hash(String, String)) : String

runs an endpoint controller's instructions method, an internal route, returning the instructions for the session

raises RPCError if it fails and Unauthorized if authentication is enabled and it responds with a 401

Source
probe(path : String, origin : HTTP::Request) : Bool

requests the route provided with the forwarded credentials, returning true on success

Source
read(tool : Tool, uri : String, variables : Hash(String, String), origin : HTTP::Request, bound : Hash(String, String) = {} of String => String, modern : Bool = true) : String | StreamedResult

reads a resource by requesting its route, returning a ReadResourceResult JSON string, or a StreamedResult for long running routes.

raises RPCError if the resource can't be read and Unauthorized if authentication is enabled and the route responds with a 401

Source
readable?(tool : Tool, variables : Hash(String, String), origin : HTTP::Request, bound : Hash(String, String) = {} of String => String) : Bool

true if the resource can be read with the request's credentials

Source

Nested types