A containerized Model Context Protocol (MCP) server providing static code analysis using Joern's Code Property Graph (CPG) technology with support for Java, C/C++, JavaScript, Python, Go, Kotlin, C#, Ghidra, Jimple, PHP, Ruby, and Swift.
Before you begin, make sure you have:
- Docker and Docker Compose installed
- Python 3.10+ (Python 3.13 recommended)
- pip (Python package manager)
To verify your setup:
docker --version
docker-compose --version
python --version# Create a virtual environment (optional but recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txtdocker compose up -dThis starts:
- Joern Server: Static code analysis engine (runs CPG generation and queries)
- Redis: Metadata storage (tracks codebases, ports, and CPG information)
Verify services are running:
docker compose ps# Set the correct Redis port (maps to container's 6379)
REDIS_PORT=6380 python main.pyThe MCP server will be available at http://localhost:4242.
# Stop MCP server (Ctrl+C in terminal)
# Stop Docker services
docker-compose down
# Optional: Clean up everything
bash cleanup.shUse the provided cleanup script to reset your environment:
bash cleanup.shThis will:
- Stop and remove Docker containers
- Kill orphaned Joern/MCP processes
- Clear Python cache (
__pycache__,.pytest_cache) - Optionally clear the playground directory (CPGs and cached codebases)
Edit the MCP configuration file for VS Code (GitHub Copilot):
Path:
~/.config/Code/User/mcp.json
Example configuration:
{
"inputs": [],
"servers": {
"codebadger-toolkit": {
"url": "http://localhost:4242/mcp",
"type": "http"
}
}
}To integrate codebadger-toolkit into Claude Desktop, edit:
Path:
Claude β Settings β Developer β Edit Config β claude_desktop_config.json
Add the following:
{
"mcpServers": {
"codebadger-toolkit": {
"url": "http://localhost:4242/mcp",
"type": "http"
}
}
}generate_cpg: Generate a CPG for a codebase (from local path or GitHub URL)get_cpg_status: Get status and existence of a CPG bycodebase_hashrun_cpgql_query: Execute CPGQL queries (synchronous)
get_codebase_summary: Get codebase overviewlist_files: List source fileslist_methods: Discover methods/functionsget_method_source: Retrieve method source codelist_calls: Find function call relationshipsget_call_graph: Build call graphslist_parameters: Get parameter informationfind_literals: Search for hardcoded valuesget_code_snippet: Retrieve code snippets
find_taint_sources: Locate external input pointsfind_taint_sinks: Locate dangerous sinksfind_taint_flows: Find dataflow pathsfind_argument_flows: Find expression reusecheck_method_reachability: Check call graph connectionslist_taint_paths: List detailed taint pathsget_program_slice: Build program slices
Thanks for contributing! Here's a quick guide to get started with running tests and contributing code.
- Python 3.10+ (3.13 is used in CI)
- Docker and Docker Compose (for integration tests)
- Create a virtual environment and install dependencies
python -m venv venv
pip install -r requirements.txt- Start Docker services (for integration tests)
docker-compose up -d- Run unit tests
pytest tests/ -q- Run integration tests (requires Docker Compose running)
# Start MCP server in background
REDIS_PORT=6380 python main.py &
# Run integration tests
pytest tests/integration -q
# Stop MCP server
pkill -f "python main.py"- Run all tests
pytest tests/ -q- Cleanup after testing
bash cleanup.sh
docker-compose downPlease follow these guidelines when contributing:
- Follow repository conventions
- Write tests for behavioral changes
- Ensure all tests pass before submitting PR
- Include a clear changelog in your PR description
- Update documentation if needed
The MCP server can be configured via environment variables or config.yaml.
Key settings (optional - defaults shown):
# Server
MCP_HOST=0.0.0.0
MCP_PORT=4242
# Redis (running inside Docker container)
REDIS_HOST=localhost
REDIS_PORT=6380 # β οΈ IMPORTANT: Port 6380 on host maps to 6379 in container
# Joern
JOERN_BINARY_PATH=joern
JOERN_JAVA_OPTS="-Xmx4G -Xms2G -XX:+UseG1GC -Dfile.encoding=UTF-8"
# CPG Generation
CPG_GENERATION_TIMEOUT=600
MAX_REPO_SIZE_MB=500
# Query
QUERY_TIMEOUT=30
QUERY_CACHE_ENABLED=true
QUERY_CACHE_TTL=300Create a config.yaml from config.example.yaml:
cp config.example.yaml config.yamlThen customize as needed.
Since Redis runs inside the Docker container:
- Inside container: Redis listens on
6379 - Host mapping: Docker maps
6380:6379 - MCP server should use:
REDIS_PORT=6380
Always start the MCP server with:
REDIS_PORT=6380 python main.py