arthas-mcp

arthas-mcp

A Model Context Protocol server that connects AI agents to live Java processes via Alibaba Arthas, enabling real-time diagnostics, debugging, and performance analysis without code changes.

Category
访问服务器

README

arthas-mcp

npm license node

Let AI agents diagnose live JVMs. An MCP server that connects Claude (or any MCP client) to Alibaba Arthas, the battle-tested Java diagnostics tool — no restarts, no code changes, no redeploy.

中文文档

Ask your AI things like:

"Why is this service burning 200% CPU?" → it pulls the dashboard, finds the hottest threads, reads their stacks, and tells you which method is spinning.

"What arguments is OrderService.createOrder actually receiving in production?" → it sets up a watch, captures live invocations, and shows you real params and return values.

"Is the deployed class the version we think it is?" → it decompiles the loaded bytecode with jad and diffs it against your source.

How it works

Claude / MCP client  ──stdio──▶  arthas-mcp  ──HTTP──▶   Arthas (sync commands)
                                             ──WebSocket──▶ Arthas (streaming: watch/trace/monitor)
                                                              │
                                                              ▼
                                                        target JVM

Sync commands (dashboard, thread, jad, …) go over Arthas' HTTP API and return directly. Streaming commands (watch, trace, stack, monitor, tt -t) run as background jobs over WebSocket: output streams to a local log file, the tool waits up to awaitMs (default 5s) and returns results inline if the command finished — otherwise it hands back a job ID you can poll with arthas_read_log and cancel with arthas_stop_job. Long captures never block the conversation and never flood the context window (every response is capped, ~16k chars, configurable).

Quick start

1. Attach Arthas to your Java process

curl -O https://arthas.aliyun.com/arthas-boot.jar
java -jar arthas-boot.jar        # pick the target JVM from the list

That's it — Arthas serves its HTTP/WebSocket API on 127.0.0.1:8563 by default, which is exactly where arthas-mcp looks.

2. Add the MCP server

Claude Code

claude mcp add arthas -- npx -y arthas-mcp

Claude Desktop / Windsurf / Cursor (mcpServers config):

{
  "mcpServers": {
    "arthas": {
      "command": "npx",
      "args": ["-y", "arthas-mcp"],
      "env": {
        "ARTHAS_WS_URL": "ws://127.0.0.1:8563/ws"
      }
    }
  }
}

env is optional if Arthas runs on the default port.

3. Ask questions

Open your client and ask anything about the running JVM. The AI picks the right Arthas commands by itself.

Diagnosing a JVM in Kubernetes

Arthas must run inside the pod; then port-forward its API port:

# copy + attach arthas inside the pod (or bake it into your image)
kubectl exec -it <pod> -- sh -c 'curl -sO https://arthas.aliyun.com/arthas-boot.jar && java -jar arthas-boot.jar 1 --target-ip 0.0.0.0'

# expose the HTTP/WS API locally
kubectl port-forward <pod> 8563:8563

arthas-mcp on your laptop now talks to the JVM in the cluster.

Tools

Tool What it does
arthas_cookbook Start here for a symptom — proven step-by-step recipes (high CPU, memory leak, slow requests, worker-pool exhaustion, deadlocks, HikariCP, Spring, flame graphs). Human-readable copy: COOKBOOK.md
arthas_dashboard Threads / memory / GC / runtime overview
arthas_thread Thread list, top-N CPU, blocking threads, per-thread stacks
arthas_jvm, arthas_memory JVM info and detailed memory breakdown
arthas_sc, arthas_sm Search loaded classes / methods
arthas_jad Decompile a loaded class (see what's actually deployed)
arthas_watch Capture live method params / return values / exceptions ⏳
arthas_trace Call-path timing — find the slow hop ⏳
arthas_stack Who calls this method, live ⏳
arthas_monitor Invocation stats: QPS, RT, failure rate ⏳
arthas_tt Time Tunnel: record invocations, replay them later ⏳ (record mode)
arthas_ognl, arthas_getstatic Evaluate OGNL / read static fields
arthas_classloader Classloader hierarchy and leaks
arthas_profiler async-profiler: CPU / alloc / lock flame graphs
arthas_heapdump Dump the heap to a file
arthas_exec Escape hatch: run any raw Arthas command
arthas_async_jobs, arthas_read_log, arthas_stop_job Manage background jobs ⏳
arthas_set_config Repoint to another Arthas instance mid-session
arthas_version, arthas_help Meta

⏳ = streaming command, runs as a background job (see How it works).

Configuration

Env var / flag Default Meaning
ARTHAS_WS_URL ws://127.0.0.1:8563/ws Arthas WebSocket endpoint (HTTP API URL is derived)
ARTHAS_HTTP_URL derived Alternative: give the HTTP API URL instead
ARTHAS_MAX_OUTPUT 16000 Per-response character cap before truncation
--url <url> / positional URL — CLI override, takes precedence over env

Background-job logs live under $TMPDIR/arthas-mcp-logs/.

Security

Arthas is a full-power diagnostics tool: ognl evaluates arbitrary expressions inside the target JVM, and arthas_exec runs any Arthas command. Only point arthas-mcp at JVMs you are authorized to debug, keep the Arthas port bound to localhost (or reached via kubectl port-forward / SSH tunnel), and never expose 8563 to untrusted networks.

Development

git clone https://github.com/HeavenC/arthas-mcp.git
cd arthas-mcp
npm install
npm run build        # tsc → dist/
node dist/index.js   # speaks MCP on stdio

The whole server is a single file: src/index.ts.

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选