Repository navigation
feat(tools): add process_info MCP tool - #6
Merged
Merged
Conversation
Single-PID drill-down. Peer of cgroup-mcp's get_unit_stats: takes one PID and returns the full bundle. Wire shape composes ProcessEntry (shared identifier fields with pids_in_cgroup and top_processes) via #[serde(flatten)], and adds: - uid: real uid from /proc/<pid>/status - num_threads: process group thread count - fd_count: count of /proc/<pid>/fd entries (null on EACCES) - memory: parsed smaps_rollup with Rss/Pss/Shared/Private/Anon/Swap in bytes; null for kernel threads or EACCES - io: cumulative read_bytes/write_bytes/syscr/syscw from /proc/<pid>/io; null on EACCES (very common as non-root) PSS in particular gives the agent a fairer number than RSS when pages are shared across processes. Internals: three new collector modules (smaps, fd, io) with inline parser tests. parse_status extended to capture uid and num_threads (synthetic_proc_tree helper updated to write them). 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
Per-plan: single-PID drill-down. Peer of cgroup-mcp's
get_unit_stats.Takes one PID, returns the full bundle:
pids_in_cgroup/top_processes(pid, comm, cmdline, state, ppid, rss_bytes, cgroup_path) via#[serde(flatten)]uid,num_threads,fd_count,memory(smaps_rollup breakdown),io(counters)Wire shape highlights
memory.pss_bytes: fairest single number for "this process's memory cost" when pages are shared across processes (browser tabs, JVM workers, etc.)fd_count,memory,ioare nullable. Common non-null states:fd_countnull = EACCES on/proc/<pid>/fd(common across user namespaces)memorynull = kernel thread (no userspace memory map) or EACCESionull = EACCES (very common as non-root)New collector modules
collector/smaps.rs: parses/proc/<pid>/smaps_rollup. Sums Shared_Clean+Shared_Dirty and Private_Clean+Private_Dirty. Future-compat (ignores unknown lines).collector/fd.rs: counts entries in/proc/<pid>/fd/. Returns None on EACCES/NotFound.collector/io.rs: parses/proc/<pid>/io. Returns None on EACCES/NotFound.Plus
parse_statusextended to captureUid:andThreads:lines; ProcessSnapshot carries them now.Test plan
top_processes🤖 Generated with Claude Code