maven-decoder-mcp 1.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- maven_decoder_mcp-1.2.0/LICENSE +21 -0
- maven_decoder_mcp-1.2.0/MANIFEST.in +10 -0
- maven_decoder_mcp-1.2.0/PKG-INFO +487 -0
- maven_decoder_mcp-1.2.0/README.md +441 -0
- maven_decoder_mcp-1.2.0/maven_decoder_mcp/__init__.py +39 -0
- maven_decoder_mcp-1.2.0/maven_decoder_mcp/config.py +337 -0
- maven_decoder_mcp-1.2.0/maven_decoder_mcp/decompiler.py +569 -0
- maven_decoder_mcp-1.2.0/maven_decoder_mcp/decompiler_paths.py +11 -0
- maven_decoder_mcp-1.2.0/maven_decoder_mcp/maven_analyzer.py +531 -0
- maven_decoder_mcp-1.2.0/maven_decoder_mcp/maven_central.py +585 -0
- maven_decoder_mcp-1.2.0/maven_decoder_mcp/maven_decoder_server.py +1901 -0
- maven_decoder_mcp-1.2.0/maven_decoder_mcp/setup_tool.py +173 -0
- maven_decoder_mcp-1.2.0/maven_decoder_mcp.egg-info/PKG-INFO +487 -0
- maven_decoder_mcp-1.2.0/maven_decoder_mcp.egg-info/SOURCES.txt +27 -0
- maven_decoder_mcp-1.2.0/maven_decoder_mcp.egg-info/dependency_links.txt +1 -0
- maven_decoder_mcp-1.2.0/maven_decoder_mcp.egg-info/entry_points.txt +3 -0
- maven_decoder_mcp-1.2.0/maven_decoder_mcp.egg-info/requires.txt +16 -0
- maven_decoder_mcp-1.2.0/maven_decoder_mcp.egg-info/top_level.txt +7 -0
- maven_decoder_mcp-1.2.0/pyproject.toml +84 -0
- maven_decoder_mcp-1.2.0/requirements.txt +14 -0
- maven_decoder_mcp-1.2.0/scripts/release.py +283 -0
- maven_decoder_mcp-1.2.0/setup.cfg +4 -0
- maven_decoder_mcp-1.2.0/setup_decompilers.sh +67 -0
- maven_decoder_mcp-1.2.0/skills/maven-code-search/SKILL.md +106 -0
- maven_decoder_mcp-1.2.0/start_server.sh +18 -0
- maven_decoder_mcp-1.2.0/tests/conftest.py +89 -0
- maven_decoder_mcp-1.2.0/tests/test_maven_central.py +919 -0
- maven_decoder_mcp-1.2.0/tests/test_maven_repository_resolution.py +95 -0
- maven_decoder_mcp-1.2.0/tests/test_pagination.py +418 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Maven Decoder MCP
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
include README.md
|
|
2
|
+
include LICENSE
|
|
3
|
+
include requirements.txt
|
|
4
|
+
include setup_decompilers.sh
|
|
5
|
+
include start_server.sh
|
|
6
|
+
recursive-include src/maven_decoder_mcp/decompilers *.jar
|
|
7
|
+
recursive-include src/maven_decoder_mcp *.py
|
|
8
|
+
exclude test_*.py
|
|
9
|
+
exclude diagnose_*.py
|
|
10
|
+
exclude *.log
|
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: maven-decoder-mcp
|
|
3
|
+
Version: 1.2.0
|
|
4
|
+
Summary: MCP server for reading and decompiling Maven jar files, with online Maven Central search and comprehensive Java project analysis
|
|
5
|
+
Author-email: Ali Tabatabaei <ali79taba@gmail.com>
|
|
6
|
+
Maintainer-email: Ali Tabatabaei <ali79taba@gmail.com>
|
|
7
|
+
License: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/salitaba/maven-decoder-mcp
|
|
9
|
+
Project-URL: Documentation, https://github.com/salitaba/maven-decoder-mcp#readme
|
|
10
|
+
Project-URL: Repository, https://github.com/salitaba/maven-decoder-mcp.git
|
|
11
|
+
Project-URL: Bug Tracker, https://github.com/salitaba/maven-decoder-mcp/issues
|
|
12
|
+
Keywords: mcp,maven,java,decompiler,jar,analysis,cursor,ide,maven-central,search
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
25
|
+
Classifier: Topic :: Software Development :: Debuggers
|
|
26
|
+
Classifier: Topic :: Software Development :: Disassemblers
|
|
27
|
+
Requires-Python: >=3.10
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
License-File: LICENSE
|
|
30
|
+
Requires-Dist: mcp>=1.0.0
|
|
31
|
+
Requires-Dist: pydantic>=2.0.0
|
|
32
|
+
Requires-Dist: xmltodict>=0.13.0
|
|
33
|
+
Requires-Dist: javatools>=1.4.0
|
|
34
|
+
Requires-Dist: py4j>=0.10.9
|
|
35
|
+
Requires-Dist: aiofiles>=23.0.0
|
|
36
|
+
Requires-Dist: pathspec>=0.11.0
|
|
37
|
+
Requires-Dist: requests>=2.25.0
|
|
38
|
+
Provides-Extra: dev
|
|
39
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
40
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
41
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
42
|
+
Requires-Dist: isort>=5.12.0; extra == "dev"
|
|
43
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
44
|
+
Requires-Dist: flake8>=6.0.0; extra == "dev"
|
|
45
|
+
Dynamic: license-file
|
|
46
|
+
|
|
47
|
+
# Maven Decoder MCP Server
|
|
48
|
+
|
|
49
|
+
[](https://skills.sh/salitaba/maven-decoder-mcp)
|
|
50
|
+
|
|
51
|
+
A comprehensive Model Context Protocol (MCP) server for analyzing Maven jar files, both in your local repository (`~/.m2`) and **online on Maven Central**. 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.
|
|
52
|
+
|
|
53
|
+
## 🚀 Features
|
|
54
|
+
|
|
55
|
+
### Core Functionality
|
|
56
|
+
- **Jar File Analysis**: Deep inspection of jar files including metadata, manifests, and structure
|
|
57
|
+
- **Dependency Resolution**: Complete dependency tree analysis with transitive dependencies
|
|
58
|
+
- **Source Code Extraction**: Extract source code from source jars or decompile bytecode
|
|
59
|
+
- **Class Information**: Detailed class signatures, methods, fields, and annotations
|
|
60
|
+
- **Search Capabilities**: Find classes, methods, and dependencies across all artifacts
|
|
61
|
+
- **Version Management**: Compare versions, find dependents, and track version conflicts
|
|
62
|
+
|
|
63
|
+
### Online Maven Support
|
|
64
|
+
- **Maven Central Search**: Find artifacts and classes that are **not installed locally**
|
|
65
|
+
- **Remote Version Listing**: See every published version, not just the ones you have
|
|
66
|
+
- **On-Demand Download**: Fetch any artifact (jar, sources, POM) into a local cache
|
|
67
|
+
- **Transparent Fallback**: Every analysis tool automatically downloads a missing artifact, so decompiling a dependency you never installed just works
|
|
68
|
+
- **Mirror Friendly**: Point it at a corporate Nexus/Artifactory, with optional credentials
|
|
69
|
+
- **Offline Mode**: A single env var restores fully local, network-free behavior
|
|
70
|
+
|
|
71
|
+
### Advanced Features
|
|
72
|
+
- **Decompilation Support**: Integrated support for multiple Java decompilers (CFR, Fernflower, Procyon)
|
|
73
|
+
- **Conflict Analysis**: Detect and analyze dependency version conflicts
|
|
74
|
+
- **Repository Navigation**: Browse and explore the local Maven repository structure
|
|
75
|
+
- **Metadata Parsing**: Extract and parse Maven POM files and metadata
|
|
76
|
+
- **Service Discovery**: Find and analyze Java services and SPI implementations
|
|
77
|
+
- **Response Management**: Intelligent pagination and summarization for large responses
|
|
78
|
+
- **Method Extraction**: Extract specific methods from large Java classes
|
|
79
|
+
- **Integrity Checking**: Downloads are verified against the repository's SHA-1 checksums
|
|
80
|
+
|
|
81
|
+
## 📦 Installation
|
|
82
|
+
|
|
83
|
+
### Prerequisites
|
|
84
|
+
- Java 8+ (for decompilation features)
|
|
85
|
+
- Maven local repository (`~/.m2/repository`)
|
|
86
|
+
- One of: **Python 3.8+**, **Node.js 14+**, or **Docker**
|
|
87
|
+
|
|
88
|
+
### 🚀 Quick Install
|
|
89
|
+
|
|
90
|
+
#### One-Line Install (Recommended)
|
|
91
|
+
```bash
|
|
92
|
+
curl -fsSL https://raw.githubusercontent.com/salitaba/maven-decoder-mcp/main/install.sh | bash
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### 📋 Installation Methods
|
|
96
|
+
|
|
97
|
+
#### Method 1: uvx (Recommended)
|
|
98
|
+
```bash
|
|
99
|
+
# Install uv (if not installed)
|
|
100
|
+
curl -Ls https://astral.sh/uv/install.sh | sh
|
|
101
|
+
# Ensure your shell PATH is updated (restart shell or eval as printed by installer)
|
|
102
|
+
|
|
103
|
+
# Run the server via uvx (isolated, fast, no venv needed)
|
|
104
|
+
uvx maven-decoder-mcp
|
|
105
|
+
|
|
106
|
+
# Optional: pick a specific Python
|
|
107
|
+
# uvx --python 3.12 maven-decoder-mcp
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
#### Method 2: Node.js/npm
|
|
111
|
+
```bash
|
|
112
|
+
# Install globally
|
|
113
|
+
npm install -g maven-decoder-mcp
|
|
114
|
+
|
|
115
|
+
# Or install locally
|
|
116
|
+
npm install maven-decoder-mcp
|
|
117
|
+
|
|
118
|
+
# Run the server
|
|
119
|
+
maven-decoder-mcp
|
|
120
|
+
# or if installed locally: npx maven-decoder-mcp
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
#### Method 3: Docker
|
|
124
|
+
```bash
|
|
125
|
+
# Pull and run
|
|
126
|
+
docker run --rm -it \
|
|
127
|
+
-v ~/.m2:/home/mcpuser/.m2 \
|
|
128
|
+
-v $(pwd):/workspace \
|
|
129
|
+
ali79taba/maven-decoder-mcp:latest
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
#### Method 4: From Source (Development)
|
|
133
|
+
```bash
|
|
134
|
+
# Clone repository
|
|
135
|
+
git clone https://github.com/salitaba/maven-decoder-mcp.git
|
|
136
|
+
cd maven-decoder-mcp
|
|
137
|
+
|
|
138
|
+
# Option A: Using Virtual Environment
|
|
139
|
+
python3 -m venv .venv
|
|
140
|
+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
|
|
141
|
+
pip install -r requirements.txt
|
|
142
|
+
pip install "git+https://github.com/modelcontextprotocol/python-sdk.git"
|
|
143
|
+
./setup_decompilers.sh
|
|
144
|
+
|
|
145
|
+
# Option B: System-wide Installation (not recommended)
|
|
146
|
+
./setup_decompilers.sh
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## 🔧 Configuration
|
|
150
|
+
|
|
151
|
+
### For Cursor IDE
|
|
152
|
+
Add to your `~/.cursor/mcp_servers.json`:
|
|
153
|
+
|
|
154
|
+
```json
|
|
155
|
+
{
|
|
156
|
+
"maven-decoder": {
|
|
157
|
+
"command": "uvx",
|
|
158
|
+
"args": ["maven-decoder-mcp"]
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### For Other MCP Clients
|
|
164
|
+
The server runs as a standard MCP server and can be integrated with any MCP-compatible client.
|
|
165
|
+
|
|
166
|
+
## 🧠 AI Agent Skill
|
|
167
|
+
|
|
168
|
+
This repository includes a `maven-code-search` agent skill that tells AI coding agents when and how to use this MCP for searching installed Maven package code.
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
npx skills add https://github.com/salitaba/maven-decoder-mcp --skill maven-code-search
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
The skill is located at `skills/maven-code-search` and is ready for skills.sh indexing after the repository is pushed.
|
|
175
|
+
|
|
176
|
+
## 🛠️ Available Tools
|
|
177
|
+
|
|
178
|
+
### Local Analysis
|
|
179
|
+
|
|
180
|
+
| Tool | Description |
|
|
181
|
+
|------|-------------|
|
|
182
|
+
| `list_artifacts` | List artifacts in Maven repository with filtering |
|
|
183
|
+
| `analyze_jar` | Analyze jar file structure and contents |
|
|
184
|
+
| `extract_class_info` | Get detailed information about Java classes |
|
|
185
|
+
| `get_dependencies` | Retrieve Maven dependencies from POM files |
|
|
186
|
+
| `search_classes` | Search for classes across all jars, optionally filtered by annotation |
|
|
187
|
+
| `extract_source_code` | Decompile and extract Java source code |
|
|
188
|
+
| `extract_jar_resource` | Extract text resources such as `.proto` files, services, and metadata |
|
|
189
|
+
| `compare_versions` | Compare different versions of artifacts |
|
|
190
|
+
| `find_usage_examples` | Find classes that reference a given class or method |
|
|
191
|
+
| `get_dependency_tree` | Get complete dependency tree |
|
|
192
|
+
| `find_dependents` | Find artifacts that depend on a specific artifact |
|
|
193
|
+
| `get_version_info` | Get installed versions of an artifact (set `include_remote` to add published ones) |
|
|
194
|
+
| `analyze_jar_structure` | Analyze overall jar structure and metadata |
|
|
195
|
+
| `extract_method_info` | Extract specific method information from Java classes |
|
|
196
|
+
|
|
197
|
+
### Online (Maven Central)
|
|
198
|
+
|
|
199
|
+
| Tool | Description |
|
|
200
|
+
|------|-------------|
|
|
201
|
+
| `search_maven_central` | Search Maven Central for artifacts by name, coordinates, or contained class |
|
|
202
|
+
| `get_remote_versions` | List every version published remotely, flagging which are installed |
|
|
203
|
+
| `download_artifact` | Download an artifact (jar/sources/POM) into the local cache; accepts `latest` |
|
|
204
|
+
|
|
205
|
+
## 💡 Usage Examples
|
|
206
|
+
|
|
207
|
+
### Finding Dependencies
|
|
208
|
+
```
|
|
209
|
+
"Show me all dependencies of org.springframework:spring-core:5.3.21"
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Decompiling Classes
|
|
213
|
+
```
|
|
214
|
+
"Decompile the class com.example.MyService from my Maven repository"
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Analyzing Conflicts
|
|
218
|
+
```
|
|
219
|
+
"Find all version conflicts in my Maven repository"
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Exploring APIs
|
|
223
|
+
```
|
|
224
|
+
"Show me all public methods in the Jackson ObjectMapper class"
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### Inspecting Compiled-Only Artifacts
|
|
228
|
+
```
|
|
229
|
+
"The sources jar is missing. Use extract_class_info for bytecode-backed fields and methods."
|
|
230
|
+
"Find and read .proto resources from com.example:protobuf-lib:1.0.0"
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
When a dependency has no sources jar, `extract_class_info` uses `javap` internally and returns parsed fields, methods, bytecode version, and optional verbose bytecode output. Agents should use `analyze_jar`, `extract_class_info`, `extract_source_code`, and `extract_jar_resource` through this MCP instead of running `jar` or `javap` directly.
|
|
234
|
+
|
|
235
|
+
### Working with Large Responses
|
|
236
|
+
```
|
|
237
|
+
"List all Spring classes with pagination (page 2, 10 items per page)"
|
|
238
|
+
"Extract source code for a large class with summarization"
|
|
239
|
+
"Get method information for specific patterns in a class"
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Searching Maven Central (Online)
|
|
243
|
+
```
|
|
244
|
+
"Which Maven artifact contains the class HikariDataSource?"
|
|
245
|
+
"Search Maven Central for retrofit"
|
|
246
|
+
"What is the newest published version of org.apache.commons:commons-lang3?"
|
|
247
|
+
"Download com.google.code.gson:gson:latest and show me the JsonParser class"
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
## 🌐 Online Maven Support
|
|
251
|
+
|
|
252
|
+
The server works against the local repository **and** remote repositories. Online
|
|
253
|
+
access is enabled by default.
|
|
254
|
+
|
|
255
|
+
### How it works
|
|
256
|
+
|
|
257
|
+
1. Every tool first looks in your local repository (`~/.m2/repository`).
|
|
258
|
+
2. On a miss, the artifact is downloaded from Maven Central into a cache
|
|
259
|
+
(`~/.cache/maven-decoder-mcp/repository`) that uses the standard Maven layout.
|
|
260
|
+
3. All existing analysis (decompilation, class info, dependencies) then runs on
|
|
261
|
+
the cached artifact exactly as it would on an installed one.
|
|
262
|
+
|
|
263
|
+
The cache is deliberately **separate from `~/.m2`** so downloads never interfere
|
|
264
|
+
with your Maven or Gradle builds. Responses include an `origin` field
|
|
265
|
+
(`local-repository` or `remote-cache`) so you always know where a result came from.
|
|
266
|
+
|
|
267
|
+
### Going offline
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
MAVEN_OFFLINE=true # no network access at all; original local-only behavior
|
|
271
|
+
MAVEN_AUTO_DOWNLOAD=false # keep online search, but never auto-download
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### Using a private mirror
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
MAVEN_REMOTE_REPOS="https://nexus.corp/repository/maven-public"
|
|
278
|
+
MAVEN_REMOTE_USERNAME=builder
|
|
279
|
+
MAVEN_REMOTE_PASSWORD=secret
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### A note on the search index
|
|
283
|
+
|
|
284
|
+
Artifact **downloads** use `repo1.maven.org`, which is fast and reliable.
|
|
285
|
+
Artifact **search** uses `search.maven.org`, the only public index that answers
|
|
286
|
+
class-level (`c:` / `fc:`) queries correctly. That index rate-limits bursts, so
|
|
287
|
+
requests are retried with backoff; a busy period can still surface as a timeout.
|
|
288
|
+
Downloads and version listing are unaffected, because they read
|
|
289
|
+
`maven-metadata.xml` directly from the repository.
|
|
290
|
+
|
|
291
|
+
## 🔄 Response Management
|
|
292
|
+
|
|
293
|
+
### Pagination Support
|
|
294
|
+
The server automatically handles large responses through intelligent pagination:
|
|
295
|
+
|
|
296
|
+
- **Automatic Detection**: Responses exceeding 50KB are automatically paginated
|
|
297
|
+
- **Configurable Page Size**: Default 20 items per page, customizable per request
|
|
298
|
+
- **Pagination Metadata**: Each response includes pagination information
|
|
299
|
+
- **Supported Tools**: `list_artifacts`, `extract_class_info`, `search_classes`, `get_dependencies`, `find_dependents`, `get_version_info`
|
|
300
|
+
|
|
301
|
+
### Summarization Features
|
|
302
|
+
Large text content is automatically summarized to improve readability:
|
|
303
|
+
|
|
304
|
+
- **Smart Summarization**: Preserves important parts (package declarations, method signatures, closing braces)
|
|
305
|
+
- **Configurable Limits**: Default 10KB text limit, customizable
|
|
306
|
+
- **Java-Specific**: Optimized for Java source code structure
|
|
307
|
+
- **Metadata Preservation**: Original structure and metadata are maintained
|
|
308
|
+
|
|
309
|
+
### Method Extraction
|
|
310
|
+
New tool for targeted access to specific methods:
|
|
311
|
+
|
|
312
|
+
- **Pattern Matching**: Use regex patterns to find specific methods
|
|
313
|
+
- **Limited Results**: Control the number of methods returned
|
|
314
|
+
- **Full Context**: Includes method signatures, bodies, and line numbers
|
|
315
|
+
- **Efficient Processing**: Only extracts requested methods, not entire classes
|
|
316
|
+
|
|
317
|
+
## 🏗️ Architecture
|
|
318
|
+
|
|
319
|
+
The server is built with a modular architecture:
|
|
320
|
+
|
|
321
|
+
- **`MavenDecoderServer`**: Main MCP server implementation
|
|
322
|
+
- **`ResponseManager`**: Handles pagination and summarization
|
|
323
|
+
- **`JavaDecompiler`**: Handles multiple decompilation strategies
|
|
324
|
+
- **`MavenDependencyAnalyzer`**: Analyzes Maven dependencies and metadata
|
|
325
|
+
- **`MavenCentralClient`**: Remote search, version listing, and artifact downloads
|
|
326
|
+
- **Decompilers**: CFR, Procyon, Fernflower, and javap integration
|
|
327
|
+
|
|
328
|
+
## 🧪 Development
|
|
329
|
+
|
|
330
|
+
### Running Tests
|
|
331
|
+
```bash
|
|
332
|
+
# Install development dependencies
|
|
333
|
+
pip install -e ".[dev]"
|
|
334
|
+
|
|
335
|
+
# Run tests
|
|
336
|
+
pytest
|
|
337
|
+
|
|
338
|
+
# Run specific test
|
|
339
|
+
python test_startup.py
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
### Building Package
|
|
343
|
+
```bash
|
|
344
|
+
# Build distribution
|
|
345
|
+
python setup.py sdist bdist_wheel
|
|
346
|
+
|
|
347
|
+
# Install locally
|
|
348
|
+
pip install dist/maven_decoder_mcp-*.whl
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
### Docker Development
|
|
352
|
+
```bash
|
|
353
|
+
# Build Docker image
|
|
354
|
+
docker build -t maven-decoder-mcp .
|
|
355
|
+
|
|
356
|
+
# Run container
|
|
357
|
+
docker run --rm -it maven-decoder-mcp
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
## 📝 Configuration Options
|
|
361
|
+
|
|
362
|
+
### Environment Variables
|
|
363
|
+
|
|
364
|
+
#### Local repository
|
|
365
|
+
- `MAVEN_REPOSITORY` / `MAVEN_REPO`: direct path to local Maven repository (e.g. `F:\data\repository`). Highest precedence.
|
|
366
|
+
- `MAVEN_HOME` / `M2_HOME`: Maven install dir or repository dir. A nested `repository/` subdir wins when it exists; `conf/settings.xml` `<localRepository>` honored.
|
|
367
|
+
- `~/.m2/settings.xml` `<localRepository>` honored when no env var set. Fallback: `~/.m2/repository`.
|
|
368
|
+
|
|
369
|
+
#### Online access
|
|
370
|
+
- `MAVEN_OFFLINE`: set to `true` to disable all network access (default: `false`)
|
|
371
|
+
- `MAVEN_AUTO_DOWNLOAD`: auto-fetch artifacts missing locally (default: `true`)
|
|
372
|
+
- `MAVEN_REMOTE_REPOS` / `MAVEN_REMOTE_REPO`: comma/space separated repository base URLs (default: `https://repo1.maven.org/maven2`)
|
|
373
|
+
- `MAVEN_SEARCH_URL`: comma/space separated Solr search endpoints (default: `https://search.maven.org/solrsearch/select`)
|
|
374
|
+
- `MAVEN_DECODER_CACHE_DIR`: where downloaded artifacts are cached (default: `~/.cache/maven-decoder-mcp/repository`)
|
|
375
|
+
- `MAVEN_REMOTE_USERNAME` / `MAVEN_REMOTE_PASSWORD`: basic-auth credentials for a private mirror
|
|
376
|
+
- `MAVEN_HTTP_TIMEOUT`: per-request timeout in seconds (default: 30)
|
|
377
|
+
- `MAVEN_HTTP_RETRIES`: retries for transient network failures (default: 3)
|
|
378
|
+
- `MAVEN_MAX_DOWNLOAD_SIZE`: maximum download size in bytes (default: 104857600)
|
|
379
|
+
- `MAVEN_VERIFY_CHECKSUM`: verify downloads against published SHA-1 (default: `true`)
|
|
380
|
+
|
|
381
|
+
#### Responses
|
|
382
|
+
- `MCP_LOG_LEVEL`: Logging level (DEBUG, INFO, WARNING, ERROR)
|
|
383
|
+
- `MCP_MAX_RESPONSE_SIZE`: Maximum response size in bytes (default: 50000)
|
|
384
|
+
- `MCP_MAX_ITEMS_PER_PAGE`: Default items per page (default: 20)
|
|
385
|
+
- `MCP_MAX_TEXT_LENGTH`: Maximum text length before summarization (default: 10000)
|
|
386
|
+
- `MCP_MAX_LINES`: Maximum lines before summarization (default: 500)
|
|
387
|
+
- `MCP_USAGE_SCAN_LIMIT`: Max classes scanned by `find_usage_examples` (default: 200000)
|
|
388
|
+
- `MAVEN_DECODER_DECOMPILER_DIR`: Directory holding `cfr.jar` / `procyon-decompiler.jar`
|
|
389
|
+
|
|
390
|
+
### Advanced Configuration
|
|
391
|
+
The server automatically detects and configures:
|
|
392
|
+
- Maven repository location
|
|
393
|
+
- Available Java decompilers
|
|
394
|
+
- System capabilities
|
|
395
|
+
|
|
396
|
+
## 🔍 Troubleshooting
|
|
397
|
+
|
|
398
|
+
### Common Issues
|
|
399
|
+
|
|
400
|
+
**Server won't start**
|
|
401
|
+
```bash
|
|
402
|
+
# Check Python installation
|
|
403
|
+
python --version
|
|
404
|
+
|
|
405
|
+
# Check Maven repository
|
|
406
|
+
ls ~/.m2/repository
|
|
407
|
+
|
|
408
|
+
# Check logs
|
|
409
|
+
maven-decoder-mcp --debug
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
**Decompilation fails**
|
|
415
|
+
```bash
|
|
416
|
+
# Check the environment: Java, repository, cache and available decompilers
|
|
417
|
+
maven-decoder-setup status
|
|
418
|
+
|
|
419
|
+
# Install the optional CFR and Procyon decompilers
|
|
420
|
+
maven-decoder-setup decompilers
|
|
421
|
+
```
|
|
422
|
+
Without CFR or Procyon the server still works, falling back to `javap` from
|
|
423
|
+
the JDK for signatures, fields and methods.
|
|
424
|
+
|
|
425
|
+
**No artifacts found**
|
|
426
|
+
```bash
|
|
427
|
+
# Verify Maven repository location
|
|
428
|
+
ls ~/.m2/repository
|
|
429
|
+
|
|
430
|
+
# Run a Maven build to populate repository
|
|
431
|
+
mvn dependency:resolve
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
**Maven Central search times out**
|
|
435
|
+
|
|
436
|
+
The public search index rate-limits bursts of requests. Retries with backoff are
|
|
437
|
+
built in, but during heavy throttling a search can still fail. Workarounds:
|
|
438
|
+
|
|
439
|
+
```bash
|
|
440
|
+
# Wait a moment and retry, or raise the retry budget
|
|
441
|
+
MAVEN_HTTP_RETRIES=5
|
|
442
|
+
|
|
443
|
+
# Downloads and version listing do not use the search index, so these keep
|
|
444
|
+
# working even while search is throttled:
|
|
445
|
+
# get_remote_versions, download_artifact
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
**Downloads fail behind a proxy or firewall**
|
|
449
|
+
```bash
|
|
450
|
+
# requests honors the standard proxy variables
|
|
451
|
+
export HTTPS_PROXY=http://proxy.corp:8080
|
|
452
|
+
|
|
453
|
+
# Or point at an internal mirror
|
|
454
|
+
export MAVEN_REMOTE_REPOS="https://nexus.corp/repository/maven-public"
|
|
455
|
+
|
|
456
|
+
# Or turn the network off entirely
|
|
457
|
+
export MAVEN_OFFLINE=true
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
## 🤝 Contributing
|
|
461
|
+
|
|
462
|
+
1. Fork the repository
|
|
463
|
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
464
|
+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
465
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
466
|
+
5. Open a Pull Request
|
|
467
|
+
|
|
468
|
+
## 📄 License
|
|
469
|
+
|
|
470
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
471
|
+
|
|
472
|
+
## 🙏 Acknowledgments
|
|
473
|
+
|
|
474
|
+
- [Model Context Protocol](https://github.com/modelcontextprotocol) - The protocol that powers this server
|
|
475
|
+
- [CFR](https://github.com/leibnitz27/cfr) - Java decompiler
|
|
476
|
+
- [Procyon](https://github.com/mstrobel/procyon) - Java decompiler
|
|
477
|
+
- [Maven](https://maven.apache.org/) - Dependency management
|
|
478
|
+
|
|
479
|
+
## 📊 Stats
|
|
480
|
+
|
|
481
|
+

|
|
482
|
+

|
|
483
|
+

|
|
484
|
+
|
|
485
|
+
---
|
|
486
|
+
|
|
487
|
+
**Made with ❤️ for the Java development community**
|