Merge pull request #306 from koic/support_customizing_faraday_client_in_mcp_client_http

Support customizing the Faraday client in `MCP::Client::HTTP`
This commit is contained in:
Koichi ITO 2026-04-10 13:42:41 +09:00 • committed by GitHub
commit a05d941edd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -242,6 +242,31 @@ module MCP
assert_equal({ method: "tools/list", params: nil }, error.request)
end
def test_block_customizes_faraday_connection
custom_client = HTTP.new(url: url) do |faraday|
faraday.headers["X-Custom"] = "test-value"
end
request = {
jsonrpc: "2.0",
id: "test_id",
method: "tools/list",
}
stub_request(:post, url).with(
headers: {
"X-Custom" => "test-value",
"Accept" => "application/json, text/event-stream",
},
).to_return(
status: 200,
headers: { "Content-Type" => "application/json" },
body: { result: { tools: [] } }.to_json,
)
custom_client.send_request(request: request)
end
def test_send_request_raises_error_for_non_json_response
request = {
jsonrpc: "2.0",