](https://mseep.ai/app/sfncat-mcp-joern)
Joern MCP服务器
Joern的简单MCP服务器。
项目介绍
这个项目是一个基于Joern的MCP服务器,提供了一系列功能来帮助开发人员进行代码审查和安全分析。
环境要求
- Python>=3.10(默认值3.12)&uv
- 年份
安装步骤
- 在本地克隆项目:
git clone https://github.com/sfncat/mcp-joern.git
cd mcp-joern- 安装Python依赖项:
uv venv .venv
source .venv/bin/activate
uv sync项目结构
├── server.py # MCP Server main program
├── test_mcp_client.py # Test program for joern server and mcp tool
├── test_sc_tools.py # Direct test program for sc tools
├── common_tools.py # Common utility functions
├── server_tools.py # Server utility functions
├── server_tools.sc # Scala implementation of server utility functions
├── server_tools_source.sc # Scala implementation of server utility functions,use sourceCode to get the source code of method
├── requirements.txt # Python dependency file
├── sample_cline_mcp_settings.json # Sample cline mcp configuration file
└── env_example.txt # Environment variables example file用法
- 启动Joern服务器:
joern -J-Xmx40G --server --server-host 127.0.0.1 --server-port 16162 --server-auth-username user --server-auth-password password --import server_tools.sc
Or
joern -J-Xmx40G --server --server-host 127.0.0.1 --server-port 16162 --server-auth-username user --server-auth-password password --import server_tools_source.sc如果您在Windows下使用它,您可能需要通过命令行或在系统环境变量中设置JVM系统变量。
set _JAVA_OPTIONS=-Dfile.encoding=UTF-8将joern日志记录级别设置为ERROR
set SL_LOGGING_LEVEL=ERROR //windows
export SL_LOGGING_LEVEL=ERROR //linux如果您有以下警告
Unable to create a system terminal, creating a dumb terminal (enable debug logging for more information)您可以通过设置环境变量来禁用它
set TERM=dumb
export TERM=dumb恢复默认行为
set TERM=xterm-256color
export TERM=xterm-256color- 将env.example.txt复制到.env
修改配置信息以匹配joern服务器启动配置
- 运行测试连接:
修改中的信息 test_mcp_client.py 确认joern服务器工作正常
uv run test_mcp_client.py
Starting MCP server test...
==================================================
Testing server connection...
[04/16/25 20:38:54] INFO Processing request of type CallToolRequest server.py:534
Connection test result: Successfully connected to Joern MCP, joern server version is XXX- 配置MCP服务器
在cline中配置mcp服务器,请参阅 sample_cline_mcp_settings.json.
- 使用MCP服务器
向大型语言模型提问,请参阅 prompts_en.md
开发说明
.env文件用于存储环境变量.gitignorefile定义了Git版本控制要忽略的文件pyproject.toml定义项目的Python配置- MCP工具开发
- 实施中 server_tools.sc,在中添加定义 server_tools.py,并在中添加测试 test_mcp_client.py
贡献指南
欢迎提交问题和拉取请求以帮助改进项目。
欢迎添加更多工具。
参考文献
https://github.com/flankerhqd/jebmcp
https://docs.joern.io/server/
https://docs.joern.io/interpreter/
