codeparse-mcp
Parses Java and Xtend source code into a graph database and provides MCP tools for querying classes, methods, control flow graphs, and MC/DC conditions, enabling AI-driven unit test generation for ISO 26262 ASIL-D compliance.
README
codeparse-mcp
Java/Xtend Code Parser → Graph DB → MCP Server
Knowledge base for AI-driven ISO 26262 ASIL-D unit test generation with 100% MC/DC + C0 + C1 coverage.
Architecture
Java/Xtend Sources
│
▼
┌─────────────┐ ┌──────────────────┐
│ Java Parser │ │ Xtend Parser │
│ (java-parser│ │ (pattern-based │
│ npm, CST) │ │ + CFG analyzer) │
└──────┬──────┘ └────────┬─────────┘
│ │
▼ ▼
┌──────────────────────────────────┐
│ Graph Builder │
│ AST → Classes, Methods, │
│ Fields, CFG Nodes/Edges, │
│ Call Graph, MC/DC Conditions │
└──────────────┬───────────────────┘
│
▼
┌──────────────────────────────────┐
│ SQLite Graph DB │
│ files / classes / methods / │
│ cfg_nodes / cfg_edges / │
│ call_edges / mcdc_conditions │
└──────────────┬───────────────────┘
│
▼
┌──────────────────────────────────┐
│ MCP Server │
│ 14 tools exposed via stdio │
│ Compatible with: │
│ • GitHub Copilot │
│ • Claude Desktop │
│ • Any MCP client │
└──────────────────────────────────┘
Quick Start
Option A: Node.js (local)
# Install
git clone <repo>
cd codeparse-mcp
npm install
# Initialize DB for your project
node src/cli/index.js init --root /path/to/your/project
# Parse all Java/Xtend files
node src/cli/index.js sync --root /path/to/your/project
# Check status
node src/cli/index.js status
Option B: Docker
# Build image
docker build -t codeparse-mcp:latest .
# Init DB
docker run --rm \
-v /your/project:/project:ro \
-v codeparse-data:/data \
codeparse-mcp:latest init
# Sync (parse all files)
docker run --rm \
-v /your/project:/project:ro \
-v codeparse-data:/data \
codeparse-mcp:latest sync
# Status
docker run --rm \
-v /your/project:/project:ro \
-v codeparse-data:/data \
codeparse-mcp:latest status
# Or with docker compose
PROJECT_ROOT=/your/project docker compose run --rm codeparse sync
CLI Commands
| Command | Description |
|---|---|
codeparse init [--force] |
Initialize/reset graph database |
codeparse sync [--force] |
Parse all files, sync changes only |
codeparse status [--errors] |
Show graph stats and health |
codeparse sync-file <path> |
Sync a single file (incremental) |
codeparse serve |
Start MCP server on stdio |
Sync Options
codeparse sync \
--force \ # Re-parse all files
--include "**/*.java,**/*.xtend" \ # Custom patterns
--exclude "**/generated/**" \ # Extra exclusions
--verbose # Per-file progress
MCP Integration
GitHub Copilot (.vscode/mcp.json)
{
"servers": {
"codeparse": {
"type": "stdio",
"command": "node",
"args": ["${workspaceFolder}/src/mcp/server.js"]
}
}
}
Or via Docker:
{
"servers": {
"codeparse": {
"type": "stdio",
"command": "docker",
"args": [
"run", "--rm", "-i",
"-v", "${workspaceFolder}:/project:ro",
"-v", "codeparse-data:/data",
"codeparse-mcp:latest", "serve"
]
}
}
}
Claude Desktop (claude_desktop_config.json)
See config/claude-desktop-mcp.json for the full example.
MCP Tools
Lifecycle
| Tool | Description |
|---|---|
codeparse_init |
Initialize/reset DB |
codeparse_sync |
Parse and sync all files |
codeparse_status |
DB health and statistics |
sync_file |
Sync a single file |
Class Queries
| Tool | Description |
|---|---|
get_class |
Full class info (fields, hierarchy, annotations, ASIL) |
search_classes |
Find classes by name pattern |
Method Queries
| Tool | Description |
|---|---|
get_methods |
All methods for a class |
search_methods |
Find methods by name/signature |
Control Flow Graph
| Tool | Description |
|---|---|
get_cfg |
CFG nodes + edges for a method (C0/C1 coverage) |
MC/DC (ISO 26262 ASIL-D)
| Tool | Description |
|---|---|
get_mcdc |
MC/DC conditions, truth tables, independence pairs for a method |
get_mcdc_for_class |
All MC/DC data for entire class |
Call Graph
| Tool | Description |
|---|---|
get_callees |
Methods called by a method (mock targets) |
get_callers |
Methods that call a method (impact) |
UT Generation
| Tool | Description |
|---|---|
get_ut_context |
Primary tool — full context for AI UT generation: class + methods + CFG + MC/DC + mock targets |
get_dependencies |
Import dependencies for a file |
What Gets Parsed
Java
- Package and import declarations
- Class/interface/enum/annotation declarations (nested included)
- All modifiers, annotations, Javadoc
- Method signatures, parameters, return types, throws
- Field declarations with types and visibility
- CFG: if/for/while/do/switch/try/catch/return/throw nodes and edges
- MC/DC: boolean condition decomposition, truth tables, independence pairs
- Call graph: method invocations with line numbers
- ASIL level detection from
@ASIL_Dannotations or/** @ASIL D */Javadoc
Xtend
- Package, import, class declarations
def,override,dispatchmethodsval/varfields + Java-style fields- All visibility modifiers
- CFG: if/for/while/do/switch/try/catch/return/throw (pattern-based)
- MC/DC analysis on boolean expressions
- Extension method detection
- ASIL annotation detection
Graph DB Schema
The SQLite database stores:
files → source file registry + SHA-256 for change detection
packages → Java package index
classes → class/interface/enum with full metadata
methods → method signatures + CFG stats + MC/DC summary
fields → class fields
cfg_nodes → CFG nodes per method (ENTRY, STATEMENT, BRANCH, LOOP, RETURN, ...)
cfg_edges → CFG edges (sequential, true_branch, false_branch, exception, loop_back)
call_edges → caller → callee relationships
dependencies → file-level import and type dependencies
mcdc_conditions → expanded MC/DC conditions with truth tables and independence pairs
parse_errors → per-file error log
Example: AI UT Generation Workflow
1. User asks Copilot/Claude: "Generate unit tests for com.safety.BrakeController"
2. AI calls: get_ut_context { qualifiedName: "com.safety.BrakeController" }
3. Response includes:
- Class metadata + ASIL-D level
- All 12 methods with parameters and signatures
- CFG for each method (C0/C1 coverage map)
- MC/DC conditions with independence pairs (ASIL-D 100% target)
- Mock targets (callees to stub)
- Estimated minimum 47 test cases needed
4. AI generates JUnit 5 test class covering:
- All statement paths (C0)
- All branch pairs (C1)
- All MC/DC independence pairs
- ASIL-D annotation on each test
Configuration (.codeparse.json)
{
"projectRoot": "/path/to/project",
"dbPath": "/path/to/.codeparse/graph.db",
"include": ["**/*.java", "**/*.xtend"],
"exclude": [
"**/node_modules/**",
"**/build/**",
"**/target/**",
"**/.gradle/**",
"**/generated/**"
]
}
Incremental Sync
Files are tracked by SHA-256 hash. On each sync:
- New files → parsed and inserted
- Changed files → deleted from DB (cascade) and re-parsed
- Unchanged files → skipped (fast)
- Call graph → second-pass resolution of caller→callee IDs
This means sync is safe to run on every save or in CI without performance penalty.
Extending: Add More Languages
- Add a parser in
src/parser/<lang>-parser.jsimplementingparse<Lang>(source, path) - Return
{ packageName, imports, classes }matching the existing schema - Add the extension to
includeglobs in config - Register in
src/graph/builder.jssyncProjectswitch
Requirements
- Node.js ≥ 20
- Or Docker (no Node required on host)
- SQLite (bundled via better-sqlite3)
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。