We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/BIFROTEK-com/supabase-mcp-http-stream-n8n'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
# π§ͺ Testing Documentation
## Overview
This project includes comprehensive security tests for the MCP HTTP Server to ensure it's hardened against common attacks and follows security best practices.
## Test Coverage
### β
**Security Features Tested**
#### π **Authentication & Authorization**
- API key authentication (optional/required modes)
- Multiple API key support
- Header variations (`X-API-Key`, `API-Key`, `Authorization: Bearer`)
- Invalid key rejection
- Missing authentication handling
#### π‘οΈ **Request Validation**
- JSON-RPC 2.0 format validation
- Required field checking (`jsonrpc`, `id`, `method`)
- Dangerous method blocking (`eval`, `exec`, `system`, etc.)
- Malformed JSON rejection
- Empty request body handling
#### π§ **Rate Limiting**
- MCP endpoint rate limiting (15min windows)
- General endpoint rate limiting (1min windows)
- Health check bypass
- Configurable limits via environment variables
#### π **CORS Protection**
- Default allow-all behavior
- Configurable origin restrictions
- Preflight request handling
- Cross-origin header management
#### π **Security Headers**
- Helmet.js security headers
- Content type protection
- XSS protection
- Frame options
#### π‘ **Transport Support**
- Server-Sent Events (SSE) handling
- Content type detection
- Streaming response management
## Running Tests
### **HTTP Server Tests**
```bash
# Run all HTTP security tests
npm run test:http
# Run tests in watch mode
npm run test:http:watch
# Run tests with coverage report
npm run test:http:coverage
```
### **Package Tests (Supabase MCP)**
```bash
# Run all workspace tests
npm test
# Run tests with coverage
npm run test:coverage
```
## Test Results
**Current Status: β
All 27 tests passing**
```
β Health Endpoint (1)
β Status Endpoint (1)
β Authentication (4)
β Request Validation (3)
β Security Headers (1)
β SSE Support (1)
β CORS Configuration (2)
β Rate Limiting Edge Cases (2)
β Multiple API Keys (2)
β Header Variations (2)
β Payload Security (3)
β Content Type Handling (2)
β Error Response Format (3)
```
## Test Categories
### **Core Security Tests**
| Category | Tests | Description |
|----------|-------|-------------|
| Authentication | 4 | API key validation and auth flows |
| Request Validation | 3 | JSON-RPC format and dangerous method blocking |
| Security Headers | 1 | Helmet.js security header verification |
### **Edge Case Tests**
| Category | Tests | Description |
|----------|-------|-------------|
| Rate Limiting | 2 | Time windows and bypass logic |
| Multiple API Keys | 2 | Multi-key support and whitespace handling |
| Header Variations | 2 | Different auth header formats |
| Payload Security | 3 | Malformed requests and method validation |
| Content Type | 2 | JSON handling and content type requirements |
| Error Handling | 3 | Structured error response validation |
### **Integration Tests**
| Category | Tests | Description |
|----------|-------|-------------|
| Health Endpoint | 1 | Unauthenticated health checks |
| Status Endpoint | 1 | MCP capability reporting |
| SSE Support | 1 | Event stream transport |
| CORS | 2 | Cross-origin request handling |
## Environment Variables Tested
```bash
# Authentication
MCP_API_KEYS="key1,key2,key3"
# Rate Limiting
MCP_RATE_LIMIT_REQUESTS="100" # Per 15 minutes
MCP_RATE_LIMIT_GENERAL="60" # Per minute
# CORS
MCP_ALLOWED_ORIGINS="https://allowed.com,https://trusted.app"
```
## Security Validation
### **π What's Tested**
β
**Authentication bypass prevention**
β
**Injection attack protection** (`eval`, `exec`, etc.)
β
**Rate limiting effectiveness**
β
**CORS policy enforcement**
β
**Input validation robustness**
β
**Error message security** (no info leakage)
β
**Header security** (XSS, frame protection)
### **π¨ Attack Scenarios Covered**
- **Unauthenticated access attempts**
- **Brute force API key attacks**
- **Code injection via method names**
- **DDoS via rapid requests**
- **Cross-origin attacks**
- **Malformed payload exploits**
## Adding New Tests
### **Test Structure**
```javascript
describe('New Security Feature', () => {
test('should prevent specific attack', async () => {
const app = createTestApp();
await request(app)
.post('/mcp')
.send(maliciousPayload)
.expect(403); // or appropriate error code
});
});
```
### **Test Categories to Add**
- **WebSocket security** (if implemented)
- **File upload validation** (if added)
- **SQL injection prevention** (database operations)
- **Memory exhaustion protection**
- **Timeout handling**
## Security Recommendations
Based on test results, the server includes:
β
**Production-ready security hardening**
β
**Configurable authentication** (warn if disabled)
β
**Rate limiting** (prevent abuse)
β
**Input validation** (block dangerous operations)
β
**Security headers** (XSS/CSRF protection)
β
**Error handling** (no information leakage)
## Continuous Security
```bash
# Run tests before deployment
npm run test:http
# Check for security vulnerabilities
npm audit
# Format and lint
npm run format:check
```
## Test Dependencies
- **Vitest**: Modern test framework
- **Supertest**: HTTP testing library
- **Express**: Test app framework
- **Helmet**: Security headers
- **Rate Limiter**: DDoS protection
---
**π Security Status: HARDENED**
**π§ͺ Test Coverage: 27/27 PASSING**
**π Production Ready: YES**