connect_ur
Connect to Universal Robots collaborative robots using the robot's IP address. This tool establishes communication with industrial robots for control through voice or text commands.
Instructions
根据用户提供的IP连接UR IP:机器人地址
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ip | Yes |
Implementation Reference
- The handler and registration for the 'connect_ur' MCP tool. This function connects to a UR robot using the provided IP address, initializes the robot model and script extension, stores them in global dictionaries, and verifies the RTDE connection. The @mcp.tool() decorator registers it as a tool, with the function signature and docstring providing the input schema.@mcp.tool() def connect_ur(ip: str): """根据用户提供的IP连接UR IP:机器人地址""" try: host = ip global robot_list, robotModle_list if robot_list.get(ip, "unknown") != "unknown": robot_list[ip].robotConnector.close() return return_msg(f"优傲机器人连接失败: {ip}") robotModle = URBasic.robotModel.RobotModel() robot = URBasic.urScriptExt.UrScriptExt(host=host, robotModel=robotModle) robot_list[ip] = robot robotModle_list[ip] = robotModle if robot_list.get(ip, "unknown") == "unknown" or not robot_list[ ip].robotConnector.RTDE.isRunning(): return return_msg(f"优傲机器人连接失败: {ip}") logger.info(f"连接成功。IP:{host}") return return_msg(f"连接成功。IP:{host}") except Exception as e: logger.error(f"优傲机器人连接失败: {str(e)}") return return_msg(f"优傲机器人连接失败: {str(e)}")