Skip to main content
Glama
devlimelabs

MCP Troubleshooter

by devlimelabs

validate-mcp-server-config

Validate specific server configurations in the MCP Troubleshooter framework to ensure correct setup and diagnose potential issues.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
serverNameNoSpecific server configuration to validate

Implementation Reference

  • Complete tool registration and handler implementation for 'validate-mcp-server-config'. The handler reads claude_desktop_config.json, parses MCP servers section, validates each server's command (checks if in PATH using 'which' or 'where'), ensures 'args' is array and flags relative paths, checks 'env' is object, and generates a markdown validation report listing valid/invalid servers with issues.
    server.tool(
      "validate-mcp-server-config",
      {
        serverName: z.string().optional().describe("Specific server configuration to validate")
      },
      async ({ serverName }) => {
        try {
          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');
          
          try {
            const configObject = JSON.parse(configContent);
            
            if (!configObject.mcpServers) {
              return {
                content: [{ type: "text", text: "Configuration file does not contain an 'mcpServers' section." }]
              };
            }
            
            const servers = configObject.mcpServers;
            const serverNames = Object.keys(servers);
            
            if (serverNames.length === 0) {
              return {
                content: [{ type: "text", text: "No MCP servers are configured." }]
              };
            }
            
            // If a specific server is requested, only validate that one
            const targetsToValidate = serverName ? 
              (serverNames.includes(serverName) ? [serverName] : []) : 
              serverNames;
              
            if (serverName && targetsToValidate.length === 0) {
              return {
                content: [{ type: "text", text: `Server '${serverName}' not found in configuration.` }]
              };
            }
            
            // Validate each server configuration
            let validationResults = [];
            
            for (const name of targetsToValidate) {
              const serverConfig = servers[name];
              let issues = [];
              
              // Check command exists
              if (!serverConfig.command) {
                issues.push("Missing 'command' field");
              } else {
                // Try to find the command in PATH
                try {
                  await execAsync(`which ${serverConfig.command}`);
                } catch (error) {
                  try {
                    await execAsync(`where ${serverConfig.command}`);
                  } catch (error2) {
                    issues.push(`Command '${serverConfig.command}' not found in PATH`);
                  }
                }
              }
              
              // Check args
              if (!serverConfig.args) {
                issues.push("Missing 'args' field");
              } else if (!Array.isArray(serverConfig.args)) {
                issues.push("'args' field must be an array");
              }
              
              // Check for relative paths in args that might cause issues
              if (Array.isArray(serverConfig.args)) {
                const relativePathArgs = serverConfig.args.filter(arg => 
                  typeof arg === 'string' && 
                  arg.includes('/') && 
                  !arg.startsWith('/') && 
                  !arg.includes(':/')
                );
                
                if (relativePathArgs.length > 0) {
                  issues.push(`Potential relative path issues in args: ${relativePathArgs.join(', ')}`);
                }
              }
              
              // Check env vars if present
              if (serverConfig.env && typeof serverConfig.env !== 'object') {
                issues.push("'env' field must be an object");
              }
              
              // Add validation result
              validationResults.push({
                server: name,
                config: serverConfig,
                valid: issues.length === 0,
                issues: issues
              });
            }
            
            // Format the results
            let validationReport = "# MCP Server Configuration Validation\n\n";
            
            for (const result of validationResults) {
              validationReport += `## ${result.server}\n\n`;
              validationReport += `Status: ${result.valid ? '✅ Valid' : '❌ Invalid'}\n\n`;
              
              if (!result.valid) {
                validationReport += "Issues:\n";
                for (const issue of result.issues) {
                  validationReport += `- ${issue}\n`;
                }
                validationReport += "\n";
              }
              
              validationReport += `Configuration:\n\`\`\`json\n${JSON.stringify(result.config, null, 2)}\n\`\`\`\n\n`;
            }
            
            return {
              content: [{ type: "text", text: validationReport }]
            };
            
          } catch (error) {
            return {
              isError: true,
              content: [{ type: "text", text: `Error parsing configuration: ${error.message}` }]
            };
          }
        } catch (error) {
          return {
            isError: true,
            content: [{ type: "text", text: `Error validating configuration: ${error.message}` }]
          };
        }
      }
    );
  • Input schema using Zod: optional serverName string to validate specific server.
    {
      serverName: z.string().optional().describe("Specific server configuration to validate")
  • src/index.ts:374-375 (registration)
    Registration of the tool via server.tool() call.
    server.tool(
      "validate-mcp-server-config",
Behavior1/5

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

Tool has no description.

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

Conciseness1/5

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

Tool has no description.

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?

Tool has no description.

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

Parameters1/5

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

Tool has no description.

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

Purpose1/5

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

Tool has no description.

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

Usage Guidelines1/5

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

Tool has no description.

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

Related 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/devlimelabs/mcp-troubleshooter-mcp'

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