Skip to main content
Glama

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
NameRequiredDescriptionDefault
commandYesCommand to execute
descriptionNoDescription of what this command does
from_idYesYour instance ID
to_idYesTarget instance ID

Implementation Reference

  • 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}")]
  • 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(
  • 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"] } ),

Other Tools

Related Tools

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