Labsco
kirti676 logo

API Tester

β˜… 6

from kirti676

This MCP Server accepts swagger/postman documents as input. It then generates API & Load test scenarios, executes the tests and generates the execution report.

πŸ”₯πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedFreeQuick setup

API Tester MCP Server

npm (scoped) npm downloads 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

✨ Features

  • πŸ“₯ Input Support: OpenAPI/Swagger documents, Postman collections, and GraphQL schemas
  • πŸ”„ 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

LanguageFrameworkDescriptionUse Case
πŸ“˜ TypeScript🎭 PlaywrightModern E2E testing with excellent API support🏒 Enterprise web applications
πŸ“˜ TypeScriptπŸš€ SupertestExpress.js focused API testing🟒 Node.js backend services
πŸ“™ JavaScriptπŸƒ JestPopular testing framework with good ecosystemπŸ”§ General API testing
πŸ“™ JavaScript🌲 CypressE2E testing with great developer experience🌐 Full-stack applications
🐍 PythonπŸ§ͺ pytestComprehensive testing with fixtures & pluginsπŸ“Š Data-heavy APIs & ML services
🐍 PythonπŸ“‘ requestsSimple 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",
  file_path: "./path/to/your/api-spec.json",
  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 11 comprehensive MCP tools with detailed parameter specifications:

1. πŸ“₯ ingest_spec - Load API Specifications

Load OpenAPI/Swagger, Postman collections, or GraphQL schemas with language/framework preferences

{
  "spec_type": "openapi",           // openapi, swagger, postman, graphql (optional, auto-detected)
  "file_path": "./api-spec.json",   // Path to JSON, YAML, or GraphQL schema file (required)
  "preferred_language": "python",   // python, typescript, javascript (optional, default: python)
  "preferred_framework": "requests" // pytest, requests, playwright, jest, cypress, supertest (optional, default: requests)
}

2. πŸ”§ set_env_vars - Configure Authentication & Environment

Set environment variables with automatic validation and guidance

{
  "variables": {},                  // Dictionary of custom environment variables (optional)
  "baseUrl": null,                 // API base URL (optional)
  "auth_bearer": null,             // Bearer/JWT token (optional)
  "auth_apikey": null,             // API key (optional)
  "auth_basic": null,              // Base64 encoded credentials (optional)
  "auth_username": null,           // Username for basic auth (optional)
  "auth_password": null            // Password for basic auth (optional)
}

3. 🎬 generate_scenarios - Create Test Scenarios

Generate test scenarios from ingested specifications

{
  "include_negative_tests": true,   // Generate failure scenarios (default: true)
  "include_edge_cases": true        // Generate boundary conditions (default: true)
}

4. πŸ§ͺ generate_test_cases - Convert to Executable Tests

Convert scenarios to executable test cases in preferred language/framework

{
  "scenario_ids": null              // Array of scenario IDs or null for all (optional)
}

5. πŸš€ run_api_tests - Execute API Tests

Execute API tests with detailed results and reporting

{
  "test_case_ids": null,           // Array of test case IDs or null for all (optional)
  "max_concurrent": 10             // Number of concurrent requests 1-50 (default: 10)
}

6. ⚑ run_load_tests - Execute Performance Tests

Execute load/performance tests with configurable parameters

{
  "test_case_ids": null,           // Array of test case IDs or null for all (optional)
  "duration": 60,                  // Test duration in seconds (default: 60)
  "users": 10,                     // Number of concurrent virtual users (default: 10)
  "ramp_up": 10                    // Ramp up time in seconds (default: 10)
}

7. 🌐 get_supported_languages - List Language/Framework Options

Get list of supported programming languages and testing frameworks

// No parameters required
{}

8. πŸ“¦ generate_project_files - Generate Complete Projects

Generate complete project structure with dependencies and configuration

{
  "project_name": null,            // Project folder name (optional, auto-generated if null)
  "include_examples": true         // Include example test files (default: true)
}

9. πŸ“ get_workspace_info - Workspace Information

Get information about workspace directory and file generation locations

// No parameters required
{}

10. πŸ” debug_file_system - File System Diagnostics

Get comprehensive workspace information and file system diagnostics

// No parameters required
{}

11. πŸ“Š get_session_status - Session Status & Progress

Retrieve current session information with progress details

// No parameters required
{}

πŸ“š 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",
  file_path: "./api-specification.json"
});

// 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
  file_path: "./api-spec.json", // Path to JSON or YAML specification file
  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
});

πŸš€ 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", {
  spec_type: "openapi",
  file_path: "./examples/petstore_openapi.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"
});

πŸ” 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

πŸ“¦ Dependencies

🐍 Python Dependencies

  • πŸš€ fastmcp>=0.2.0
  • πŸ“Š pydantic>=2.0.0
  • 🌐 requests>=2.28.0
  • βœ… jsonschema>=4.0.0
  • πŸ“ pyyaml>=6.0
  • 🎨 jinja2>=3.1.0
  • ⚑ aiohttp>=3.8.0
  • 🎭 faker>=19.0.0

🟒 Node.js Dependencies

  • ✨ None (self-contained package)

🀝 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 - Supports GraphQL Schemas ✨ NEW!
  • 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