MCP Server Tester
A comprehensive testing tool for Model Context Protocol (MCP) servers, providing protocol compliance validation, capability testing, and diagnostic features.
Features
Core Testing
- Protocol Compliance Testing: Validates JSON-RPC 2.0 and MCP protocol compliance
- Multi-Transport Support: Tests HTTP, HTTPS, WebSocket, and stdio transports
- OAuth 2.0 Authentication (NEW!): Interactive browser-based OAuth flow with PKCE, token caching, and automatic middleware injection across all transport types
- Comprehensive Diagnostics: Layer-by-layer connection troubleshooting
- Server Comparison: Compare capabilities and performance between servers
- CI/CD Ready: JSON output for automated testing pipelines
Discovery & Validation (NEW!)
- Tool Schema Validation: Automatically validates JSON schemas and warns about incomplete definitions
- Resource Testing: Tests resource discovery, reading, and metadata validation
- Prompt Testing: Validates prompt templates, arguments, and metadata
- Metadata Validation: Checks for missing descriptions, MIME types, and other essential metadata
Test Automation (NEW!)
- Automated Scenario Generation: Generates test scenarios from discovered server capabilities
- Smart Schema Analysis: Creates appropriate test values based on JSON schema definitions
- Tool Testing: Discover and test individual tools with custom arguments
- Scenario Testing: Define and run complex test scenarios from YAML/JSON files
- Assertion Framework: Validate server responses with powerful assertions
Reporting
- Multiple Output Formats: Pretty, JSON, minimal, and verbose outputs
- Schema Validation Reports: Detailed warnings about tool schema completeness
- Color-Coded Results: Visual feedback for test status and warnings
Installation
# From the examples directory
# The binary will be at target/release/mcp-tester
Usage
Quick Start
# Test a local HTTP server
# Test with tools validation
# Test a stdio server
# Quick connectivity check
# Test OAuth-protected server with access token
Testing OAuth-Protected MCP Servers (Interactive OAuth)
The MCP Tester now supports interactive OAuth 2.0 authentication with automatic browser-based login and token management.
Interactive OAuth Flow
For servers that require OAuth authentication, the tester provides a seamless authentication experience:
Auto-Discovery vs Explicit Issuer: If
--oauth-issueris omitted, the tester attempts OIDC discovery from the MCP server base URL. Providing--oauth-issuerexplicitly is recommended for reliability, especially when the OAuth provider and MCP server are on different domains.
# Interactive OAuth with automatic browser login (OIDC discovery - explicit issuer recommended)
What happens:
- ✅ Tester generates secure PKCE challenge
- 🌐 Opens your browser to the OAuth provider login page
- 🔐 You authenticate with your credentials
- ✅ Tester receives the authorization code via local callback server
- 🎫 Exchanges code for access token
- 💾 Caches token locally for future requests
- 🚀 Automatically injects
Authorization: Bearerheader into all MCP requests
Token Caching
Tokens are cached in ~/.mcp-tester/tokens.json:
- Cached tokens are automatically reused until expiration
- No need to re-authenticate for every test run
- Tokens are stored securely with expiration timestamps
- Manual refresh is handled automatically when tokens expire
AWS Cognito Example (OIDC discovery)
Testing an MCP server protected by AWS Cognito:
Important for AWS Cognito:
- Add
http://localhost:8765/callbackto your Cognito App Client's allowed callback URLs - Ensure your App Client has "Authorization code grant" enabled
- The tester automatically handles PKCE (no client secret needed)
Multi-Transport OAuth Support
OAuth middleware now works seamlessly across all transport types:
- ✅ JSON-RPC HTTP (AWS Lambda, API Gateway, standard HTTP servers)
- ✅ StreamableHTTP (SSE-based streaming servers)
- ✅ Automatic Transport Detection - OAuth works regardless of transport
The tester automatically detects the correct transport and applies OAuth middleware appropriately.
Manual Token Usage (Alternative)
If you already have an access token from another source:
# Pass token directly
# Or via environment variable
The tester will automatically add the Authorization: Bearer YOUR_ACCESS_TOKEN header to all requests.
Commands
test - Run Full Test Suite
|||)
)
# OAuth 2.0 Authentication (OIDC discovery)
)
)
)
)
)
compliance - Protocol Compliance Validation
tools - Discover and Test Tools with Schema Validation
NEW: Schema Validation Output Example:
✓ Found 10 tools:
• search_wikipedia - Search for Wikipedia articles by query
✓ Schema properly defined
• get_article - Retrieve full Wikipedia article content
⚠ Tool 'get_article' missing 'properties' field for object type
• get_summary - Get a summary of a Wikipedia article
⚠ Tool 'get_summary' has empty input schema - consider defining parameters
Schema Validation Summary:
⚠ 3 total warnings found
- 1 tools with empty schema
- 2 tools missing 'properties' in schema
resources - Test Resources (NEW!)
prompts - Test Prompts (NEW!)
generate-scenario - Generate Test Scenarios (NEW!)
)
# Generate basic scenario
# Generate comprehensive scenario
diagnose - Connection Diagnostics
compare - Compare Two Servers
health - Server Health Check
scenario - Run Test Scenarios
# Run a basic test scenario
# Run with detailed output
# Run performance tests
Test scenarios allow you to define complex test sequences with variables, assertions, and workflows. See SCENARIO_FORMAT.md for detailed documentation on creating test scenarios.
Scenario Generation (NEW!)
The MCP Tester can automatically generate test scenarios from your server's discovered capabilities. This feature analyzes tool schemas and creates comprehensive test templates.
Generated Scenario Example
When you run mcp-tester generate-scenario, it creates a YAML file like this:
name: wikipedia-mcp-server Test Scenario
description: Automated test scenario for server
timeout: 60
stop_on_failure: false
variables:
test_id: test_123
test_value: sample_value
steps:
- name: List available capabilities
operation:
type: list_tools
store_result: available_tools
assertions:
- type: success
- type: exists
path: tools
- name: Test tool: search_wikipedia
operation:
type: tool_call
tool: search_wikipedia
arguments:
query: "TODO: query" # Automatically generated from schema
timeout: 30
continue_on_failure: true
store_result: search_wikipedia_result
assertions:
- type: success
- name: Test tool: get_article
operation:
type: tool_call
tool: get_article
arguments:
title: "TODO: title" # Placeholder based on schema type
store_result: get_article_result
assertions:
- type: success
Smart Value Generation
The scenario generator creates appropriate placeholder values based on JSON schema types:
| Schema Type | Example Generated Value |
|---|---|
string with format uri |
"https://example.com" |
string with format email |
"test@example.com" |
string with format date |
"2024-01-01" |
string with format uuid |
"550e8400-e29b-41d4-a716-446655440000" |
string with description containing "path" |
"/path/to/file" |
string with description containing "id" |
"test_id_123" |
number with minimum |
The minimum value |
boolean |
false |
array |
Sample array with one item |
object |
Nested object with all properties |
| Unknown types | "TODO: field_name" |
Workflow
-
Generate the scenario:
-
Edit the generated file to replace TODOs with actual test data:
arguments: query: "artificial intelligence" # Was: "TODO: query" limit: 10 -
Add custom assertions:
assertions: - type: success - type: array_length path: results greater_than: 0 - type: contains path: results[0].title value: "AI" -
Run the scenario:
Examples
Testing an OAuth-enabled Server
# Test the OAuth example server (local development)
& # Start server in background
# Run tests with OAuth middleware
# Test specific tool with arguments
# Test AWS Lambda MCP server with interactive OAuth (recommended)
# Or with manual token (if you already have one)
# Subsequent runs will use cached token (no re-authentication needed!)
CI/CD Integration
# Output JSON for automated testing
# Check exit code
if [; then
else
fi
Debugging Connection Issues
# Run comprehensive diagnostics
# This will test:
# - URL validation
# - DNS resolution
# - TCP connectivity
# - TLS/SSL certificates (for HTTPS)
# - HTTP response
# - MCP protocol handshake
Running Test Scenarios
# Run a basic test scenario
# Create a custom scenario for your server
# Run the custom scenario
Comparing Server Implementations
# Compare two servers
# This compares:
# - Protocol versions
# - Capabilities
# - Available tools
# - Performance metrics
Output Formats
Pretty (Default)
Color-coded terminal output with symbols:
- ✓ Passed (green)
- ✗ Failed (red)
- ⚠ Warning (yellow)
- ○ Skipped (gray)
JSON
Structured output for programmatic processing:
Minimal
Single-line summary:
PASS: 8 passed, 0 failed, 1 warnings in 2.50s
Verbose
Detailed output with full error messages and protocol exchanges.
Test Categories
Core Tests
- Connection establishment
- Server initialization
- Capability discovery
- Health endpoints
Protocol Tests
- JSON-RPC 2.0 compliance
- MCP protocol version validation
- Required method implementation
- Error code standards
Tool Tests
- Tool discovery (tools/list)
- Tool invocation
- Input validation
- Response format validation
Performance Tests
- Connection latency
- Response times
- Throughput measurements
Deployment-Specific Testing
AWS Lambda
# Test Lambda function via API Gateway
# Lambda cold starts may timeout - increase timeout
Docker Containers
# Test containerized server
Kubernetes
# Port-forward to test in-cluster service
Troubleshooting
Connection Refused
# Run diagnostics to identify the issue
# Common solutions:
# - Verify server is running
# - Check port is correct
# - Review firewall settings
TLS Certificate Errors
# For self-signed certificates
Protocol Version Mismatch
The tester supports protocol versions:
- 2024-11-05 (current)
- 2025-03-26
- 2025-06-18
Timeout Issues
# Increase timeout for slow servers
Integration with CI/CD
GitHub Actions
- name: Test MCP Server
run: |
cargo run --bin mcp-tester -- test ${{ env.SERVER_URL }} --format json > results.json
- name: Upload Test Results
uses: actions/upload-artifact@v2
with:
name: test-results
path: results.json
Jenkins
Contributing
The server tester is part of the Rust MCP SDK. Contributions are welcome!
Adding New Tests
- Add test logic to
src/tester.rs - Add validators to
src/validators.rs - Update test categories in
src/report.rs - Add CLI options in
src/main.rs
Testing the Tester
# Run against known good server
# Run against test fixtures
License
MIT - See LICENSE file in the repository root.