share_command
Execute and share command outputs between instances on the Claude IPC MCP server. Facilitates inter-process communication for efficient AI assistant collaboration.
Instructions
Execute a command and share output with another instance
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| command | Yes | Command to execute | |
| description | No | Description of what this command does | |
| from_id | Yes | Your instance ID | |
| to_id | Yes | Target instance ID |
Implementation Reference
- src/claude_ipc_server.py:1196-1242 (handler)The handler for the 'share_command' tool. Validates registration, parses and executes the command securely using subprocess.run (shell=False, timeout=30s), captures output/error/returncode, constructs an IPC message, and sends it to the target instance via the message broker.elif name == "share_command": if not current_session_token: return [TextContent(type="text", text="Error: Not registered. Please register first.")] try: import subprocess import shlex # Parse command safely to prevent injection try: cmd_args = shlex.split(arguments["command"]) except ValueError as e: return [TextContent(type="text", text=f"Invalid command format: {e}")] # Run without shell=True for security result = subprocess.run( cmd_args, shell=False, capture_output=True, text=True, timeout=30 # Add timeout to prevent hanging ) message = { "content": f"Command output: {arguments['command']}", "data": { "type": "command", "command": arguments["command"], "stdout": result.stdout, "stderr": result.stderr, "returncode": result.returncode, "description": arguments.get("description", "") } } response = BrokerClient.send_request({ "action": "send", "from_id": arguments["from_id"], "to_id": arguments["to_id"], "message": message, "session_token": current_session_token }) return [TextContent(type="text", text=f"Command output shared: {json.dumps(response, indent=2)}")] except Exception as e: return [TextContent(type="text", text=f"Error executing command: {e}")]
- src/claude_ipc_server.py:1019-1045 (registration)Registration of the 'share_command' tool in the MCP server's list_tools() function, including its name, description, and input schema definition.Tool( name="share_command", description="Execute a command and share output with another instance", inputSchema={ "type": "object", "properties": { "from_id": { "type": "string", "description": "Your instance ID" }, "to_id": { "type": "string", "description": "Target instance ID" }, "command": { "type": "string", "description": "Command to execute" }, "description": { "type": "string", "description": "Description of what this command does" } }, "required": ["from_id", "to_id", "command"] } ), Tool(
- src/claude_ipc_server.py:1022-1044 (schema)Input schema for the 'share_command' tool, defining parameters: from_id, to_id (required), command (required), and optional description.inputSchema={ "type": "object", "properties": { "from_id": { "type": "string", "description": "Your instance ID" }, "to_id": { "type": "string", "description": "Target instance ID" }, "command": { "type": "string", "description": "Command to execute" }, "description": { "type": "string", "description": "Description of what this command does" } }, "required": ["from_id", "to_id", "command"] } ),