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
相关服务器
Alpha Vantage MCP Server
赞助Access financial market data: realtime & historical stock, ETF, options, forex, crypto, commodities, fundamentals, technical indicators, & more
SheetsData
Instant access to electronic component datasheets for AI agents — specs, pinouts, package info, and absolute max ratings extracted from manufacturer PDFs on demand.
MicroShift Test Analyzer
Analyzes MicroShift test failures from Google Sheets to correlate them with specific MicroShift versions.
DreamFactory MCP
An MCP server for integrating with the DreamFactory API to manage and access data sources.
Multiverse MCP Server
A middleware server for running multiple, isolated instances of MCP servers with unique namespaces and configurations.
rftools
203 RF & electronics calculators + 13 server-side simulation tools for AI agents.
Code Analysis MCP Server
A modular MCP server for code analysis, supporting file operations, code search, and structure analysis.
Port MCP Server
An MCP server for Port.io that enables advanced automations and natural language interactions for developers and AI applications.
Random Number
Provides LLMs with essential random generation abilities, built entirely on Python's standard library.
Markdown Sidecar MCP Server
An MCP server to access markdown documentation for locally installed NPM, Go, and PyPi packages.
Instant Meshes MCP
A 3D model processing server for automatic retopology, simplification, and quality analysis of OBJ/GLB models.