Repository navigation
feat(tools): add top_processes MCP tool - #4
Merged
Merged
Conversation
System-wide process ranker. Returns the top N processes sorted by rss_bytes descending. Optionally scoped to a cgroup subtree via cgroup_prefix with path-aware matching (so system.slice matches the slice and its descendants but not siblings like system.slice2). Sort is by memory only for now; CPU rate sampling is planned but deferred to keep the first ship blocking-free. Refactor: ProcessEntry, format_cmdline, and the redaction policy moved from pids_in_cgroup into a shared src/mcp/process_entry.rs with a ProcessEntry::from_snapshot(snap, redact) constructor. Both tools now return identical-shaped entries which keeps the agent's ergonomics consistent across response types. 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
System-wide process ranker, peer of pids_in_cgroup. Returns the top N processes by
rss_bytesdesc, optionally scoped to a cgroup subtree.Tool shape
cgroup_prefixis path-aware:system.slicematchessystem.sliceitself and any descendant (system.slice/nginx.service) but never siblings (system.slice2/...). Empty/omitted = no filter.redact_argspolicy aspids_in_cgroup: redact*key=*/*token=*/*password=*/*secret=*by default, opt out viaredact_args=false.Refactor along the way
ProcessEntry+format_cmdline+ redaction logic moved frompids_in_cgroup.rsinto a sharedsrc/mcp/process_entry.rswith aProcessEntry::from_snapshot(snap, redact)constructor. Both tools now project identical-shaped entries.Files
src/mcp/process_entry.rs(new): shared wire-shape projection + redactionsrc/mcp/tools/top_processes.rs(new): the tool, plus inline tests for the prefix-match functionsrc/mcp/tools/pids_in_cgroup.rs: stripped of duplicated types/helpers, now imports fromprocess_entrytests/mcp_server.rs: 10 new integration tests covering rank+filter+sort, n cap, default n, kernel-thread sort placement, redaction, prefix validation, sibling-mismatch, empty prefix == no filter, skipped countTest plan
🤖 Generated with Claude Code