rad_id
Retrieve the current node's Radicle ID for peer-to-peer code collaboration and repository management across Radicle and GitHub platforms.
Instructions
Get the current node's Radicle ID.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/radicle_mcp/server.py:207-218 (handler)The handler function for the 'rad_id' tool. It is decorated with @mcp.tool() for registration and executes the 'rad self' command using the shared run_rad_command helper to retrieve and return the current node's Radicle ID.@mcp.tool() async def rad_id() -> str: """ Get the current node's Radicle ID. """ result = await run_rad_command(["rad", "self"]) if result["success"]: return f"🆔 Your Radicle ID:\n{result['stdout']}" else: return f"❌ Failed to get Radicle ID: {result['stderr']}"
- src/radicle_mcp/server.py:37-85 (helper)Shared utility function used by the rad_id tool (and others) to execute Radicle 'rad' commands asynchronously, capturing stdout, stderr, return code, and handling errors.async def run_rad_command(command: List[str], cwd: Optional[str] = None) -> Dict[str, Any]: """ Run a rad command and return the result. Args: command: List of command arguments starting with 'rad' cwd: Working directory to run the command in Returns: Dictionary with stdout, stderr, and return_code """ try: # Ensure command starts with 'rad' if not command or command[0] != "rad": command = ["rad"] + command logger.info(f"Running command: {' '.join(command)}") process = await asyncio.create_subprocess_exec( *command, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE, cwd=cwd ) stdout, stderr = await process.communicate() return { "stdout": stdout.decode("utf-8").strip(), "stderr": stderr.decode("utf-8").strip(), "return_code": process.returncode, "success": process.returncode == 0 } except FileNotFoundError: return { "stdout": "", "stderr": "rad command not found. Please ensure Radicle is installed.", "return_code": 127, "success": False } except Exception as e: return { "stdout": "", "stderr": f"Error running command: {str(e)}", "return_code": 1, "success": False }