Skip to main content
Glama
alxspiker

Windows Command Line MCP Server

get_service_info

Retrieve Windows service information, including detailed status for specific services or query all services, to monitor and manage system processes.

Instructions

Retrieve information about Windows services. Can query all services or get detailed status of a specific service.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionNoAction to performquery
serviceNameNoService name to get info about (optional)

Implementation Reference

  • The handler function for the 'get_service_info' tool. It checks if the platform is Windows, constructs a PowerShell command based on the 'action' ('query' or 'status') and optional 'serviceName', executes it using executeCommand, and returns the stdout or an error.
    async ({ action, serviceName }) => { if (!isWindows) { return { content: [ { type: "text", text: "The service info tool is only available on Windows. Current platform: " + platform(), }, ], }; } try { let cmd = "powershell.exe -Command \""; if (action === "query") { if (serviceName) { cmd += "Get-Service -Name '" + serviceName + "' | Format-List Name, DisplayName, Status, StartType, Description"; } else { cmd += "Get-Service | Select-Object Name, DisplayName, Status, StartType | Format-Table -AutoSize | Out-String"; } } else if (action === "status" && serviceName) { cmd += "Get-Service -Name '" + serviceName + "' | Format-List *; " + "Get-CimInstance -ClassName Win32_Service -Filter \"Name='" + serviceName + "'\" | Format-List *"; } else { return { isError: true, content: [ { type: "text", text: "For 'status' action, serviceName parameter is required", }, ], }; } cmd += "\""; const stdout = executeCommand(cmd); return { content: [ { type: "text", text: stdout.toString(), }, ], }; } catch (error) { return { isError: true, content: [ { type: "text", text: `Error retrieving service info: ${error}`, }, ], }; } }
  • Input schema for the 'get_service_info' tool using Zod validation: 'action' enum (query/status, default query) and optional 'serviceName' string.
    { action: z.enum(["query", "status"]).default("query").describe("Action to perform"), serviceName: z.string().optional().describe("Service name to get info about (optional)"), },
  • index.ts:326-393 (registration)
    Registration of the 'get_service_info' tool on the MCP server, including name, description, input schema, and handler function.
    server.tool( "get_service_info", "Retrieve information about Windows services. Can query all services or get detailed status of a specific service.", { action: z.enum(["query", "status"]).default("query").describe("Action to perform"), serviceName: z.string().optional().describe("Service name to get info about (optional)"), }, async ({ action, serviceName }) => { if (!isWindows) { return { content: [ { type: "text", text: "The service info tool is only available on Windows. Current platform: " + platform(), }, ], }; } try { let cmd = "powershell.exe -Command \""; if (action === "query") { if (serviceName) { cmd += "Get-Service -Name '" + serviceName + "' | Format-List Name, DisplayName, Status, StartType, Description"; } else { cmd += "Get-Service | Select-Object Name, DisplayName, Status, StartType | Format-Table -AutoSize | Out-String"; } } else if (action === "status" && serviceName) { cmd += "Get-Service -Name '" + serviceName + "' | Format-List *; " + "Get-CimInstance -ClassName Win32_Service -Filter \"Name='" + serviceName + "'\" | Format-List *"; } else { return { isError: true, content: [ { type: "text", text: "For 'status' action, serviceName parameter is required", }, ], }; } cmd += "\""; const stdout = executeCommand(cmd); return { content: [ { type: "text", text: stdout.toString(), }, ], }; } catch (error) { return { isError: true, content: [ { type: "text", text: `Error retrieving service info: ${error}`, }, ], }; } } );

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/alxspiker/Windows-Command-Line-MCP-Server'

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