agregar_habitacion
Add a new room to your smart home system by specifying its type (dining room, kitchen, bathroom, living room, or bedroom). The system automatically names and tracks rooms, supporting up to six total rooms for device management.
Instructions
Crea una nueva habitación en el sistema.
Args: room_type: tipo de habitación (comedor, cocina, baño, living, dormitorio)
Returns: Confirmación de creación con el nombre generado de la habitación.
Restricciones: - Máximo 6 habitaciones en el sistema - Solo tipos permitidos: comedor, cocina, baño, living, dormitorio - El sistema numera automáticamente (ej: si ya existe "dormitorio", crea "dormitorio 2")
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| room_type | Yes |
Implementation Reference
- servers/mcp_rooms.py:169-185 (handler)MCP tool handler and registration for 'agregar_habitacion'. Defines the tool function signature (schema), docstring with validation details, and delegates execution to storage.add_room.@mcp.tool() def agregar_habitacion(room_type: str) -> dict: """ Crea una nueva habitación en el sistema. Args: room_type: tipo de habitación (comedor, cocina, baño, living, dormitorio) Returns: Confirmación de creación con el nombre generado de la habitación. Restricciones: - Máximo 6 habitaciones en el sistema - Solo tipos permitidos: comedor, cocina, baño, living, dormitorio - El sistema numera automáticamente (ej: si ya existe "dormitorio", crea "dormitorio 2") """ return storage.add_room(room_type)
- storage.py:71-90 (helper)Supporting utility method in storage class that implements the core room addition logic: validates room limits and type, generates unique room name, persists the new Room object to JSON file.def add_room(self, room_type: str) -> dict: """Crea una nueva habitación.""" self.reload() # Sincronizar con archivo if len(self.rooms) >= self.MAX_ROOMS: raise ValueError(f"Máximo {self.MAX_ROOMS} habitaciones") # Validar que el tipo sea permitido if room_type not in self.ALLOWED_ROOM_TYPES: raise ValueError(f"Tipo de habitación '{room_type}' no válido. Tipos permitidos: {', '.join(self.ALLOWED_ROOM_TYPES)}") # Generar nombre único con numeración count = sum(1 for room in self.rooms.values() if room.type == room_type) if count == 0: room_name = room_type else: room_name = f"{room_type} {count + 1}" self.rooms[room_name] = Room(name=room_name, type=room_type) self._save_to_file() return {"room": room_name, "type": room_type, "status": "created"}