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
Drupal Tools
A server providing resources, tools, and prompts for Drupal development.
MCP Talk Demo Files
A collection of demo files for MCP servers and clients, illustrating various transport protocols and server capabilities using Python.
Gemini MCP
Integrate the full power of Gemini Pro 3 to Claude Code
SoftProbe MCP Server
An MCP server for managing API test data and resources.
Google Workspace Developers
Developer documentation for Google Workspace APIs
Sentry MCP Server
An MCP server for interacting with the Sentry error tracking and performance monitoring platform.
claude-session-continuity-mcp
Zero-config session continuity for Claude Code. Auto-captures context via Claude Hooks, provides 24 tools for memory, tasks, solutions, and knowledge graph. Multilingual semantic search (94+ languages).
Keycloak MCP Server
An MCP server for Keycloak administration, offering over 30 tools to manage users, realms, clients, roles, and more from AI assistants.
pfSense MCP Server
Enables natural language interaction with pfSense firewalls through GenAI applications.
MCP Tool Poisoning Attacks
A Node.js project demonstrating MCP client and server interactions for tool poisoning attacks, requiring an Anthropic API key.