pm2-mcp: Instructions file for Codex

AGENTS.md

pm2-mcp AGENTS.md is an instructions file for Codex, OpenCode from TadMSTR/pm2-mcp. It costs 1,374 tokens per session, scanned A, original, MIT.

A local MCP server that wraps PM2, a process manager for running Node.js services. It provides structured access to service status, details, recent logs, and selected lifecycle controls.

In plain words
What is it for?
Useful for listing services, inspecting a service, reading recent standard-output or error logs, and starting, stopping, restarting, reloading, or deleting PM2-managed services.
Why use it?
It removes the need to manage PM2 services through separate command-line calls while the agent is working.

Instructions file for CodexOpenCode

Written for Codex and OpenCode: the file is AGENTS.md.

This is TadMSTR/pm2-mcp's own configuration. It tells Codex and OpenCode how to work on pm2-mcp itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything pm2-mcp configures →

Reuse

Borrowing it

Nothing to install: this file belongs to TadMSTR/pm2-mcp. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/TadMSTR/pm2-mcp/main/AGENTS.md
Clone the repo
git clone --depth 1 https://github.com/TadMSTR/pm2-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 pm2-mcp AGENTS.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/tadmstr/pm2-mcp/agents-md/github.svg)](https://agentmods.dev/instructions/tadmstr/pm2-mcp/agents-md)
Your own site
<a href="https://agentmods.dev/instructions/tadmstr/pm2-mcp/agents-md"><img src="https://agentmods.dev/badge/instructions/tadmstr/pm2-mcp/agents-md/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for pm2-mcp AGENTS.md

Your own site · 80×15
<a href="https://agentmods.dev/instructions/tadmstr/pm2-mcp/agents-md"><img src="https://agentmods.dev/badge/instructions/tadmstr/pm2-mcp/agents-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 1,374 This file is loaded in full into every session.
When invoked 1,374 The same file — it is already loaded in full.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.01374 $0.01374
Opus 5.5 $0.00550 $0.00550
Sonnet 5.5 $0.00275 $0.00275
Haiku 4.5 $0.00137 $0.00137

Measured 10d ago against content hash b3b38f909b69, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

pm2-mcp AGENTS.md scanned grade A with 1 finding 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 10d 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.

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

tests/test_pm2.py Unit tests; _run_pm2 / subprocess.run mocked
AGENTS.md · 64 lines

How it starts

The opening of the file, as written. The whole thing — 64 lines — stays where its author put it; the contents beside it link to each section on GitHub.

pm2-mcp

FastMCP server wrapping the PM2 CLI via subprocess. Provides structured read and limited write access to PM2 processes.

What it does

Exposes PM2 process management as MCP tools — list, inspect, control lifecycle, and fetch recent logs for any PM2-managed service on the host.

Tools

  • list_services(status_filter) — All PM2 processes as summary dicts (name, pm_id, status, pid, uptime_ms, restarts, cpu_pct, memory_mb, exec_mode). Optional filter: online, stopped, errored.
  • get_service(name) — Full detail for a named service.
  • get_logs(name, lines, include_errors) — Recent log lines. lines defaults to 50, clamped to 1..500.
  • restart_service(name) — Restart a service.
  • stop_service(name) — Stop a service. Does not deregister it.
  • start_service(name) — Resume a service already registered with PM2. Does not register a new process.
  • reload_service(name) — Graceful zero-downtime reload.
  • save() — Persist the current PM2 process list to disk.
  • flush_logs(name) — Clear a service's log files.
  • get_status() — Server metadata and PM2 health summary.

There is no delete_service, deliberately — recovering from a bad PM2 registration is an operator task. This list said otherwise until 2026-09-09, along with naming get_service_logs (the tool is get_logs) and describing reload as cluster-mode-only.

Structure

src/pm2_mcp/server.py   The FastMCP server: all tools, _run_pm2(), _find_service(),
                        _clean_env(), _resolve_bind(), _configure_logging(),
                        HostOriginGuard, main() (the `pm2-mcp` entry point)
tests/test_pm2.py       Unit tests; _run_pm2 / subprocess.run mocked
tests/test_host_origin.py   Host/Origin check against the real Starlette app
tests/test_integration_pm2.py   Write verbs against a real pm2 and a private daemon
uv.lock                 The dependency set CI tests, audits and the deploy installs

Key architecture decisions

  • _run_pm2(*args) — all PM2 invocations go through this helper, which raises RuntimeError on non-zero exit. Do not shell out to PM2 directly in tool handlers.
  • _find_service(name) — validates the service exists before any write operation (restart/stop/start/reload/flush) and before get_logs (since v0.5.0: pm2 logs takes ids, namespaces, all and options in the same position). Returns structured data from pm2 jlist. This is an allowlist: the name must already be a registered PM2 app.
  • _clean_env() — the trust boundary. Strips PM2's IPC variables and anything matching the CLAUDE prefix from the environment handed to the pm2 child. pm2 start/restart --update-env copy the caller's whole environment into the target app and pm2 save writes it to disk, so a regression here persists credentials silently (vikunja#767). Changes to this function or _run_pm2 must pass scripts/mutation-gate.sh.
  • _is_loopback(host) / _resolve_bind(argv, env) — the network trust boundary (vikunja#770). _resolve_bind resolves the bind with precedence argv > env > 127.0.0.1:8486, per field, and refuses any non-loopback result by exiting non-zero. _is_loopback is in the mutation gate's function set; _resolve_bind deliberately is not, and the script says why. Do not add an override flag — the refusal is the mitigation that docs/threat-model.md §1 leans on, and an escape hatch removes it.
  • _configure_logging() — must stay a function called from main(), never module-level or import-time code. pyproject.toml sets fail_under = 100 and excludes the __main__ block from coverage, so startup logic written there is untestable, invisible to coverage, and unreachable from a regression test. That is exactly how vikunja#772 shipped: the shadow log had no level and no handler for its entire life, and every test that "covered" it forced the level via caplog.at_level(...), which production never has. If you add startup behaviour, extract it the same way and test it without forcing a level.
  • HostOriginGuard — the DNS-rebinding check (v0.5.0). Loopback Host names and the bound address on any port (mcp's prefix wildcard), plus exact PM2_MCP_ALLOWED_HOSTS entries (* refuses to start); any non-empty Origin refused. It is handed to mcp.run by main(), and a test pins that it is. Never log the header values.
  • PM2_MCP_ENV_MODE — shadow (default) or enforce; anything else makes main() refuse to start. Do not flip it as part of other work: that is Ted's decision on vikunja#771.
  • Dependencies — fastmcp, and minimum versions on mcp and several transitives, each carrying the advisory it closes. uv.lock is the source of truth; CI installs from it and audits it. PM2 must already be installed on the host. No auth — this server is intended for localhost use only, and the loopback bind is enforced. See docs/threat-model.md.

Read the full file on GitHub · 64 lines

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. 10d ago Changed · +12 lines · +400 tokens per session b3b38f909b69
  2. 1mo ago Changed · +3 lines · +302 tokens per session f1722ff76c54
  3. 1mo ago Changed · +7 lines · +258 tokens per session 09fad00b831f
  4. 2mo ago First seen · 42 lines · 414 tokens per session scan A 106e85c7c67c

Subscribe to this mod's changes

pm2-mcp AGENTS.md is an instructions file published in the GitHub repository TadMSTR/pm2-mcp (0 stars, last pushed 4d ago), licensed MIT. It adds 1,374 tokens to every session, about $0.0055 per session on Opus 5.5. A static security scan graded it A with 1 finding (runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

pm2-mcp AGENTS.md compared with instructions from other repositories

pm2-mcp AGENTS.md next to 6 instructions from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
pm2-mcp AGENTS.mdTadMSTR/pm2-mcpInstructions file04d agoMITA1,374Codex, OpenCode
vscode buildNext.instructions.mdmicrosoft/vscodeInstructions file195kyesterdayMITA9,719GitHub Copilot
next.js AGENTS.mdvercel/next.jsInstructions file143kyesterdayMITA7,461Codex, OpenCode
langchain AGENTS.mdlangchain-ai/langchainInstructions file149kyesterdayMITA4,680Codex, OpenCode
vscode oss-third-party-notices.instructions.mdmicrosoft/vscodeInstructions file195kyesterdayMITA5,516GitHub Copilot
vscode copilot-instructions.mdmicrosoft/vscodeInstructions file195kyesterdayMITA3,093GitHub Copilot
deepseek-harness AGENTS.mddeepseek-ai/deepseek-harnessInstructions file274k2d agoMITA4,313Codex, OpenCode