Skip to main content
Glama
Mming-Lab
by Mming-Lab

execute_command

Run Minecraft commands directly through the MCP server to control gameplay, manipulate the world, and manage player actions in Minecraft Bedrock Edition.

Instructions

Execute a Minecraft command

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandYesThe Minecraft command to execute

Implementation Reference

  • src/server.ts:442-485 (registration)
    Registration of the 'execute_command' MCP tool, including schema definition (command: string) and handler function that calls executeCommand, optimizes result, adds hints, and formats MCP response.
    this.mcpServer.registerTool(
      "execute_command",
      {
        title: "Execute Command",
        description: "Execute a Minecraft command",
        inputSchema: {
          command: z.string().describe("The Minecraft command to execute"),
        },
      },
      async ({ command }: { command: string }) => {
        const result = await this.executeCommand(command);
    
        // トークン最適化: コマンド結果を要約
        const optimized = optimizeCommandResult(result.data);
    
        let responseText: string;
        if (result.success) {
          responseText = `✅ ${optimized.summary}`;
          if (optimized.details) {
            responseText += `\n\n${JSON.stringify(optimized.details, null, 2)}`;
          }
        } else {
          // エラーメッセージにヒントを追加
          const errorMsg = result.message || "Command execution failed";
          const enrichedError = enrichErrorWithHints(errorMsg);
          responseText = `❌ ${enrichedError}`;
        }
    
        // レスポンスサイズチェック
        const sizeWarning = checkResponseSize(responseText);
        if (sizeWarning) {
          responseText += `\n\n${sizeWarning}`;
        }
    
        return {
          content: [
            {
              type: "text",
              text: responseText,
            },
          ],
        };
      }
    );
  • Core handler logic for executing Minecraft commands via SocketBE World.runCommandAsync, handling world connection check and storing last response.
    public async executeCommand(command: string): Promise<ToolCallResult> {
      if (!this.currentWorld) {
        return { success: false, message: "No player connected" };
      }
    
      try {
        const result = await this.currentWorld.runCommand(command);
    
        // レスポンスをlastCommandResponseに保存(位置情報取得などで使用)
        this.lastCommandResponse = result;
    
        return {
          success: true,
          message: "Command executed successfully",
          data: result,
        };
      } catch (error) {
        return {
          success: false,
          message: `Command execution failed: ${error}`,
        };
      }
    }
  • BaseTool helper method for command execution, delegates to injected commandExecutor (server's executeCommand), used by modular tools.
    protected async executeCommand(command: string): Promise<ToolCallResult> {
        if (!this.commandExecutor) {
            return { success: false, message: 'Command executor not set' };
        }
        
        try {
            return await this.commandExecutor(command);
        } catch (error) {
            return { 
                success: false, 
                message: `Command execution error: ${error instanceof Error ? error.message : String(error)}` 
            };
        }
    }
  • Input schema definition for execute_command tool using Zod: command as required string.
    inputSchema: {
      command: z.string().describe("The Minecraft command to execute"),
    },
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. 'Execute a Minecraft command' implies a potentially powerful action but doesn't specify permissions required, whether commands are reversible, what happens on failure, or any rate limits. For a tool that could significantly alter game state, this is inadequate.

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 maximally concise - a single sentence that communicates the core function without any wasted words. It's appropriately sized for a tool with one parameter and good schema documentation.

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 that executes potentially powerful Minecraft commands with no annotations and no output schema, the description is insufficient. It doesn't explain what commands are valid, what permissions are needed, what happens on success/failure, or what the return value might be. Given the complexity of Minecraft command execution, more context is needed.

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?

Schema description coverage is 100%, with the single parameter 'command' clearly documented in the schema. The description doesn't add any additional parameter information beyond what the schema provides, such as command syntax examples or valid command types. Baseline 3 is appropriate when the schema does the heavy lifting.

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 action ('execute') and the resource ('a Minecraft command'), making the purpose immediately understandable. However, it doesn't differentiate this tool from its many siblings (like 'send_message', 'player', or 'world'), which all operate in the Minecraft context but perform different functions.

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 alternatives. With 18 sibling tools in the Minecraft ecosystem, there's no indication of whether this is for administrative commands, gameplay actions, or how it differs from tools like 'send_message' or 'player'.

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

  • @Mming-Lab/minecraft-bedrock-mcp-server
  • @yuniko-software/minecraft-mcp-server
  • @Mming-Lab/minecraft-bedrock-mcp-server
  • @Mming-Lab/minecraft-bedrock-mcp-server
  • @zeeweebee/mcp-server
  • @leo4life2/minecraft-mcp-http

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/Mming-Lab/minecraft-bedrock-mcp-server'

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