Skip to main content
Glama

edit_level_tile

Modify a specific tile in a VibeTide 2D platformer level by specifying its position and new tile type to customize level design.

Instructions

Edit a single tile in a VibeTide level.

Args: encoded_level: An encoded level string from a URL or sharing link row: Row index (0-based, from top) col: Column index (0-based, from left) new_tile_type: New tile type (0-7, see tile legend) Returns the modified level data with the single tile changed.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
encoded_levelYes
rowYes
colYes
new_tile_typeYes

Implementation Reference

  • The core handler function for the 'edit_level_tile' MCP tool. It decodes the input encoded level string, validates row, column, and new tile type parameters, modifies the specific tile in the 2D tiles array, re-encodes the level, generates a visualization and play URL, and returns the updated level data. The @mcp.tool() decorator handles both registration and schema definition via the docstring.
    @mcp.tool() async def edit_level_tile( encoded_level: str, row: int, col: int, new_tile_type: int ) -> Dict[str, Any]: """Edit a single tile in a VibeTide level. Args: encoded_level: An encoded level string from a URL or sharing link row: Row index (0-based, from top) col: Column index (0-based, from left) new_tile_type: New tile type (0-7, see tile legend) Returns the modified level data with the single tile changed. """ try: # Decode the level first try: level_data = level_encoder.decode(encoded_level) except Exception as e: return { "success": False, "error": f"Failed to decode level: {str(e)}", } tiles = level_data["tiles"] if not isinstance(tiles, list) or not tiles: return {"success": False, "error": "Invalid tiles array"} height = len(tiles) width = len(tiles[0]) if tiles else 0 # Validate coordinates if row < 0 or row >= height: return { "success": False, "error": f"Invalid row {row} - must be 0-{height-1}", } if col < 0 or col >= width: return { "success": False, "error": f"Invalid column {col} - must be 0-{width-1}", } # Validate tile type if new_tile_type < 0 or new_tile_type > 7: return { "success": False, "error": f"Invalid tile type {new_tile_type} - must be 0-7", } # Make the edit old_tile_type = tiles[row][col] tiles[row][col] = new_tile_type # Create new level data edited_level = level_data.copy() edited_level["tiles"] = tiles # Generate encoded version try: encoded_level = level_encoder.encode(edited_level) play_url = f"{VIBE_TIDE_CONFIG['web_player_url']}?level={encoded_level}" except Exception as e: logger.warning(f"Failed to encode edited level: {e}") encoded_level = None play_url = None # Generate visualization visualization = visualize_level(edited_level) old_tile_name = TILE_TYPES.get(old_tile_type, {"name": "Unknown"})["name"] new_tile_name = TILE_TYPES.get(new_tile_type, {"name": "Unknown"})["name"] return { "success": True, "level_data": edited_level, "encoded_level": encoded_level, "play_url": play_url, "visualization": visualization, "change_summary": f"Changed tile at ({row}, {col}) from {old_tile_name} to {new_tile_name}", "message": f"Successfully edited tile at position ({row}, {col})", } except Exception as e: logger.error(f"Failed to edit level tile: {e}") return {"success": False, "error": f"Failed to edit level tile: {str(e)}"}
  • The docstring of the handler defines the input schema (parameters: encoded_level (str), row (int), col (int), new_tile_type (int)) and output description for the MCP tool.
    """Edit a single tile in a VibeTide level. Args: encoded_level: An encoded level string from a URL or sharing link row: Row index (0-based, from top) col: Column index (0-based, from left) new_tile_type: New tile type (0-7, see tile legend) Returns the modified level data with the single tile changed. """
  • Global TILE_TYPES dictionary referenced in the handler for tile names and descriptions used in change_summary and validation context.
    TILE_TYPES = { 0: {"name": "Empty", "symbol": "⬜", "description": "Walkable air space"}, 1: {"name": "Grass", "symbol": "🌱", "description": "Standard ground platform"}, 2: {"name": "Rock", "symbol": "🗿", "description": "Solid stone platform"}, 3: {"name": "Yellow", "symbol": "⭐", "description": "Special yellow platform"}, 4: {"name": "Ice", "symbol": "❄️", "description": "Slippery ice platform"}, 5: {"name": "Red", "symbol": "🔥", "description": "Dangerous red platform"}, 6: {"name": "Spikes", "symbol": "⚠️", "description": "Hazardous spikes"}, 7: {"name": "Water", "symbol": "💧", "description": "Water tiles"}, }
  • Global instance of LevelEncoder class used by the handler for decoding and encoding level data.
    level_encoder = LevelEncoder()

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/banjtheman/vibe_tide_mcp'

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