Skip to main content
Glama
carlosedp

Windows MCP Server

by carlosedp

Windows-top-processes-by-cpu

Retrieves the top processes by CPU usage on Windows, enabling identification of high-resource applications and performance analysis.

Instructions

Get the top X processes by CPU usage.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
amountNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • main.py:238-271 (registration)
    Registration of the tool 'Windows-top-processes-by-cpu' via @mcp.tool decorator
    @mcp.tool(
            name="Windows-top-processes-by-cpu",
            description="Get the top X processes by CPU usage."
    )
    def get_top_processes_by_cpu(amount: int = 5) -> list[ProcessInfo]:
        """Get the top X processes by CPU usage. Uses sampling for accurate percentages and returns structured results."""
        import psutil
        import time
    
        # Prime CPU percentage counters
        tracked = []
        for p in psutil.process_iter(['pid', 'name']):
            try:
                p.cpu_percent(None)
                tracked.append(p)
            except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
                continue
    
        # Short sampling interval
        time.sleep(0.3)
    
        results: list[ProcessInfo] = []
        for p in tracked:
            try:
                cpu = p.cpu_percent(None)
                rss = p.memory_info().rss
                mem_mb = rss / (1024 ** 2)
                name = p.info.get('name') if hasattr(p, 'info') and p.info.get('name') else p.name()
                results.append(ProcessInfo(pid=p.pid, name=name, cpu_percent=cpu, memoryMB=mem_mb))
            except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
                continue
    
        results.sort(key=lambda x: x.cpu_percent or 0.0, reverse=True)
        return results[:amount]
  • main.py:242-271 (handler)
    Handler function get_top_processes_by_cpu that samples CPU usage over a short interval (0.3s sleep) and returns top processes by CPU percent.
    def get_top_processes_by_cpu(amount: int = 5) -> list[ProcessInfo]:
        """Get the top X processes by CPU usage. Uses sampling for accurate percentages and returns structured results."""
        import psutil
        import time
    
        # Prime CPU percentage counters
        tracked = []
        for p in psutil.process_iter(['pid', 'name']):
            try:
                p.cpu_percent(None)
                tracked.append(p)
            except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
                continue
    
        # Short sampling interval
        time.sleep(0.3)
    
        results: list[ProcessInfo] = []
        for p in tracked:
            try:
                cpu = p.cpu_percent(None)
                rss = p.memory_info().rss
                mem_mb = rss / (1024 ** 2)
                name = p.info.get('name') if hasattr(p, 'info') and p.info.get('name') else p.name()
                results.append(ProcessInfo(pid=p.pid, name=name, cpu_percent=cpu, memoryMB=mem_mb))
            except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
                continue
    
        results.sort(key=lambda x: x.cpu_percent or 0.0, reverse=True)
        return results[:amount]
  • main.py:19-24 (schema)
    ProcessInfo schema/model used as the return type of the tool
    class ProcessInfo(BaseModel):
        """Model for process information returned by top-processes tools."""
        pid: int = Field(description="Process ID")
        name: str = Field(description="Process name")
        cpu_percent: float | None = Field(default=None, description="CPU usage percentage sampled over a short interval")
        memoryMB: float | None = Field(default=None, description="Resident memory usage in MB")
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Without annotations, the description carries the full burden but only states the basic function. It fails to disclose any behavioral details such as whether it returns a live snapshot, required permissions, or the format of process details.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness2/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence, which is concise, but it is under-specified. It does not earn its place as it omits critical information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with no annotations and a sibling requiring differentiation, the description is completely inadequate. It lacks mention of scope (system-wide?), sort order, or any behavioral context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The parameter 'amount' is not described beyond its name and default value. With 0% schema description coverage, the description should add meaning but does not. The name is suggestive but minimal.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a clear verb 'Get' and specifies the resource 'top X processes by CPU usage'. However, it does not differentiate from the sibling tool 'Windows-top-processes-by-memory'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like Windows-top-processes-by-memory. The description lacks any when-to-use or when-not-to-use context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/carlosedp/windows-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server