arthas-mcp AGENTS.md

arthas-mcp AGENTS.md is an instructions file for Codex, OpenCode from x0c/arthas-mcp. It costs 960 tokens per session, scanned B, original, MIT.

Project instructions for maintaining arthas-mcp, a Node service that exposes Alibaba Arthas Java diagnostics through MCP in standard-input or HTTP mode.

In plain words
What is it for?
Use them when changing the service, its configuration, JVM discovery, MCP commands, logging, or regression tests for clean shutdown.
Why use it?
They document repository rules and safeguards, including cross-platform JVM discovery and preventing abandoned processes from consuming resources.

Instructions file for CodexOpenCode

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/x0c/arthas-mcp/agents-md
Clone the repo
git clone --depth 1 https://github.com/x0c/arthas-mcp

Made for: Codex, OpenCode.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for arthas-mcp AGENTS.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/x0c/arthas-mcp/agents-md.svg)](https://agentmods.dev/instructions/x0c/arthas-mcp/agents-md)
Your own site
<a href="https://agentmods.dev/instructions/x0c/arthas-mcp/agents-md"><img src="https://agentmods.dev/badge/instructions/x0c/arthas-mcp/agents-md.svg" alt="Measured on agentmods" height="20"></a>
Per session 960 This file is loaded in full into every session.
When invoked 960 The same file — it is already loaded in full.
Security scan B 2 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00960 $0.00960
Opus 5 $0.00480 $0.00480
Sonnet 5 $0.00192 $0.00192
Haiku 4.5 $0.00096 $0.00096

Measured 3d ago against content hash 5c3bbfaec873, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade B, and why

arthas-mcp AGENTS.md scanned grade B with 2 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Sends data to an external URLmediumData exfiltration

A POST to an outside endpoint may be telemetry or may be exfiltration; either way the mod talks to somewhere, and you should know where.

涉及发现/attach 逻辑的改动,再起一个带包名的长驻 JVM(如 `com.example.demo.SleeperApp`)实跑一轮:日志应出现「发现新 Java 服务」与「就绪 (port=…)」,`curl -X POST http://127.0.0.1:<port>/api -d '{"action":"exec","command":"version"}'` 应返回 `SUCCEEDED`。

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

涉及发现/attach 逻辑的改动,再起一个带包名的长驻 JVM(如 `com.example.demo.SleeperApp`)实跑一轮:日志应出现「发现新 Java 服务」与「就绪 (port=…)」,`curl -X POST http://127.0.0.1:<port>/api -d '{"action":"exec","command":"version"}'` 应返回 `SUCCEEDED`。
AGENTS.md · 41 lines

What it actually says

arthas-mcp

把阿里 Arthas Java 诊断能力通过 MCP 暴露给 AI 助手的 Node 服务(stdio / HTTP 双模式)。公开镜像 github.com/x0c/arthas-mcp;与官方 arthas-mcp-server 的关系(独立实现,非封装)见 README.md

硬约束

  • stdio 模式必须监听 stdin 关闭并退出cli/arthas-mcp.mjsexitWhenClientGone,2026-08-25 修复)。删掉它会复发孤儿泄漏事故:客户端退出后扫描定时器吊住 Node 事件循环,进程永不退出,堆积吃内存,且每个实例持续空转探测。回归命令:npm test(stdin 关闭 5 秒内必须自行退出,挂死即回归)。
  • 扫描定时器默认 15 秒一轮 jps每次探测都是一个完整 JVM 启动(约 0.3-0.5s CPU)。调整间隔或新增轮询类逻辑前先算清楚成本;活跃 agent 会话多时实例数 = 会话数,成本按实例数翻倍。
  • 进程参数读取按平台分支(lib/discovery.mjs _getProcessArgs):Linux 读 /proc/<pid>/cmdline、macOS 用 ps、Windows 走 PowerShell CIM。改这段时三端语义要对齐:返回值都是完整命令行字符串;java 启动器判定用跨平台正则(容忍引号与反斜杠路径),不要退回 ^\S*java\s 这种 Unix 假设。

结构

路径 职责
cli/arthas-mcp.mjs 入口:参数解析、stdio/HTTP 双模式、优雅关闭
lib/discovery.mjs JVM 自动发现(jps + 黑名单)+ Arthas 生命周期与端口管理 + 服务名提取(跨平台正则)
lib/mcp.mjs MCP Server 工厂:list_agents / exec / async_exec / pull_results / interrupt_job
lib/config.mjs 配置解析(CLI > 环境变量 > config.json > 默认值)、arthas-boot 自动探测、stripPrefixes
lib/log.mjs 日志
scripts/smoke.mjs 孤儿泄漏回归测试(CI 与本地共用)

注意:入口目录刻意叫 cli/ 不叫 bin/(沿用本工作区约定),不要改回 bin/

本地配置与运行数据

~/.config/arthas-mcp/ 与仓库分离、已 gitignore:config.json(含 stripPrefixes 服务名前缀剥离)、aliases.json(服务名别名)、state.json(Agent 运行状态)。仓库默认值不含任何用户特定前缀。

改动验证

npm run check          # 全部 mjs 语法检查
node cli/arthas-mcp.mjs --version
npm test               # 孤儿回归:stdin 关闭 5 秒内自行退出

涉及发现/attach 逻辑的改动,再起一个带包名的长驻 JVM(如 com.example.demo.SleeperApp)实跑一轮:日志应出现「发现新 Java 服务」与「就绪 (port=…)」,curl -X POST http://127.0.0.1:<port>/api -d '{"action":"exec","command":"version"}' 应返回 SUCCEEDED

发布

公开远端 github.com/x0c/arthas-mcp(main 分支)。改动合并后同推两处远端;GitHub 侧更新 Description / Topics 用 gh repo edit。npm 包 arthas-mcp 名字已留空可发布(未登录时用 npx -y github:x0c/arthas-mcp 作为安装口径,README 中已注明缩短形式的过渡说明)。

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 41 lines · 960 tokens per session scan B 5c3bbfaec873

Subscribe to this mod's changes

arthas-mcp AGENTS.md is an instructions file published in the GitHub repository x0c/arthas-mcp (0 stars, last pushed 9d ago), licensed MIT. It adds 960 tokens to every session, about $0.0048 per session on Opus 5. A static security scan graded it B with 2 findings (sends data to an external url, makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other instructions, from other repositories