Arthas MCP Proxy
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Arthas MCP ProxySSH to 192.168.1.100, list Java processes and thread dump for PID 1234"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Arthas MCP Proxy
基于 MCP (Model Context Protocol) 的 Arthas 诊断代理服务器,支持在 Claude 对话中通过 SSH 动态连接到任意服务器进行 JVM 实时诊断。
功能特性
对话中动态连接:直接传入 SSH 地址、用户名、密码/密钥,实时连接目标服务器
多进程并行诊断:每个 JVM 进程独立 Arthas agent,切换 PID 无延迟
连接池自动复用:按
user@host:port缓存 SSH 连接,空闲 5 分钟自动回收Arthas 自动 attach:目标 PID 首次使用时自动后台 attach,后续复用
SSE 远程部署:支持 HTTP SSE 模式常驻部署,Claude 通过 URL 连接
离线构建支持:内网零网络环境下通过预下载 whl 包完成 Docker 构建
MCP 工具列表
工具名 | 说明 |
| 建立 SSH 连接,返回 session_id |
| 列出目标机 Java 进程(显示 Arthas 附加状态) |
| 获取线程栈(top N by CPU) |
| 查看内存/Dashboard 信息 |
| 监听方法入参和返回值 |
| 执行任意 Arthas 命令 |
| 断开 SSH 连接释放资源 |
并发诊断模型
重要:Arthas 每个 JVM 进程需要独立的 agent 实例
PID 1234 (web) <---> Arthas agent (port 3658)
PID 5678 (cpu) <---> Arthas agent (port 3660)
PID 9012 (memory) <---> Arthas agent (port 3661)首次使用:自动后台 attach,Arthas 自动分配端口(约 5 秒)
后续切换:直接连接已有 agent,零延迟
多进程支持:可同时保持多个 agent 运行,任意切换
资源占用:每个 agent 约 20-30MB 内存,建议同时 <= 10 个
释放:使用
exec_command执行stop或断开 SSH 时自动清理
技术栈
组件 | 选型 |
语言 | Python 3.11+ |
MCP SDK | mcp >= 1.6.0 |
SSH 库 | paramiko >= 3.4.0 |
HTTP 框架 | starlette + uvicorn |
快速开始
1. 在线构建(有网络环境)
docker build -t arthas-mcp-proxy .
# 或
docker-compose up -d2. 离线构建(内网无网络环境)
步骤 1:外网机器预下载依赖
bash download-packages.sh
# 完成后 packages/ 目录包含所有 .whl 文件步骤 2:打包传入内网
zip -r arthas-mcp-proxy.zip arthas-mcp-proxy/
# 通过 U 盘/SCP 传入内网服务器步骤 3:内网构建
cd arthas-mcp-proxy
docker build --build-arg PIP_SOURCE=offline -t arthas-mcp-proxy .
# 或
PIP_SOURCE=offline docker-compose up -d --build3. Claude 配置
SSE 模式(远程部署):
{
"mcpServers": {
"arthas": {
"type": "sse",
"url": "http://your-server-ip:8000/sse"
}
}
}stdio 模式(本地嵌入):
{
"mcpServers": {
"arthas": {
"command": "python",
"args": ["/path/to/main.py", "--transport", "stdio"]
}
}
}使用示例
在 Claude 对话中:
连接到 192.168.1.100,用户 root,密码 xxx,查看上面的 Java 进程。Claude 会自动调用 connect_ssh -> list_java_processes。
然后:
查看 PID 1234 的线程栈 top 10,然后查看 PID 5678 的内存情况。Claude 会自动在多个 PID 间切换诊断,每个 PID 首次使用时自动 attach,后续复用。
项目结构
arthas-mcp-proxy/
├── main.py # MCP Server 入口(SSE + stdio 双模式)
├── ssh_pool.py # SSH 连接池(动态连接 + session 复用)
├── arthas_client.py # Arthas 命令封装(多 PID 并行支持)
├── requirements.txt # Python 依赖
├── Dockerfile # 双模式构建 Dockerfile
├── docker-compose.yml # Docker Compose 配置
├── download-packages.sh # 外网预下载脚本
├── packages/ # 离线 whl 包目录
└── README.md # 本文档目标机要求
已安装 Arthas(
/opt/arthas/as.sh或自定义路径)SSH 可达,运行用户有权限 attach 目标 JVM
jps命令可用(JDK 自带)
License
MIT License
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/narcissux/arthas-mcp-proxy'
If you have feedback or need assistance with the MCP directory API, please join our Discord server