-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add server conformance testing #1375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+1,192
−2
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -133,3 +133,6 @@ dist/ | |
|
|
||
| # IDE | ||
| .idea/ | ||
|
|
||
| # Conformance test results | ||
| results/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| #!/bin/bash | ||
| # Script to run server conformance tests | ||
| # Starts the conformance server, runs conformance tests, then stops the server | ||
|
|
||
| set -e | ||
|
|
||
| PORT="${PORT:-3000}" | ||
| SERVER_URL="http://localhost:${PORT}/mcp" | ||
|
|
||
| # Navigate to the repo root | ||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| cd "$SCRIPT_DIR/.." | ||
|
|
||
| # Start the server in the background | ||
| echo "Starting conformance test server on port ${PORT}..." | ||
| npx tsx src/conformance/everything-server.ts & | ||
| SERVER_PID=$! | ||
|
|
||
| # Function to cleanup on exit | ||
| cleanup() { | ||
| echo "Stopping server (PID: ${SERVER_PID})..." | ||
| kill $SERVER_PID 2>/dev/null || true | ||
| wait $SERVER_PID 2>/dev/null || true | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| # Wait for server to be ready | ||
| echo "Waiting for server to be ready..." | ||
| MAX_RETRIES=30 | ||
| RETRY_COUNT=0 | ||
| while ! curl -s "${SERVER_URL}" > /dev/null 2>&1; do | ||
| RETRY_COUNT=$((RETRY_COUNT + 1)) | ||
| if [ $RETRY_COUNT -ge $MAX_RETRIES ]; then | ||
| echo "Server failed to start after ${MAX_RETRIES} attempts" | ||
| exit 1 | ||
| fi | ||
| sleep 0.5 | ||
| done | ||
|
|
||
| echo "Server is ready. Running conformance tests..." | ||
|
|
||
| # Run conformance tests - pass through all arguments | ||
| npx @modelcontextprotocol/conformance server --url "${SERVER_URL}" "$@" | ||
|
|
||
| echo "Conformance tests completed." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| # Conformance Tests | ||
|
|
||
| This directory contains conformance test implementations for the TypeScript MCP SDK. | ||
|
|
||
| ## Client Conformance Tests | ||
|
|
||
| Tests the SDK's client implementation against a conformance test server. | ||
|
|
||
| ```bash | ||
| # Run all client tests | ||
| pnpm run test:conformance:client:all | ||
|
|
||
| # Run specific suite | ||
| pnpm run test:conformance:client -- --suite auth | ||
|
|
||
| # Run single scenario | ||
| pnpm run test:conformance:client -- --scenario auth/basic-cimd | ||
| ``` | ||
|
|
||
| ## Server Conformance Tests | ||
|
|
||
| Tests the SDK's server implementation by running a conformance server. | ||
|
|
||
| ```bash | ||
| # Run all active server tests | ||
| pnpm run test:conformance:server | ||
|
|
||
| # Run all server tests (including pending) | ||
| pnpm run test:conformance:server:all | ||
| ``` | ||
|
|
||
| ## Local Development | ||
|
|
||
| ### Running Tests Against Local Conformance Repo | ||
|
|
||
| Link the local conformance package: | ||
| ```bash | ||
| cd ~/code/mcp/typescript-sdk | ||
| pnpm link ~/code/mcp/conformance | ||
| ``` | ||
|
|
||
| Then run tests as above. | ||
|
|
||
| ### Debugging Server Tests | ||
|
|
||
| Start the server manually: | ||
| ```bash | ||
| pnpm run test:conformance:server:run | ||
| ``` | ||
|
|
||
| In another terminal, run specific tests: | ||
| ```bash | ||
| npx @modelcontextprotocol/conformance server \ | ||
| --url http://localhost:3000/mcp \ | ||
| --scenario server-initialize | ||
| ``` | ||
|
|
||
| ## Files | ||
|
|
||
| - `everything-client.ts` - Client that handles all client conformance scenarios | ||
| - `everything-server.ts` - Server that implements all server conformance features | ||
| - `helpers/` - Shared utilities for conformance tests | ||
|
|
||
| Scripts are in `scripts/` at the repo root. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this feels slightly odd - it makes sense in the
conformancerepo because it's obvious whatresultsis there, but here it could be slightly confusing.E.g.
src/conformance/results/orconformance-results(nit only though, not sure if that might require a bunch of refactors)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea... let me make an issue. i want to just not output the results by default, we don't use them.