class

MCPC::HttpConnection

Inherits Reference < Object

This MCP connection encapsulates HttpTransport and JsonRpcSession, adding additional processing and awareness. Usage example:

mcp = MCPC::HttpConnection.new(ECHO)
puts mcp.list_tools
puts mcp.call_tool("echo", Hash{"message" => "Hello, world!"})

Constructors

new(url, tracing : Bool = false, auth_token : Nil | SensitiveData(String) = nil, transport_type : MCPC::TransportType = TransportType::AutoDetect)

Sets up the MCP connection

Source

Instance methods

call_tool(name : String, args : Hash(String, String | Number | Bool | JSON::Any)) : JSON::Any | Nil

Calls a tool and returns the content from the reply on success

Source
close

Clean up the connection; will be unusable without subsequent call to #reset

Source
get_prompt(name : String, args : Hash(String, String)) : MCP::PromptResult | Nil

Calls a tool and returns the content from the reply on success

Source
list_prompts
Source
list_tools

Returns an array of tools, if any

Source
origin

Short title

Source
reset

Reset to re-initialize the connection whenever calls fail with a 404 error; sets up a new transport and session, and initializes the session. TODO better handling of reset scenarios.

Source
server_name
Source
server_version
Source
supports_prompts?
Source
supports_resources?
Source
supports_roots?
Source
supports_tools?
Source
to_s(io)

Returns a JSON representation of the state of this connection

Source
tracing=(trace : Bool)

Enable / disable tracing from this point on

Source
tracing?
Source
transport_type
Source