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"]
                }
            )
        ]
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool executes a command and shares output, implying potential side effects or permissions needed, but doesn't specify execution context (e.g., local vs. remote), security implications, error handling, or output format. This leaves significant gaps for a tool that likely involves system interactions.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core functionality without unnecessary details. Every word earns its place by clearly stating the tool's purpose, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of executing and sharing commands, lack of annotations, and no output schema, the description is incomplete. It doesn't address critical aspects like what 'execute' entails (e.g., shell commands, permissions), how output is shared (e.g., format, size limits), or potential risks, leaving the agent with insufficient context for safe and effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, meaning all parameters are documented in the schema itself. The description adds no additional meaning beyond what the schema provides (e.g., it doesn't clarify parameter relationships or usage examples). Baseline 3 is appropriate as the schema handles the heavy lifting, but the description doesn't compensate with extra insights.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('execute a command and share output') and resource ('with another instance'), providing a specific verb+resource combination. However, it doesn't differentiate from sibling tools like 'send' or 'broadcast' which might have overlapping functionality, preventing a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'send' or 'broadcast' from the sibling list. It mentions the basic context of sharing with another instance but offers no exclusions, prerequisites, or comparative advice, leaving usage decisions ambiguous.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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