Skip to content

Commit b0cf837

Browse files
felixweinbergerclaudepcarleton
authored
feat: add conformance test infrastructure for v1.x (#1518)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Paul Carleton <paulcarletonjr@gmail.com>
1 parent fe9c07b commit b0cf837

File tree

12 files changed

+1734
-15
lines changed

12 files changed

+1734
-15
lines changed

.github/workflows/conformance.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Conformance Tests
2+
3+
on:
4+
push:
5+
branches: [v1.x]
6+
pull_request:
7+
branches: [v1.x]
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: conformance-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
client-conformance:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
- uses: actions/setup-node@v4
23+
with:
24+
node-version: 20
25+
cache: npm
26+
- run: npm ci
27+
- run: npm run build
28+
- run: npm run test:conformance:client:all
29+
30+
server-conformance:
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/checkout@v4
34+
- uses: actions/setup-node@v4
35+
with:
36+
node-version: 20
37+
cache: npm
38+
- run: npm ci
39+
- run: npm run build
40+
- run: npm run test:conformance:server

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,4 @@ dist/
133133

134134
# IDE
135135
.idea/
136+
test/conformance/node_modules/

package-lock.json

Lines changed: 101 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,12 @@
8383
"test:watch": "vitest",
8484
"start": "npm run server",
8585
"server": "tsx watch --clear-screen=false scripts/cli.ts server",
86-
"client": "tsx scripts/cli.ts client"
86+
"client": "tsx scripts/cli.ts client",
87+
"test:conformance:server": "test/conformance/scripts/run-server-conformance.sh --expected-failures test/conformance/conformance-baseline.yml",
88+
"test:conformance:server:all": "test/conformance/scripts/run-server-conformance.sh --suite all --expected-failures test/conformance/conformance-baseline.yml",
89+
"test:conformance:server:run": "npx tsx test/conformance/src/everythingServer.ts",
90+
"test:conformance:client": "npx @modelcontextprotocol/conformance client --command 'npx tsx test/conformance/src/everythingClient.ts' --expected-failures test/conformance/conformance-baseline.yml",
91+
"test:conformance:client:all": "npx @modelcontextprotocol/conformance client --command 'npx tsx test/conformance/src/everythingClient.ts' --suite all --expected-failures test/conformance/conformance-baseline.yml"
8792
},
8893
"dependencies": {
8994
"@hono/node-server": "^1.19.9",
@@ -118,6 +123,7 @@
118123
},
119124
"devDependencies": {
120125
"@cfworker/json-schema": "^4.1.1",
126+
"@modelcontextprotocol/conformance": "^0.1.11",
121127
"@eslint/js": "^9.39.1",
122128
"@types/content-type": "^1.1.8",
123129
"@types/cors": "^2.8.17",
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Known conformance test failures for v1.x
2+
# These are tracked and should be removed as they're fixed.
3+
#
4+
# tools_call: conformance runner's test server reuses a single Server
5+
# instance across requests, triggering v1.26.0's "Already connected"
6+
# guard (GHSA-345p-7cg4-v4c7). Fixed in conformance repo (PR #141),
7+
# remove this entry once a new conformance release is published.
8+
#
9+
# auth/pre-registration: scenario added in conformance 0.1.11 that
10+
# requires a dedicated client handler for pre-registered credentials.
11+
# Needs to be implemented in both v1.x and main.
12+
client:
13+
- tools_call
14+
- auth/pre-registration
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash
2+
# Script to run server conformance tests
3+
# Starts the conformance server, runs conformance tests, then stops the server
4+
5+
set -e
6+
7+
PORT="${PORT:-3000}"
8+
SERVER_URL="http://localhost:${PORT}/mcp"
9+
10+
# Navigate to repo root
11+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
12+
cd "$SCRIPT_DIR/../../.."
13+
14+
# Start the server in the background
15+
echo "Starting conformance test server on port ${PORT}..."
16+
npx tsx test/conformance/src/everythingServer.ts &
17+
SERVER_PID=$!
18+
19+
# Function to cleanup on exit
20+
cleanup() {
21+
echo "Stopping server (PID: ${SERVER_PID})..."
22+
kill $SERVER_PID 2>/dev/null || true
23+
wait $SERVER_PID 2>/dev/null || true
24+
}
25+
trap cleanup EXIT
26+
27+
# Wait for server to be ready
28+
echo "Waiting for server to be ready..."
29+
MAX_RETRIES=30
30+
RETRY_COUNT=0
31+
while ! curl -s "${SERVER_URL}" > /dev/null 2>&1; do
32+
RETRY_COUNT=$((RETRY_COUNT + 1))
33+
if [ $RETRY_COUNT -ge $MAX_RETRIES ]; then
34+
echo "Server failed to start after ${MAX_RETRIES} attempts"
35+
exit 1
36+
fi
37+
sleep 0.5
38+
done
39+
40+
echo "Server is ready. Running conformance tests..."
41+
42+
# Run conformance tests - pass through all arguments
43+
npx @modelcontextprotocol/conformance server --url "${SERVER_URL}" "$@"
44+
45+
echo "Conformance tests completed."

0 commit comments

Comments
 (0)