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

build_line

Create straight lines of blocks between two points in Minecraft Bedrock Edition. Customize start and end coordinates to build paths, fences, bridges, or supports with specific materials like stone or wood.

Instructions

Build a straight line of blocks between two points. Perfect for paths, roads, fences, bridges, pillars, or structural frameworks. Example: from (0,64,0) to (10,80,10) creates a diagonal line useful for building supports or artistic structures

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionNoBuild action to performbuild
materialNoBlock type to build the line with (e.g. stone, cobblestone, wood, concrete)minecraft:stone
x1YesStarting X coordinate (east-west position where line begins)
x2YesEnding X coordinate (east-west position where line ends)
y1YesStarting Y coordinate (height where line begins, typically 64 for ground level)
y2YesEnding Y coordinate (height where line ends, can be different for slopes/ramps)
z1YesStarting Z coordinate (north-south position where line begins)
z2YesEnding Z coordinate (north-south position where line ends)

Implementation Reference

  • BuildLineTool class: defines the 'build_line' tool with name, description, inputSchema, and the full execute handler method that computes line positions using Bresenham algorithm via calculateLinePositions, validates limits, and builds using executeBuildWithOptimization.
    export class BuildLineTool extends BaseTool {
        readonly name = 'build_line';
        readonly description = 'Build a straight line of blocks between two points. Perfect for paths, roads, fences, bridges, pillars, or structural frameworks. Example: from (0,64,0) to (10,80,10) creates a diagonal line useful for building supports or artistic structures';
        readonly inputSchema: InputSchema = {
            type: 'object',
            properties: {
                action: {
                    type: 'string',
                    description: 'Build action to perform',
                    enum: ['build'],
                    default: 'build'
                },
                x1: {
                    type: 'number',
                    description: 'Starting X coordinate (east-west position where line begins)'
                },
                y1: {
                    type: 'number',
                    description: 'Starting Y coordinate (height where line begins, typically 64 for ground level)'
                },
                z1: {
                    type: 'number',
                    description: 'Starting Z coordinate (north-south position where line begins)'
                },
                x2: {
                    type: 'number',
                    description: 'Ending X coordinate (east-west position where line ends)'
                },
                y2: {
                    type: 'number',
                    description: 'Ending Y coordinate (height where line ends, can be different for slopes/ramps)'
                },
                z2: {
                    type: 'number',
                    description: 'Ending Z coordinate (north-south position where line ends)'
                },
                material: {
                    type: 'string',
                    description: 'Block type to build the line with (e.g. stone, cobblestone, wood, concrete)',
                    default: 'minecraft:stone'
                }
            },
            required: ['x1', 'y1', 'z1', 'x2', 'y2', 'z2']
        };
    
        /**
         * 直線構造物を建築します
         * 
         * @param args - 建築パラメータ
         * @param args.x1 - 開始点のX座標(東西方向の位置)
         * @param args.y1 - 開始点のY座標(高さ、通常64が地上レベル)
         * @param args.z1 - 開始点のZ座標(南北方向の位置)
         * @param args.x2 - 終了点のX座標(東西方向の位置)
         * @param args.y2 - 終了点のY座標(高さ、斜面の場合は異なる高さ可)
         * @param args.z2 - 終了点のZ座標(南北方向の位置)
         * @param args.material - 使用するブロック素材(デフォルト: "minecraft:stone")
         * @returns 建築実行結果
         * 
         * @throws Y座標が範囲外の場合(-64から320の範囲外)
         * @throws 線の長さが制限を超える場合(100ブロック超過)
         * @throws ブロック数が制限を超える場合(100ブロック超過)
         * 
         * @example
         * ```typescript
         * // 縦方向の橋を建築
         * const result = await tool.execute({
         *   x1: 50, y1: 65, z1: 0,
         *   x2: 50, y2: 75, z2: 20,
         *   material: "cobblestone"
         * });
         * 
         * if (result.success) {
         *   console.log(`直線建築完了: ${result.data.blocksPlaced}ブロック配置`);
         * }
         * ```
         */
        async execute(args: {
            action?: string;
            x1: number;
            y1: number;
            z1: number;
            x2: number;
            y2: number;
            z2: number;
            material?: string;
        }): Promise<ToolCallResult> {
            try {
                const { action = 'build', x1, y1, z1, x2, y2, z2, material = 'minecraft:stone' } = args;
                
                // actionパラメータをサポート(現在は build のみ)
                if (action !== 'build') {
                    return this.createErrorResponse(`Unknown action: ${action}. Only 'build' is supported.`);
                }
                
                // 座標の整数化
                const start = {
                    x: Math.floor(x1),
                    y: Math.floor(y1),
                    z: Math.floor(z1)
                };
                const end = {
                    x: Math.floor(x2),
                    y: Math.floor(y2),
                    z: Math.floor(z2)
                };
                
                // Y座標の検証
                if (start.y < -64 || start.y > 320 || end.y < -64 || end.y > 320) {
                    return {
                        success: false,
                        message: 'Y coordinates must be between -64 and 320'
                    };
                }
                
                // ブロックIDの正規化
                let blockId = material;
                if (!blockId.includes(':')) {
                    blockId = `minecraft:${blockId}`;
                }
                
                // 直線の長さを計算
                const distance = Math.sqrt(
                    Math.pow(end.x - start.x, 2) + 
                    Math.pow(end.y - start.y, 2) + 
                    Math.pow(end.z - start.z, 2)
                );
                
                if (distance > 100) {
                    return {
                        success: false,
                        message: 'Line too long (maximum 100 blocks)'
                    };
                }
                
                // 直線の座標を計算
                const positions = calculateLinePositions(start, end);
                
                if (positions.length > BUILD_LIMITS.LINE) {
                    return {
                        success: false,
                        message: `Too many blocks to place (maximum ${BUILD_LIMITS.LINE.toLocaleString()})`
                    };
                }
                
                // Socket-BE APIを使用してブロック配置
                if (!this.world) {
                    return { success: false, message: 'World not available. Ensure Minecraft is connected.' };
                }
    
                try {
                    // 最適化されたビルド実行
                    const result = await executeBuildWithOptimization(
                        this.world,
                        positions,
                        blockId,
                        {
                            type: 'line',
                            from: start,
                            to: end,
                            material: blockId,
                            apiUsed: 'Socket-BE'
                        }
                    );
                    
                    if (!result.success) {
                        return {
                            success: false,
                            message: result.message
                        };
                    }
    
                    return {
                        success: true,
                        message: result.message,
                        data: result.data
                    };
                } catch (error) {
                    return {
                        success: false,
                        message: `Building error: ${error instanceof Error ? error.message : String(error)}`
                    };
                }
    
            } catch (error) {
                return {
                    success: false,
                    message: `Error building line: ${error instanceof Error ? error.message : String(error)}`
                };
            }
        }
    }
  • Input schema defining parameters for build_line: coordinates (x1,y1,z1 to x2,y2,z2), material, and action.
    readonly inputSchema: InputSchema = {
        type: 'object',
        properties: {
            action: {
                type: 'string',
                description: 'Build action to perform',
                enum: ['build'],
                default: 'build'
            },
            x1: {
                type: 'number',
                description: 'Starting X coordinate (east-west position where line begins)'
            },
            y1: {
                type: 'number',
                description: 'Starting Y coordinate (height where line begins, typically 64 for ground level)'
            },
            z1: {
                type: 'number',
                description: 'Starting Z coordinate (north-south position where line begins)'
            },
            x2: {
                type: 'number',
                description: 'Ending X coordinate (east-west position where line ends)'
            },
            y2: {
                type: 'number',
                description: 'Ending Y coordinate (height where line ends, can be different for slopes/ramps)'
            },
            z2: {
                type: 'number',
                description: 'Ending Z coordinate (north-south position where line ends)'
            },
            material: {
                type: 'string',
                description: 'Block type to build the line with (e.g. stone, cobblestone, wood, concrete)',
                default: 'minecraft:stone'
            }
        },
        required: ['x1', 'y1', 'z1', 'x2', 'y2', 'z2']
    };
  • src/server.ts:494-573 (registration)
    Registration loop in registerModularTools(): iterates over tools array (including BuildLineTool), converts schema to Zod, and calls mcpServer.registerTool for each tool.name ('build_line'), wrapping tool.execute.
    this.tools.forEach((tool) => {
      // inputSchemaをZod形式に変換(SchemaToZodConverterを使用)
      const zodSchema = schemaConverter.convert(tool.inputSchema);
    
      // ツールを登録
      this.mcpServer.registerTool(
        tool.name,
        {
          title: tool.name,
          description: tool.description,
          inputSchema: zodSchema,
        },
        async (args: any) => {
          try {
            const result = await tool.execute(args);
    
            let responseText: string;
    
            if (result.success) {
              // 建築ツールの場合は最適化
              if (tool.name.startsWith('build_')) {
                const optimized = optimizeBuildResult(result);
                responseText = `✅ ${optimized.message}`;
                if (optimized.summary) {
                  responseText += `\n\n📊 Summary:\n${JSON.stringify(optimized.summary, null, 2)}`;
                }
              } else {
                // 通常ツールの場合
                responseText = result.message || `Tool ${tool.name} executed successfully`;
                if (result.data) {
                  // データサイズチェック
                  const dataStr = JSON.stringify(result.data, null, 2);
                  const sizeWarning = checkResponseSize(dataStr);
    
                  if (sizeWarning) {
                    // 大きすぎる場合はデータタイプのみ表示
                    responseText += `\n\n${sizeWarning}`;
                    responseText += `\nData type: ${Array.isArray(result.data) ? `Array[${result.data.length}]` : typeof result.data}`;
                  } else {
                    responseText += `\n\nData: ${dataStr}`;
                  }
                }
              }
            } else {
              // エラーメッセージにヒントを追加
              const errorMsg = result.message || "Tool execution failed";
              const enrichedError = enrichErrorWithHints(errorMsg);
              responseText = `❌ ${enrichedError}`;
              if (result.data) {
                responseText += `\n\nDetails:\n${JSON.stringify(result.data, null, 2)}`;
              }
            }
    
            return {
              content: [
                {
                  type: "text",
                  text: responseText,
                },
              ],
            };
          } catch (error) {
            const errorMsg =
              error instanceof Error ? error.message : String(error);
            const errorStack = error instanceof Error ? error.stack : undefined;
    
            const exceptionMessage = `Tool execution failed with exception: ${errorMsg}${errorStack ? `\n\nStack trace:\n${errorStack}` : ""}`;
    
            return {
              content: [
                {
                  type: "text",
                  text: `❌ ${exceptionMessage}`,
                },
              ],
            };
          }
        }
      );
    });
  • src/server.ts:359-372 (registration)
    Instantiation of BuildLineTool added to the tools array in initializeTools(), which is then registered in the MCP server.
      // Advanced Building ツール(高レベル建築機能)
      new BuildCubeTool(), // ✅ 完全動作
      new BuildLineTool(), // ✅ 完全動作
      new BuildSphereTool(), // ✅ 完全動作
      new BuildCylinderTool(), // ✅ 修正済み
      new BuildParaboloidTool(), // ✅ 基本動作
      new BuildHyperboloidTool(), // ✅ 基本動作
      new BuildRotateTool(), // ✅ 基本動作
      new BuildTransformTool(), // ✅ 基本動作
      new BuildTorusTool(), // ✅ 修正完了
      new BuildHelixTool(), // ✅ 修正完了
      new BuildEllipsoidTool(), // ✅ 修正完了
      new BuildBezierTool(), // ✅ 新規追加(可変制御点ベジェ曲線)
    ];
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 mentions what the tool does ('build a straight line of blocks') but lacks critical behavioral details such as whether it overwrites existing blocks, requires specific permissions, has rate limits, or what happens on execution failure. The example adds some context but doesn't cover operational traits.

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

Conciseness4/5

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

The description is appropriately sized with two sentences: the first states the core purpose with examples, and the second provides a concrete example with coordinates. It's front-loaded with the main functionality, though the example could be slightly more concise. Every sentence adds value without redundancy.

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

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (8 parameters, no output schema, no annotations), the description is adequate but incomplete. It explains what the tool does and provides an example, but lacks behavioral transparency, error handling information, and output expectations. For a building tool with multiple parameters, more operational context would be beneficial.

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%, providing comprehensive parameter documentation. The description adds minimal value beyond the schema by mentioning 'blocks' and giving an example coordinate range, but doesn't explain parameter interactions, constraints, or provide additional semantic context. This meets the baseline for high schema coverage.

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

Purpose5/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 with a specific verb ('build') and resource ('straight line of blocks between two points'), distinguishing it from sibling tools like build_cube or build_sphere by focusing exclusively on linear construction. It provides concrete examples of applications (paths, roads, fences, etc.) that reinforce its distinct functionality.

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

Usage Guidelines4/5

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

The description implicitly suggests usage contexts through examples ('Perfect for paths, roads, fences, bridges...'), but does not explicitly state when to choose this tool over alternatives like build_cube or build_cylinder. It provides a clear example of a diagonal line use case, offering practical guidance without naming specific sibling tools or exclusion criteria.

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

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