MCP server that wraps a local Joern instance for AI-driven code security analysis. Gives Claude Code the ability to import codebases, query the Code Property Graph (CPG), trace data flows, and detect vulnerabilities.
Claude Code <--stdio--> joern-mcp (TypeScript) <--HTTP--> Joern server (JVM)
joern-mcp is the bridge. It translates MCP tool calls into CPGQL queries sent to Joern's /query-sync HTTP endpoint.
- Node.js 18+
- Joern installed and on PATH (install guide)
Tested with Joern v4.x. The HTTP API has been stable since mid-2023.
bun install
bun run buildclaude mcp add joern-mcp -- node /path/to/joern-mcp/dist/index.js- Start Joern server:
joern --server - In a Claude Code session, use the tools:
# Import a codebase (one-time, builds the CPG)
import_code("/path/to/repo", "my-project")
# Scan for vulnerabilities
find_vulnerabilities()
# Trace data flow from source to sink
taint_analysis({ source: "method.name(\"gets\").parameter", sink: "method.name(\"strcpy\").parameter" })
# Run any CPGQL query
query("cpg.method.name.l")
| Environment Variable | Default | Purpose |
|---|---|---|
JOERN_HOST |
localhost |
Joern server hostname |
JOERN_PORT |
8080 |
Joern server port |
JOERN_QUERY_TIMEOUT |
30000 |
Query timeout in ms |
JOERN_IMPORT_TIMEOUT |
300000 |
Import/analysis timeout in ms |
| Tool | Description |
|---|---|
import_code |
Import a codebase into Joern (builds CPG) |
list_projects |
List all projects in the workspace |
switch_project |
Set the active project |
close_project |
Unload a CPG from memory |
| Tool | Description |
|---|---|
query |
Run arbitrary CPGQL against the active CPG |
get_methods |
List methods (optional name filter) |
get_calls |
Find call sites (optional method filter) |
get_types |
List types/classes (optional name filter) |
| Tool | Description |
|---|---|
find_vulnerabilities |
Run default vulnerability detection |
taint_analysis |
Trace data flow from source to sink |
reachable_by |
Check if sink is reachable from source |
get_data_flows |
Get all data flow paths between two points |
| Tool | Description |
|---|---|
get_source |
Read source code of a method |
get_callers |
Find all callers of a method |
get_callees |
Find all methods called by a method |
get_parameters |
Get parameter types and names |
The repo includes a Claude Code skill at .claude/skills/joern-analysis/SKILL.md that guides the full security analysis workflow — from importing code through vulnerability scanning to data flow tracing.
To make it available globally, symlink it:
ln -s /path/to/joern-mcp/.claude/skills/joern-analysis ~/.claude/skills/joern-analysisThen invoke it in any Claude Code session with /joern-analysis. The skill walks through the standard workflow:
- Connect and import — verify Joern is up, build the CPG
- Explore — list methods, types, call sites
- Navigate — trace callers/callees, class hierarchies
- Analyze — run vulnerability scans, taint analysis, data flow tracing
- Raw queries — arbitrary CPGQL for anything the structured tools don't cover
bun run build # Compile TypeScript
bun run dev # Watch mode
bun run test # Run unit + integration tests (no Joern needed)
bun run test:watch # Watch mode for tests
# Smoke tests (requires running Joern server)
JOERN_SMOKE=1 bun run test tests/smoke.test.ts- Parsers — Pure function tests for ANSI stripping and Scala REPL output parsing
- CPGQL templates — String construction tests
- HTTP client — Mocked
fetch, covers all error paths - MCP integration — Full round-trip via
InMemoryTransport(no Joern, no stdio) - Smoke tests — Real Joern, skipped unless
JOERN_SMOKE=1
The HTTP API (/query-sync) is implemented by scala-repl-pp and has been stable since mid-2023. CPGQL query syntax can change in any Joern nightly release — all query templates are centralized in src/cpgql.ts for easy audit on upgrades.
MIT