Skip to main content

MCP server for API testing with Swagger/OpenAPI and Postman collection 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

  • 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
  • ⚡ Test Execution: Run generated tests with detailed reporting
  • 🔐 Authentication: Bearer token and API key support via set_env_vars
  • 📊 HTML Reports: Beautiful, accessible reports via MCP resources
  • 📈 Real-time Progress: Live updates during test execution
  • ✅ Schema Validation: Request body generation from schema examples
  • 🎯 Assertions: Per-endpoint status code assertions (2xx, 4xx, 5xx)

🛠️ MCP Tools

The server provides 7 comprehensive MCP tools:

  1. ingest_spec - Load Swagger/OpenAPI or Postman collections
  2. set_env_vars - Configure authentication and environment variables
  3. generate_scenarios - Create test scenarios from specifications
  4. generate_test_cases - Convert scenarios to executable test cases
  5. run_api_tests - Execute API tests with detailed results
  6. run_load_tests - Execute performance/load tests
  7. 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

🔧 Configuration Example

// 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"
  }
});

// Ingest an OpenAPI specification
await mcp.call("ingest_spec", {
  spec_type: "openapi",
  content: openapi_json_string
});

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

// Run API tests
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. Run with --verbose flag for detailed logging
  3. 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

  • GraphQL API support
  • Additional authentication methods (OAuth2, JWT)
  • Performance monitoring and alerting
  • Integration with CI/CD pipelines
  • Test data generation from examples
  • API contract testing

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.0.0.tar.gz (29.5 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.0.0-py3-none-any.whl (27.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for api_tester_mcp-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2f696d3eb5a3afd6b29febfd07e1ad6a7603d8ae26745b160fb781c0484108b4
MD5 993f1ebd2d6ce233bcb09b7a65c7dd88
BLAKE2b-256 66caa70403c26f042a81b560ebd0f8aba4d65e8f860df0d6fb1621bc5d0d3ae9

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for api_tester_mcp-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9bf27e53ffbffd4236767e142c98bde9411cac585990833ae511c5224f3ee1a6
MD5 dba6d8a6315d30a1dccbda5498ecd970
BLAKE2b-256 73e4b256a983366790e1f216659b2abbe54083554fe84faafdc6c115a0a85f4a

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