write_clipboard
Copy text to your macOS clipboard for easy pasting into other applications. This tool transfers provided text directly to your clipboard using the system's pbcopy command.
Instructions
Write the given text to the clipboard (macOS). Uses pbcopy.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes |
Implementation Reference
- server.py:78-89 (handler)The core handler function for the MCP 'write_clipboard' tool. It uses subprocess to pipe text into 'pbcopy' on macOS to update the clipboard. Decorated with @mcp.tool() for automatic registration and schema inference.@mcp.tool() def write_clipboard(text: str) -> str: """Write the given text to the clipboard (macOS). Uses `pbcopy`.""" try: completed = subprocess.run([ "bash", "-lc", "pbcopy" ], input=text, text=True, capture_output=True) if completed.returncode != 0: return f"❌ Failed to write clipboard (pbcopy exited {completed.returncode})." return "✅ Clipboard updated" except Exception as e: return f"❌ Error writing clipboard: {str(e)}"
- server.py:78-78 (registration)The @mcp.tool() decorator registers the write_clipboard function as an MCP tool, inferring schema from signature and docstring.@mcp.tool()
- lang_graph_client.py:28-32 (helper)LangGraph node that invokes the MCP write_clipboard tool as part of a workflow.async def node_write_clipboard(state: AppState) -> AppState: text = state.get("search_result", "") async with Client("server.py") as client: result = await client.call_tool("write_clipboard", {"text": text}) return {"clipboard_status": str(result)}
- lang_graph_client.py:54-54 (registration)Registers the node_write_clipboard as a node named 'write_clipboard' in the LangGraph workflow.graph.add_node("write_clipboard", node_write_clipboard)