Sponsored by Deepsite.site

MCP Server Tester

Created By
r-huijts8 months ago
Automated testing tool for Model Context Protocol (MCP) servers - WORK IN PROGRESS
Content

MCP Server Tester

⚠️ WORK IN PROGRESS: This project is under active development and has not been thoroughly tested yet. Features may be incomplete, contain bugs, or change significantly. Use at your own risk in non-production environments only.

A powerful, configuration-driven testing tool for Model Context Protocol (MCP) servers. This project provides a comprehensive solution for validating, benchmarking, and ensuring reliability of MCP servers that integrate with AI models like Claude.

Current Status

This tool is in early development stage with:

  • ✅ Basic configuration framework implemented
  • ✅ MCP server connection capabilities
  • ✅ Test generation using Claude AI
  • ✅ Natural language query generation for tests
  • ✅ Report generation in multiple formats
  • 🚧 Comprehensive test validation (in progress)
  • 🚧 Additional reporting options (in progress)
  • ❌ Full test coverage of the tool itself
  • ❌ Production hardening

If you're interested in contributing, please feel free to open issues and submit pull requests.

Introduction

The Model Context Protocol (MCP) enables AI models to access external tools and data sources through standardized interfaces. As MCP servers grow in complexity and importance, ensuring their correct functionality becomes critical. The MCP Server Tester addresses this need by:

  • Automating tests for all tools exposed by an MCP server
  • Leveraging Claude AI to generate intelligent, contextually-relevant test cases
  • Validating responses against expected outcomes and schemas
  • Providing detailed reports to identify issues and performance bottlenecks

This tool is designed for MCP server developers, AI integration teams, and quality assurance professionals who need to ensure their MCP implementations are robust, reliable, and correctly follow the protocol specifications.

Repository

Features

  • 🔍 Automatically discovers available tools from any MCP server
  • 🧪 Generates realistic test cases for each tool using Claude AI
  • ⚡ Executes tests and validates responses
  • 📊 Provides detailed test reports
  • 🔑 Supports multiple connection methods through configuration
  • Configuration-Based: Simple JSON configuration for defining MCP servers to test
  • Multiple Server Support: Test multiple MCP servers at once
  • Comprehensive Testing: Tests all tools exposed by each server
  • Natural Language Context: Includes the user query that would trigger each tool, providing real-world context
  • Detailed Reports: Generate reports in console, JSON, or HTML formats
  • Secure: Keeps API keys in environment variables, not in configuration files

Prerequisites

  • Node.js 18 or higher
  • An Anthropic API key for generating test cases

Installation

Since this project is still in development, installation is done by cloning the repository:

# Clone the repository
git clone https://github.com/r-huijts/mcp-server-tester.git
cd mcp-server-tester

# Install dependencies
npm install

# Build the project
npm run build

# Create a symbolic link to use it globally (optional)
npm link

Configuration-Based Usage

The MCP Server Tester is designed to be driven entirely through configuration files. This approach offers several advantages:

  • Reusability: Define your servers once, test them repeatedly
  • Version control: Check in your test configurations alongside your code
  • Sharing: Easily share server test configurations with team members

Basic Usage

# Create a .env file with your Anthropic API key
echo "ANTHROPIC_API_KEY=your-api-key-here" > .env

# Run tests using the configuration
mcp-server-tester

# Use a custom configuration file
mcp-server-tester path/to/my-config.json

Configuration File Structure

The configuration file (mcp-servers.json) controls all aspects of testing:

{
  "numTestsPerTool": 3,
  "timeoutMs": 10000,
  "outputFormat": "console",
  "outputPath": "./reports/results.json",
  "verbose": false,
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "./"],
      "env": {
        "DEBUG": "true"
      }
    },
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "your-github-token-here"
      }
    },
    "dev-server": {
      "command": "node",
      "args": ["/absolute/path/to/your/dev-server.js"],
      "env": {
        "DEBUG": "true",
        "NODE_ENV": "development"
      }
    }
  }
}

By default, the tool will test all servers defined in the mcpServers section. If you want to test only specific servers, you can add an optional servers array:

{
  "servers": ["filesystem", "dev-server"],
  "numTestsPerTool": 3,
  // other settings...
  "mcpServers": {
    // server definitions...
  }
}

Configuration Options

Test Settings

OptionDescriptionDefault
serversOptional array of specific server names to testAll servers in mcpServers
numTestsPerToolNumber of tests to generate per tool3
timeoutMsTimeout for test execution in milliseconds10000
outputFormatFormat for test reports (json, console, html)"console"
outputPathPath to output fileundefined
verboseEnable verbose loggingfalse

Server Definitions

The mcpServers section defines all available servers that can be tested:

PropertyDescriptionRequired
commandExecutable or command to runYes
argsArray of command-line argumentsYes
envEnvironment variables to setYes

Server Connection Types

You can define various types of MCP servers in your configuration:

NPM Package

"npm-package": {
  "command": "npx",
  "args": ["-y", "@modelcontextprotocol/server-github"],
  "env": {}
}

Local Script with Relative Path

"python-script": {
  "command": "python",
  "args": ["./servers/custom_server.py"],
  "env": {
    "PORT": "8080"
  }
}

Local Script with Absolute Path

Useful for testing development versions of servers:

"dev-server": {
  "command": "node",
  "args": ["/absolute/path/to/your/dev-server.js"],
  "env": {
    "DEBUG": "true",
    "NODE_ENV": "development"
  }
}

Socket Connection

"remote-socket": {
  "command": "nc",
  "args": ["localhost", "3000"],
  "env": {}
}

API Key Management

For security reasons, your Anthropic API key should only be set in one of these ways:

  1. Environment variable: ANTHROPIC_API_KEY=your-api-key
  2. .env file in your project directory:
    ANTHROPIC_API_KEY=your-api-key
    

Important: Never put your API key in the configuration file, as it may be committed to version control.

Command-Line Options

MCP Server Tester supports minimal command-line options:

OptionDescription
--init or -iCreate a default configuration file
--list or -lList all servers defined in your configuration
--help or -hDisplay help information
[config-path]Specify a custom configuration file path

Test Generation Process

The tool uses Claude AI to automatically generate appropriate test cases for each tool exposed by the MCP server:

  1. It discovers all available tools from the server
  2. For each tool, it analyzes:
    • Tool name and description
    • Required and optional parameters
    • Parameter types and constraints
  3. Claude generates multiple test cases per tool:
    • Happy path tests with valid inputs
    • Edge case tests with boundary values
    • Error case tests with invalid inputs

Each test case includes:

  • Description of what's being tested
  • Input parameters
  • Expected outcome criteria

Test Execution and Validation

For each server specified in the configuration (or all servers if none specified):

  1. The tool connects to the server
  2. It discovers all available tools
  3. It generates test cases for each tool
  4. It executes each test case against the server
  5. It validates the responses against expected outcomes
  6. It generates a report of the results

Reporting Options

The tool can generate reports in multiple formats, controlled by the outputFormat configuration option:

Console Output (Default)

Displays test results directly in the terminal.

JSON Report

Creates a structured JSON file at the path specified in outputPath.

HTML Report

Generates an HTML report with visualizations at the path specified in outputPath.

Complete Examples

Basic Setup and Testing

  1. Create a default configuration file:

    mcp-server-tester --init
    
  2. Edit the mcp-servers.json file to add your own servers and settings

  3. Create a .env file with your Anthropic API key:

    echo "ANTHROPIC_API_KEY=your-api-key-here" > .env
    
  4. Run the tests:

    mcp-server-tester
    

Testing a Dev Version of Your Server

To test a development version of your MCP server:

  1. Add a configuration for your development server with the absolute path:
{
  "mcpServers": {
    "my-dev-server": {
      "command": "node",
      "args": ["/path/to/your/project/dist/server.js"],
      "env": {
        "DEBUG": "true",
        "NODE_ENV": "development"
      }
    }
  }
}
  1. Run the tests:
mcp-server-tester

Testing Multiple Different Configurations

You can maintain different configuration files for different testing scenarios:

# Create different config files for different environments
cp mcp-servers.json config-dev.json
cp mcp-servers.json config-prod.json

# Edit each file with appropriate settings

# Run tests with specific config
mcp-server-tester ./config-dev.json
mcp-server-tester ./config-prod.json

Troubleshooting

Connection Issues

If you're having trouble connecting to an MCP server:

  1. Verify the server configuration in your mcp-servers.json file
  2. Check if the server supports the MCP protocol
  3. Try increasing the timeoutMs for slower servers
  4. Enable verbose logging by setting verbose: true
  5. Check server process startup with environment variable DEBUG=true

API Key Issues

If you encounter API key issues:

  1. Verify your Anthropic API key is valid
  2. Make sure the API key is correctly set in your environment or .env file
  3. Check for any spaces or extra characters in your API key
  4. Confirm that the .env file is in the correct location (project root)

Tool Execution Failures

If tool executions are failing:

  1. Ensure your server implements the MCP protocol correctly
  2. Check the server logs for errors
  3. Verify the tool parameters are valid
  4. Increase the timeout if the tool takes longer to execute

Node.js Deprecation Warnings

punycode Module Deprecation Warning

If you encounter this warning:

(node:71439) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.

This is a harmless warning from Node.js about an internal module being deprecated. It doesn't affect the functionality of the MCP Server Tester. The warning comes from one of the dependencies and will be resolved in future updates.

Solutions:

  1. Ignore the warning - It doesn't affect functionality
  2. Suppress warnings - Run with the NODE_NO_WARNINGS=1 environment variable:
    NODE_NO_WARNINGS=1 mcp-server-tester
    
  3. Use the npm scripts - The included npm scripts already suppress these warnings:
    npm start
    

Development

To set up the development environment:

# Clone the repository
git clone https://github.com/r-huijts/mcp-server-tester.git
cd mcp-server-tester

# Install dependencies
npm install

# Create your .env file
cp .env.example .env
# Edit .env and add your API key

# Run the tool in development mode
npm run dev

License

MIT

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
WindsurfThe new purpose-built IDE to harness magic
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
DeepChatYour AI Partner on Desktop
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Amap Maps高德地图官方 MCP Server
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Playwright McpPlaywright MCP server
CursorThe AI Code Editor
ChatWiseThe second fastest AI chatbot™
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Tavily Mcp
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Serper MCP ServerA Serper MCP Server