This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a Python-based MCP (Model Context Protocol) server that provides security analytics and YAML configuration management for StackHawk's security scanning platform. The server integrates with StackHawk's API to provide vulnerability analysis, sensitive data reporting, and YAML configuration validation.
# Run all tests
pytest
# Run specific test file
pytest tests/test_<name>.py
# Run with asyncio mode (already configured in pyproject.toml)
pytest -v# Format code with Black
black stackhawk_mcp/
# Type checking with mypy
mypy stackhawk_mcp/
# Both formatting and type checking should be run before commits# Run MCP server (stdio mode)
python -m stackhawk_mcp.server
# Run HTTP server (FastAPI)
python -m stackhawk_mcp.http_server
# CLI entry point
stackhawk-mcp# Install in development mode
pip install -e .
# Install with dev dependencies
pip install -e .[dev]
# Set required environment variable
export STACKHAWK_API_KEY="your-api-key-here"stackhawk_mcp/server.py: Main MCP server implementation with all tool handlersstackhawk_mcp/http_server.py: FastAPI HTTP wrapper for the MCP serverstackhawk_mcp/__main__.py: CLI entry point and argument parsingstackhawk_mcp/__init__.py: Package initialization and version management
- Security Analytics Tools: Organization info, application management, vulnerability search, trend analysis
- YAML Configuration Management: Create, validate, and manage StackHawk YAML configs with schema validation
- Sensitive Data & Threat Surface Analysis: Repository analysis, data exposure mapping, risk assessment
- Anti-Hallucination: Field validation to prevent LLMs from suggesting invalid configuration fields
- All API calls to StackHawk include custom User-Agent header:
StackHawk-MCP/{version} - Version is managed in
stackhawk_mcp/__init__.pyand referenced in server.py - Authentication via
STACKHAWK_API_KEYenvironment variable - Schema caching with 24-hour TTL for YAML validation
- Comprehensive test suite in
tests/directory covering all major features - Tests use pytest with asyncio mode enabled
- Individual test files for each major feature area
- API integration tests and schema validation tests included
- Requires Python 3.10 or higher
- Uses modern Python features and type hints throughout
- Async/await pattern for API calls and MCP operations
- Black formatting with 100 character line length
- mypy type checking with strict settings
- Comprehensive docstrings for all public functions
- Uses the
mcplibrary for server implementation - Supports both stdio and HTTP modes
- Tool schemas defined inline with handlers
- Proper error handling and logging throughout
- Version bumping handled via GitHub Actions "Prepare Release" workflow
- Supports minor and major version bumps
- Automated commit and push to main branch
- Version stored in
stackhawk_mcp/__init__.py
pyproject.toml: Project metadata, dependencies, and tool configurationpytest.ini: Additional pytest configuration for deprecation warningscursor-mcp-config.json: Example MCP configuration for Cursor IDE integrationrequirements.txt: Runtime dependencies list
- API key management via environment variables only
- No secrets should be committed to the repository
- All API interactions are read-only analytics operations
- Input validation on all user-provided data (YAML, search queries, etc.)