## 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.
59 lines
1.6 KiB
Ruby
59 lines
1.6 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require "bundler/gem_tasks"
|
|
require "rake/testtask"
|
|
|
|
Rake::TestTask.new(:test) do |t|
|
|
t.ruby_opts = ["-W0", "-W:deprecated"]
|
|
t.libs << "test"
|
|
t.libs << "lib"
|
|
t.test_files = FileList["test/**/*_test.rb"]
|
|
end
|
|
|
|
require "rubocop/rake_task"
|
|
|
|
RuboCop::RakeTask.new
|
|
|
|
task default: [:rubocop, :test, :conformance]
|
|
|
|
desc "Run MCP conformance tests (PORT, SCENARIO, SPEC_VERSION, VERBOSE)"
|
|
task :conformance do |t|
|
|
next unless npx_available?(t.name)
|
|
|
|
require_relative "conformance/server_runner"
|
|
require_relative "conformance/client_runner"
|
|
|
|
options = {}
|
|
options[:port] = Integer(ENV["PORT"]) if ENV["PORT"]
|
|
options[:scenario] = ENV["SCENARIO"] if ENV["SCENARIO"]
|
|
options[:spec_version] = ENV["SPEC_VERSION"] if ENV["SPEC_VERSION"]
|
|
options[:verbose] = true if ENV["VERBOSE"]
|
|
|
|
Conformance::ServerRunner.new(**options).run
|
|
Conformance::ClientRunner.new(**options.except(:port)).run
|
|
end
|
|
|
|
desc "List available conformance scenarios"
|
|
task :conformance_list do |t|
|
|
next unless npx_available?(t.name)
|
|
|
|
system("npx", "--yes", "@modelcontextprotocol/conformance", "list", "--server")
|
|
system("npx", "--yes", "@modelcontextprotocol/conformance", "list", "--client")
|
|
end
|
|
|
|
desc "Start the conformance server (PORT)"
|
|
task :conformance_server do
|
|
require_relative "conformance/server"
|
|
|
|
options = {}
|
|
options[:port] = Integer(ENV["PORT"]) if ENV["PORT"]
|
|
|
|
Conformance::Server.new(**options).start
|
|
end
|
|
|
|
def npx_available?(task_name)
|
|
return true if system("which", "npx", out: File::NULL, err: File::NULL)
|
|
|
|
warn("Skipping #{task_name}: npx is not installed. Install Node.js to run this task: https://nodejs.org/")
|
|
false
|
|
end
|