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
MCP Documentation Server
Integrates LLM applications with documentation sources using the Model Context Protocol.
Pathmode
Build structured intent specs through Socratic AI conversation. Describe a problem or paste a support ticket — Claude challenges vague thinking, asks pointed questions, and builds a structured spec. Exports as intent.md, .cursorrules, or CLAUDE.md.
MCP Simple Server
A simple MCP server with streamable HTTP transport that supports basic math tools like add and multiply.
Lilith Shell
Execute terminal commands through a secure shell interface using an AI assistant.
iOS Development Bridge (idb)
Interact with iOS simulators and devices using Facebook's iOS Development Bridge (idb).
s&box MCP Server
Enables AI assistants to interact with s&box game objects and components via WebSocket communication.
WordPress Docs
Access WordPress documentation and development tools.
MasterGo Magic MCP
A standalone MCP service that connects MasterGo design tools with AI models, enabling them to retrieve DSL data directly from design files.
MiniMax MCP JS
A JavaScript/TypeScript server for MiniMax MCP, offering image/video generation, text-to-speech, and voice cloning.
BaseMcpServer
A minimal, containerized base for building MCP servers with the Python SDK, featuring a standardized Docker image and local development setup.