Use Server#tools instead of instance_variable_get

Follow-up to https://github.com/modelcontextprotocol/ruby-sdk/pull/301#discussion_r3046699277.

`Server#tools` method can be used instead of a hack like `instance_variable_get(:@tools)`.
This commit is contained in:
Koichi ITO 2026-05-09 19:12:37 +09:00
commit 25f3f9a33a

View file

@ -1390,7 +1390,7 @@ module MCP
Tool::Response.new({ "response" => message })
end
stored_tool = @server.instance_variable_get(:@tools)["defined_tool"]
stored_tool = @server.tools["defined_tool"]
assert_not_nil(stored_tool)
assert_equal(MCP::Tool::OutputSchema.new({ type: "object", properties: { response: { type: "string" } }, required: ["response"] }), stored_tool.output_schema)