Repository navigation
feat(tools): add process_tree MCP tool - #8
Merged
Merged
Conversation
Phase 2 from the plan, motivated by the demo: when an agent asks
"break down the Chrome process tree" or "what's the structure
inside this cgroup," a flat process list misses the parent/child
relationships. process_tree returns a forest.
Two mutually exclusive modes:
root_pid: tree rooted at one PID with all descendants nested.
cgroup_path: forest of in-cgroup PIDs, organized by in-cgroup
parent/child. A PID whose parent is outside the cgroup becomes
a forest root.
Each TreeNode flattens ProcessEntry (so identifier fields are at
the top level alongside `children`) and the existing redaction +
skipped-count behavior applies. Children sorted by rss_bytes desc
with nulls last, matching the other tools. Visited-set protects
against /proc inconsistency (defensive against ppid cycles).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The phase-2 tool from the plan, motivated by the demo's offered follow-up ("break down the Chrome renderers"). Returns parent/child forest with two mutually exclusive modes.
Modes
root_pid: tree rooted at one PID. Single-element forest with the PID at top and every descendant nested. For unpacking Chrome's main → renderer → GPU model, systemd supervisors, etc.cgroup_path: forest of in-cgroup PIDs organized by parent/child relationships among PIDs in the same cgroup. A PID whose parent is outside the cgroup becomes a forest root. For understanding the shape of a heavy cgroup identified via cgroup-mcp.Mutually exclusive: exactly one must be set; rejects both / neither.
Wire shape
Each
TreeNodeflattensProcessEntry(so identifier fields are at the top level alongsidechildren):Children sorted by
rss_bytesdesc with nulls last. Sameredact_args/skippedsemantics as the other tools.Robustness
root_pidfor a nonexistent PID errorscgroup_pathvalidated like everywhere else (no absolute, no..)Test plan
🤖 Generated with Claude Code