agregar_habitacion
Add a new room to your smart home system by specifying room type (living room, kitchen, bathroom, bedroom, dining room). The system automatically numbers duplicate room names and maintains a maximum of 6 rooms.
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-186 (handler)MCP tool handler for 'agregar_habitacion', decorated with @mcp.tool(). Delegates to storage.add_room after implicit validation via the storage layer.@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-91 (helper)Core helper method implementing room creation logic: checks limits, validates room_type against ALLOWED_ROOM_TYPES, auto-generates unique room name, instantiates Room object, persists 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"}
- main.py:90-98 (registration)Registration of the MCP rooms server in MultiServerMCPClient configuration. This spawns the mcp_rooms.py process exposing the 'agregar_habitacion' tool via stdio transport.{ "mcp_rooms": { "transport": "stdio", "command": "uv", "args": [ "run", "./servers/mcp_rooms.py" ] },
- main.py:19-19 (schema)Schema description in the system prompt for the agent, specifying input parameter room_type and allowed values.- agregar_habitacion(room_type: str) → Tipos: "comedor", "cocina", "baño", "living", "dormitorio"