Skip to content

feat(tools): add process_info MCP tool - #6

Merged
joemckenney merged 1 commit into
mainfrom
joe/process-info
May 13, 2026
Merged

joemckenney merged 1 commit into
mainfrom
joe/process-info

Conversation

@joemckenney

Copy link
Copy Markdown
Owner

Summary

Per-plan: single-PID drill-down. Peer of cgroup-mcp's get_unit_stats.

Takes one PID, returns the full bundle:

  • Shared identifier fields with pids_in_cgroup/top_processes (pid, comm, cmdline, state, ppid, rss_bytes, cgroup_path) via #[serde(flatten)]
  • New: 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, io are nullable. Common non-null states:
    • fd_count null = EACCES on /proc/<pid>/fd (common across user namespaces)
    • memory null = kernel thread (no userspace memory map) or EACCES
    • io null = EACCES (very common as non-root)
  • Errors if the PID doesn't exist (not a successful null response)

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_status extended to capture Uid: and Threads: lines; ProcessSnapshot carries them now.

Test plan

  • 37 unit + 28 integration tests pass (10 new unit tests across the 3 new collectors + parse_status extensions; 7 new integration tests for process_info)
  • fmt + clippy -D warnings + release build clean
  • tool_list_snapshot reviewed; only diff is the new tool addition
  • After merge: smoke test via Claude Code, ask it to drill into the heaviest process from top_processes

🤖 Generated with Claude Code

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>
@joemckenney
joemckenney merged commit 7df30be into main May 13, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant