Skip to main content
Glama

share_command

Execute commands and share results between Claude AI instances to coordinate tasks and exchange information.

Instructions

Execute a command and share output with another instance

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
from_idYesYour instance ID
to_idYesTarget instance ID
commandYesCommand to execute
descriptionNoDescription of what this command does

Implementation Reference

  • Executes the provided command using subprocess.run (shell=False, timeout=30s), captures stdout/stderr/returncode, packages into a structured message, and sends to target instance via the IPC 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}")]
  • Defines the JSON schema for input parameters to the share_command tool: requires from_id, to_id, command; optional description.
    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"] } ),
  • The share_command tool is registered by being included in the list returned by the list_tools() handler, which is decorated with @app.list_tools() for MCP server registration.
    @app.list_tools() async def list_tools() -> List[Tool]: """List available tools""" return [ Tool( name="register", description="Register this Claude instance with the IPC system", inputSchema={ "type": "object", "properties": { "instance_id": { "type": "string", "description": "Unique identifier for this instance (e.g., 'wsl1', 'wsl2')" } }, "required": ["instance_id"] } ), Tool( name="send", description="Send a message to another Claude instance", inputSchema={ "type": "object", "properties": { "from_id": { "type": "string", "description": "Your instance ID" }, "to_id": { "type": "string", "description": "Target instance ID" }, "content": { "type": "string", "description": "Message content" }, "data": { "type": "object", "description": "Optional structured data to send" } }, "required": ["from_id", "to_id", "content"] } ), Tool( name="broadcast", description="Broadcast a message to all other Claude instances", inputSchema={ "type": "object", "properties": { "from_id": { "type": "string", "description": "Your instance ID" }, "content": { "type": "string", "description": "Message content" }, "data": { "type": "object", "description": "Optional structured data" } }, "required": ["from_id", "content"] } ), Tool( name="check", description="Check for new messages", inputSchema={ "type": "object", "properties": { "instance_id": { "type": "string", "description": "Your instance ID" } }, "required": ["instance_id"] } ), Tool( name="list_instances", description="List all active Claude instances", inputSchema={ "type": "object", "properties": {} } ), Tool( name="share_file", description="Share file content with another instance", inputSchema={ "type": "object", "properties": { "from_id": { "type": "string", "description": "Your instance ID" }, "to_id": { "type": "string", "description": "Target instance ID" }, "filepath": { "type": "string", "description": "Path to file to share" }, "description": { "type": "string", "description": "Description of the file" } }, "required": ["from_id", "to_id", "filepath"] } ), 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( name="rename", description="Rename your instance ID (rate limited to once per hour)", inputSchema={ "type": "object", "properties": { "old_id": { "type": "string", "description": "Your current instance ID" }, "new_id": { "type": "string", "description": "The new instance ID you want" } }, "required": ["old_id", "new_id"] } ), Tool( name="auto_process", description="Automatically check and process IPC messages (for use with auto-check feature)", inputSchema={ "type": "object", "properties": { "instance_id": { "type": "string", "description": "Your instance ID" } }, "required": ["instance_id"] } ) ]

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/jdez427/claude-ipc-mcp'

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