Skip to main content
Glama
vdesabou

MCP Playground Server

by vdesabou

playground_command_validate

Validate Kafka Docker Playground CLI commands and suggest corrections to ensure proper syntax and usage.

Instructions

Validate a complete playground command and suggest corrections

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandYesComplete playground command to validate

Implementation Reference

  • MCP tool handler that extracts the command argument, calls the suggester's validateCommand method, and formats the result as MCP content response.
    private async handleCommandValidate(args: any) {
      const { command } = args;
      
      const validation = await this.suggester.validateCommand(command);
      
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(validation, null, 2),
          },
        ],
      };
    }
  • Core implementation of command validation: parses command parts, validates against command structure from parser, checks for unknown commands/options, required options, provides suggestions and errors.
    async validateCommand(command: string): Promise<ValidationResult> {
      const result: ValidationResult = {
        valid: true,
        errors: [],
        warnings: [],
        suggestions: []
      };
    
      const parts = command.trim().split(' ').filter(p => p.length > 0);
      
      if (parts.length === 0) {
        result.valid = false;
        result.errors.push('Empty command');
        return result;
      }
    
      // Check if starts with 'playground'
      if (parts[0] !== 'playground') {
        result.valid = false;
        result.errors.push('Command must start with "playground"');
        return result;
      }
    
      const commandParts = parts.slice(1).filter(part => !part.startsWith('--'));
      const optionParts = parts.slice(1).filter(part => part.startsWith('--'));
    
      // Validate command path
      if (commandParts.length === 0) {
        result.valid = false;
        result.errors.push('No command specified');
        return result;
      }
    
      const foundCommand = this.parser.findCommand(commandParts);
      if (!foundCommand) {
        result.valid = false;
        result.errors.push(`Unknown command: ${commandParts.join(' ')}`);
        
        // Suggest similar commands
        const suggestions = await this.getSuggestions(commandParts.join(' '));
        result.suggestions = suggestions.slice(0, 3).map(s => s.completion);
        
        return result;
      }
    
      // Validate options
      const providedOptions = new Set<string>();
      for (let i = 0; i < optionParts.length; i++) {
        const optionPart = optionParts[i];
        const optionName = optionPart.replace(/^--?/, '');
        
        const option = foundCommand.options?.find(opt => opt.name === optionName);
        if (!option) {
          result.valid = false;
          result.errors.push(`Unknown option: ${optionPart}`);
          continue;
        }
    
        if (providedOptions.has(optionName) && !option.repeatable) {
          result.warnings.push(`Option --${optionName} specified multiple times but is not repeatable`);
        }
        
        providedOptions.add(optionName);
      }
    
      // Check required options
      foundCommand.options?.forEach(option => {
        if (option.required && !providedOptions.has(option.name)) {
          result.valid = false;
          result.errors.push(`Missing required option: --${option.name}`);
        }
      });
    
      // Check if command needs subcommands
      if (foundCommand.subcommands && foundCommand.subcommands.length > 0) {
        // Check if this is a terminal command or needs subcommands
        const hasSubcommand = commandParts.length > 1;
        if (!hasSubcommand) {
          result.warnings.push('This command has subcommands available');
          result.suggestions.push(
            ...foundCommand.subcommands.slice(0, 3).map(sub => 
              `playground ${commandParts.join(' ')} ${sub.name}`
            )
          );
        }
      }
    
      return result;
    }
  • src/index.ts:59-72 (registration)
    Tool registration in the ListToolsRequestSchema handler, defining name, description, and input schema.
    {
      name: "playground_command_validate",
      description: "Validate a complete playground command and suggest corrections",
      inputSchema: {
        type: "object",
        properties: {
          command: {
            type: "string",
            description: "Complete playground command to validate",
          },
        },
        required: ["command"],
      },
    },
  • Input schema definition for the playground_command_validate tool.
    inputSchema: {
      type: "object",
      properties: {
        command: {
          type: "string",
          description: "Complete playground command to validate",
        },
      },
      required: ["command"],
    },
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 states the tool validates and suggests corrections, but doesn't describe what validation entails (e.g., syntax checks, semantic analysis), how suggestions are formatted, whether it's read-only or has side effects, or any error handling. This leaves significant gaps for a tool that likely involves complex processing.

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

Conciseness5/5

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

The description is a single, efficient sentence that directly states the tool's function without unnecessary words. It's front-loaded with the core purpose ('Validate a complete playground command') and adds value with the secondary action ('and suggest corrections'). Every part of the sentence earns its place.

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

Completeness2/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, no output schema, and likely complex validation logic, the description is insufficient. It doesn't explain what constitutes a 'complete' command, what types of corrections are suggested, or the format of the response. The agent lacks critical context to use this tool effectively beyond the basic parameter.

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

Parameters3/5

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

The input schema has 100% description coverage, with the 'command' parameter documented as 'Complete playground command to validate.' The description doesn't add any additional meaning beyond this, such as examples of valid commands or formatting requirements. Given the high schema coverage, a baseline score of 3 is appropriate.

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: 'Validate a complete playground command and suggest corrections.' It specifies the verb ('validate') and resource ('playground command'), and indicates it provides suggestions. However, it doesn't explicitly differentiate from sibling tools like 'playground_command_help' or 'playground_command_suggest'.

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 its siblings ('playground_command_help' and 'playground_command_suggest'). It doesn't mention prerequisites, alternatives, or exclusions, leaving the agent to infer usage from the tool name alone.

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/vdesabou/kafka-docker-playground-mcp-server'

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