Gradle Class Finder MCP
Find and decompile classes within Gradle dependencies.
Gradle Class Finder MCP
一个基于 Model Context Protocol (MCP) 的 Gradle 项目类查找服务,帮助在 Gradle 项目依赖中查找指定的类并获取其源代码。
功能特性
- 在 Gradle 项目依赖中查找指定的类
- 获取类的源代码或反编译代码
- 支持 JDK 类查找
- 智能类名解析(支持简单类名)
- Kotlin 类智能识别和反编译
运行方式
方式一:Java 原生运行
前置要求
- JDK 17 或更高版本
- Gradle 8.5 或更高版本(可选,项目包含 Gradle Wrapper)
构建项目
# 使用 Gradle Wrapper(推荐)
./gradlew shadowJar
# 或者使用系统安装的 Gradle
gradle shadowJar
构建完成后,会在 build/libs/ 目录下生成 gradle-class-finder-mcp.jar 文件。
运行服务
# 直接运行 JAR 文件
java -jar build/libs/gradle-class-finder-mcp.jar
# 或者使用 Gradle 运行
./gradlew run
方式二:Docker 运行
前置要求
- Docker 20.10 或更高版本
构建 Docker 镜像
docker build -t gradle-class-finder-mcp .
运行容器
# 基本运行
docker run gradle-class-finder-mcp
# 使用自定义内存设置
docker run -e JAVA_OPTS="-Xmx1g -Xms512m" gradle-class-finder-mcp
# 挂载本地项目目录(用于分析本地项目)
docker run -v /path/to/your/project:/workspace gradle-class-finder-mcp
配置 Claude Desktop
在 Claude Desktop 的配置文件中添加以下配置:
Java 原生运行配置
{
"mcpServers": {
"gradle-class-finder": {
"command": "java",
"args": ["-jar", "/path/to/gradle-class-finder-mcp.jar"]
}
}
}
Docker 运行配置
{
"mcpServers": {
"gradle-class-finder": {
"command": "docker",
"args": ["run", "-i", "gradle-class-finder-mcp"]
}
}
}
使用示例
查找类
使用工具 find_class 查找类:
- workspace_dir: /path/to/gradle/project
- class_name: com.example.MyClass
获取源代码
使用工具 get_source_code 获取源代码:
- jar_path: /path/to/library.jar
- class_name: com.example.MyClass
环境变量
JAVA_OPTS: JVM 参数设置(例如:-Xmx512m -Xms256m)
故障排除
Java 原生运行常见问题
-
找不到主类
- 确保使用
shadowJar任务构建,而不是普通的jar任务 - 检查 JAR 文件是否存在于
build/libs/目录
- 确保使用
-
依赖解析失败
- 确保目标项目有有效的 Gradle 配置
- 检查网络连接,确保能访问 Maven 仓库
Docker 运行常见问题
-
构建失败
- 确保 Docker 守护进程正在运行
- 检查是否有足够的磁盘空间
-
容器无法访问本地文件
- 使用
-v参数正确挂载本地目录 - 检查文件权限
- 使用
开发指南
项目结构
gradle-class-finder-mcp/
├── src/
│ └── main/
│ └── java/
│ └── com/opencare/mcp/
│ ├── GradleClassFinderMcpServer.java
│ ├── service/
│ ├── decompiler/
│ └── util/
├── build.gradle
├── Dockerfile
└── README.md
本地开发
# 运行测试
./gradlew test
# 清理构建
./gradlew clean
# 构建并运行
./gradlew clean shadowJar run
License
MIT License
相关服务器
Scout Monitoring MCP
赞助Put performance and error data directly in the hands of your AI assistant.
Alpha Vantage MCP Server
赞助Access financial market data: realtime & historical stock, ETF, options, forex, crypto, commodities, fundamentals, technical indicators, & more
Kali AI Pentest MCP Tools
An AI penetration testing tool that uses natural language to operate various security tools like nmap, sqlmap, and metasploit.
MLflow Prompt Registry
Access prompt templates managed in an MLflow Prompt Registry. Requires a running MLflow server configured via the MLFLOW_TRACKING_URI environment variable.
Streamable HTTP Server Example
An example MCP server demonstrating streamable HTTP responses using Node.js.
jarp-mcp
Java Archive Reader Protocol MCP server - Give AI agents X-ray vision into compiled Java code by decompiling JAR/WAR/EAR files and Maven/Gradle dependencies
Liana-MCP
A natural language interface for cell-cell communication analysis using the Liana framework.
MCP REST Server
A server for interacting with REST APIs, featuring authentication and Swagger documentation support.
Micronaut Fun
It exposes Micronaut framework documentation and guides as MCP resources, it offers tools to search the docs and prompts to help you write tests and perform tasks in an idiomatic way
Subotiz MCP
Connect AI assistants to Subotiz - Using Subotiz's external capabilities through natural language
Kunobi
Kubernetes desktop IDE with an embedded MCP server for visual oversight of AI-driven cluster operations. Supports FluxCD, ArgoCD, and Helm.
Prometheus MCP
Expose Prometheus monitoring tools to an LLM for querying and analysis.