arthas-mcp-proxy
Aggregates multiple Arthas agents into a single MCP server, allowing Claude to diagnose any number of Java processes with just one MCP configuration.
README
arthas-mcp-proxy
Arthas 多 Agent 聚合代理 MCP。Claude 端只配 1 个 MCP,即可诊断任意多个已启动 arthas-agent 的 Java 进程。
原理
Claude (Code / Desktop) ──stdio──> server.py ──┬─ /mcp 转发(30 个官方工具)──> 各 arthas agent
│读 └─ /api 执行(list_agents/help/execute)
├─ agents.yaml (agent 清单 + tags)
└─ arthas_tools.json(官方 30 工具 schema,固化)
对外暴露 33 个工具,每个用 target 参数选目标 agent。新增服务只改 agents.yaml,Claude 端零改动。
工具
代理自有(走 /api):
list_agents(tag?)— 列出所有可用 target,可按 tag 筛选help(target, command?)— 查 arthas 命令的权威帮助/语法execute(target, command, timeout_ms?)— 兜底执行任意命令(危险命令走灰名单确认 / 黑名单拦截)
30 个官方工具(镜像 arthas 原生 /mcp,schema 与官方 100% 一致,走 /mcp 转发):
jvm dashboard memory thread sysprop sysenv perfcounter mbean vmoption vmtool options
sc sm jad getstatic classloader dump redefine retransform
trace watch stack monitor tt profiler
ognl mc heapdump viewfile stop
每个官方工具多一个
target参数,其余参数与官方完全相同。调用如thread(target="xxx服务", topN=3)。
工作机制
- 官方工具定义固化在
arthas_tools.json(启动不联网拉取)。MirrorTool子类读取它批量注册,运行时取出target→ 连该 agent 的/mcp→ 转调同名工具 → 原样返回。 - 因此工具的参数/描述始终与官方一致,且 arthas 升级后只需重新 dump 一次。
arthas 升级后刷新工具定义
.venv/bin/python -c "
import asyncio, json
from fastmcp import Client
from fastmcp.client.transports import StreamableHttpTransport
tp = StreamableHttpTransport('http://xx.xx.xx.xx:8563/mcp', headers={'Authorization':'Bearer arthas'})
async def main():
async with Client(tp) as c:
tools = await c.list_tools()
json.dump([{'name':t.name,'description':t.description,'inputSchema':t.inputSchema} for t in tools],
open('arthas_tools.json','w'), ensure_ascii=False, indent=2)
print('refreshed', len(tools))
asyncio.run(main())
"
配置(agents.yaml)
agents:
- name: "xxx服务"
url: http://xx.xx.xx.xx:8563
tags: ["测试", "IC", "biz"] # 打标签,便于 list_agents(tag=...) 批量定位
defaults:
username: arthas # 公共账号,所有 agent 共用(个别不同可在该 agent 下覆盖)
password: arthas
auth: basic # basic | bearer
exec_timeout_ms: 10000
confirm_commands: [stop, redefine, retransform, mc, reset] # 灰名单:执行前需用户确认
blocked_commands: [] # 黑名单:完全禁用、不暴露
配置路径默认本目录 agents.yaml,也可用环境变量 ARTHAS_AGENTS_CONFIG 指定。
安全控制:灰名单 / 黑名单
危险操作分两级,对 30 个官方工具和 execute 两条路径统一生效:
- 灰名单
confirm_commands:工具正常暴露,但带一个confirm参数。不带confirm=true调用会被拦下并返回警告,需在用户明确同意后带confirm=true重新调用才执行。默认含stop/redefine/retransform/mc/reset。 - 黑名单
blocked_commands:完全禁用——mirror 工具不暴露、execute 直接拒绝。默认空。
说明:原计划用 MCP elicitation 做弹窗确认,但实测 Claude 客户端在自动流程下会自动 decline、不弹窗,故改用更可靠的
confirm参数二次确认。改agents.yaml这两项即可调整,重启 Claude 生效。
安装
cd /path/to/arthas-mcp-proxy
uv venv && uv pip install fastmcp httpx pyyaml
接入 Claude
Claude Code(local scope):
claude mcp add arthas-proxy --scope local -- \
/path/to/arthas-mcp-proxy/.venv/bin/python /path/to/arthas-mcp-proxy/server.py
Claude Desktop(claude_desktop_config.json):
"arthas-proxy": {
"command": "/path/to/arthas-mcp-proxy/.venv/bin/python",
"args": ["/path/to/arthas-mcp-proxy/server.py"]
}
改动 server.py / agents.yaml 后需重启 Claude 生效。
本地冒烟测试
.venv/bin/python -c "
import asyncio, server
from fastmcp import Client
async def main():
async with Client(server.mcp) as c:
print('工具数:', len(await c.list_tools()))
r = await c.call_tool('jvm', {'target':'xxx服务'})
print(r.content[0].text[:120])
asyncio.run(main())
"
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。