@mustafagoksever/java-inspector 1.0.4
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.
- package/LICENSE +201 -0
- package/README.md +276 -0
- package/dist/analyzer/JavaClassAnalyzer.d.ts +61 -0
- package/dist/analyzer/JavaClassAnalyzer.d.ts.map +1 -0
- package/dist/analyzer/JavaClassAnalyzer.js +313 -0
- package/dist/analyzer/JavaClassAnalyzer.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +73 -0
- package/dist/cli.js.map +1 -0
- package/dist/decompiler/DecompilerService.d.ts +39 -0
- package/dist/decompiler/DecompilerService.d.ts.map +1 -0
- package/dist/decompiler/DecompilerService.js +270 -0
- package/dist/decompiler/DecompilerService.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +290 -0
- package/dist/index.js.map +1 -0
- package/dist/scanner/DependencyScanner.d.ts +56 -0
- package/dist/scanner/DependencyScanner.d.ts.map +1 -0
- package/dist/scanner/DependencyScanner.js +283 -0
- package/dist/scanner/DependencyScanner.js.map +1 -0
- package/dist/utils/cachePaths.d.ts +10 -0
- package/dist/utils/cachePaths.d.ts.map +1 -0
- package/dist/utils/cachePaths.js +25 -0
- package/dist/utils/cachePaths.js.map +1 -0
- package/lib/cfr-0.152.jar +0 -0
- package/package.json +88 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { execFile } from 'child_process';
|
|
2
|
+
import { promisify } from 'util';
|
|
3
|
+
import * as fs from 'fs-extra';
|
|
4
|
+
import { readFile, readdir } from 'fs/promises';
|
|
5
|
+
import * as path from 'path';
|
|
6
|
+
import * as yauzl from 'yauzl';
|
|
7
|
+
import { fileURLToPath } from 'url';
|
|
8
|
+
import { createWriteStream } from 'fs';
|
|
9
|
+
import { DependencyScanner } from '../scanner/DependencyScanner.js';
|
|
10
|
+
import { getDecompileCacheDir, getClassTempDir } from '../utils/cachePaths.js';
|
|
11
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
12
|
+
const __dirname = path.dirname(__filename);
|
|
13
|
+
const execFileAsync = promisify(execFile);
|
|
14
|
+
export class DecompilerService {
|
|
15
|
+
scanner;
|
|
16
|
+
cfrPath;
|
|
17
|
+
constructor() {
|
|
18
|
+
this.scanner = new DependencyScanner();
|
|
19
|
+
this.cfrPath = '';
|
|
20
|
+
}
|
|
21
|
+
async initializeCfrPath() {
|
|
22
|
+
if (!this.cfrPath) {
|
|
23
|
+
this.cfrPath = await this.findCfrJar();
|
|
24
|
+
if (!this.cfrPath) {
|
|
25
|
+
throw new Error('CFR decompiler tool not found. Please download CFR jar to lib directory or set CFR_PATH environment variable');
|
|
26
|
+
}
|
|
27
|
+
console.error(`CFR tool path: ${this.cfrPath}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Decompile specified Java class file
|
|
32
|
+
*/
|
|
33
|
+
async decompileClass(className, projectPath, useCache = true, cfrPath) {
|
|
34
|
+
try {
|
|
35
|
+
// If external CFR path is specified, use external path
|
|
36
|
+
if (cfrPath) {
|
|
37
|
+
this.cfrPath = cfrPath;
|
|
38
|
+
console.error(`Using externally specified CFR tool path: ${this.cfrPath}`);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
await this.initializeCfrPath();
|
|
42
|
+
}
|
|
43
|
+
// 1. Check cache
|
|
44
|
+
const cachePath = this.getCachePath(className, projectPath);
|
|
45
|
+
if (useCache && await fs.pathExists(cachePath)) {
|
|
46
|
+
console.error(`Using cached decompilation result: ${cachePath}`);
|
|
47
|
+
return await readFile(cachePath, 'utf-8');
|
|
48
|
+
}
|
|
49
|
+
// 2. Find corresponding JAR package for class
|
|
50
|
+
console.error(`Finding JAR package for class ${className}...`);
|
|
51
|
+
// Add timeout handling
|
|
52
|
+
const jarPath = await Promise.race([
|
|
53
|
+
this.scanner.findJarForClass(className, projectPath),
|
|
54
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error('JAR package lookup timeout')), 10000))
|
|
55
|
+
]);
|
|
56
|
+
if (!jarPath) {
|
|
57
|
+
throw new Error(`JAR package for class ${className} not found, please run scan_dependencies first to build class index`);
|
|
58
|
+
}
|
|
59
|
+
console.error(`Found JAR package: ${jarPath}`);
|
|
60
|
+
// 3. Extract .class file from JAR package
|
|
61
|
+
const classFilePath = await this.extractClassFile(jarPath, className, projectPath);
|
|
62
|
+
// 4. Use CFR to decompile
|
|
63
|
+
const sourceCode = await this.decompileWithCfr(classFilePath);
|
|
64
|
+
// 5. Save to cache
|
|
65
|
+
if (useCache) {
|
|
66
|
+
await fs.ensureDir(path.dirname(cachePath));
|
|
67
|
+
await fs.outputFile(cachePath, sourceCode, 'utf-8');
|
|
68
|
+
console.error(`Decompilation result cached: ${cachePath}`);
|
|
69
|
+
}
|
|
70
|
+
// 6. Clean up temporary files (only when not using cache)
|
|
71
|
+
if (!useCache) {
|
|
72
|
+
try {
|
|
73
|
+
await fs.remove(classFilePath);
|
|
74
|
+
console.error(`Cleaning up temporary file: ${classFilePath}`);
|
|
75
|
+
}
|
|
76
|
+
catch (cleanupError) {
|
|
77
|
+
console.warn(`Failed to clean up temporary file: ${cleanupError}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return sourceCode;
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
console.error(`Failed to decompile class ${className}:`, error);
|
|
84
|
+
throw error; // Re-throw error for upper layer handling
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Get cache file path
|
|
89
|
+
*/
|
|
90
|
+
getCachePath(className, projectPath) {
|
|
91
|
+
const packagePath = className.substring(0, className.lastIndexOf('.'));
|
|
92
|
+
const simpleName = className.substring(className.lastIndexOf('.') + 1);
|
|
93
|
+
const cacheDir = getDecompileCacheDir(projectPath);
|
|
94
|
+
const packageDir = path.join(cacheDir, packagePath.replace(/\./g, path.sep));
|
|
95
|
+
return path.join(packageDir, `${simpleName}.java`);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Extract specified .class file from JAR package
|
|
99
|
+
*/
|
|
100
|
+
async extractClassFile(jarPath, className, projectPath) {
|
|
101
|
+
const classFileName = className.replace(/\./g, '/') + '.class';
|
|
102
|
+
const tempDir = getClassTempDir(projectPath);
|
|
103
|
+
// Create directory structure by full package name path
|
|
104
|
+
const packagePath = className.substring(0, className.lastIndexOf('.'));
|
|
105
|
+
const packageDir = path.join(tempDir, packagePath.replace(/\./g, path.sep));
|
|
106
|
+
const classFilePath = path.join(packageDir, `${className.substring(className.lastIndexOf('.') + 1)}.class`);
|
|
107
|
+
await fs.ensureDir(packageDir);
|
|
108
|
+
console.error(`Extracting class file from JAR package: ${jarPath} -> ${classFileName}`);
|
|
109
|
+
return new Promise((resolve, reject) => {
|
|
110
|
+
yauzl.open(jarPath, { lazyEntries: true }, (err, zipfile) => {
|
|
111
|
+
if (err) {
|
|
112
|
+
reject(new Error(`Unable to open JAR package ${jarPath}: ${err.message}`));
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
let found = false;
|
|
116
|
+
zipfile.readEntry();
|
|
117
|
+
const closeAndReject = (err) => {
|
|
118
|
+
try {
|
|
119
|
+
zipfile.close();
|
|
120
|
+
}
|
|
121
|
+
catch (e) {
|
|
122
|
+
// ignore close errors
|
|
123
|
+
}
|
|
124
|
+
reject(err);
|
|
125
|
+
};
|
|
126
|
+
zipfile.on('entry', (entry) => {
|
|
127
|
+
if (entry.fileName === classFileName) {
|
|
128
|
+
found = true;
|
|
129
|
+
zipfile.openReadStream(entry, (err, readStream) => {
|
|
130
|
+
if (err) {
|
|
131
|
+
closeAndReject(new Error(`Unable to read class file ${classFileName} from JAR package: ${err.message}`));
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
const writeStream = createWriteStream(classFilePath);
|
|
135
|
+
readStream.pipe(writeStream);
|
|
136
|
+
writeStream.on('close', () => {
|
|
137
|
+
console.error(`Class file extracted successfully: ${classFilePath}`);
|
|
138
|
+
try {
|
|
139
|
+
zipfile.close();
|
|
140
|
+
}
|
|
141
|
+
catch (e) {
|
|
142
|
+
// ignore close errors
|
|
143
|
+
}
|
|
144
|
+
resolve(classFilePath);
|
|
145
|
+
});
|
|
146
|
+
writeStream.on('error', (err) => {
|
|
147
|
+
closeAndReject(new Error(`Failed to write temporary file: ${err.message}`));
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
zipfile.readEntry();
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
zipfile.on('end', () => {
|
|
156
|
+
if (!found) {
|
|
157
|
+
closeAndReject(new Error(`Class file ${classFileName} not found in JAR package ${jarPath}`));
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
zipfile.on('error', (err) => {
|
|
161
|
+
closeAndReject(new Error(`Failed to read JAR package: ${err.message}`));
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Use CFR to decompile .class file
|
|
168
|
+
*/
|
|
169
|
+
async decompileWithCfr(classFilePath) {
|
|
170
|
+
if (!this.cfrPath) {
|
|
171
|
+
throw new Error('CFR decompiler tool not found, please ensure CFR jar is in classpath');
|
|
172
|
+
}
|
|
173
|
+
try {
|
|
174
|
+
const javaCmd = this.getJavaCommand();
|
|
175
|
+
console.error(`Executing CFR decompilation: ${javaCmd} -jar "${this.cfrPath}" "${classFilePath}"`);
|
|
176
|
+
console.error(`Running: ${javaCmd} -jar "${this.cfrPath}" "${classFilePath}"`);
|
|
177
|
+
const { stdout, stderr } = await execFileAsync(javaCmd, ['-jar', this.cfrPath, classFilePath, '--silent', 'true'], {
|
|
178
|
+
timeout: 30000
|
|
179
|
+
});
|
|
180
|
+
if (stderr && stderr.trim()) {
|
|
181
|
+
console.warn('CFR warning:', stderr);
|
|
182
|
+
}
|
|
183
|
+
if (!stdout || stdout.trim() === '') {
|
|
184
|
+
throw new Error('CFR decompilation returned empty result, possibly due to corrupted class file or incompatible CFR version');
|
|
185
|
+
}
|
|
186
|
+
return stdout;
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
console.error('CFR decompilation execution failed:', error);
|
|
190
|
+
if (error instanceof Error && error.message.includes('timeout')) {
|
|
191
|
+
throw new Error('CFR decompilation timeout, please check Java environment and CFR tool');
|
|
192
|
+
}
|
|
193
|
+
throw new Error(`CFR decompilation failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Get package root directory (works with npx, npm install -g, and local dev)
|
|
198
|
+
*/
|
|
199
|
+
getPackageRoot() {
|
|
200
|
+
// When running from compiled dist/decompiler/DecompilerService.js
|
|
201
|
+
// __dirname = dist/decompiler/, so we go up 3 levels to get package root
|
|
202
|
+
const distDir = path.dirname(__dirname); // dist/
|
|
203
|
+
return path.dirname(distDir); // package root
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Find CFR jar package path
|
|
207
|
+
*/
|
|
208
|
+
async findCfrJar() {
|
|
209
|
+
// 1. Check CFR_PATH env var first (allows custom CFR version)
|
|
210
|
+
if (process.env.CFR_PATH && await fs.pathExists(process.env.CFR_PATH)) {
|
|
211
|
+
return process.env.CFR_PATH;
|
|
212
|
+
}
|
|
213
|
+
// 2. Try bundled CFR at package root lib/ (works with npx and npm install)
|
|
214
|
+
const bundledLibPath = path.join(this.getPackageRoot(), 'lib');
|
|
215
|
+
if (await fs.pathExists(bundledLibPath)) {
|
|
216
|
+
const files = await readdir(bundledLibPath);
|
|
217
|
+
const cfrJar = files.find(file => /^cfr-.*\.jar$/.test(file));
|
|
218
|
+
if (cfrJar) {
|
|
219
|
+
return path.join(bundledLibPath, cfrJar);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
// 3. Try current working directory lib/ (for local development)
|
|
223
|
+
const cwdLibPath = path.join(process.cwd(), 'lib');
|
|
224
|
+
if (await fs.pathExists(cwdLibPath)) {
|
|
225
|
+
const files = await readdir(cwdLibPath);
|
|
226
|
+
const cfrJar = files.find(file => /^cfr-.*\.jar$/.test(file));
|
|
227
|
+
if (cfrJar) {
|
|
228
|
+
return path.join(cwdLibPath, cfrJar);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
// 4. Try CLASSPATH (legacy support)
|
|
232
|
+
const classpath = process.env.CLASSPATH || '';
|
|
233
|
+
const classpathEntries = classpath.split(path.delimiter);
|
|
234
|
+
for (const entry of classpathEntries) {
|
|
235
|
+
if (entry.includes('cfr') && entry.endsWith('.jar') && await fs.pathExists(entry)) {
|
|
236
|
+
return entry;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return '';
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Batch decompile multiple classes
|
|
243
|
+
*/
|
|
244
|
+
async decompileClasses(classNames, projectPath, useCache = true, cfrPath) {
|
|
245
|
+
const results = new Map();
|
|
246
|
+
for (const className of classNames) {
|
|
247
|
+
try {
|
|
248
|
+
const sourceCode = await this.decompileClass(className, projectPath, useCache, cfrPath);
|
|
249
|
+
results.set(className, sourceCode);
|
|
250
|
+
}
|
|
251
|
+
catch (error) {
|
|
252
|
+
console.warn(`Failed to decompile class ${className}: ${error}`);
|
|
253
|
+
results.set(className, `// Decompilation failed: ${error}`);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return results;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Get Java command path
|
|
260
|
+
*/
|
|
261
|
+
getJavaCommand() {
|
|
262
|
+
const javaHome = process.env.JAVA_HOME;
|
|
263
|
+
if (javaHome) {
|
|
264
|
+
const javaCmd = process.platform === 'win32' ? 'java.exe' : 'java';
|
|
265
|
+
return path.join(javaHome, 'bin', javaCmd);
|
|
266
|
+
}
|
|
267
|
+
return 'java'; // Fallback to java in PATH
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
//# sourceMappingURL=DecompilerService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DecompilerService.js","sourceRoot":"","sources":["../../src/decompiler/DecompilerService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,IAAI,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE/E,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAE3C,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAE1C,MAAM,OAAO,iBAAiB;IAClB,OAAO,CAAoB;IAC3B,OAAO,CAAS;IAExB;QACI,IAAI,CAAC,OAAO,GAAG,IAAI,iBAAiB,EAAE,CAAC;QACvC,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;IACtB,CAAC;IAEO,KAAK,CAAC,iBAAiB;QAC3B,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAChB,IAAI,CAAC,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;YACvC,IAAI,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O,OAAO,CAAC;IACnB,CAAC;IAGD;;OAEG;IACK,cAAc;QAClB,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;QACvC,IAAI,QAAQ,EAAE,CAAC;YACX,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC;YACnE,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAC/C,CAAC;QACD,OAAO,MAAM,CAAC,CAAC,2BAA2B;IAC9C,CAAC;CACJ"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
export declare class JavaClassAnalyzerMCPServer {
|
|
3
|
+
private server;
|
|
4
|
+
private analyzer;
|
|
5
|
+
private scanner;
|
|
6
|
+
private decompiler;
|
|
7
|
+
constructor();
|
|
8
|
+
private setupHandlers;
|
|
9
|
+
private handleScanDependencies;
|
|
10
|
+
private handleDecompileClass;
|
|
11
|
+
private handleAnalyzeClass;
|
|
12
|
+
/**
|
|
13
|
+
* Ensure index file exists, create automatically if not
|
|
14
|
+
*/
|
|
15
|
+
private ensureIndexExists;
|
|
16
|
+
run(): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAaA,qBAAa,0BAA0B;IACnC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,QAAQ,CAAoB;IACpC,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,UAAU,CAAoB;;IAuBtC,OAAO,CAAC,aAAa;YAqHP,sBAAsB;YAqBtB,oBAAoB;YAkDpB,kBAAkB;IA+ChC;;OAEG;YACW,iBAAiB;IAmBzB,GAAG;CAWZ"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
+
import { JavaClassAnalyzer } from './analyzer/JavaClassAnalyzer.js';
|
|
6
|
+
import { DependencyScanner } from './scanner/DependencyScanner.js';
|
|
7
|
+
import { DecompilerService } from './decompiler/DecompilerService.js';
|
|
8
|
+
import { getClassIndexPath } from './utils/cachePaths.js';
|
|
9
|
+
export class JavaClassAnalyzerMCPServer {
|
|
10
|
+
server;
|
|
11
|
+
analyzer;
|
|
12
|
+
scanner;
|
|
13
|
+
decompiler;
|
|
14
|
+
constructor() {
|
|
15
|
+
this.server = new Server({
|
|
16
|
+
name: 'java-class-analyzer',
|
|
17
|
+
version: '1.0.0',
|
|
18
|
+
}, {
|
|
19
|
+
capabilities: {
|
|
20
|
+
tools: {},
|
|
21
|
+
logging: {},
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
this.analyzer = new JavaClassAnalyzer();
|
|
25
|
+
this.scanner = new DependencyScanner();
|
|
26
|
+
this.decompiler = new DecompilerService();
|
|
27
|
+
this.setupHandlers();
|
|
28
|
+
}
|
|
29
|
+
setupHandlers() {
|
|
30
|
+
this.server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
31
|
+
return {
|
|
32
|
+
tools: [
|
|
33
|
+
{
|
|
34
|
+
name: 'scan_dependencies',
|
|
35
|
+
description: 'Scan all dependencies of a Maven project and build mapping index from class names to JAR packages',
|
|
36
|
+
inputSchema: {
|
|
37
|
+
type: 'object',
|
|
38
|
+
properties: {
|
|
39
|
+
projectPath: {
|
|
40
|
+
type: 'string',
|
|
41
|
+
description: 'Maven project root directory path',
|
|
42
|
+
},
|
|
43
|
+
forceRefresh: {
|
|
44
|
+
type: 'boolean',
|
|
45
|
+
description: 'Whether to force refresh index',
|
|
46
|
+
default: false,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
required: ['projectPath'],
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: 'decompile_class',
|
|
54
|
+
description: 'Decompile specified Java class file and return Java source code',
|
|
55
|
+
inputSchema: {
|
|
56
|
+
type: 'object',
|
|
57
|
+
properties: {
|
|
58
|
+
className: {
|
|
59
|
+
type: 'string',
|
|
60
|
+
description: 'Fully qualified name of the Java class to decompile, e.g., com.example.QueryBizOrderDO',
|
|
61
|
+
},
|
|
62
|
+
projectPath: {
|
|
63
|
+
type: 'string',
|
|
64
|
+
description: 'Maven project root directory path',
|
|
65
|
+
},
|
|
66
|
+
useCache: {
|
|
67
|
+
type: 'boolean',
|
|
68
|
+
description: 'Whether to use cache, default true',
|
|
69
|
+
default: true,
|
|
70
|
+
},
|
|
71
|
+
cfrPath: {
|
|
72
|
+
type: 'string',
|
|
73
|
+
description: 'JAR package path of CFR decompilation tool, optional',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
required: ['className', 'projectPath'],
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: 'analyze_class',
|
|
81
|
+
description: 'Analyze structure, methods, fields and other information of a Java class',
|
|
82
|
+
inputSchema: {
|
|
83
|
+
type: 'object',
|
|
84
|
+
properties: {
|
|
85
|
+
className: {
|
|
86
|
+
type: 'string',
|
|
87
|
+
description: 'Fully qualified name of the Java class to analyze',
|
|
88
|
+
},
|
|
89
|
+
projectPath: {
|
|
90
|
+
type: 'string',
|
|
91
|
+
description: 'Maven project root directory path',
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
required: ['className', 'projectPath'],
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
};
|
|
99
|
+
});
|
|
100
|
+
this.server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
|
|
101
|
+
const { name, arguments: args } = request.params;
|
|
102
|
+
const sendProgress = async (message, progress, total) => {
|
|
103
|
+
if (extra._meta?.progressToken !== undefined) {
|
|
104
|
+
await extra.sendNotification({
|
|
105
|
+
method: 'notifications/progress',
|
|
106
|
+
params: {
|
|
107
|
+
progressToken: extra._meta.progressToken,
|
|
108
|
+
progress,
|
|
109
|
+
total,
|
|
110
|
+
message
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
console.error(`[${name}] ${message}`);
|
|
115
|
+
};
|
|
116
|
+
try {
|
|
117
|
+
await sendProgress(`Starting tool: ${name}`);
|
|
118
|
+
switch (name) {
|
|
119
|
+
case 'scan_dependencies':
|
|
120
|
+
return await this.handleScanDependencies(args, sendProgress);
|
|
121
|
+
case 'decompile_class':
|
|
122
|
+
return await this.handleDecompileClass(args, sendProgress);
|
|
123
|
+
case 'analyze_class':
|
|
124
|
+
return await this.handleAnalyzeClass(args, sendProgress);
|
|
125
|
+
default:
|
|
126
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
131
|
+
console.error(`Tool call exception [${name}]:`, error);
|
|
132
|
+
await sendProgress(`Failed: ${errorMessage}`);
|
|
133
|
+
return {
|
|
134
|
+
content: [
|
|
135
|
+
{
|
|
136
|
+
type: 'text',
|
|
137
|
+
text: `Tool call failed: ${errorMessage}\n\nSuggestions:\n1. Check if input parameters are correct\n2. Ensure necessary preparations have been completed\n3. Check server logs for detailed information`,
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
async handleScanDependencies(args, sendProgress) {
|
|
145
|
+
const { projectPath, forceRefresh = false } = args;
|
|
146
|
+
await sendProgress?.(`Scanning project: ${projectPath}`, 0, 100);
|
|
147
|
+
const result = await this.scanner.scanProject(projectPath, forceRefresh, sendProgress);
|
|
148
|
+
await sendProgress?.(`Scan complete: ${result.jarCount} JARs, ${result.classCount} classes`, 100, 100);
|
|
149
|
+
return {
|
|
150
|
+
content: [
|
|
151
|
+
{
|
|
152
|
+
type: 'text',
|
|
153
|
+
text: `Dependency scanning complete!\n\n` +
|
|
154
|
+
`Scanned JAR count: ${result.jarCount}\n` +
|
|
155
|
+
`Indexed class count: ${result.classCount}\n` +
|
|
156
|
+
`Index file path: ${result.indexPath}\n\n` +
|
|
157
|
+
`Sample index entries:\n${result.sampleEntries.slice(0, 5).join('\n')}`,
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
async handleDecompileClass(args, sendProgress) {
|
|
163
|
+
const { className, projectPath, useCache = true, cfrPath } = args;
|
|
164
|
+
try {
|
|
165
|
+
await sendProgress?.(`Starting decompilation of class: ${className}`, 0, 100);
|
|
166
|
+
console.error(`Starting decompilation of class: ${className}, project path: ${projectPath}, use cache: ${useCache}, CFR path: ${cfrPath || 'auto-detect'}`);
|
|
167
|
+
// Check if index exists, create if not
|
|
168
|
+
await sendProgress?.('Checking class index...', 10, 100);
|
|
169
|
+
await this.ensureIndexExists(projectPath, sendProgress);
|
|
170
|
+
await sendProgress?.('Decompiling class...', 50, 100);
|
|
171
|
+
const sourceCode = await this.decompiler.decompileClass(className, projectPath, useCache, cfrPath);
|
|
172
|
+
await sendProgress?.('Decompilation complete', 100, 100);
|
|
173
|
+
if (!sourceCode || sourceCode.trim() === '') {
|
|
174
|
+
return {
|
|
175
|
+
content: [
|
|
176
|
+
{
|
|
177
|
+
type: 'text',
|
|
178
|
+
text: `Warning: Decompilation result for class ${className} is empty, possibly due to CFR tool issues or corrupted class file`,
|
|
179
|
+
},
|
|
180
|
+
],
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
return {
|
|
184
|
+
content: [
|
|
185
|
+
{
|
|
186
|
+
type: 'text',
|
|
187
|
+
text: `Decompiled source code for class ${className}:\n\n\`\`\`java\n${sourceCode}\n\`\`\``,
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
194
|
+
console.error(`Failed to decompile class ${className}:`, error);
|
|
195
|
+
await sendProgress?.(`Decompilation failed: ${errorMessage}`);
|
|
196
|
+
return {
|
|
197
|
+
content: [
|
|
198
|
+
{
|
|
199
|
+
type: 'text',
|
|
200
|
+
text: `Decompilation failed: ${errorMessage}\n\nSuggestions:\n1. Ensure scan_dependencies has been run to build class index\n2. Check if CFR tool is properly installed\n3. Verify class name is correct`,
|
|
201
|
+
},
|
|
202
|
+
],
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
async handleAnalyzeClass(args, sendProgress) {
|
|
207
|
+
const { className, projectPath } = args;
|
|
208
|
+
await sendProgress?.(`Analyzing class: ${className}`, 0, 100);
|
|
209
|
+
// Check if index exists, create if not
|
|
210
|
+
await sendProgress?.('Checking class index...', 20, 100);
|
|
211
|
+
await this.ensureIndexExists(projectPath, sendProgress);
|
|
212
|
+
await sendProgress?.('Running javap analysis...', 50, 100);
|
|
213
|
+
const analysis = await this.analyzer.analyzeClass(className, projectPath);
|
|
214
|
+
await sendProgress?.('Analysis complete', 100, 100);
|
|
215
|
+
let result = `Analysis result for class ${className}:\n\n`;
|
|
216
|
+
result += `Package name: ${analysis.packageName}\n`;
|
|
217
|
+
result += `Class name: ${analysis.className}\n`;
|
|
218
|
+
result += `Modifiers: ${analysis.modifiers.join(' ')}\n`;
|
|
219
|
+
result += `Super class: ${analysis.superClass || 'None'}\n`;
|
|
220
|
+
result += `Implemented interfaces: ${analysis.interfaces.join(', ') || 'None'}\n\n`;
|
|
221
|
+
if (analysis.fields.length > 0) {
|
|
222
|
+
result += `Fields (${analysis.fields.length}):\n`;
|
|
223
|
+
analysis.fields.forEach(field => {
|
|
224
|
+
result += ` - ${field.modifiers.join(' ')} ${field.type} ${field.name}\n`;
|
|
225
|
+
});
|
|
226
|
+
result += '\n';
|
|
227
|
+
}
|
|
228
|
+
if (analysis.methods.length > 0) {
|
|
229
|
+
result += `Methods (${analysis.methods.length}):\n`;
|
|
230
|
+
analysis.methods.forEach(method => {
|
|
231
|
+
result += ` - ${method.modifiers.join(' ')} ${method.returnType} ${method.name}(${method.parameters.join(', ')})\n`;
|
|
232
|
+
});
|
|
233
|
+
result += '\n';
|
|
234
|
+
}
|
|
235
|
+
return {
|
|
236
|
+
content: [
|
|
237
|
+
{
|
|
238
|
+
type: 'text',
|
|
239
|
+
text: result,
|
|
240
|
+
},
|
|
241
|
+
],
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Ensure index file exists, create automatically if not
|
|
246
|
+
*/
|
|
247
|
+
async ensureIndexExists(projectPath, sendProgress) {
|
|
248
|
+
const fs = await import('fs-extra');
|
|
249
|
+
const indexPath = getClassIndexPath(projectPath);
|
|
250
|
+
if (!(await fs.pathExists(indexPath))) {
|
|
251
|
+
console.error('Index file does not exist, creating automatically...');
|
|
252
|
+
await sendProgress?.('Index file does not exist, creating automatically...');
|
|
253
|
+
try {
|
|
254
|
+
await this.scanner.scanProject(projectPath, false, sendProgress);
|
|
255
|
+
console.error('Index file creation complete');
|
|
256
|
+
await sendProgress?.('Index file creation complete');
|
|
257
|
+
}
|
|
258
|
+
catch (error) {
|
|
259
|
+
console.error('Failed to create index automatically:', error);
|
|
260
|
+
throw new Error(`Unable to create class index file: ${error instanceof Error ? error.message : String(error)}`);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
async run() {
|
|
265
|
+
const transport = new StdioServerTransport();
|
|
266
|
+
await this.server.connect(transport);
|
|
267
|
+
const env = process.env.NODE_ENV || 'development';
|
|
268
|
+
if (env === 'development') {
|
|
269
|
+
console.error('Java Class Analyzer MCP Server running on stdio (DEBUG MODE)');
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
console.error('Java Class Analyzer MCP Server running on stdio');
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
const mcpServer = new JavaClassAnalyzerMCPServer();
|
|
277
|
+
// Add global exception handling to prevent server crashes
|
|
278
|
+
process.on('uncaughtException', (error) => {
|
|
279
|
+
console.error('Uncaught exception:', error);
|
|
280
|
+
// Don't exit process, continue running
|
|
281
|
+
});
|
|
282
|
+
process.on('unhandledRejection', (reason, promise) => {
|
|
283
|
+
console.error('Unhandled Promise rejection:', reason);
|
|
284
|
+
// Don't exit process, continue running
|
|
285
|
+
});
|
|
286
|
+
mcpServer.run().catch((error) => {
|
|
287
|
+
console.error('Server startup failed:', error);
|
|
288
|
+
process.exit(1);
|
|
289
|
+
});
|
|
290
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACH,qBAAqB,EACrB,sBAAsB,GACzB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,MAAM,OAAO,0BAA0B;IAC3B,MAAM,CAAS;IACf,QAAQ,CAAoB;IAC5B,OAAO,CAAoB;IAC3B,UAAU,CAAoB;IAEtC;QACI,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,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