Tools¶
System Tools¶
pcp_mcp.tools.system
¶
System health tools for clumped metric queries.
get_filesystem_usage
async
¶
get_filesystem_usage(
ctx: Context,
host: Annotated[
Optional[str],
Field(
description="Target pmcd host to query (default: server's configured target)"
),
] = None,
) -> ToolResult
Get mounted filesystem usage (similar to df command).
Returns capacity, used, available, and percent full for each mounted filesystem. Useful for monitoring disk space and identifying filesystems that may need attention.
Examples:
get_filesystem_usage() - Check all filesystems on default host get_filesystem_usage(host="db1.example.com") - Check remote host
Source code in src/pcp_mcp/tools/system.py
get_process_top
async
¶
get_process_top(
ctx: Context,
sort_by: Annotated[
Literal["cpu", "memory", "io"],
Field(description="Resource to sort by"),
] = "cpu",
limit: Annotated[
int,
Field(
default=10,
ge=1,
le=50,
description="Number of processes to return",
),
] = 10,
sample_interval: Annotated[
float,
Field(
default=1.0,
ge=0.5,
le=5.0,
description="Seconds to sample for CPU/IO rates",
),
] = 1.0,
host: Annotated[
Optional[str],
Field(
description="Target pmcd host to query (default: server's configured target)"
),
] = None,
) -> ToolResult
Get top processes by resource consumption.
For CPU and I/O, takes two samples to calculate rates. Memory is instantaneous. Returns the top N processes sorted by the requested resource.
Examples:
get_process_top() - Top 10 by CPU (default) get_process_top(sort_by="memory", limit=20) - Top 20 memory consumers get_process_top(sort_by="io", sample_interval=2.0) - Top I/O with longer sample get_process_top(host="db1.example.com") - Query remote host
Source code in src/pcp_mcp/tools/system.py
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 | |
get_system_snapshot
async
¶
get_system_snapshot(
ctx: Context,
categories: Annotated[
Optional[list[str]],
Field(
default=None,
description="Categories to include: cpu, memory, disk, network, load. Defaults to all five if not specified.",
),
] = None,
sample_interval: Annotated[
float,
Field(
default=1.0,
ge=0.1,
le=10.0,
description="Seconds between samples for rate calculation",
),
] = 1.0,
host: Annotated[
Optional[str],
Field(
description="Target pmcd host to query (default: server's configured target)"
),
] = None,
) -> ToolResult
Get a point-in-time system health overview.
Returns CPU, memory, disk I/O, network I/O, and load metrics in a single call. For rate metrics (CPU %, disk I/O, network throughput), takes two samples to calculate per-second rates.
Use this tool FIRST for system troubleshooting. It automatically handles counter-to-rate conversion. Do NOT use query_metrics() for CPU, disk, or network counters - those return raw cumulative values since boot.
Examples:
get_system_snapshot() - Quick health check (all categories) get_system_snapshot(categories=["cpu", "memory"]) - CPU and memory only get_system_snapshot(categories=["cpu", "load"]) - CPU and load averages get_system_snapshot(categories=["disk", "network"]) - I/O analysis get_system_snapshot(host="web1.example.com") - Query remote host
Source code in src/pcp_mcp/tools/system.py
quick_health
async
¶
quick_health(
ctx: Context,
host: Annotated[
Optional[str],
Field(
description="Target pmcd host to query (default: server's configured target)"
),
] = None,
) -> ToolResult
Fast system health check returning only CPU and memory metrics.
Use this for rapid status checks when you don't need disk/network/load details. Uses a shorter sample interval (0.5s) for faster results.
Examples:
quick_health() - Fast health check on default host quick_health(host="web1.example.com") - Fast check on remote host
Source code in src/pcp_mcp/tools/system.py
smart_diagnose
async
¶
smart_diagnose(
ctx: Context,
host: Annotated[
Optional[str],
Field(
description="Target pmcd host to query (default: server's configured target)"
),
] = None,
) -> ToolResult
Use LLM to analyze system metrics and provide diagnosis.
Collects a quick system snapshot (CPU, memory, load) and asks the connected LLM to analyze the metrics and provide actionable insights.
This tool demonstrates FastMCP's LLM sampling capability, where the MCP server can request LLM assistance for complex analysis tasks.
Examples:
smart_diagnose() - Analyze default host smart_diagnose(host="db1.example.com") - Analyze remote host
Source code in src/pcp_mcp/tools/system.py
Metrics Tools¶
pcp_mcp.tools.metrics
¶
Core metric tools for querying PCP metrics.
describe_metric
async
¶
describe_metric(
ctx: Context,
name: Annotated[
str,
Field(
description="Full PCP metric name (e.g., 'kernel.all.cpu.user')"
),
],
host: Annotated[
Optional[str],
Field(
description="Target pmcd host to query (default: server's configured target)"
),
] = None,
) -> ToolResult
Get detailed metadata about a PCP metric.
Returns type, semantics, units, and help text for the metric. Use this to understand what a metric measures and how to interpret it.
Examples:
describe_metric("kernel.all.load") - Learn about load average semantics describe_metric("mem.util.available") - Understand available memory describe_metric("disk.all.read_bytes") - Check if metric is counter vs instant describe_metric("kernel.all.load", host="web1.example.com") - Describe on remote
Source code in src/pcp_mcp/tools/metrics.py
query_metrics
async
¶
query_metrics(
ctx: Context,
names: Annotated[
list[str],
Field(
description="List of PCP metric names to fetch (e.g., ['kernel.all.load'])"
),
],
host: Annotated[
Optional[str],
Field(
description="Target pmcd host to query (default: server's configured target)"
),
] = None,
) -> ToolResult
Fetch current values for specific PCP metrics.
Returns the current value for each requested metric. For metrics with instances (e.g., per-CPU, per-disk), returns one MetricValue per instance.
Examples:
query_metrics(["kernel.all.load"]) - Get load averages query_metrics(["mem.util.available", "mem.physmem"]) - Get memory stats query_metrics(["hinv.ncpu"]) - Get CPU count query_metrics(["kernel.all.load"], host="web1.example.com") - Query remote host
Warning: CPU, disk, and network metrics are counters (cumulative since boot). Use get_system_snapshot() instead for rates.
Source code in src/pcp_mcp/tools/metrics.py
search_metrics
async
¶
search_metrics(
ctx: Context,
pattern: Annotated[
str,
Field(
description="Metric name prefix to search for (e.g., 'kernel.all', 'mem')"
),
],
host: Annotated[
Optional[str],
Field(
description="Target pmcd host to query (default: server's configured target)"
),
] = None,
) -> ToolResult
Find PCP metrics matching a name pattern.
Use this to discover available metrics before querying them. Returns metric names and brief descriptions.
Examples:
search_metrics("kernel.all") - Find kernel-wide metrics search_metrics("mem.util") - Find memory utilization metrics search_metrics("disk.dev") - Find per-disk metrics search_metrics("network.interface") - Find per-interface metrics search_metrics("kernel", host="db1.example.com") - Search on remote host