Support running MCP client conformance tests against the Ruby SDK
## Motivation and Context PR #248 introduced server conformance testing using `@modelcontextprotocol/conformance`. This extends coverage to the client side so that `MCP::Client` behavior can also be validated against the MCP specification. ### Scope Client conformance is driven by the conformance runner, which spawns test servers for each scenario and invokes `conformance/client.rb` against them. The client script delegates the MCP initialize handshake to `MCP::Client#connect` and executes scenario-specific operations (for example listing tools or calling a tool). ### Usage Run all conformance tests (server + client): ```console bundle exec rake conformance ``` Run a single client scenario: ```console bundle exec rake conformance SCENARIO=initialize ``` List available scenarios: ```console bundle exec rake conformance_list ``` ## How Has This Been Tested? Ran `bundle exec rake conformance` locally. - Server conformance: 40 passed, 0 failed. - Client conformance: 3 passed, 54 failed (all 54 listed in `expected_failures.yml`). ## Breaking Change No. This change only adds test infrastructure under `conformance/` and does not modify SDK behavior.
This commit is contained in:
parent
d18698890a
commit
9603b2fe93
1 changed files with 131 additions and 17 deletions
48
conformance/client_runner.rb
Normal file
48
conformance/client_runner.rb
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Runs `npx @modelcontextprotocol/conformance client` against the conformance client script.
|
||||
require "English"
|
||||
|
||||
module Conformance
|
||||
class ClientRunner
|
||||
def initialize(scenario: nil, spec_version: nil, verbose: false)
|
||||
@scenario = scenario
|
||||
@spec_version = spec_version
|
||||
@verbose = verbose
|
||||
end
|
||||
|
||||
def run
|
||||
command = build_command
|
||||
puts "Command: #{command.join(" ")}\n\n"
|
||||
|
||||
system(*command)
|
||||
conformance_exit_code = $CHILD_STATUS.exitstatus
|
||||
exit(conformance_exit_code || 1) unless conformance_exit_code == 0
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def build_command
|
||||
expected_failures_yml = File.expand_path("expected_failures.yml", __dir__)
|
||||
client_script = File.expand_path("client.rb", __dir__)
|
||||
|
||||
npx_command = [
|
||||
"npx",
|
||||
"--yes",
|
||||
"@modelcontextprotocol/conformance",
|
||||
"client",
|
||||
"--command",
|
||||
"bundle exec ruby #{client_script}",
|
||||
]
|
||||
npx_command += if @scenario
|
||||
["--scenario", @scenario]
|
||||
else
|
||||
["--suite", "all"]
|
||||
end
|
||||
npx_command += ["--spec-version", @spec_version] if @spec_version
|
||||
npx_command += ["--verbose"] if @verbose
|
||||
npx_command += ["--expected-failures", expected_failures_yml]
|
||||
npx_command
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Reference in a new issue