CodeBadger Toolkit

CodeBadger Toolkit

Provides static code analysis using Joern's Code Property Graph technology for 12+ programming languages. Enables security analysis, code browsing, taint flow detection, and CPGQL queries through natural language.

Category
访问服务器

README

🦡 codebadger-toolkit

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.

Prerequisites

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

Quick Start

1. Install Python Dependencies

# 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.txt

2. Start the Docker Services (Joern + Redis)

docker compose up -d

This 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

3. Start the MCP Server

# Set the correct Redis port (maps to container's 6379)
REDIS_PORT=6380 python main.py

The MCP server will be available at http://localhost:4242.

4. Stop All Services

# Stop MCP server (Ctrl+C in terminal)

# Stop Docker services
docker-compose down

# Optional: Clean up everything
bash cleanup.sh

Cleanup Script

Use the provided cleanup script to reset your environment:

bash cleanup.sh

This 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)

Integrations

GitHub Copilot Integration

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"
    }
  }
}

Claude Code Integration

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"
    }
  }
}

Available Tools

Core Tools (hash-based)

  • generate_cpg: Generate a CPG for a codebase (from local path or GitHub URL)
  • get_cpg_status: Get status and existence of a CPG by codebase_hash
  • run_cpgql_query: Execute CPGQL queries (synchronous)

Code Browsing Tools

  • get_codebase_summary: Get codebase overview
  • list_files: List source files
  • list_methods: Discover methods/functions
  • get_method_source: Retrieve method source code
  • list_calls: Find function call relationships
  • get_call_graph: Build call graphs
  • list_parameters: Get parameter information
  • find_literals: Search for hardcoded values
  • get_code_snippet: Retrieve code snippets

Security Analysis Tools

  • find_taint_sources: Locate external input points
  • find_taint_sinks: Locate dangerous sinks
  • find_taint_flows: Find dataflow paths
  • find_argument_flows: Find expression reuse
  • check_method_reachability: Check call graph connections
  • list_taint_paths: List detailed taint paths
  • get_program_slice: Build program slices

Contributing & Tests

Thanks for contributing! Here's a quick guide to get started with running tests and contributing code.

Prerequisites

  • Python 3.10+ (3.13 is used in CI)
  • Docker and Docker Compose (for integration tests)

Local Development Setup

  1. Create a virtual environment and install dependencies
python -m venv venv
pip install -r requirements.txt
  1. Start Docker services (for integration tests)
docker-compose up -d
  1. Run unit tests
pytest tests/ -q
  1. 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"
  1. Run all tests
pytest tests/ -q
  1. Cleanup after testing
bash cleanup.sh
docker-compose down

Code Contributions

Please follow these guidelines when contributing:

  1. Follow repository conventions
  2. Write tests for behavioral changes
  3. Ensure all tests pass before submitting PR
  4. Include a clear changelog in your PR description
  5. Update documentation if needed

Configuration

The MCP server can be configured via environment variables or config.yaml.

Environment Variables

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=300

Config File

Create a config.yaml from config.example.yaml:

cp config.example.yaml config.yaml

Then customize as needed.

Important: Redis Port Configuration

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

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选