Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion conformance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Validates the Ruby SDK's conformance to the MCP specification using [`@modelcont
- Node.js (for `npx`)
- `bundle install` completed

## Running the Tests
## Server Conformance

### Run all scenarios

Expand Down Expand Up @@ -64,6 +64,33 @@ bundle exec rake conformance_list

Prints all scenario names that can be passed to `SCENARIO`.

## Client Conformance

The client conformance tests validate `MCP::Client` against the MCP specification by running
it through scenarios served by the conformance test runner.

### Run all client scenarios

```bash
npx @modelcontextprotocol/conformance client --suite core --command "ruby conformance/client.rb"
```

### Run a single scenario

```bash
npx @modelcontextprotocol/conformance client --scenario initialize --command "ruby conformance/client.rb"
```

### List available client scenarios

```bash
npx @modelcontextprotocol/conformance list --client
```

The conformance runner starts a test server for each scenario, sets the
`MCP_CONFORMANCE_SCENARIO` environment variable, and invokes the command with the server URL
as the first argument.

## SDK Tier Report

The [MCP SDK Tier system](https://modelcontextprotocol.io/community/sdk-tiers) requires SDK
Expand Down Expand Up @@ -92,6 +119,7 @@ submissions.
conformance/
server.rb # Conformance server (Rack + Puma, default port 9292)
runner.rb # Starts the server, runs npx conformance, exits with result code
client.rb # Conformance client for client-side scenario testing
expected_failures.yml # Baseline of known-failing scenarios
README.md # This file
```
Expand Down
42 changes: 42 additions & 0 deletions conformance/client.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# frozen_string_literal: true

# Conformance test client for MCP client testing.
#
# Usage: ruby conformance/client.rb <server-url>
#
# The scenario name is read from the MCP_CONFORMANCE_SCENARIO environment variable,
# which is set by the conformance test runner.

$LOAD_PATH.unshift(File.expand_path("../lib", __dir__))
require "mcp"
require "mcp/client"
require "mcp/client/http"

server_url = ARGV[0]
scenario = ENV["MCP_CONFORMANCE_SCENARIO"]

unless server_url && scenario
warn "Usage: MCP_CONFORMANCE_SCENARIO=<scenario> ruby conformance/client.rb <server-url>"
exit 1
end

transport = MCP::Client::HTTP.new(url: server_url)
client = MCP::Client.new(transport: transport)

case scenario
when "initialize"
client.connect(client_info: { name: "ruby-conformance-client", version: "1.0.0" })
client.tools
client.close
when "tools_call"
client.connect(client_info: { name: "ruby-conformance-client", version: "1.0.0" })
tools = client.tools
tool = tools.find { |t| t.name == "add_numbers" }
if tool
client.call_tool(tool: tool, arguments: { a: 1, b: 2 })
end
client.close
else
warn "Unknown scenario: #{scenario}"
exit 1
end
Loading
Loading