Skip to main content
Glama
DynamicEndpoints

PowerShell Exec MCP Server

get_system_info

Retrieve system information from Windows computers using PowerShell. Specify which ComputerInfo properties to collect and set timeout parameters for enterprise automation and monitoring.

Instructions

Get system information.

Args:
    properties: List of ComputerInfo properties to retrieve (optional)
    timeout: Command timeout in seconds (1-300, default 60)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
propertiesNo
timeoutNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The core handler function for the 'get_system_info' tool. It constructs a PowerShell 'Get-ComputerInfo' command, optionally filters by specified properties, ensures JSON output formatting, and executes it via the shared execute_powershell helper.
    @mcp.tool()
    async def get_system_info(properties: Optional[List[str]] = None, timeout: Optional[int] = 60) -> str:
        """Get system information.
        
        Args:
            properties: List of ComputerInfo properties to retrieve (optional)
            timeout: Command timeout in seconds (1-300, default 60)
        """
        code = "Get-ComputerInfo"
        if properties:
            properties_str = ",".join(properties)
            code = f"{code} -Property {properties_str}"
        return await execute_powershell(format_json_output(code), timeout)
  • Shared utility function that securely executes arbitrary PowerShell code with timeout protection, dangerous command validation, and optional MCP context logging. Called by get_system_info to run the system info query.
    async def execute_powershell(code: str, timeout: Optional[int] = 60, ctx: Optional[Context] = None) -> str:
        """Execute PowerShell commands securely.
        
        Args:
            code: PowerShell code to execute
            timeout: Command timeout in seconds (1-300, default 60)
            ctx: MCP context for logging and progress reporting
        
        Returns:
            Command output as string
        """
        # Validate timeout
        if not isinstance(timeout, int) or timeout < 1 or timeout > 300:
            raise ValueError("timeout must be between 1 and 300 seconds")
            
        # Validate code
        if not validate_powershell_code(code):
            raise ValueError("PowerShell code contains potentially dangerous commands")
    
        if ctx:
            await ctx.info("Validating PowerShell code...")
    
        # Create and run process
        if ctx:
            await ctx.info("Starting PowerShell process...")
        
        process = await asyncio.create_subprocess_exec(
            "powershell",
            "-NoProfile",      # Don't load profiles
            "-NonInteractive", # No interactive prompts
            "-Command",
            code,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE
        )
    
        try:
            if ctx:
                await ctx.info("Executing command...")
            stdout, stderr = await asyncio.wait_for(
                process.communicate(),
                timeout=timeout
            )
        except asyncio.TimeoutError:
            process.kill()
            if ctx:
                await ctx.error(f"Command timed out after {timeout} seconds")
            raise TimeoutError(f"Command timed out after {timeout} seconds")
    
        if process.returncode != 0:
            error_msg = stderr.decode() if stderr else "Command failed with no error output"
            if ctx:
                await ctx.error(f"PowerShell command failed: {error_msg}")
            raise RuntimeError(error_msg)
        
        result = stdout.decode() if stdout else ""
        if ctx:
            await ctx.info(f"Command completed successfully, returned {len(result)} characters")
            
        return result
  • Helper function that appends '| ConvertTo-Json' to PowerShell code if missing, ensuring JSON-formatted output. Used by get_system_info before execution.
    def format_json_output(code: str) -> str:
        """Add JSON formatting to PowerShell code if not present."""
        if not code.strip().lower().endswith('| convertto-json'):
            code = f"{code} | ConvertTo-Json"
        return code
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions a timeout parameter with constraints (1-300 seconds, default 60), which adds some behavioral context. However, it doesn't disclose important aspects like what permissions are required, whether this is a read-only operation, what happens if properties are invalid, or how the information is returned. For a system information tool with zero annotation coverage, this leaves significant gaps.

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

Conciseness4/5

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

The description is appropriately sized with three sentences that each serve a purpose: stating the tool's purpose, explaining the properties parameter, and explaining the timeout parameter. It's front-loaded with the core purpose and uses a clear Args: section. There's minimal waste, though the formatting could be slightly cleaner.

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

Completeness3/5

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

Given the tool has an output schema (which handles return values), 2 parameters with 0% schema coverage, and no annotations, the description does an adequate job. It explains both parameters' semantics and constraints, which addresses the schema coverage gap. However, for a system information tool that likely requires specific permissions and has behavioral nuances, the description should provide more context about what 'system information' includes and any limitations.

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

Parameters4/5

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

The description adds meaningful context for both parameters beyond what the schema provides. For 'properties', it specifies they are 'ComputerInfo properties to retrieve' and clarifies they're optional. For 'timeout', it provides the valid range (1-300) and default value (60), which aren't in the schema. With 0% schema description coverage, the description effectively compensates by explaining both parameters' purposes and constraints.

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 clearly states the tool's purpose as 'Get system information' which is a specific verb+resource combination. It distinguishes itself from sibling tools like get_event_logs, get_processes, and get_running_services by focusing on general system information rather than specific subsystems. However, it doesn't specify what type of system information (hardware, OS, configuration) or what 'ComputerInfo properties' encompasses.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when this tool is appropriate compared to sibling tools like get_event_logs or get_processes, nor does it specify prerequisites or constraints. The agent must infer usage from the tool name alone without contextual guidance.

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/DynamicEndpoints/PowerShell-Exec-MCP-Server'

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