MCP server for API testing: generates test cases, validates specs, compares versions, and creates mock data from Swagger/OpenAPI specifications
swagger-testcase-mcp
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
MCP server for API testing: generates test cases, validates specs, compares versions, and creates mock data from Swagger/OpenAPI specifications.
Feed it your API spec URL — get structured, categorized test cases (positive, negative, boundary, auth, security, idempotency, pagination) ready for manual testing or import into your TMS.
Why
- **Writing test cases manually is slow.** A single endpoint with 10+ parameters can require 30-50 test cases across positive, negative, boundary, and security scenarios. Multiply that by dozens of endpoints — and you're spending days on routine work instead of actual testing.
- **Negative and boundary cases get skipped.** Under deadline pressure, QA focuses on happy paths. Edge cases, invalid inputs, and security checks are the first to be cut — and the first to cause production incidents.
- **Specs change faster than test docs, and internal APIs get left behind.** New endpoints, renamed fields, changed constraints — keeping test cases in sync is constant overhead. Corporate APIs behind VPN or custom auth make it even harder, since most tooling doesn't support authenticated spec access.
- **Getting test cases into your TMS takes extra steps.** Even if you write great test cases, formatting them for TestRail, Allure, or Postman import is tedious work that adds no value.
This tool automates the baseline: point it at any Swagger/OpenAPI spec (public, internal, localhost), get categorized test cases in seconds, and save ready-to-import files for your TMS or test runner. You focus on business logic and exploratory testing — the tool handles the rest.
Features
- **Parses Swagger 2.0 and OpenAPI 3.x** — JSON and YAML
- **Smart test case generation** — analyzes parameters, schemas, constraints, response codes, and security to produce relevant test cases
- **8 test categories** — positive, negative, boundary, authorization, business logic, security injection, idempotency, pagination & sorting
- **9 export formats** — Markdown, JSON, CSV, Allure CSV, Gherkin, Postman, k6, pytest, TestRail CSV (two templates: Steps and Text)
- **Spec validation** — quality scoring with 11 rules and actionable suggestions
- **Spec comparison** — diff two versions with breaking change detection
- **Mock data generation** — realistic test data from schemas with locale support
- **Coverage analysis** — identify gaps in test coverage with prioritized recommendations
- **Auto-save to file** — exports are saved to the working directory automatically, no manual copy-paste
- **Configurable generation** — filter by category, priority, locale, custom preconditions
- **Batch generation** — filter by tag, HTTP method, path prefix, deprecated status
- **Works with any MCP client** — Claude Desktop, Cursor, VS Code + Cline, etc.
Generated test case categories
| Category | What it covers |
|----------|---------------|
| ✅ Positive | Happy path with required fields, happy path with all fields |
| ❌ Negative | Missing required fields, invalid types, empty strings, nulls, invalid enums, empty body |
| 📏 Boundary | Min/max values for numbers, minLength/maxLength for strings |
| 🔐 Auth | No token, invalid token, insufficient permissions |
| 💼 Business Logic | 404 for non-existent resources, 409 conflicts, 429 rate limiting, concurrency |
| 🛡️ Security | XSS, SQL injection, path traversal, command injection, CRLF injection |
| 🔄 Idempotency | Repeated PUT/DELETE, POST with Idempotency-Key |
| 📄 Pagination | First/last page, negative offset, zero limit, invalid sort fields |
Installation
Or run directly with npx:
Configuration
Claude Desktop
Add to claude_desktop_config.json:
Cursor
Add to .cursor/mcp.json:
VS Code + Claude Code
Add to .vscode/mcp.json:
VS Code + Cline
Add to Cline MCP settings: