check-mcp-server-process
Verify the process status of an MCP server to diagnose and resolve operational issues. Input the server name to analyze logs, validate configurations, and ensure seamless functionality.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| serverName | Yes | Name of the MCP server to check |
Implementation Reference
- src/index.ts:559-644 (handler)Full implementation of the 'check-mcp-server-process' tool handler. Reads Claude Desktop config, parses JSON to find server command, then uses platform-specific commands (tasklist on Windows, ps/grep on Unix) to check if the process is running and returns details or status.
server.tool( "check-mcp-server-process", { serverName: z.string().describe("Name of the MCP server to check") }, async ({ serverName }) => { try { // Read configuration to get the command for this server try { await fs.access(configPath); } catch (error) { return { content: [{ type: "text", text: `Configuration file not found at ${configPath}.` }] }; } const configContent = await fs.readFile(configPath, 'utf-8'); let configObject; try { configObject = JSON.parse(configContent); } catch (error) { return { isError: true, content: [{ type: "text", text: `Invalid JSON in configuration file: ${error.message}` }] }; } if (!configObject.mcpServers || !configObject.mcpServers[serverName]) { return { content: [{ type: "text", text: `Server '${serverName}' not found in configuration.` }] }; } const serverConfig = configObject.mcpServers[serverName]; const command = serverConfig.command; if (!command) { return { content: [{ type: "text", text: `Server '${serverName}' has no command specified in configuration.` }] }; } // Check if process is running (platform specific) const platform = os.platform(); let processCheckCommand; if (platform === "win32") { processCheckCommand = `tasklist /FI "IMAGENAME eq ${command}*"`; } else { processCheckCommand = `ps aux | grep "${command}" | grep -v grep`; } try { const { stdout } = await execAsync(processCheckCommand); if (stdout.trim()) { // Process is likely running return { content: [{ type: "text", text: `Process for server '${serverName}' appears to be running.\n\nProcess details:\n\`\`\`\n${stdout}\n\`\`\`` }] }; } else { return { content: [{ type: "text", text: `No running process found for server '${serverName}'.` }] }; } } catch (error) { // Process not found or error checking return { content: [{ type: "text", text: `No running process found for server '${serverName}', or error checking process: ${error.message}` }] }; } } catch (error) { return { isError: true, content: [{ type: "text", text: `Error checking server process: ${error.message}` }] }; } } ); - src/index.ts:561-563 (schema)Input schema for the tool using Zod: requires 'serverName' string parameter.
{ serverName: z.string().describe("Name of the MCP server to check") }, - src/index.ts:560-644 (registration)Registers the tool on the MCP server instance with name, schema, and handler.
"check-mcp-server-process", { serverName: z.string().describe("Name of the MCP server to check") }, async ({ serverName }) => { try { // Read configuration to get the command for this server try { await fs.access(configPath); } catch (error) { return { content: [{ type: "text", text: `Configuration file not found at ${configPath}.` }] }; } const configContent = await fs.readFile(configPath, 'utf-8'); let configObject; try { configObject = JSON.parse(configContent); } catch (error) { return { isError: true, content: [{ type: "text", text: `Invalid JSON in configuration file: ${error.message}` }] }; } if (!configObject.mcpServers || !configObject.mcpServers[serverName]) { return { content: [{ type: "text", text: `Server '${serverName}' not found in configuration.` }] }; } const serverConfig = configObject.mcpServers[serverName]; const command = serverConfig.command; if (!command) { return { content: [{ type: "text", text: `Server '${serverName}' has no command specified in configuration.` }] }; } // Check if process is running (platform specific) const platform = os.platform(); let processCheckCommand; if (platform === "win32") { processCheckCommand = `tasklist /FI "IMAGENAME eq ${command}*"`; } else { processCheckCommand = `ps aux | grep "${command}" | grep -v grep`; } try { const { stdout } = await execAsync(processCheckCommand); if (stdout.trim()) { // Process is likely running return { content: [{ type: "text", text: `Process for server '${serverName}' appears to be running.\n\nProcess details:\n\`\`\`\n${stdout}\n\`\`\`` }] }; } else { return { content: [{ type: "text", text: `No running process found for server '${serverName}'.` }] }; } } catch (error) { // Process not found or error checking return { content: [{ type: "text", text: `No running process found for server '${serverName}', or error checking process: ${error.message}` }] }; } } catch (error) { return { isError: true, content: [{ type: "text", text: `Error checking server process: ${error.message}` }] }; } } );