Skip to main content
Glama

robot_camera

Control robot cameras to get live feeds, adjust angles, capture images, and manage video streams for monitoring and visual data collection.

Instructions

Robot camera and visual feed control portmanteau.

PORTMANTEAU PATTERN: Consolidates camera operations into a single tool.

SUPPORTED OPERATIONS:

  • get_camera_feed: Get live camera feed (physical Scout camera)

  • get_virtual_camera: Get Unity camera view from robot perspective

  • set_camera_angle: Adjust camera angle

  • capture_image: Capture still image

  • start_streaming: Start video stream

  • stop_streaming: Stop video stream

  • get_camera_status: Get camera status and settings

Args: robot_id: Robot identifier (e.g., "scout_01", "vbot_scout_01"). action: Camera operation to perform. angle_x: Camera angle X (pitch) in degrees for set_camera_angle. angle_y: Camera angle Y (yaw) in degrees for set_camera_angle. output_path: Output file path for capture_image. stream_url: Stream URL for start_streaming.

Returns: Dictionary containing operation result with image data or stream info.

Examples: Get camera feed: result = await robot_camera(robot_id="scout_01", action="get_camera_feed")

Capture image: result = await robot_camera( robot_id="scout_01", action="capture_image", output_path="C:/Images/scout_capture.jpg" ) Set camera angle: result = await robot_camera( robot_id="scout_01", action="set_camera_angle", angle_x=10.0, angle_y=0.0 )

Input Schema

NameRequiredDescriptionDefault
robot_idYes
actionYes
angle_xNo
angle_yNo
output_pathNo
stream_urlNo

Input Schema (JSON Schema)

{ "properties": { "action": { "enum": [ "get_camera_feed", "get_virtual_camera", "set_camera_angle", "capture_image", "start_streaming", "stop_streaming", "get_camera_status" ], "type": "string" }, "angle_x": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "default": null }, "angle_y": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "default": null }, "output_path": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null }, "robot_id": { "type": "string" }, "stream_url": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null } }, "required": [ "robot_id", "action" ], "type": "object" }

Implementation Reference

  • Primary handler function for the 'robot_camera' MCP tool. Handles all camera actions (get_feed, set_angle, capture, streaming, status) for both physical and virtual robots by routing to specialized handlers.
    @self.mcp.tool() async def robot_camera( robot_id: str, action: Literal[ "get_camera_feed", "get_virtual_camera", "set_camera_angle", "capture_image", "start_streaming", "stop_streaming", "get_camera_status", ], angle_x: Optional[float] = None, angle_y: Optional[float] = None, output_path: Optional[str] = None, stream_url: Optional[str] = None, ) -> Dict[str, Any]: """Robot camera and visual feed control portmanteau. PORTMANTEAU PATTERN: Consolidates camera operations into a single tool. SUPPORTED OPERATIONS: - get_camera_feed: Get live camera feed (physical Scout camera) - get_virtual_camera: Get Unity camera view from robot perspective - set_camera_angle: Adjust camera angle - capture_image: Capture still image - start_streaming: Start video stream - stop_streaming: Stop video stream - get_camera_status: Get camera status and settings Args: robot_id: Robot identifier (e.g., "scout_01", "vbot_scout_01"). action: Camera operation to perform. angle_x: Camera angle X (pitch) in degrees for set_camera_angle. angle_y: Camera angle Y (yaw) in degrees for set_camera_angle. output_path: Output file path for capture_image. stream_url: Stream URL for start_streaming. Returns: Dictionary containing operation result with image data or stream info. Examples: Get camera feed: result = await robot_camera(robot_id="scout_01", action="get_camera_feed") Capture image: result = await robot_camera( robot_id="scout_01", action="capture_image", output_path="C:/Images/scout_capture.jpg" ) Set camera angle: result = await robot_camera( robot_id="scout_01", action="set_camera_angle", angle_x=10.0, angle_y=0.0 ) """ try: robot = self.state_manager.get_robot(robot_id) if not robot: return format_error_response( f"Robot {robot_id} not found", error_type="not_found", robot_id=robot_id, action=action, ) # Route to appropriate handler if robot.is_virtual: return await self._handle_virtual_camera(robot, action, angle_x, angle_y, output_path, stream_url) else: return await self._handle_physical_camera(robot, action, angle_x, angle_y, output_path, stream_url) except Exception as e: return handle_tool_error("robot_camera", e, robot_id=robot_id, action=action)
  • Registration of the RobotCameraTool instance by calling its register() method during server initialization.
    self.robot_camera.register() # Portmanteau: camera and visual feed control
  • Helper function handling virtual (Unity) robot camera operations by proxying calls to unity3d-mcp tools like execute_unity_method on RobotCamera class.
    async def _handle_virtual_camera( self, robot: Any, action: str, angle_x: Optional[float], angle_y: Optional[float], output_path: Optional[str], stream_url: Optional[str], ) -> Dict[str, Any]: """Handle virtual robot camera.""" try: if robot.platform == "unity" and "unity" in self.mounted_servers: async with Client(self.mcp) as client: if action == "get_virtual_camera": # Call Unity RobotCamera.GetCameraFeed() result = await client.call_tool( "execute_unity_method", { "class_name": "RobotCamera", "method_name": "GetCameraFeed", "parameters": { "robotId": robot.robot_id, }, }, ) return format_success_response( f"Virtual camera feed retrieved for {robot.robot_id}", robot_id=robot.robot_id, action=action, data=result, ) elif action == "set_camera_angle": # Call Unity RobotCamera.SetCameraAngle() result = await client.call_tool( "execute_unity_method", { "class_name": "RobotCamera", "method_name": "SetCameraAngle", "parameters": { "robotId": robot.robot_id, "angleX": angle_x or 0.0, "angleY": angle_y or 0.0, }, }, ) return format_success_response( f"Camera angle set for {robot.robot_id}", robot_id=robot.robot_id, action=action, data=result, ) elif action == "capture_image": # Call Unity RobotCamera.CaptureImage() result = await client.call_tool( "execute_unity_method", { "class_name": "RobotCamera", "method_name": "CaptureImage", "parameters": { "robotId": robot.robot_id, "outputPath": output_path or "", }, }, ) return format_success_response( f"Image captured for {robot.robot_id}", robot_id=robot.robot_id, action=action, data=result, ) elif action == "start_streaming": # Call Unity RobotCamera.StartStreaming() result = await client.call_tool( "execute_unity_method", { "class_name": "RobotCamera", "method_name": "StartStreaming", "parameters": { "robotId": robot.robot_id, "streamUrl": stream_url or "", }, }, ) return format_success_response( f"Streaming started for {robot.robot_id}", robot_id=robot.robot_id, action=action, data=result, ) elif action == "stop_streaming": # Call Unity RobotCamera.StopStreaming() result = await client.call_tool( "execute_unity_method", { "class_name": "RobotCamera", "method_name": "StopStreaming", "parameters": { "robotId": robot.robot_id, }, }, ) return format_success_response( f"Streaming stopped for {robot.robot_id}", robot_id=robot.robot_id, action=action, data=result, ) elif action == "get_camera_status": # Call Unity RobotCamera.GetCameraStatus() result = await client.call_tool( "execute_unity_method", { "class_name": "RobotCamera", "method_name": "GetCameraStatus", "parameters": { "robotId": robot.robot_id, }, }, ) return format_success_response( f"Camera status retrieved for {robot.robot_id}", robot_id=robot.robot_id, action=action, data=result, ) else: # get_camera_feed for virtual = get_virtual_camera return await self._handle_virtual_camera(robot, "get_virtual_camera", None, None, None, None) else: # Mock camera for testing logger.info("Mock camera", robot_id=robot.robot_id, action=action) return format_success_response( f"Mock camera: {action} for {robot.robot_id}", robot_id=robot.robot_id, action=action, data={"note": "Mock mode - Unity not available", "mock_image": "base64_encoded_mock_image"}, ) except Exception as e: return handle_tool_error("_handle_virtual_camera", e, robot_id=robot.robot_id, action=action)
  • Placeholder helper for physical robot camera operations (TODO: ROS integration).
    async def _handle_physical_camera( self, robot: Any, action: str, angle_x: Optional[float], angle_y: Optional[float], output_path: Optional[str], stream_url: Optional[str], ) -> Dict[str, Any]: """Handle physical robot camera.""" # TODO: Implement ROS-based camera control (sensor_msgs/Image topics) logger.info("Physical robot camera", robot_id=robot.robot_id, action=action) return format_success_response( f"Physical robot camera: {action} for {robot.robot_id}", robot_id=robot.robot_id, action=action, data={"note": "Physical robot camera not yet implemented (requires ROS integration)"}, )
  • The register() method of RobotCameraTool that defines and registers the tool handler using @self.mcp.tool() decorator.
    def register(self): """Register robot camera tool with MCP server."""

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/sandraschi/robotics-mcp'

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