You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With Sorbet strict typing on a tool definition (example tool below), internal MCP server introspection of tool call method parameters breaks, since it is re-written by sorbet-runtime's call validation.
i.e. Despite a tool defining call with the param server_context:, the logic falls incorrectly into the else case of this logic.
Setup an MCP server with a Sorbet-typed tool as below
Try invoking the tool with Claude IDE (for example)
💥
# typed: strict# frozen_string_literal: trueclassCounterTool < ModelContextProtocol::ToolextendT::Sigdescription"A simple counter tool that can increment and read a counter value"input_schema(properties: {action: {type: "string",enum: ["increment","read"],description: "The action to perform: increment the counter or read its current value",},},required: ["action"],)# Track the counter state@@counter=T.let(0,Integer)sig{params(action: String,server_context: T::Hash[T.any(String,Symbol),T.untyped]).returns(ModelContextProtocol::Tool::Response)}defself.call(action:,server_context:)caseactionwhen"increment"@@counter += 1ModelContextProtocol::Tool::Response.new([{type: "text",text: "Counter incremented to #{@@counter}"}],)when"read"ModelContextProtocol::Tool::Response.new([{type: "text",text: "Current counter value is #{@@counter}"}],)elseModelContextProtocol::Tool::Response.new([{type: "text",text: "Invalid action. Use 'increment' or 'read'."}],is_error: true,)endendend
Describe the bug
With Sorbet strict typing on a tool definition (example tool below), internal MCP server introspection of tool
call
method parameters breaks, since it is re-written by sorbet-runtime's call validation.i.e. Despite a tool defining
call
with the paramserver_context:
, the logic falls incorrectly into theelse
case of this logic.Which leads to a runtime error of:
To Reproduce
Expected behavior
Sorbet typed MCP tools should "just work".
Suggested solution
See #10
Sorbet provides
T::Utils.signature_for_method
, which we can use if it's defined to introspect the original method's parameters.The text was updated successfully, but these errors were encountered: