Skip to main content
Glama

clear_region

Remove all puzzle tiles within a specified rectangular area to automatically solve that section of the level.

Instructions

Clear all tiles in a rectangular region. Auto-solves.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
x1YesTop-left X
y1YesTop-left Y
x2YesBottom-right X
y2YesBottom-right Y

Implementation Reference

  • The main handler function for clear_region tool. It gets the current draft, calculates the bounded rectangular region from x1,y1 to x2,y2, iterates through each position and calls draftStore.removeElement(), counts cleared positions, and returns a response with the count and auto-solved visualization.
    handler: async (args) => {
      const draft = draftStore.getCurrentDraft();
      if (!draft) return { content: [{ type: 'text', text: 'No active draft. Use create_level first.' }] };
      let cleared = 0;
      const minX = Math.max(1, Math.min(args.x1, args.x2));
      const maxX = Math.min(draft.gridWidth - 2, Math.max(args.x1, args.x2));
      const minY = Math.max(1, Math.min(args.y1, args.y2));
      const maxY = Math.min(draft.gridHeight - 2, Math.max(args.y1, args.y2));
      for (let y = minY; y <= maxY; y++) {
        for (let x = minX; x <= maxX; x++) {
          draftStore.removeElement(x, y);
          cleared++;
        }
      }
      const current = draftStore.getCurrentDraft()!;
      return { content: [{ type: 'text', text: `Cleared ${cleared} positions\n\n${autoSolveAndVisualize(current)}` }] };
    },
  • Input schema definition for clear_region tool. Defines an object with properties x1, y1, x2, y2 (all required numbers) representing the top-left and bottom-right coordinates of the rectangular region to clear.
    inputSchema: {
      type: 'object',
      properties: {
        x1: { type: 'number', description: 'Top-left X' },
        y1: { type: 'number', description: 'Top-left Y' },
        x2: { type: 'number', description: 'Bottom-right X' },
        y2: { type: 'number', description: 'Bottom-right Y' },
      },
      required: ['x1', 'y1', 'x2', 'y2'],
    },
  • Tool definition object for clear_region, including name, description, inputSchema, and handler. This is part of the array returned by getTileOperationTools() function that registers all tile operation tools.
      name: 'clear_region',
      description: 'Clear all tiles in a rectangular region. Auto-solves after clear.',
      inputSchema: {
        type: 'object',
        properties: {
          x1: { type: 'number', description: 'Top-left X' },
          y1: { type: 'number', description: 'Top-left Y' },
          x2: { type: 'number', description: 'Bottom-right X' },
          y2: { type: 'number', description: 'Bottom-right Y' },
        },
        required: ['x1', 'y1', 'x2', 'y2'],
      },
      handler: async (args) => {
        const draft = draftStore.getCurrentDraft();
        if (!draft) return { content: [{ type: 'text', text: 'No active draft. Use create_level first.' }] };
        let cleared = 0;
        const minX = Math.max(1, Math.min(args.x1, args.x2));
        const maxX = Math.min(draft.gridWidth - 2, Math.max(args.x1, args.x2));
        const minY = Math.max(1, Math.min(args.y1, args.y2));
        const maxY = Math.min(draft.gridHeight - 2, Math.max(args.y1, args.y2));
        for (let y = minY; y <= maxY; y++) {
          for (let x = minX; x <= maxX; x++) {
            draftStore.removeElement(x, y);
            cleared++;
          }
        }
        const current = draftStore.getCurrentDraft()!;
        return { content: [{ type: 'text', text: `Cleared ${cleared} positions\n\n${autoSolveAndVisualize(current)}` }] };
      },
    },
  • Helper function autoSolveAndVisualize() used by the clear_region handler. It exports puzzle data, solves it, updates the draft with solver result, renders the level with coordinates, and returns a formatted string with the visualization and solver info.
    function autoSolveAndVisualize(draft: DraftState): string {
      const puzzleData = draftStore.exportPuzzleData();
      if (puzzleData) {
        const result = solve(puzzleData);
        draftStore.updateDraft({ lastSolverResult: result, isDirty: false });
      }
      const current = draftStore.getCurrentDraft()!;
      const viz = renderLevel(current, { showCoords: true });
      const solverInfo = current.lastSolverResult ? formatSolverResult(current.lastSolverResult) : '';
      return `${viz}\n${solverInfo}`;
    }
Behavior3/5

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

With no annotations provided, the description carries full burden. It discloses the 'Auto-solves' behavior which is valuable context beyond basic clearing. However, it doesn't mention whether this is destructive (likely yes), permission requirements, rate limits, or what 'Auto-solves' specifically entails.

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?

Two concise sentences with zero waste. First sentence states core functionality, second adds crucial behavioral context. Perfectly front-loaded and appropriately sized.

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?

For a destructive operation with no annotations and no output schema, the description is minimal but functional. It covers the basic purpose and one behavioral trait, but lacks details about what 'Clear all tiles' means (what happens to different tile types), the 'Auto-solves' mechanism, or error conditions.

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 clear parameter documentation. The description adds no additional parameter information beyond what's in the schema. Baseline 3 is appropriate when schema does the heavy lifting.

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 specific action ('Clear all tiles'), target resource ('in a rectangular region'), and behavioral outcome ('Auto-solves'). It distinguishes from siblings like 'clear_level' (which clears entire level) and 'remove_tile' (which removes individual tiles).

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

Usage Guidelines3/5

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

The description implies usage for clearing rectangular regions and mentions auto-solving, but provides no explicit guidance on when to use this versus alternatives like 'clear_level', 'remove_tile', or 'fill_region'. No prerequisites or exclusions are mentioned.

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/wmoten/ice-puzzle-mcp'

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