MCP server for reading and decompiling Maven .m2 jar files with comprehensive Java project analysis
npm install maven-decoder-mcpA comprehensive Model Context Protocol (MCP) server for analyzing Maven jar files in your local repository (~/.m2). This server provides powerful tools for agentic coding assistance in Java projects, enabling AI agents to understand dependencies, analyze bytecode, extract source code, and navigate the Maven ecosystem.
~/.m2/repository)#### One-Line Install (Recommended)
``bash`
curl -fsSL https://raw.githubusercontent.com/salitaba/maven-decoder-mcp/main/install.sh | bash
#### Method 1: uvx (Recommended)
`bashInstall uv (if not installed)
curl -Ls https://astral.sh/uv/install.sh | shEnsure your shell PATH is updated (restart shell or eval as printed by installer)
#### Method 2: Node.js/npm
`bash
Install globally
npm install -g maven-decoder-mcpOr install locally
npm install maven-decoder-mcpRun the server
maven-decoder-mcp
or if installed locally: npx maven-decoder-mcp
`#### Method 3: Docker
`bash
Pull and run
docker run --rm -it \
-v ~/.m2:/home/mcpuser/.m2 \
-v $(pwd):/workspace \
ali79taba/maven-decoder-mcp:latest
`#### Method 4: From Source (Development)
`bash
Clone repository
git clone https://github.com/salitaba/maven-decoder-mcp.git
cd maven-decoder-mcpOption A: Using Virtual Environment
python3 -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install -r requirements.txt
pip install "git+https://github.com/modelcontextprotocol/python-sdk.git"
./setup_decompilers.shOption B: System-wide Installation (not recommended)
./setup_decompilers.sh
`๐ง Configuration
$3
Add to your ~/.cursor/mcp_servers.json:`json
{
"maven-decoder": {
"command": "uvx",
"args": ["maven-decoder-mcp"]
}
}
`$3
The server runs as a standard MCP server and can be integrated with any MCP-compatible client.๐ ๏ธ Available Tools
| Tool | Description |
|------|-------------|
|
list_artifacts | List artifacts in Maven repository with filtering |
| analyze_jar | Analyze jar file structure and contents |
| extract_class_info | Get detailed information about Java classes |
| get_dependencies | Retrieve Maven dependencies from POM files |
| search_classes | Search for classes across all jars |
| extract_source_code | Decompile and extract Java source code |
| compare_versions | Compare different versions of artifacts |
| find_usage_examples | Find usage examples in test code |
| get_dependency_tree | Get complete dependency tree |
| find_dependents | Find artifacts that depend on a specific artifact |
| get_version_info | Get all available versions of an artifact |
| analyze_jar_structure | Analyze overall jar structure and metadata |
| extract_method_info | Extract specific method information from Java classes |๐ก Usage Examples
$3
`
"Show me all dependencies of org.springframework:spring-core:5.3.21"
`$3
`
"Decompile the class com.example.MyService from my Maven repository"
`$3
`
"Find all version conflicts in my Maven repository"
`$3
`
"Show me all public methods in the Jackson ObjectMapper class"
`$3
`
"List all Spring classes with pagination (page 2, 10 items per page)"
"Extract source code for a large class with summarization"
"Get method information for specific patterns in a class"
`๐ Response Management
$3
The server automatically handles large responses through intelligent pagination:- Automatic Detection: Responses exceeding 50KB are automatically paginated
- Configurable Page Size: Default 20 items per page, customizable per request
- Pagination Metadata: Each response includes pagination information
- Supported Tools:
list_artifacts, extract_class_info, search_classes, get_dependencies, find_dependents, get_version_info$3
Large text content is automatically summarized to improve readability:- Smart Summarization: Preserves important parts (package declarations, method signatures, closing braces)
- Configurable Limits: Default 10KB text limit, customizable
- Java-Specific: Optimized for Java source code structure
- Metadata Preservation: Original structure and metadata are maintained
$3
New tool for targeted access to specific methods:- Pattern Matching: Use regex patterns to find specific methods
- Limited Results: Control the number of methods returned
- Full Context: Includes method signatures, bodies, and line numbers
- Efficient Processing: Only extracts requested methods, not entire classes
๐๏ธ Architecture
The server is built with a modular architecture:
-
MavenDecoderServer: Main MCP server implementation
- ResponseManager: Handles pagination and summarization
- JavaDecompiler: Handles multiple decompilation strategies
- MavenDependencyAnalyzer: Analyzes Maven dependencies and metadata
- Decompilers: CFR, Procyon, Fernflower, and javap integration๐งช Development
$3
`bash
Install development dependencies
pip install -e ".[dev]"Run tests
pytestRun specific test
python test_startup.py
`$3
`bash
Build distribution
python setup.py sdist bdist_wheelInstall locally
pip install dist/maven_decoder_mcp-*.whl
`$3
`bash
Build Docker image
docker build -t maven-decoder-mcp .Run container
docker run --rm -it maven-decoder-mcp
`๐ Configuration Options
$3
- MAVEN_HOME: Custom Maven repository location (default: ~/.m2/repository)
- MCP_LOG_LEVEL: Logging level (DEBUG, INFO, WARNING, ERROR)
- MCP_MAX_RESPONSE_SIZE: Maximum response size in bytes (default: 50000)
- MCP_MAX_ITEMS_PER_PAGE: Default items per page (default: 20)
- MCP_MAX_TEXT_LENGTH: Maximum text length before summarization (default: 10000)
- MCP_MAX_LINES: Maximum lines before summarization (default: 500)$3
The server automatically detects and configures:
- Maven repository location
- Available Java decompilers
- System capabilities๐ Troubleshooting
$3
Server won't start
`bash
Check Python installation
python --versionCheck Maven repository
ls ~/.m2/repositoryCheck logs
maven-decoder-mcp --debug
`Decompilation fails
`bash
Check Java installation
java -versionSetup decompilers manually
maven-decoder-setup decompilers
`No artifacts found
`bash
Verify Maven repository location
ls ~/.m2/repositoryRun a Maven build to populate repository
mvn dependency:resolve
`๐ค Contributing
1. Fork the repository
2. Create a feature branch (
git checkout -b feature/amazing-feature)
3. Commit your changes (git commit -m 'Add amazing feature')
4. Push to the branch (git push origin feature/amazing-feature`)This project is licensed under the MIT License - see the LICENSE file for details.
- Model Context Protocol - The protocol that powers this server
- CFR - Java decompiler
- Procyon - Java decompiler
- Maven - Dependency management
!GitHub Stars
!PyPI Downloads
!Docker Pulls
---
Made with โค๏ธ for the Java development community