Skip to main content

MCP server for reading and decompiling Maven .m2 jar files with comprehensive Java project analysis

Project description

Maven Decoder MCP Server

A 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.

🚀 Features

Core Functionality

  • Jar File Analysis: Deep inspection of jar files including metadata, manifests, and structure
  • Dependency Resolution: Complete dependency tree analysis with transitive dependencies
  • Source Code Extraction: Extract source code from source jars or decompile bytecode
  • Class Information: Detailed class signatures, methods, fields, and annotations
  • Search Capabilities: Find classes, methods, and dependencies across all artifacts
  • Version Management: Compare versions, find dependents, and track version conflicts

Advanced Features

  • Decompilation Support: Integrated support for multiple Java decompilers (CFR, Fernflower, Procyon)
  • Conflict Analysis: Detect and analyze dependency version conflicts
  • Repository Navigation: Browse and explore the local Maven repository structure
  • Metadata Parsing: Extract and parse Maven POM files and metadata
  • Service Discovery: Find and analyze Java services and SPI implementations

📦 Installation

Prerequisites

  • Java 8+ (for decompilation features)
  • Maven local repository (~/.m2/repository)
  • One of: Python 3.8+, Node.js 14+, or Docker

🚀 Quick Install

One-Line Install (Recommended)

curl -fsSL https://raw.githubusercontent.com/salitaba/maven-decoder-mcp/main/install.sh | bash

📋 Installation Methods

Method 1: uvx (Recommended)

# Install uv (if not installed)
curl -Ls https://astral.sh/uv/install.sh | sh
# Ensure your shell PATH is updated (restart shell or eval as printed by installer)

# Run the server via uvx (isolated, fast, no venv needed)
uvx maven-decoder-mcp

# Optional: pick a specific Python
# uvx --python 3.12 maven-decoder-mcp

Method 2: Node.js/npm

# Install globally
npm install -g maven-decoder-mcp

# Or install locally
npm install maven-decoder-mcp

# Run the server
maven-decoder-mcp
# or if installed locally: npx maven-decoder-mcp

Method 3: Docker

# Pull and run
docker run --rm -it \
  -v ~/.m2:/home/mcpuser/.m2 \
  -v $(pwd):/workspace \
  maven-decoder/mcp-server:latest

Method 4: From Source (Development)

# Clone repository
git clone https://github.com/salitaba/maven-decoder-mcp.git
cd maven-decoder-mcp

# Option 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.sh

# Option B: System-wide Installation (not recommended)
./setup_decompilers.sh

🔧 Configuration

For Cursor IDE

Add to your ~/.cursor/mcp_servers.json:

{
  "maven-decoder": {
    "command": "uvx",
    "args": ["maven-decoder-mcp"]
  }
}

For Other MCP Clients

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

💡 Usage Examples

Finding Dependencies

"Show me all dependencies of org.springframework:spring-core:5.3.21"

Decompiling Classes

"Decompile the class com.example.MyService from my Maven repository"

Analyzing Conflicts

"Find all version conflicts in my Maven repository"

Exploring APIs

"Show me all public methods in the Jackson ObjectMapper class"

🏗️ Architecture

The server is built with a modular architecture:

  • MavenDecoderServer: Main MCP server implementation
  • JavaDecompiler: Handles multiple decompilation strategies
  • MavenDependencyAnalyzer: Analyzes Maven dependencies and metadata
  • Decompilers: CFR, Procyon, Fernflower, and javap integration

🧪 Development

Running Tests

# Install development dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Run specific test
python test_startup.py

Building Package

# Build distribution
python setup.py sdist bdist_wheel

# Install locally
pip install dist/maven_decoder_mcp-*.whl

Docker Development

# Build Docker image
docker build -t maven-decoder-mcp .

# Run container
docker run --rm -it maven-decoder-mcp

📝 Configuration Options

Environment Variables

  • MAVEN_HOME: Custom Maven repository location (default: ~/.m2/repository)
  • MCP_LOG_LEVEL: Logging level (DEBUG, INFO, WARNING, ERROR)

Advanced Configuration

The server automatically detects and configures:

  • Maven repository location
  • Available Java decompilers
  • System capabilities

🔍 Troubleshooting

Common Issues

Server won't start

# Check Python installation
python --version

# Check Maven repository
ls ~/.m2/repository

# Check logs
maven-decoder-mcp --debug

Decompilation fails

# Check Java installation
java -version

# Setup decompilers manually
maven-decoder-setup decompilers

No artifacts found

# Verify Maven repository location
ls ~/.m2/repository

# Run 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)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

📊 Stats

GitHub Stars PyPI Downloads Docker Pulls


Made with ❤️ for the Java development community

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

maven_decoder_mcp-1.0.17.tar.gz (26.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

maven_decoder_mcp-1.0.17-py3-none-any.whl (25.4 kB view details)

Uploaded Python 3

File details

Details for the file maven_decoder_mcp-1.0.17.tar.gz.

File metadata

  • Download URL: maven_decoder_mcp-1.0.17.tar.gz
  • Upload date:
  • Size: 26.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for maven_decoder_mcp-1.0.17.tar.gz
Algorithm Hash digest
SHA256 250d369f95548736b0742f2765a1b7b0b00b90e68c85c1e25162dd9d445b7ec7
MD5 328e4e276eca01378fdb133df0847c95
BLAKE2b-256 16dc39b45cf3fb0931ab1eaa07904418229f0637ae4e0c7f20f6845c733c1b8e

See more details on using hashes here.

File details

Details for the file maven_decoder_mcp-1.0.17-py3-none-any.whl.

File metadata

File hashes

Hashes for maven_decoder_mcp-1.0.17-py3-none-any.whl
Algorithm Hash digest
SHA256 ddf399eaabfdbfc7fb921c45990a4fedc2b9e52ff6b4f957900d81c0018da4bc
MD5 597f166b8cf4a8d14ed9b3ab0ca7f1d5
BLAKE2b-256 e7a2189283d25d70086e031528766afa753c756f9f270050f117b35a508ec9db

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page