get_programs
Retrieve all programs from a specific robot using IP, SSH username, and password. Facilitates program management on UR collaborative robots via nUR MCP Server.
Instructions
获取指定IP机器人的所有程序。 IP:机器人地址 username:ssh账号 password:ssh密码
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ip | Yes | ||
| password | No | easybot | |
| username | No | root |
Implementation Reference
- The handler function for the 'get_programs' tool. It connects to the robot via SSH, lists programs in /programs directory filtering for .urp files, and returns the list. Registered as an MCP tool using the @mcp.tool() decorator. The function signature and docstring define the input schema.@mcp.tool() def get_programs(ip: str, username='root', password='easybot'): """获取指定IP机器人的所有程序。 IP:机器人地址 username:ssh账号 password:ssh密码 """ try: ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(hostname=ip, port=22, username=username, password=password) # 创建交互式 shell shell = ssh.invoke_shell() # 执行多个命令 shell.send('cd /programs\n') shell.send('ls -1\n') # 获取输出 import time time.sleep(1) # 等待命令执行 output = shell.recv(65535).decode() ssh.close() files = [] for file in output.split('\n'): name = file.replace(' ', '').replace('\r', '') if name.endswith('.urp'): files.append(name) return return_msg(f"命令已发送:{str(files)}") except Exception as e: return return_msg(f"程序列表获取失败。{str(e)}")
- src/nonead_universal_robots_mcp/server.py:450-450 (registration)The @mcp.tool() decorator registers the get_programs function as an MCP tool with the name 'get_programs'.@mcp.tool()
- Input schema defined by function parameters (ip: str required, username and password with defaults) and docstring descriptions.def get_programs(ip: str, username='root', password='easybot'): """获取指定IP机器人的所有程序。 IP:机器人地址 username:ssh账号 password:ssh密码 """