class ActionController::MCPServer::Invoker

Overview

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

Defined in:

action-controller/mcp/invoker.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(route_handler : Router::RouteHandler, prompt_handler : Router::RouteHandler = Router::RouteHandler.new) #

prompts are internal routes, not accessible via HTTP


[View source]

Instance Method Detail

def 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


[View source]
def dispatch(request : HTTP::Request, handler : Router::RouteHandler = @route_handler) : HTTP::Client::Response #

runs the request through the application routes in-process


[View source]
def forwarded_headers(origin : HTTP::Request) : HTTP::Headers #

the credential headers copied from the MCP request


[View source]
def 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


[View source]
def probe(path : String, origin : HTTP::Request) : Bool #

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


[View source]