StackHawk MCP Server for Security Analytics and Developer Integration
Project description
StackHawk MCP Server
Current Version: 0.1.0 Requires Python 3.10 or higher
A Model Context Protocol (MCP) server for integrating with StackHawk's security scanning platform. Provides security analytics, YAML configuration management, sensitive data/threat surface analysis, and anti-hallucination tools for LLMs.
Table of Contents
- Features
- Installation
- Usage
- Configuration
- Available Tools & API
- YAML & Anti-Hallucination
- Sensitive Data & Threat Surface
- Testing & Development
- Example Configurations
- Contributing
- License
- Integrating with LLMs and IDEs
Features
- Security Analytics: Organization, application, and vulnerability tools
- YAML Configuration Tools: Creation, validation, schema reference, anti-hallucination field validation
- Sensitive Data & Threat Surface Analysis: Repository, application, and data exposure mapping
- Custom User-Agent: All API calls include a versioned
User-Agentheader - Comprehensive Test Suite: Automated tests for all major features
Installation
- Install via pip:
pip install stackhawk-mcp # Requires Python 3.10 or higher
- Set your StackHawk API key:
export STACKHAWK_API_KEY="your-api-key-here"
Usage
Running the MCP Server
python -m stackhawk_mcp.server
Running the HTTP Server (FastAPI)
python -m stackhawk_mcp.http_server
Running Tests
pytest
Integrating with LLMs and IDEs
StackHawk MCP can be used as a tool provider for AI coding assistants and LLM-powered developer environments, enabling security analytics, YAML validation, and anti-hallucination features directly in your workflow.
Cursor (AI Coding Editor)
- Setup:
- You can install
stackhawk-mcpglobally with pip, or use pipx for isolated environments (recommended for CLI tools):pipx install stackhawk-mcp
- Run the MCP server locally:
python -m stackhawk_mcp.serveror the HTTP server:python -m stackhawk_mcp.http_server. - In Cursor, add a custom tool provider pointing to your local MCP server endpoint (e.g.,
http://localhost:8080/mcp). - Configure your API key as an environment variable:
export STACKHAWK_API_KEY=your-api-key. - Example
cursor-mcp-config.jsonusing pipx:{ "mcpServers": { "stackhawk": { "command": "pipx", "args": ["run", "stackhawk-mcp", "-m", "stackhawk_mcp.server"], "env": { "STACKHAWK_API_KEY": "${env:STACKHAWK_API_KEY}" } } } }
- Or, if
stackhawk-mcpprovides a CLI entry point:{ "mcpServers": { "stackhawk": { "command": "pipx", "args": ["run", "stackhawk-mcp"], "env": { "STACKHAWK_API_KEY": "${env:STACKHAWK_API_KEY}" } } } }
- Example
cursor-mcp-config.jsonusing python directly:{ "mcpServers": { "stackhawk": { "command": "python3", "args": ["-m", "stackhawk_mcp.server"], "env": { "STACKHAWK_API_KEY": "${env:STACKHAWK_API_KEY}" } } } }
- You can install
- Usage:
- Use Cursor's tool invocation to call StackHawk MCP tools (e.g., vulnerability search, YAML validation).
- Example prompt:
Validate this StackHawk YAML config for errors.
OpenAI, Anthropic, and Other LLMs
- Setup:
- Deploy the MCP HTTP server and expose it to your LLM system (local or cloud).
- Use the LLM's tool-calling or function-calling API to connect to the MCP endpoint.
- Pass the required arguments (e.g., org_id, yaml_content) as specified in the tool schemas.
- Example API Call:
{ "method": "tools/call", "params": { "name": "validate_stackhawk_config", "arguments": {"yaml_content": "..."} } }
- Best Practices:
- Use anti-hallucination tools to validate field names and schema compliance.
- Always check the tool's output for warnings or suggestions.
IDEs like Windsurf
- Setup:
- Add StackHawk MCP as a tool provider or extension in your IDE, pointing to the local or remote MCP server endpoint.
- Configure environment variables as needed.
- Usage:
- Invoke security analytics, YAML validation, or sensitive data tools directly from the IDE's command palette or tool integration panel.
General Tips
- Ensure the MCP server is running and accessible from your LLM or IDE environment.
- Review the Available Tools & API section for supported operations.
- For advanced integration, see the example tool usage in this README or explore the codebase for custom workflows.
Configuration
- All HTTP requests include a custom
User-Agentheader:User-Agent: StackHawk-MCP/{version} - The version is set in
stackhawk_mcp/server.pyasSTACKHAWK_MCP_VERSION. - Set your API key via the
STACKHAWK_API_KEYenvironment variable.
Available Tools & API
Security Analytics
- Organization Info: Get details about StackHawk organizations
- Application Management: List/search applications with security status
- Vulnerability Search: Search for vulnerabilities across applications
- Security Dashboard: Generate executive dashboards
- Vulnerability Reporting: Generate detailed reports and analysis
- Trend Analysis: Analyze vulnerability trends
- Critical Findings: Get high-priority findings
- Executive Summaries: Generate executive-level summaries
YAML Configuration Management
- Create Config: Generate StackHawk YAML config files
- Validate Config: Validate YAML against the official schema
- Schema Reference: Fetch the latest StackHawk schema
- Schema Caching: 24-hour TTL, manual refresh
- Anti-Hallucination: Field validation tools
Sensitive Data & Threat Surface
- Sensitive Data Reporting: Organization, app, and repo-level
- Trend Analysis: Track sensitive data exposure
- Critical Data Findings: Identify high-risk data
- Surface Mapping: Map sensitive data and threat surfaces
Example Tool Usage
# Get organization info
org_info = await server._get_organization_info(org_id="your-org-id")
# Validate a YAML config
result = await server._validate_stackhawk_config(yaml_content="...")
# Get application vulnerabilities
vulns = await server._get_application_vulnerabilities(app_id="your-app-id")
YAML & Anti-Hallucination
- Field Validation: Prevents LLMs from suggesting invalid fields
- Schema Reference: Always up-to-date with the official StackHawk schema
- AI Suggestions: Use
suggest_configurationfor YAML recommendations - YAML Validation: Validate any config with
validate_stackhawk_config
Official Schema URL: https://download.stackhawk.com/hawk/jsonschema/hawkconfig.json
Sensitive Data & Threat Surface
- Data Type Categorization: PII, PCI, PHI
- Risk Assessment: Risk scoring, levels, and factors
- Exposure Mapping: Application and repository analysis
- Trend Analysis: Time-based, app, repo, and data type trends
- Surface Mapping: Entry points, risk heatmap, exposure analysis
Testing & Development
Running All Tests
pytest
Running Individual Tests
pytest tests/test_sensitive_data.py
pytest tests/test_repository_analysis.py
Code Formatting
black stackhawk_mcp/
Type Checking
mypy stackhawk_mcp/
Example Configurations
Basic Configuration
app:
applicationId: "12345678-1234-1234-1234-123456789012"
env: "dev"
host: "http://localhost:3000"
name: "Development App"
description: "Local development environment"
Production Configuration with Authentication
app:
applicationId: "87654321-4321-4321-4321-210987654321"
env: "prod"
host: "https://myapp.com"
name: "Production App"
description: "Production environment"
authentication:
type: "form"
username: "your-username"
password: "your-password"
loginUrl: "https://myapp.com/login"
usernameField: "username"
passwordField: "password"
hawk:
spider:
base: true
ajax: false
maxDurationMinutes: 30
scan:
maxDurationMinutes: 60
threads: 10
startupTimeoutMinutes: 5
failureThreshold: "high"
tags:
- name: "environment"
value: "production"
- name: "application"
value: "myapp"
Contributing
Contributions are welcome! Please open issues or pull requests for bug fixes, new features, or documentation improvements.
License
Apache License 2.0. See LICENSE for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stackhawk_mcp-0.1.0.tar.gz.
File metadata
- Download URL: stackhawk_mcp-0.1.0.tar.gz
- Upload date:
- Size: 48.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
516bd73093a06234a29281c02cc8a49962b296be89173a1284d7abaf3d986e93
|
|
| MD5 |
1e24a8d50b7173a8e20ae5f2683e08ec
|
|
| BLAKE2b-256 |
b1b71c420d289a46d3c5e67686e8730651d05082dd78b8fb09ca496614e69b4b
|
Provenance
The following attestation bundles were made for stackhawk_mcp-0.1.0.tar.gz:
Publisher:
publish-pypi.yml on stackhawk/stackhawk-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stackhawk_mcp-0.1.0.tar.gz -
Subject digest:
516bd73093a06234a29281c02cc8a49962b296be89173a1284d7abaf3d986e93 - Sigstore transparency entry: 265741783
- Sigstore integration time:
-
Permalink:
stackhawk/stackhawk-mcp@99127974e89b7dc137c7dbdfbfd7ab1a906fbcd6 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/stackhawk
-
Access:
internal
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@99127974e89b7dc137c7dbdfbfd7ab1a906fbcd6 -
Trigger Event:
workflow_run
-
Statement type:
File details
Details for the file stackhawk_mcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: stackhawk_mcp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 29.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9892d1025bddaab6e772781efcc77208a8544fa86f2e184c60d5418719684954
|
|
| MD5 |
efd940ee391730e82063bada743f3175
|
|
| BLAKE2b-256 |
0c27fe37d0704d6e4c15832ef9c2c673a51de2b41ac53f9548c121a9c9af4932
|
Provenance
The following attestation bundles were made for stackhawk_mcp-0.1.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on stackhawk/stackhawk-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stackhawk_mcp-0.1.0-py3-none-any.whl -
Subject digest:
9892d1025bddaab6e772781efcc77208a8544fa86f2e184c60d5418719684954 - Sigstore transparency entry: 265741800
- Sigstore integration time:
-
Permalink:
stackhawk/stackhawk-mcp@99127974e89b7dc137c7dbdfbfd7ab1a906fbcd6 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/stackhawk
-
Access:
internal
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@99127974e89b7dc137c7dbdfbfd7ab1a906fbcd6 -
Trigger Event:
workflow_run
-
Statement type: