Skip to main content

Multi-language MCP server for API testing with TypeScript/Playwright, JavaScript/Jest, Python/pytest support

Project description

API Tester MCP Server

npm version npm downloads PyPI version License: MIT

A comprehensive Model Context Protocol (MCP) server for QA/SDET engineers that provides API testing capabilities with Swagger/OpenAPI and Postman collection support.

๐ŸŽ‰ Now available on NPM! Install with npx @kirti676/api-tester-mcp@latest

๐Ÿ†• What's New

  • โœ… Enhanced Progress Tracking - Real-time progress with completion percentages and ETA
  • โœ… Visual Progress Bars - ASCII progress bars with milestone notifications
  • โœ… Performance Metrics - Throughput calculations and execution summaries
  • โœ… Published on NPM - Install instantly with NPX
  • โœ… VS Code Integration - One-click installation buttons
  • โœ… Simplified Setup - No manual Python installation required
  • โœ… Cross-Platform - Works on Windows, macOS, and Linux
  • โœ… Auto-Updates - Always get the latest version with @latest

๐Ÿš€ Getting Started

Installation

The API Tester MCP server can be used directly with npx without any installation:

npx @kirti676/api-tester-mcp@latest

Quick Install:

Install in VS Code Install in VS Code Insiders

Claude Desktop

Follow the MCP install guide, use the standard config below:

{
  "mcpServers": {
    "api-tester": {
      "command": "npx",
      "args": ["@kirti676/api-tester-mcp@latest"]
    }
  }
}

Other MCP Clients

The standard configuration works with most MCP clients:

{
  "mcpServers": {
    "api-tester": {
      "command": "npx",
      "args": ["@kirti676/api-tester-mcp@latest"]
    }
  }
}

Supported Clients:

Python Installation (Alternative)

pip install api-tester-mcp

From Source

git clone https://github.com/kirti676/api_tester_mcp.git
cd api_tester_mcp
npm install

โšก Quick Start

Try the API Tester MCP server immediately:

# Run the server
npx @kirti676/api-tester-mcp@latest

# Check version
npx @kirti676/api-tester-mcp@latest --version

# Get help
npx @kirti676/api-tester-mcp@latest --help

For MCP clients like Claude Desktop, use this configuration:

{
  "mcpServers": {
    "api-tester": {
      "command": "npx",
      "args": ["@kirti676/api-tester-mcp@latest"]
    }
  }
}

โœจ Features

  • ๐Ÿ“ฅ Input Support: Swagger/OpenAPI documents and Postman collections
  • ๐Ÿ”„ Test Generation: Automatic API and Load test scenario generation
  • ๐ŸŒ Multi-Language Support: Generate tests in TypeScript/Playwright, JavaScript/Jest, Python/pytest, and more
  • โšก Test Execution: Run generated tests with detailed reporting
  • ๐Ÿ” Smart Auth Detection: Automatic environment variable analysis and setup guidance
  • ๐Ÿ” Authentication: Bearer token and API key support via set_env_vars
  • ๐Ÿ“Š HTML Reports: Beautiful, accessible reports via MCP resources
  • ๐Ÿ“ˆ Real-time Progress: Live updates with progress bars and completion percentages
  • โฑ๏ธ ETA Calculations: Estimated time to completion for all operations
  • ๐ŸŽฏ Milestone Tracking: Special notifications at key progress milestones (25%, 50%, 75%, etc.)
  • ๐Ÿ“Š Performance Metrics: Throughput calculations and execution summaries
  • โœ… Schema Validation: Request body generation from schema examples
  • ๐ŸŽฏ Assertions: Per-endpoint status code assertions (2xx, 4xx, 5xx)
  • ๐Ÿ“ฆ Project Generation: Complete project scaffolding with dependencies and configuration

๐ŸŒ Multi-Language Test Generation

The API Tester MCP now supports generating test code in multiple programming languages and testing frameworks:

Supported Language/Framework Combinations

Language Framework Description Use Case
TypeScript Playwright Modern E2E testing with excellent API support Enterprise web applications
TypeScript Supertest Express.js focused API testing Node.js backend services
JavaScript Jest Popular testing framework with good ecosystem General API testing
JavaScript Cypress E2E testing with great developer experience Full-stack applications
Python pytest Comprehensive testing with fixtures & plugins Data-heavy APIs & ML services
Python requests Simple HTTP testing for quick validation Rapid prototyping & scripts

Language Selection Workflow

// 1. Get available languages and frameworks
const languages = await mcp.call("get_supported_languages");

// 2. Choose your preferred combination
await mcp.call("ingest_spec", {
  spec_type: "openapi",
  content: spec_content,
  preferred_language: "typescript",    // python, typescript, javascript
  preferred_framework: "playwright"     // varies by language
});

// 3. Generate test cases with code
await mcp.call("generate_test_cases", {
  language: "typescript",
  framework: "playwright"
});

// 4. Get complete project setup
await mcp.call("generate_project_files", {
  language: "typescript",
  framework: "playwright",
  project_name: "my-api-tests",
  include_examples: true
});

Generated Project Structure

The generate_project_files tool creates a complete, ready-to-run project:

TypeScript + Playwright:

my-api-tests/
โ”œโ”€โ”€ package.json          # Dependencies & scripts
โ”œโ”€โ”€ playwright.config.ts  # Playwright configuration
โ”œโ”€โ”€ tests/
โ”‚   โ””โ”€โ”€ api.spec.ts      # Generated test code
โ””โ”€โ”€ README.md            # Setup instructions

Python + pytest:

my-api-tests/
โ”œโ”€โ”€ requirements.txt     # Python dependencies
โ”œโ”€โ”€ pytest.ini         # pytest configuration
โ”œโ”€โ”€ tests/
โ”‚   โ””โ”€โ”€ test_api.py    # Generated test code
โ””โ”€โ”€ README.md          # Setup instructions

JavaScript + Jest:

my-api-tests/
โ”œโ”€โ”€ package.json       # Dependencies & scripts
โ”œโ”€โ”€ jest.config.js     # Jest configuration
โ”œโ”€โ”€ tests/
โ”‚   โ””โ”€โ”€ api.test.js   # Generated test code
โ””โ”€โ”€ README.md         # Setup instructions

Framework-Specific Features

  • Playwright: Browser automation, parallel execution, detailed reporting
  • Jest: Snapshot testing, mocking, watch mode for development
  • pytest: Fixtures, parametrized tests, extensive plugin ecosystem
  • Cypress: Interactive debugging, time-travel debugging, real browser testing
  • Supertest: Express.js integration, middleware testing
  • requests: Simple API calls, session management, authentication helpers

๐Ÿ“ˆ Progress Tracking

The API Tester MCP includes comprehensive progress tracking for all operations:

Visual Progress Indicators

๐ŸŽฏ API Test Execution: [โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘] 50.0% (5/10) | ETA: 2.5s - GET /api/users โœ…

Features:

  • Progress Bars: ASCII progress bars with filled/empty indicators
  • Completion Percentages: Real-time percentage completion
  • ETA Calculations: Estimated time to completion based on current performance
  • Milestone Notifications: Special highlighting at key progress points
  • Performance Metrics: Throughput and timing statistics
  • Operation Context: Detailed information about current step being executed

Available for:

  • Scenario generation
  • Test case generation
  • API test execution
  • Load test execution
  • All long-running operations

๐Ÿ› ๏ธ MCP Tools

The server provides 10 comprehensive MCP tools:

  1. ingest_spec - Load Swagger/OpenAPI or Postman collections with language preferences
  2. get_supported_languages - Get list of supported programming languages and frameworks (NEW!)
  3. get_env_var_suggestions - Get detailed environment variable setup guidance
  4. set_env_vars - Configure authentication and environment variables
  5. generate_scenarios - Create test scenarios from specifications
  6. generate_test_cases - Convert scenarios to executable test cases in selected language/framework (ENHANCED!)
  7. generate_project_files - Generate complete project with dependencies and configuration (NEW!)
  8. run_api_tests - Execute API tests with detailed results
  9. run_load_tests - Execute performance/load tests
  10. get_session_status - Retrieve current session information

๐Ÿ“š MCP Resources

  • file://reports - List all available test reports
  • file://reports/{report_id} - Access individual HTML test reports

๐Ÿ’ก MCP Prompts

  • create_api_test_plan - Generate comprehensive API test plans
  • analyze_test_failures - Analyze test failures and provide recommendations

๏ฟฝ Smart Environment Variable Analysis

The API Tester MCP now automatically analyzes your API specifications to detect required environment variables and provides helpful setup guidance:

Automatic Detection

  • Authentication Schemes: Bearer tokens, API keys, Basic auth, OAuth2
  • Base URLs: Extracted from specification servers/hosts
  • Template Variables: Postman collection variables like {{baseUrl}}, {{authToken}}
  • Path Parameters: Dynamic values in paths like /users/{userId}

Smart Suggestions

// 1. Ingest specification - automatic analysis included
const result = await mcp.call("ingest_spec", {
  spec_type: "openapi",
  content: openapi_json_string
});

// Check the setup message for immediate guidance
console.log(result.setup_message);
// "โš ๏ธ 2 required environment variable(s) detected..."

// 2. Get detailed setup instructions
const suggestions = await mcp.call("get_env_var_suggestions");
console.log(suggestions.setup_instructions);
// Provides copy-paste ready configuration examples

๐ŸŽฏ Default Parameter Keys

All MCP tools now provide helpful default parameter keys to guide users on what values they can set:

Environment Variables (set_env_vars)

๐Ÿ”‘ ALL PARAMETERS ARE OPTIONAL - Provide only what you need:

// Option 1: Just the base URL
await mcp.call("set_env_vars", {
  baseUrl: "https://api.example.com/v1"
});

// Option 2: Just authentication
await mcp.call("set_env_vars", {
  auth_bearer: "your-jwt-token-here"
});

// Option 3: Multiple parameters
await mcp.call("set_env_vars", {
  baseUrl: "https://api.example.com/v1",
  auth_bearer: "your-jwt-token",
  auth_apikey: "your-api-key"
});

// Option 4: Using variables dict for custom values
await mcp.call("set_env_vars", {
  variables: {
    "baseUrl": "https://api.example.com/v1",
    "custom_header": "custom-value"
  }
});

Language & Framework Selection

Default values help you understand available options:

// Ingest with defaults shown
await mcp.call("ingest_spec", {
  spec_type: "openapi",        // openapi, swagger, postman
  content: "...",              // JSON or YAML specification content
  preferred_language: "python", // python, typescript, javascript
  preferred_framework: "requests" // pytest, requests, playwright, jest, cypress, supertest
});

// Project generation with defaults
await mcp.call("generate_project_files", {
  language: "python",          // python, typescript, javascript
  framework: "requests",       // Framework matching the language
  project_name: "api-tests",   // Project folder name
  include_examples: true       // Include example test files
});

Test Execution Parameters

Clear defaults for performance tuning:

// API tests with concurrency control
await mcp.call("run_api_tests", {
  test_case_ids: null,        // ["test_1", "test_2"] or null for all
  max_concurrent: 10          // Number of concurrent requests (1-50)
});

// Load tests with performance parameters  
await mcp.call("run_load_tests", {
  test_case_ids: null,        // ["test_1", "test_2"] or null for all
  duration: 60,               // Test duration in seconds
  users: 10,                  // Number of concurrent virtual users
  ramp_up: 10                 // Ramp up time in seconds
});

๐Ÿ”ง Configuration Example

// NEW: Check supported languages and frameworks
const languages = await mcp.call("get_supported_languages");
console.log(languages.supported_combinations);

// Ingest specification with language preferences
await mcp.call("ingest_spec", {
  spec_type: "openapi",
  content: openapi_json_string,
  preferred_language: "typescript",
  preferred_framework: "playwright"
});

// Set environment variables for authentication
await mcp.call("set_env_vars", {
  variables: {
    "baseUrl": "https://api.example.com",
    "auth_bearer": "your-bearer-token",
    "auth_apikey": "your-api-key"
  }
});

// Generate test scenarios
await mcp.call("generate_scenarios", {
  include_negative_tests: true,
  include_edge_cases: true
});

// Generate test cases in TypeScript/Playwright
await mcp.call("generate_test_cases", {
  language: "typescript",
  framework: "playwright"
});

// Generate complete project files
await mcp.call("generate_project_files", {
  language: "typescript",
  framework: "playwright",
  project_name: "my-api-tests",
  include_examples: true
});

// Run API tests (still works with existing execution engine)
await mcp.call("run_api_tests", {
  max_concurrent: 5
});

๏ฟฝ Complete Workflow Example

Here's a complete example of testing the Petstore API:

# 1. Start the MCP server
npx @kirti676/api-tester-mcp@latest

Then in your MCP client (like Claude Desktop):

// 1. Load the Petstore OpenAPI spec
await mcp.call("ingest_spec", {
  kind: "openapi", 
  path_or_text: "https://petstore.swagger.io/v2/swagger.json"
});

// 2. Set environment variables
await mcp.call("set_env_vars", {
  pairs: {
    "baseUrl": "https://petstore.swagger.io/v2",
    "auth_apikey": "special-key"
  }
});

// 3. Generate test cases
const tests = await mcp.call("get_generated_tests");

// 4. Run API tests
const result = await mcp.call("run_api_tests");

// 5. View results in HTML report
const reports = await mcp.call("list_resources", {
  uri: "file://reports"
});

๏ฟฝ๐Ÿ“– Usage Examples

Basic API Testing Workflow

  1. Ingest API Specification

    {
      "tool": "ingest_spec",
      "params": {
        "spec_type": "openapi",
        "content": "{ ... your OpenAPI spec ... }"
      }
    }
    
  2. Configure Authentication

    {
      "tool": "set_env_vars", 
      "params": {
        "variables": {
          "auth_bearer": "your-token",
          "baseUrl": "https://api.example.com"
        }
      }
    }
    
  3. Generate and Run Tests

    {
      "tool": "generate_scenarios",
      "params": {
        "include_negative_tests": true
      }
    }
    
  4. View Results

    • Access HTML reports via MCP resources
    • Get session status and statistics

Load Testing

{
  "tool": "run_load_tests",
  "params": {
    "users": 10,
    "duration": 60,
    "ramp_up": 10
  }
}

๐Ÿ” Test Generation Features

  • Positive Tests: Valid requests with expected 2xx responses
  • Negative Tests: Invalid authentication (401), wrong methods (405)
  • Edge Cases: Large payloads, boundary conditions
  • Schema-based Bodies: Automatic request body generation from OpenAPI schemas
  • Comprehensive Assertions: Status codes, response times, content validation

๐Ÿ“Š HTML Reports

Generated reports include:

  • Test execution summary with pass/fail statistics
  • Detailed test results with timing information
  • Assertion breakdowns and error details
  • Response previews and debugging information
  • Mobile-friendly responsive design

๐Ÿ”’ Authentication Support

  • Bearer Tokens: auth_bearer environment variable
  • API Keys: auth_apikey environment variable (sent as X-API-Key header)
  • Basic Auth: auth_basic environment variable

๐Ÿ”ง Requirements

  • Python: 3.8 or higher
  • Node.js: 14 or higher (for npm installation)

๐Ÿ“ฆ Dependencies

Python Dependencies

  • fastmcp>=0.2.0
  • pydantic>=2.0.0
  • aiohttp>=3.8.0
  • jinja2>=3.1.0
  • pyyaml>=6.0
  • jsonschema>=4.0.0
  • faker>=19.0.0

Node.js Dependencies

  • None (self-contained package)

๐Ÿ”ง Troubleshooting

Common Issues

NPX Command Not Working

# If npx command fails, try:
npm install -g @kirti676/api-tester-mcp@latest

# Or run directly:
node ./node_modules/@kirti676/api-tester-mcp/cli.js

Python Not Found

# Make sure Python 3.8+ is installed and in PATH
python --version

# Install Python dependencies manually if needed:
pip install fastmcp>=0.2.0 pydantic>=2.0.0 requests>=2.28.0

MCP Client Connection Issues

  • Ensure the MCP server is running on stdio transport (default)
  • Check that your MCP client supports the latest MCP protocol version
  • Verify the configuration JSON syntax is correct

Getting Help

  1. Check the Examples directory for working configurations
  2. See PROGRESS_TRACKING.md for detailed progress tracking documentation
  3. Run with --verbose flag for detailed logging
  4. Report issues on GitHub Issues

๐Ÿค Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ› Issues & Support

๐Ÿ“ˆ Roadmap

  • Multi-Language Test Generation - TypeScript/Playwright, JavaScript/Jest, Python/pytest support โœจ NEW!
  • Complete Project Generation - Full project scaffolding with dependencies and configuration โœจ NEW!
  • GraphQL API support
  • Additional authentication methods (OAuth2, JWT)
  • Go/Golang test generation (with testify/ginkgo)
  • C#/.NET test generation (with NUnit/xUnit)
  • Performance monitoring and alerting
  • Integration with CI/CD pipelines (GitHub Actions, Jenkins)
  • Advanced test data generation from examples and schemas
  • API contract testing with Pact support
  • Mock server generation for development

Made with โค๏ธ for QA/SDET engineers

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

api_tester_mcp-1.3.0.tar.gz (52.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

api_tester_mcp-1.3.0-py3-none-any.whl (48.5 kB view details)

Uploaded Python 3

File details

Details for the file api_tester_mcp-1.3.0.tar.gz.

File metadata

  • Download URL: api_tester_mcp-1.3.0.tar.gz
  • Upload date:
  • Size: 52.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for api_tester_mcp-1.3.0.tar.gz
Algorithm Hash digest
SHA256 e7a64bfd05645343a4e3892945a763584bcfc4c24020dab6b707a60ee02b199b
MD5 6a713b4b93b954be31018d94420d53d4
BLAKE2b-256 b2feb735fd23fcf0d790341d0a4c8b15ed898ddbc99d9bdae0aac0420b16a2f8

See more details on using hashes here.

File details

Details for the file api_tester_mcp-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: api_tester_mcp-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 48.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for api_tester_mcp-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 25be210e92f3bc4b64c926dbe963340bf77f853858a872016796048cd9b4107a
MD5 2fc4d1da8552e6818fa5af6d7fdc6b6e
BLAKE2b-256 91ab1bd5544d517795cf8444c800f31b50d36043d25c7d7ba61ec9946bcfcccc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page