Skip to main content
Glama
purpleax

Fastly NGWAF MCP Server

by purpleax
README.md
# Fastly NGWAF MCP Server

A comprehensive Model Context Protocol (MCP) server that provides seamless integration with the Fastly NGWAF (Next-Gen Web Application Firewall) API. This server enables AI assistants like Claude to manage web application security through natural language interactions.

## Features

šŸ›”ļø **Complete WAF Management**
- Create, read, update, and delete security rules
- Manage IP allow/block lists
- Configure rate limiting and alerts
- Monitor security events and analytics

šŸ¢ **Multi-tenancy Support**
- Corporation and site-level management
- Context-aware operations
- Bulk operations across multiple sites

šŸ¤– **AI-Friendly Interface**
- Natural language rule creation
- Intelligent threat pattern detection
- Automated security policy suggestions

## Installation

### Prerequisites
- Node.js 18+ 
- Fastly NGWAF account with API access
- MCP-compatible AI assistant (Claude Desktop, etc.)

### Setup

1. **Clone the repository**
```bash
git clone https://github.com/yourusername/FastlyMCP.git
cd FastlyMCP
```

2. **Install dependencies**
```bash
npm install
```

3. **Configure environment variables (optional)**
```bash
# Create .env file
FASTLY_NGWAF_EMAIL=your-email@example.com
FASTLY_NGWAF_TOKEN=your-api-token
FASTLY_NGWAF_DEFAULT_CORP=your-corp-name
FASTLY_NGWAF_DEFAULT_SITE=your-site-name
```

4. **Start the server**
```bash
npm start
```

## Configuration

### Claude Desktop Integration

Add this to your Claude Desktop configuration file:

**Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`

```json
{
  "mcpServers": {
    "fastly-ngwaf": {
      "command": "node",
      "args": ["path/to/FastlyMCP/server.js"],
      "env": {
        "FASTLY_NGWAF_EMAIL": "your-email@example.com",
        "FASTLY_NGWAF_TOKEN": "your-api-token"
      }
    }
  }
}
```


### AI-Powered Interactions

**Natural Language**: *"Create a rule to block SQL injection attacks on my website"*

**AI Response**: The assistant will automatically:
1. Detect the intent (create security rule)
2. Identify the threat type (SQL injection) 
3. Generate appropriate rule conditions
4. Apply the rule to your configured site


## Available Tools

### Authentication & Setup
- `set_credentials` - Configure API credentials
- `test_connection` - Validate API connectivity
- `set_context` - Set default corp/site context
- `discover_environment` - Explore available resources

### Rule Management
- `list_corp_rules` / `list_site_rules` - List security rules
- `create_corp_rule` / `create_site_rule` - Create new rules
- `delete_corp_rule` / `delete_site_rule` - Remove rules

### Security Monitoring
- `list_events` - View security events
- `search_requests` - Search request logs  
- `get_suspicious_ips` - Identify threat sources
- `expire_event` - Manually unblock IPs

### IP List Management
- `manage_whitelist` - Allow/block IP addresses
- `manage_blacklist` - Block malicious IPs
- `manage_lists` - Custom IP/country/string lists

### Analytics & Reporting
- `get_analytics` - Security metrics and trends
- `get_corp_overview` - High-level attack summary
- `manage_alerts` - Configure monitoring alerts

### Advanced Features
- `manage_cloudwaf` - CloudWAF instance management
- `manage_users` - User access control

## Common Use Cases

### 🚨 Incident Response
*"An IP address 1.2.3.4 is attacking my site, block it immediately"*
- AI automatically identifies the threat
- Adds IP to blacklist with appropriate duration
- Confirms blocking is active

### šŸ›”ļø Proactive Security
*"Set up protection against the latest OWASP top 10 vulnerabilities"*  
- Creates comprehensive rule sets
- Configures appropriate thresholds
- Sets up monitoring alerts

### šŸ“Š Security Analytics
*"Show me attack trends from the past month and suggest improvements"*
- Analyzes historical attack data
- Identifies patterns and threat sources
- Recommends rule optimizations

### šŸ”§ Bulk Management
*"Apply the same security rules from site A to sites B, C, and D"*
- Exports existing rule configurations
- Adapts rules for different sites
- Bulk applies with verification

## API Reference

The server exposes the complete Fastly NGWAF API through intuitive MCP tools. Each tool maps to specific API endpoints while handling authentication, context resolution, and error management automatically.



### Rate Limiting
The server respects Fastly API rate limits and implements appropriate retry logic.

## Development

### Project Structure
```
FastlyMCP/
ā”œā”€ā”€ server.js          # Main MCP server implementation
ā”œā”€ā”€ package.json       # Dependencies and scripts  
ā”œā”€ā”€ README.md          # This documentation
└── .env.example       # Environment variable template
```

### Testing
```bash
# Test API connectivity
npm start
# In another terminal/AI session:
# test_connection()
```

## Troubleshooting

### Common Issues

**Authentication Failed**
- Verify email and API token are correct
- Ensure token has appropriate permissions
- Check Fastly account status

**Context Errors**
- Set default corporation: `set_context({ corpName: "your-corp" })`
- Verify corp/site names exist: `discover_environment()`

**Permission Denied**
- Check user role has necessary permissions
- Verify site access in Fastly dashboard

### Debug Mode
Enable verbose logging by setting environment variable:
```bash
DEBUG=fastly-ngwaf npm start
```

## Security Considerations

- Store API credentials securely (environment variables or secure credential managers)
- Use principle of least privilege for API tokens  
- Regularly rotate API credentials
- Monitor for unauthorized API usage
- Keep dependencies updated

## License

MIT License - see LICENSE file for details.

## Support

- šŸ“š [Fastly NGWAF Documentation](https://docs.fastly.com/products/web-application-firewall)

## Changelog

### v1.0.0
- Initial release with complete NGWAF API coverage
- MCP server implementation
- Rule management (CRUD operations)
- IP list management
- Analytics and monitoring
- CloudWAF support
- User management features

TDQS

B3/5.0

Scored across 29 tools

Disambiguation4/5

Most tools have distinct purposes targeting specific resources (sites, rules, events, lists, etc.), but some overlap exists: manage_blacklist and manage_whitelist are clear opposites, but manage_lists (custom lists) could be confused with them. Tools like manage_alerts and manage_cloudwaf are distinct but their boundaries with other monitoring/configuration tools might require careful reading of descriptions.

Naming Consistency5/5

Tool names follow a highly consistent verb_noun pattern throughout (e.g., create_corp_rule, list_sites, get_analytics, manage_users). All use snake_case with clear action prefixes (create, delete, get, list, manage, set, etc.), making them predictable and easy to parse for an agent.

Tool Count3/5

With 29 tools, the count is borderline high for a WAF management server. While it covers many aspects (rules, sites, events, analytics, configuration), it risks being overwhelming. A typical well-scoped server might have 15-25 tools; this is slightly above that range but not extreme.

Completeness5/5

The toolset provides comprehensive coverage for WAF management: CRUD for sites and rules (create, get, list, update, delete), event handling (list, expire), analytics, context management, credential setup, and utilities like testing connections. No obvious gaps are present; agents can perform full lifecycle operations.

Maintenance

ActivityInactive
ResponsivenessNo issues