dhqanh-rcc/stackrox-mcp
If you are the rightful owner of stackrox-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The StackRox MCP Server is a Model Context Protocol server that provides AI assistants with secure access to StackRox security data and alerts.
StackRox MCP Server
A Model Context Protocol (MCP) server that provides AI assistants with secure access to StackRox security data and alerts.
๐ Features
- Security Alerts: List and query security alerts from StackRox
- Alert Counting: Get total count of security alerts
- MCP Protocol: Standard MCP interface for AI assistant integration
- Secure Authentication: Token-based authentication with StackRox API
๐ Prerequisites
- Go 1.23 or later
- Access to a StackRox/Red Hat Advanced Cluster Security (RHACS) instance
- StackRox API token with appropriate permissions
๐ง Installation
From Source
# Clone the repository
git clone https://github.com/yourusername/stackrox-mcp.git
cd stackrox-mcp
# Build the binary
go build -o stackrox-mcp ./cmd/main.go
# Run the server
./stackrox-mcp
Using Go Install
go install github.com/yourusername/stackrox-mcp/cmd@latest
โ๏ธ Configuration
The server requires the following environment variables:
Variable | Description | Required | Example |
---|---|---|---|
STACKROX_ENDPOINT | StackRox API endpoint URL | Yes | https://stackrox.example.com |
STACKROX_API_TOKEN | StackRox API authentication token | Yes | your-api-token-here |
Creating a StackRox API Token
- Log in to your StackRox Central instance
- Navigate to Platform Configuration โ Integrations
- Click API Token โ Generate Token
- Assign appropriate roles (minimum: read access to alerts)
- Copy the generated token
Configuration File
Create a .env
file in the project root:
STACKROX_ENDPOINT=https://stackrox.example.com
STACKROX_API_TOKEN=your-api-token-here
๐ฏ Usage
Running the Server
# With environment variables
export STACKROX_ENDPOINT="https://stackrox.example.com"
export STACKROX_API_TOKEN="your-api-token"
./stackrox-mcp
# With .env file
./stackrox-mcp
Available MCP Tools
The server exposes the following tools via the MCP protocol:
1. list_alerts
List security alerts from StackRox.
Parameters:
limit
(optional, number): Maximum number of alerts to return (default: 10)
Example:
{
"name": "list_alerts",
"arguments": {
"limit": 20
}
}
2. count_alerts
Get the total count of security alerts.
Parameters: None
Example:
{
"name": "count_alerts",
"arguments": {}
}
๐ Integrating with AI Assistants
Claude Desktop
Add to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"stackrox": {
"command": "/path/to/stackrox-mcp",
"env": {
"STACKROX_ENDPOINT": "https://stackrox.example.com",
"STACKROX_API_TOKEN": "your-api-token"
}
}
}
}
Other MCP Clients
The server implements the standard MCP protocol and works with any MCP-compatible client:
# Start the server (stdio mode)
./stackrox-mcp
๐๏ธ Architecture
โโโโโโโโโโโโโโโโโโโ
โ AI Assistant โ
โ (Claude, etc) โ
โโโโโโโโโโฌโโโโโโโโโ
โ MCP Protocol
โ (stdio)
โโโโโโโโโโผโโโโโโโโโ
โ StackRox MCP โ
โ Server โ
โโโโโโโโโโฌโโโโโโโโโ
โ HTTPS/REST
โ
โโโโโโโโโโผโโโโโโโโโ
โ StackRox โ
โ Central API โ
โโโโโโโโโโโโโโโโโโโ
Components
- cmd/main.go: Entry point and MCP server setup
- internal/config: Configuration management
- internal/service: StackRox API client and business logic
- generated/http: Auto-generated HTTP client from OpenAPI spec
๐ Security
Best Practices
-
Token Security
- Store API tokens securely (use environment variables or secret managers)
- Never commit tokens to version control
- Rotate tokens regularly
- Use read-only tokens when possible
-
Network Security
- Always use HTTPS for StackRox connections
- Validate TLS certificates in production
- Use network policies to restrict access
-
Least Privilege
- Grant minimal required permissions to API tokens
- Use separate tokens for different environments
Security Scanning
This project uses:
- Trivy: Container vulnerability scanning
- Gosec: Go security code analysis
- Dependabot: Dependency vulnerability alerts
See for CI/CD security details.
๐งช Development
Prerequisites
- Go 1.23+
- Docker (for container builds)
- Make (optional)
Setup Development Environment
# Clone repository
git clone https://github.com/yourusername/stackrox-mcp.git
cd stackrox-mcp
# Install dependencies
go mod download
# Run tests
go test -v ./...
# Run with race detection
go test -race ./...
# Build
go build -o stackrox-mcp ./cmd/main.go
Project Structure
stackrox-mcp/
โโโ cmd/
โ โโโ main.go # Application entry point
โโโ internal/
โ โโโ config/
โ โ โโโ config.go # Configuration loading
โ โโโ service/
โ โโโ stackrox.go # StackRox API client
โโโ generated/
โ โโโ http/ # Generated API client code
โโโ .github/
โ โโโ workflows/ # CI/CD workflows
โโโ Dockerfile # Container image definition
โโโ go.mod # Go module definition
โโโ README.md # This file
Running Tests
# Run all tests
go test ./...
# Run with coverage
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out
# Run specific package
go test ./internal/service/...
Code Quality
# Run linter
golangci-lint run
# Format code
go fmt ./...
# Check for security issues
gosec ./...
๐ฆ Building
Binary
# Build for current platform
go build -o stackrox-mcp ./cmd/main.go
# Build with optimizations
go build -ldflags="-s -w" -trimpath -o stackrox-mcp ./cmd/main.go
# Cross-compile for different platforms
GOOS=linux GOARCH=amd64 go build -o stackrox-mcp-linux-amd64 ./cmd/main.go
GOOS=darwin GOARCH=arm64 go build -o stackrox-mcp-darwin-arm64 ./cmd/main.go
GOOS=windows GOARCH=amd64 go build -o stackrox-mcp-windows-amd64.exe ./cmd/main.go
Docker Image
# Build image
docker build -t stackrox-mcp:latest .
# Run container
docker run -e STACKROX_ENDPOINT="https://stackrox.example.com" \
-e STACKROX_API_TOKEN="your-token" \
stackrox-mcp:latest
# Build multi-platform image
docker buildx build --platform linux/amd64,linux/arm64 -t stackrox-mcp:latest .
๐ข Deployment
Docker Compose
version: '3.8'
services:
stackrox-mcp:
image: yourusername/stackrox-mcp:latest
environment:
- STACKROX_ENDPOINT=https://stackrox.example.com
- STACKROX_API_TOKEN=${STACKROX_API_TOKEN}
restart: unless-stopped
Kubernetes
apiVersion: apps/v1
kind: Deployment
metadata:
name: stackrox-mcp
spec:
replicas: 1
selector:
matchLabels:
app: stackrox-mcp
template:
metadata:
labels:
app: stackrox-mcp
spec:
containers:
- name: stackrox-mcp
image: yourusername/stackrox-mcp:latest
env:
- name: STACKROX_ENDPOINT
value: "https://stackrox.example.com"
- name: STACKROX_API_TOKEN
valueFrom:
secretKeyRef:
name: stackrox-mcp-secret
key: api-token
๐ค Contributing
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
Development Guidelines
- Write tests for new features
- Follow Go best practices and idioms
- Run
go fmt
andgolangci-lint
before committing - Update documentation for API changes
- Add examples for new features
๐ License
This project is licensed under the MIT License - see the file for details.
๐ Acknowledgments
- MCP Go SDK - Model Context Protocol implementation
- StackRox - Kubernetes security platform
- Red Hat Advanced Cluster Security - Enterprise Kubernetes security
๐ Additional Resources
- Model Context Protocol Specification
- StackRox API Documentation
- - CI/CD documentation
- MCP SDK Documentation
๐ Troubleshooting
Common Issues
Issue: Connection refused to StackRox
Solution: Verify STACKROX_ENDPOINT is correct and accessible
Check: curl -k https://your-stackrox-instance/v1/ping
Issue: Authentication failed
Solution: Verify API token is valid and has correct permissions
Check: Token hasn't expired and has read access to alerts
Issue: No alerts returned
Solution: Check if alerts exist in StackRox
Check: Verify token has permission to view alerts
Issue: MCP client can't connect
Solution: Ensure server is running in stdio mode
Check: Verify client configuration path to binary
๐ Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Security: Report security issues to security@example.com
๐ Status
Made with โค๏ธ for secure Kubernetes deployments