Content
# @mcp-tools/api-tester
API testing tool based on Model Context Protocol (MCP), supporting connectivity checks, database validation, and Postman integration.
## Features
- 🚀 **Out of the box** - Zero configuration to get started
- 🔧 **Highly configurable** - Supports multi-service configuration
- 📮 **Postman integration** - Automatic import of request history
- 🗄️ **Database validation** - Directly connect to database for validation
- ⚡ **Batch testing** - One-click run test cases
- 🧪 **Newman support** - CLI automation testing
## Installation
```bash
npm install -g @mcp-tools/api-tester
```
## Quick Start
👉 [Quick Start Guide](docs/QUICK-START.md) - 5-minute quick start
## Documentation Directory
| Document | Description |
|------|------|
| [Quick Start](docs/QUICK-START.md) | Quick start guide |
| [API Reference](docs/API.md) | Detailed parameters for all MCP tools |
| [Contributing Guide](docs/CONTRIBUTING.md) | Development contribution guide |
## Getting Started
### 1. Configure Your Service
Create `config/services.json`:
```json
{
"my-service": {
"name": "my-service",
"host": "localhost",
"port": 3000,
"baseUrl": "http://localhost:3000",
"db": {
"host": "localhost",
"port": 3306,
"user": "root",
"password": "your_password",
"database": "your_db",
"dialect": "mysql"
}
}
}
```
### 2. Set Environment Variables (Optional)
```bash
# Postman API Key (for automatic import)
export POSTMAN_API_KEY="your-postman-api-key"
# Custom configuration path
export SERVICES_CONFIG_PATH="./my-services.json"
```
### 3. Start MCP Server
```bash
mcp-api-tester
```
Or configure `settings.json` in Claude Code:
```json
{
"mcpServers": {
"api-tester": {
"command": "mcp-api-tester"
}
}
}
```
## MCP Tools
| Tool | Description | Postman |
|------|------|---------|
| `http_request` | Send HTTP request | autoImportPostman |
| `health_check` | Check service connectivity | - |
| `run_api_test` | Execute batch test cases | ✓ |
| `db_query` | Query/validate database | - |
| `assert_response` | Assert response | - |
| `run_with_newman` | Run with Newman CLI | - |
## Example Usage
### http_request
```javascript
{
"tool": "http_request",
"service": "my-service",
"method": "POST",
"path": "/api/users",
"body": { "name": "test", "age": 20 },
"autoImportPostman": true
}
```
### run_api_test
```javascript
{
"tool": "run_api_test",
"service": "my-service",
"testCases": [
{ "name": "Get list", "method": "GET", "path": "/api/users", "expected": { "errno": 0 } },
{ "name": "Create user", "method": "POST", "path": "/api/users", "body": { "name": "test" }, "expected": { "errno": 0 } }
]
}
```
### db_query
```javascript
{
"tool": "db_query",
"service": "my-service",
"table": "users",
"operation": "select",
"where": { "id": 1 }
}
```
## CLI Options
```bash
mcp-api-tester --help # Show help
mcp-api-tester --list # List configured services
mcp-api-tester --config ./my-config.json # Specify configuration file
```
## Project Structure
```
@mcp-tools/api-tester/
├── bin/
│ └── mcp-api-tester.js # CLI entry
├── lib/
│ ├── index.js # Main entry
│ ├── config/
│ │ └── services.js # Configuration loader
│ └── tools/
│ ├── http.js # HTTP request
│ ├── health.js # Health check
│ ├── test.js # Batch testing
│ ├── db.js # Database
│ ├── assert.js # Assertion
│ ├── newman.js # Newman
│ └── postman-api.js # Postman API
├── config/
│ ├── services.json # Default configuration
│ └── services.example.json # Example configuration
└── README.md
```
## Publish to npm
```bash
# Login to npm
npm login
# Publish
npm publish
# Publish beta version
npm publish --tag beta
```
## License
MIT