反编译指定目录下的所有 .class 和 .jar 文件(支持多线程) Args: directory_path: 要扫描的目录路径 output_dir: 输出目录,默认为目标目录下的 decompiled 文件夹 recursive: 是否递归扫描子目录,默认为 True save_to_file: 是否直接保存到文件系统(推荐),默认为 True show_progress: 是否显示详细进度信息,默认为 True max_workers: 最大并发线程数,默认为
(
directory_path: str,
output_dir: Optional[str] = None,
recursive: bool = True,
save_to_file: bool = True,
show_progress: bool = True,
max_workers: int = 4
)
| 335 | |
| 336 | @mcp.tool() |
| 337 | def decompile_directory( |
| 338 | directory_path: str, |
| 339 | output_dir: Optional[str] = None, |
| 340 | recursive: bool = True, |
| 341 | save_to_file: bool = True, |
| 342 | show_progress: bool = True, |
| 343 | max_workers: int = 4 |
| 344 | ) -> str: |
| 345 | """ |
| 346 | 反编译指定目录下的所有 .class 和 .jar 文件(支持多线程) |
| 347 | |
| 348 | Args: |
| 349 | directory_path: 要扫描的目录路径 |
| 350 | output_dir: 输出目录,默认为目标目录下的 decompiled 文件夹 |
| 351 | recursive: 是否递归扫描子目录,默认为 True |
| 352 | save_to_file: 是否直接保存到文件系统(推荐),默认为 True |
| 353 | show_progress: 是否显示详细进度信息,默认为 True |
| 354 | max_workers: 最大并发线程数,默认为 4(设为 1 则单线程处理) |
| 355 | |
| 356 | Returns: |
| 357 | 反编译结果信息 |
| 358 | """ |
| 359 | directory_path = os.path.abspath(directory_path) |
| 360 | |
| 361 | if not os.path.isdir(directory_path): |
| 362 | return f"错误:目录不存在 - {directory_path}" |
| 363 | |
| 364 | # 收集文件 |
| 365 | files = collect_files(directory_path) |
| 366 | |
| 367 | if not files: |
| 368 | return f"未在目录中找到 .class 或 .jar 文件: {directory_path}" |
| 369 | |
| 370 | # 确定输出目录 |
| 371 | if output_dir is None: |
| 372 | output_dir = os.path.join(directory_path, "decompiled") |
| 373 | |
| 374 | # 显示扫描结果 |
| 375 | scan_info = [ |
| 376 | f"� 扫描目录: {directory_path}", |
| 377 | f"🔍 找到 {len(files)} 个文件待反编译", |
| 378 | f"�📤 输出目录: {output_dir}", |
| 379 | f"🔧 并发线程: {max_workers}", |
| 380 | "" |
| 381 | ] |
| 382 | |
| 383 | result = decompile_files(files, output_dir, save_to_file, show_progress, max_workers) |
| 384 | |
| 385 | return "\n".join(scan_info) + result |
| 386 | |
| 387 | |
| 388 | @mcp.tool() |
nothing calls this directly
no test coverage detected