Skip to main content
Glama
vdesabou

MCP Playground Server

by vdesabou

playground_command_suggest

Generate command suggestions and completions for Kafka Docker Playground CLI operations based on partial input and context.

Instructions

Get command suggestions and completions for the Kafka Docker Playground CLI

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
partial_commandYesPartial playground command to complete
contextNoAdditional context about what you're trying to do

Implementation Reference

  • MCP tool handler function that processes the tool call, invokes the suggester for suggestions, retrieves command structure from parser, and returns formatted JSON response.
    private async handleCommandSuggest(args: any) {
      const { partial_command, context } = args;
      
      const suggestions = await this.suggester.getSuggestions(partial_command, context);
      
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify({
              suggestions,
              command_structure: this.parser.getCommandStructure(partial_command),
            }, null, 2),
          },
        ],
      };
    }
  • Input schema definition for the playground_command_suggest tool, specifying parameters partial_command (required) and optional context.
    inputSchema: {
      type: "object",
      properties: {
        partial_command: {
          type: "string",
          description: "Partial playground command to complete",
        },
        context: {
          type: "string",
          description: "Additional context about what you're trying to do",
        },
      },
      required: ["partial_command"],
    },
  • src/index.ts:41-59 (registration)
    Tool registration in ListTools response, defining name, description, and input schema.
    {
      name: "playground_command_suggest",
      description: "Get command suggestions and completions for the Kafka Docker Playground CLI",
      inputSchema: {
        type: "object",
        properties: {
          partial_command: {
            type: "string",
            description: "Partial playground command to complete",
          },
          context: {
            type: "string",
            description: "Additional context about what you're trying to do",
          },
        },
        required: ["partial_command"],
      },
    },
    {
  • Core helper function implementing the suggestion logic: parses partial command, handles top-level, command, and option suggestions by delegating to specialized methods.
    async getSuggestions(partialCommand: string, context?: string): Promise<CommandSuggestion[]> {
      const suggestions: CommandSuggestion[] = [];
      const parts = partialCommand.trim().split(' ').filter(p => p.length > 0);
      
      // Remove 'playground' if it's the first part
      if (parts.length > 0 && parts[0] === 'playground') {
        parts.shift();
      }
    
      if (parts.length === 0) {
        // Suggest top-level commands
        const commands = this.parser.getCommands();
        commands.forEach(cmd => {
          suggestions.push({
            completion: `playground ${cmd.name}`,
            description: cmd.description || '',
            type: 'command',
            score: 1.0
          });
        });
        return suggestions;
      }
    
      // Check if the last part is incomplete (doesn't start with --)
      const lastPart = parts[parts.length - 1];
      const isOption = lastPart.startsWith('--');
      
      if (isOption) {
        return this.getOptionSuggestions(parts);
      } else {
        return this.getCommandSuggestions(parts, context);
      }
    }
  • Helper method for suggesting option completions and values based on partial option name and command context.
    private getOptionSuggestions(parts: string[]): CommandSuggestion[] {
      const suggestions: CommandSuggestion[] = [];
      const lastPart = parts[parts.length - 1];
      const optionName = lastPart.replace(/^--?/, '');
      
      // Find the command these options belong to
      const commandParts = parts.filter(part => !part.startsWith('--'));
      const command = this.parser.findCommand(commandParts);
      
      if (!command?.options) {
        return suggestions;
      }
    
      // Suggest matching options
      command.options.forEach(option => {
        if (option.name.startsWith(optionName)) {
          const fullCommand = commandParts.join(' ');
          const completion = `playground ${fullCommand} --${option.name}`;
          
          suggestions.push({
            completion,
            description: option.description || '',
            type: 'option',
            score: this.calculateScore(option.name, optionName)
          });
    
          // If option has predefined values, suggest them too
          if (option.values) {
            option.values.forEach(value => {
              suggestions.push({
                completion: `${completion} ${value}`,
                description: `${option.description} (value: ${value})`,
                type: 'value',
                score: 0.9
              });
            });
          }
        }

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