Get the FREE Ultimate OpenClaw Setup Guide →

cfr_mcp_server

这是一个基于 Python 的 MCP (Model Context Protocol) 服务器实现,封装了 `cfr.jar` 反编译功能,并支持 SSE (Server-Sent Events) 传输协议。

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio mr-xn-cfr_mcp_server python cfr_mcp_server.py \
  --env CFR_JAR_PATH="Path to cfr.jar (required by decompiler; e.g. /path/to/cfr.jar)"

How to use

This MCP server wraps the CFR decompiler to expose a decompilation tool via the MCP protocol over SSE. The server is implemented in Python using Starlette and the mcp SDK. It exposes a single tool named decompile that can decompile Java class or JAR files by invoking CFR under the hood. Clients connect to the server and request decompilation tasks; results are streamed back over Server-Sent Events, with the decompiled Java source returned as text content. The server is configured to run CFR with options that can be customized per request, including filtering by method name, ignoring exceptions, and hiding UTF-8 characters to improve readability.

How to install

Prerequisites:

  • Python 3.8+ installed on the host
  • CFR jar file available locally (cfr.jar)

Installation steps:

  1. Create a project directory and place the CFR MCP server script (cfr_mcp_server.py) in it.
  2. Install Python dependencies:
    • pip install mcp starlette uvicorn
  3. Ensure CFR_JAR_PATH points to your CFR jar file. If running via the provided config, set CFR_JAR_PATH to the absolute path of cfr.jar (e.g. /path/to/cfr.jar).
  4. Start the server:
    • Run: python cfr_mcp_server.py
  5. Open the MCP client and connect to http://<host>:8000/sse to establish the SSE stream and issue commands via the decompile tool.

Notes:

  • The server defaults to host 0.0.0.0 and port 8000; update HOST and PORT in the script if needed.

Additional notes

Tips and caveats:

  • CFR_JAR_PATH must be valid and point to a CFR jar compatible with the Java version installed on the host.
  • The decompile tool accepts file_path (absolute path to a .class or .jar), and optional parameters like method_name, ignore_exceptions, hide_utf, and a nested options object for CFR flags.
  • Timeouts: CMD_TIMEOUT_SECONDS controls how long CFR may run before the server times out. Adjust if working with very large or complex class files.
  • If you modify CFR options, ensure option keys are alphanumeric to pass validation in the tool interface.
  • The server returns CFR stdout and appends CFR stderr (if any) as comments in the output for easier debugging.
  • If you encounter SSL or CORS issues when connecting from a frontend, consider running behind a reverse proxy that handles TLS termination and adds appropriate headers.

Related MCP Servers

Sponsor this space

Reach thousands of developers