Joern MCP
J

Joern MCP

2.5 points
6.0K

Installation

Copy the following command to your Client for configuration
Note: Your key is sensitive information, do not share it with anyone.

๐Ÿš€ ๐Ÿ•ท๏ธ joern-mcp

A Model Context Protocol (MCP) server that equips AI assistants with static code analysis capabilities using Joern's Code Property Graph (CPG) technology.

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.8+
  • Docker
  • Redis
  • Git

Installation

  1. Clone the repository and install dependencies:
git clone https://github.com/Lekssays/joern-mcp.git
cd joern-mcp
pip install -r requirements.txt
  1. Setup (builds Joern image and starts Redis):
./setup.sh
  1. Configure (optional):
cp config.example.yaml config.yaml
# Edit config.yaml as needed
  1. Run the server:
python main.py
# Server will be available at http://localhost:4242

โœจ Features

  • Multi-Language Support: Java, C/C++, JavaScript, Python, Go, Kotlin, C#, Ghidra, Jimple, PHP, Ruby, Swift
  • Docker Isolation: Each analysis session runs in a secure container
  • GitHub Integration: Analyze repositories directly from GitHub URLs
  • Session-Based: Persistent CPG sessions with automatic cleanup
  • Redis-Backed: Fast caching and session management
  • Async Queries: Non-blocking CPG generation and query execution
  • Built-in Security Queries: Pre-configured queries for common vulnerabilities

๐Ÿ’ป Usage Examples

Basic Usage

# Create session from GitHub
{
  "tool": "create_cpg_session",
  "arguments": {
    "source_type": "github",
    "source_path": "https://github.com/user/repo",
    "language": "java"
  }
}

# Get codebase overview
{
  "tool": "get_codebase_summary",
  "arguments": {
    "session_id": "abc-123-def"
  }
}

# List all methods in the codebase
{
  "tool": "list_methods",
  "arguments": {
    "session_id": "abc-123-def",
    "include_external": false,
    "limit": 50
  }
}

# Get source code for a specific method
{
  "tool": "get_method_source",
  "arguments": {
    "session_id": "abc-123-def",
    "method_name": "authenticate"
  }
}

# Find what methods call a specific function
{
  "tool": "get_call_graph",
  "arguments": {
    "session_id": "abc-123-def",
    "method_name": "execute_query",
    "depth": 2,
    "direction": "incoming"
  }
}

# Search for hardcoded secrets
{
  "tool": "find_literals",
  "arguments": {
    "session_id": "abc-123-def",
    "pattern": "(?i).*(password|secret|api_key).*",
    "limit": 20
  }
}

# Get code snippet from a file
{
  "tool": "get_code_snippet",
  "arguments": {
    "session_id": "abc-123-def",
    "filename": "src/main.c",
    "start_line": 10,
    "end_line": 25
  }
}

# Run custom CPGQL query
{
  "tool": "run_cpgql_query",
  "arguments": {
    "session_id": "abc-123-def",
    "query": "cpg.method.name.l"
  }
}

Advanced Usage

The list_queries tool provides 20+ pre-configured queries including those for security, memory safety, and code quality.

Security:

  • SQL injection detection
  • XSS vulnerabilities
  • Hardcoded secrets
  • Command injection
  • Path traversal

Memory Safety:

  • Buffer overflow risks
  • Memory leaks
  • Null pointer dereferences
  • Uninitialized variables

Code Quality:

  • All methods/functions
  • Control structures
  • Function calls
  • String literals

๐Ÿ“š Documentation

Integration with GitHub Copilot

The server uses Streamable HTTP transport for network accessibility and supports multiple concurrent clients.

Add to your VS Code settings.json:

{
  "github.copilot.advanced": {
    "mcp": {
      "servers": {
        "joern-mcp": {
          "url": "http://localhost:4242/mcp",
        }
      }
    }
  }
}

Make sure the server is running before using it with Copilot:

python main.py

Available Tools

Core Tools

  • create_cpg_session: Initialize analysis session from local path or GitHub URL
  • run_cpgql_query: Execute synchronous CPGQL queries with JSON output
  • run_cpgql_query_async: Execute asynchronous queries with status tracking
  • get_session_status: Check session state and metadata
  • list_sessions: View active sessions with filtering
  • close_session: Clean up session resources
  • list_queries: Get pre-built security and quality queries

Code Browsing Tools

  • get_codebase_summary: Get high-level overview of codebase (file count, method count, language)
  • list_files: List all source files with optional regex filtering
  • list_methods: Discover all methods/functions with filtering by name, file, or external status
  • get_method_source: Retrieve actual source code for specific methods
  • list_calls: Find function call relationships and dependencies
  • get_call_graph: Build call graphs (outgoing callees or incoming callers) with configurable depth
  • list_parameters: Get detailed parameter information for methods
  • find_literals: Search for hardcoded values (strings, numbers, API keys, etc)
  • get_code_snippet: Retrieve code snippets from files with line range

Configuration

Key settings in config.yaml:

server:
  host: 0.0.0.0
  port: 4242
  log_level: INFO

redis:
  host: localhost
  port: 6379

sessions:
  ttl: 3600                # Session timeout (seconds)
  max_concurrent: 50       # Max concurrent sessions

cpg:
  generation_timeout: 600  # CPG generation timeout (seconds)
  supported_languages: [java, c, cpp, javascript, python, go, kotlin, csharp, ghidra, jimple, php, ruby, swift]

Environment variables override config file settings (e.g., MCP_HOST, REDIS_HOST, SESSION_TTL).

Example CPGQL Queries

Find all methods:

cpg.method.name.l

Find hardcoded secrets:

cpg.literal.code("(?i).*(password|secret|api_key).*").l

Find SQL injection risks:

cpg.call.name(".*execute.*").where(_.argument.isLiteral.code(".*SELECT.*")).l

Find complex methods:

cpg.method.filter(_.cyclomaticComplexity > 10).l

๐Ÿ”ง Technical Details

Architecture

  • FastMCP Server: Built on FastMCP 2.12.4 framework with Streamable HTTP transport
  • HTTP Transport: Network-accessible API supporting multiple concurrent clients
  • Docker Containers: One isolated Joern container per session
  • Redis: Session state and query result caching
  • Async Processing: Non-blocking CPG generation
  • CPG Caching: Reuse CPGs for identical source/language combinations

Development

Project Structure

joern-mcp/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ services/       # Session, Docker, Git, CPG, Query services
โ”‚   โ”œโ”€โ”€ tools/          # MCP tool definitions
โ”‚   โ”œโ”€โ”€ utils/          # Redis, logging, validators
โ”‚   โ””โ”€โ”€ models.py       # Data models
โ”œโ”€โ”€ playground/         # Test codebases and CPGs
โ”œโ”€โ”€ main.py            # Server entry point
โ”œโ”€โ”€ config.yaml        # Configuration
โ””โ”€โ”€ requirements.txt   # Dependencies

Running Tests

# Install dev dependencies
pip install -r requirements.txt

# Run tests
pytest

# Run with coverage
pytest --cov=src --cov-report=html

Code Quality

# Format
black src/ tests/
isort src/ tests/

# Lint
flake8 src/ tests/
mypy src/

Troubleshooting

Setup issues

# Re-run setup to rebuild and restart services
./setup.sh

Docker issues

# Verify Docker is running
docker ps

# Check Joern image
docker images | grep joern

# Check Redis container
docker ps | grep joern-redis

Redis connection issues

# Test Redis connection
docker exec joern-redis redis-cli ping

# Check Redis logs
docker logs joern-redis

# Restart Redis
docker restart joern-redis

Server connectivity

# Test server is running
curl http://localhost:4242/health

# Check server logs for errors
python main.py

Debug logging

export MCP_LOG_LEVEL=DEBUG
python main.py

Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Make changes and add tests
  4. Run tests: pytest && black . && flake8
  5. Submit a pull request

Acknowledgments

Alternatives

V
Vestige
Vestige is an AI memory engine based on cognitive science. By implementing 29 neuroscience modules such as prediction error gating, FSRS - 6 spaced repetition, and memory dreaming, it provides long - term memory capabilities for AI. It includes a 3D visualization dashboard and 21 MCP tools, runs completely locally, and does not require the cloud.
Rust
9.2K
4.5 points
M
Moltbrain
MoltBrain is a long-term memory layer plugin designed for OpenClaw, MoltBook, and Claude Code, capable of automatically learning and recalling project context, providing intelligent search, observation recording, analysis statistics, and persistent storage functions.
TypeScript
8.7K
4.5 points
B
Bm.md
A feature-rich Markdown typesetting tool that supports multiple style themes and platform adaptation, providing real-time editing preview, image export, and API integration capabilities
TypeScript
14.6K
5 points
S
Security Detections MCP
Security Detections MCP is a server based on the Model Context Protocol that allows LLMs to query a unified security detection rule database covering Sigma, Splunk ESCU, Elastic, and KQL formats. The latest version 3.0 is upgraded to an autonomous detection engineering platform that can automatically extract TTPs from threat intelligence, analyze coverage gaps, generate SIEM-native format detection rules, run tests, and verify. The project includes over 71 tools, 11 pre-built workflow prompts, and a knowledge graph system, supporting multiple SIEM platforms.
TypeScript
7.7K
4 points
P
Paperbanana
Python
8.8K
5 points
B
Better Icons
An MCP server and CLI tool that provides search and retrieval of over 200,000 icons, supports more than 150 icon libraries, and helps AI assistants and developers quickly obtain and use icons.
TypeScript
10.4K
4.5 points
A
Assistant Ui
assistant - ui is an open - source TypeScript/React library for quickly building production - grade AI chat interfaces, providing composable UI components, streaming responses, accessibility, etc., and supporting multiple AI backends and models.
TypeScript
8.6K
5 points
A
Apify MCP Server
The Apify MCP Server is a tool based on the Model Context Protocol (MCP) that allows AI assistants to extract data from websites such as social media, search engines, and e-commerce through thousands of ready-to-use crawlers, scrapers, and automation tools (Apify Actors). It supports OAuth and Skyfire proxy payment and can be integrated into MCP clients such as Claude and VS Code through HTTPS endpoints or local stdio.
TypeScript
9.4K
5 points
G
Gitlab MCP Server
Certified
The GitLab MCP server is a project based on the Model Context Protocol that provides a comprehensive toolset for interacting with GitLab accounts, including code review, merge request management, CI/CD configuration, and other functions.
TypeScript
26.7K
4.3 points
D
Duckduckgo MCP Server
Certified
The DuckDuckGo Search MCP Server provides web search and content scraping services for LLMs such as Claude.
Python
79.3K
4.3 points
N
Notion Api MCP
Certified
A Python-based MCP Server that provides advanced to-do list management and content organization functions through the Notion API, enabling seamless integration between AI models and Notion.
Python
24.4K
4.5 points
M
Markdownify MCP
Markdownify is a multi-functional file conversion service that supports converting multiple formats such as PDFs, images, audio, and web page content into Markdown format.
TypeScript
37.7K
5 points
F
Figma Context MCP
Framelink Figma MCP Server is a server that provides access to Figma design data for AI programming tools (such as Cursor). By simplifying the Figma API response, it helps AI more accurately achieve one - click conversion from design to code.
TypeScript
71.0K
4.5 points
U
Unity
Certified
UnityMCP is a Unity editor plugin that implements the Model Context Protocol (MCP), providing seamless integration between Unity and AI assistants, including real - time state monitoring, remote command execution, and log functions.
C#
37.9K
5 points
G
Gmail MCP Server
A Gmail automatic authentication MCP server designed for Claude Desktop, supporting Gmail management through natural language interaction, including complete functions such as sending emails, label management, and batch operations.
TypeScript
23.6K
4.5 points
C
Context7
Context7 MCP is a service that provides real-time, version-specific documentation and code examples for AI programming assistants. It is directly integrated into prompts through the Model Context Protocol to solve the problem of LLMs using outdated information.
TypeScript
106.1K
4.7 points