Module: Hitch::MCP::Protocol
- Defined in:
- lib/hitch/mcp/protocol.rb
Overview
The MCP protocol vocabulary: the one place that says which version Hitch speaks, which methods it answers, and what a tool may be named.
Plain Ruby in lib rather than app/models, because the public test helper reads it at require time, before Rails has booted.
Constant Summary collapse
- VERSION =
"2026-07-28"- METHODS =
Every JSON-RPC method the endpoint answers. Anything else is -32601 before the SDK is built.
%w[server/discover tools/list tools/call].freeze
- MAX_TOOL_NAME_LENGTH =
The wire name of a tool, and the shape any tool name must have before it may appear in a telemetry payload or an error report.
64- TOOL_NAME =
/\A[A-Za-z0-9_.-]{1,#{MAX_TOOL_NAME_LENGTH}}\z/- GENERIC_TOOL_ERROR =
The only tool failure text that reaches a client when the host did not author one itself.
"Tool execution failed"
Class Method Summary collapse
-
.tool_name?(value) ⇒ Boolean
instance_of?, not is_a?: a String subclass can override the methods every downstream reader calls, and a tool name reaches telemetry and error reports.
Class Method Details
.tool_name?(value) ⇒ Boolean
instance_of?, not is_a?: a String subclass can override the methods every downstream reader calls, and a tool name reaches telemetry and error reports.
31 32 33 |
# File 'lib/hitch/mcp/protocol.rb', line 31 def tool_name?(value) value.instance_of?(String) && TOOL_NAME.match?(value) end |