Skip to main content
Glama

mcp-clipboard

PyPI version Python versions License CI Coverage Downloads

pip downloads pipenv downloads pipx downloads uv downloads poetry downloads pdm downloads

linux downloads macos downloads windows downloads

An MCP server that gives your AI assistant direct access to your system clipboard: read what you copied, or write clean text straight to it. Works with any MCP-compatible client, including Claude Code, Claude Desktop, Cursor, Windsurf, and others.

Why This Exists

Pasting loses structure

When you copy cells from Google Sheets or Excel and paste into a chat input, the tabular structure (rows and columns) is destroyed. It arrives as a flat string with no delimiters. The model has to guess where one cell ends and the next begins, and it often guesses wrong.

mcp-clipboard preserves it. Instead of pasting, tell your assistant to "read my clipboard." The server reads the clipboard directly, detects tabular data from the HTML that spreadsheet apps put on the clipboard, and returns it as a properly formatted Markdown table, JSON, or CSV. No structure lost, no guessing.

Bonus: it also fixes copying from Claude Code

Claude Code's terminal renderer adds 2-character padding, hard line breaks at ~80 columns, and trailing whitespace to all output. When you select and copy text from the terminal, those artifacts come along for the ride:

  echo "this is a long command that wraps and
  breaks when you paste it because of the hard
  newlines and leading spaces"

This has been reported repeatedly on the claude-code repo (issues #4686, #6827, #7670, #13378, #15199, #25040, #25427, #26016) with dozens of upvotes and no fix shipped.

mcp-clipboard sidesteps the problem entirely. Instead of copying text from the terminal, ask Claude Code to put it on your clipboard:

"Copy that command to my clipboard"

Claude Code calls clipboard_copy, writes the clean text directly to your system clipboard, and you paste it wherever you need it. No padding, no hard wraps, no cleanup.

Tip: To make this automatic, add a line to your project or global CLAUDE.md:

When you produce a shell command for the user to run, also copy it to the clipboard using clipboard_copy.

Claude Code will then copy every command it suggests without you having to ask.

Related MCP server: Clipboard MCP

Tools

Tool

Description

clipboard_paste

Primary tool. Read any clipboard content: tables, text, code, JSON, URLs, images. Tables are formatted as Markdown/JSON/CSV; pass include_schema=true to append inferred column types. Images are returned as image content the model can see.

clipboard_copy

Write content to the system clipboard. Accepts an optional mime_type parameter (text/plain by default; also text/html, text/rtf, or any text/* on Wayland/X11).

clipboard_list_formats

List what MIME types are currently on the clipboard.

clipboard_read_raw

Return raw clipboard content for a given MIME type — supports text formats plus image/svg+xml, application/json, application/xml (diagnostic).

Setup

Prerequisites

Python 3.11+ and one of: uv (recommended), pipx, or pip.

You also need a platform-specific clipboard tool:

Platform

Tool

Install

Fedora / RHEL (Wayland)

wl-copy / wl-paste

sudo dnf install wl-clipboard

Ubuntu / Debian (Wayland)

wl-copy / wl-paste

sudo apt install wl-clipboard

Linux (X11)

xclip

sudo dnf install xclip or sudo apt install xclip

macOS

Built-in

No install needed (pbcopy / pbpaste)

Windows

Built-in

No install needed (PowerShell)

Platform status: Linux with Wayland is tested and actively used. X11, macOS, and Windows implementations are complete but untested on real hardware. Bug reports and PRs are welcome.

Claude Code

claude mcp add clipboard --scope user -- uvx mcp-clipboard

Claude Desktop

Add to your Claude Desktop config:

  • Linux: ~/.config/Claude/claude_desktop_config.json

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

  • Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "clipboard": {
      "command": "uvx",
      "args": ["mcp-clipboard"]
    }
  }
}

Other MCP clients

Any client that supports MCP stdio servers can use mcp-clipboard. The simplest approach is uvx mcp-clipboard. Consult your client's documentation for how to register MCP servers.

Installing from source

If you prefer a local clone instead of installing from PyPI:

git clone https://github.com/cmeans/mcp-clipboard.git
cd mcp-clipboard
uv sync

Then point your client at the local install:

{
  "mcpServers": {
    "clipboard": {
      "command": "uv",
      "args": [
        "run",
        "--directory", "/path/to/mcp-clipboard",
        "mcp-clipboard"
      ]
    }
  }
}

Environment variables

Environment variables can be passed via the "env" key in the config.

Variable

Platform

Purpose

Default

MCP_CLIPBOARD_DEBUG

All

Enable debug logging (1 to enable)

Off

WAYLAND_DISPLAY

Linux (Wayland)

Compositor socket name or absolute path

Auto-detected

XDG_RUNTIME_DIR

Linux (Wayland)

Directory containing the Wayland socket

/run/user/<uid>

XDG_SESSION_TYPE

Linux

Session type hint (wayland or x11)

Auto-detected via socket scan

Most Linux users won't need to set any of these. Override if auto-detection fails (multiple compositors, non-standard socket path, or containerized environments).

Usage

Reading your clipboard

Copy anything (spreadsheet cells, code, text, a URL, JSON, an image), then:

  • "Paste my clipboard"

  • "Read my clipboard"

  • "What's on my clipboard?"

  • "I copied some data, take a look"

Your assistant calls clipboard_paste and returns the content with structure preserved.

Writing to your clipboard

When your agent generates a command, code block, or any text you need to use elsewhere:

  • "Copy that to my clipboard"

  • "Put that command on my clipboard"

  • "Copy that as HTML" (writes text/html so rich-text apps paste with formatting)

The agent calls clipboard_copy and the clean text goes straight to your system clipboard. No terminal rendering artifacts, just clean text. This is especially useful with Claude Code (see above).

Tip: auto-copy behavior. By default the agent only copies to the clipboard when you ask. If you want commands and code blocks copied automatically, add this to your system prompt (e.g. in a Claude Desktop project or Claude Code's CLAUDE.md):

When you output a command or code block that the user is likely to paste elsewhere, proactively copy it to the clipboard using clipboard_copy.

Table output formats

When the clipboard contains tabular data, output_format controls the format:

Format

Destination

What you get

markdown

Claude, GitHub, most tools

GFM pipe table (default)

notion

Notion

GFM pipe table (Notion renders these natively)

slack

Slack

*bold* header + space-aligned data in a monospace code block

jira

Jira

||Header|| / |Cell| wiki markup

confluence

Confluence

same as jira (shared wiki syntax)

html

Email, web, rich-text editors

<table> with <thead>/<th>/<tbody>/<td>

json

APIs, code

Array of objects keyed by header row

csv

Excel, data tools

Comma-separated values

Examples:

  • "Read my clipboard as Slack" → output_format=slack

  • "Convert my clipboard to Jira table" → output_format=jira

  • "Give me that as HTML" → output_format=html

Table schema inference

Add include_schema=true to get a column-type summary alongside the table:

"Read my clipboard with schema"

Inferred types: integer, float, currency, percentage, date, boolean, text. Uses majority-wins per column — if no type accounts for more than half the non-empty cells, the column is typed as text. Empty cells are skipped; the header row is excluded from inference.

This is useful when handing tabular data to Claude for SQL CREATE TABLE statements, Pandas dtype mappings, or validation rules — Claude gets the types upfront instead of guessing from the data.

Tips for reliable triggering

The server includes MCP instructions that tell the client when to use the clipboard tools, but results vary by model and client. If the agent doesn't pick up on your intent, be explicit: "copy that to my clipboard" or "read what I copied" work most reliably.

If you have access to a custom system prompt (e.g. in a Claude Desktop project or a custom agent), you can reinforce the behavior:

When the user asks to copy output, use clipboard_copy to write it to the system clipboard. When the user references data not in the conversation, check the clipboard using clipboard_paste.

Content handling

Content type

What happens

Spreadsheet table

Parsed from HTML/TSV, returned in your choice of format (Markdown, JSON, CSV, Slack, Jira, HTML, Notion)

JSON

Pretty-printed in a JSON code block

Code

Returned in a fenced code block

URL

Returned cleanly as a URL

Rich HTML (no table)

HTML tags stripped, readable text returned

RTF

Returned in a fenced code block (macOS, Windows, and Wayland/X11 via pass-through)

Plain text

Returned as-is

Images (PNG, etc.)

Returned as an MCP image content block the model can see and analyze

SVG

Readable as text via clipboard_read_raw with image/svg+xml, or returned as image via clipboard_paste

Audio / video

Not supported; returns a message identifying the format

How It Works

  1. Platform detection: At startup, the server detects your clipboard backend (Wayland, X11, macOS, or Windows) and selects the appropriate system commands.

  2. Reading (clipboard_paste): Calls the platform's clipboard read command. Tries text/html first (Google Sheets and Excel put <table> markup on the clipboard), parses with Python's built-in html.parser. Falls back to text/plain tab-separated values, then text/rtf, then checks for images.

  3. Writing (clipboard_copy): Pipes text to the platform's clipboard write command (wl-copy, xclip -selection clipboard, pbcopy, or PowerShell Set-Clipboard). Supports a mime_type parameter for writing typed content (e.g. text/html, text/rtf).

  4. Image passthrough: If the clipboard contains an image (PNG, etc.), it's returned as a base64-encoded MCP image content block that the model can see and analyze.

  5. Content classification: Non-tabular text content is classified as JSON, URL, code, or plain text and returned with appropriate formatting (pretty-printed JSON, fenced code blocks, etc.).

Limitations

  • Audio and video are not supported. If the clipboard contains audio or video, the server reports the format but cannot return the content.

  • Clipboard write supports text MIME types only. clipboard_copy can write text/plain, text/html, and text/rtf. Writing images or other binary data is not supported.

  • Writing multiple MIME types atomically is not supported on Wayland/X11. For example, writing both text/html and text/plain in a single clipboard operation requires owning the clipboard selection across calls.

  • Text content is truncated at 50KB to avoid overwhelming the model's context window.

  • X11, macOS, and Windows are untested on real hardware. Implementations are complete and should work, but edge cases are possible. Bug reports and PRs are welcome.

Development

# Install with dev dependencies
uv sync --extra dev

# Run tests
uv run pytest

# Run the server directly (stdio mode)
uv run mcp-clipboard

# Run with debug logging
uv run mcp-clipboard --debug

# Test with MCP Inspector
uv run mcp dev src/mcp_clipboard/server.py

Debug logging can also be enabled via MCP_CLIPBOARD_DEBUG=1, which is useful when the server is launched by Claude Desktop or Claude Code.

Project structure

mcp-clipboard/
├── src/mcp_clipboard/
│   ├── __init__.py          # Package version
│   ├── server.py            # MCP server, tool definitions, debug logging
│   ├── clipboard.py         # Platform-agnostic clipboard backend
│   ├── parser.py            # HTML table parser, formatters, content detection
│   ├── instructions/        # Tool and server descriptions (loaded at startup)
│   │   ├── server.md
│   │   ├── clipboard_copy.md
│   │   ├── clipboard_paste.md
│   │   ├── clipboard_read_raw.md
│   │   └── clipboard_list_formats.md
│   └── icons/               # SVG icons for MCP client display (light/dark)
│       ├── mcp-clipboard-logo-light.svg
│       └── mcp-clipboard-logo-dark.svg
├── tests/
│   ├── test_parser.py       # Parser and formatter tests
│   └── test_server.py       # Server, backend, and Wayland detection tests
├── .github/
│   ├── workflows/
│   │   ├── publish.yml      # PyPI publish on v* tags (OIDC trusted publisher)
│   │   └── test-publish.yml # TestPyPI publish on test-v* tags
│   └── ISSUE_TEMPLATE/      # Bug report, feature request, platform test forms
├── pyproject.toml
├── CHANGELOG.md
├── CLAUDE.md                # Claude Code project guidance
├── LICENSE                  # Apache 2.0
└── README.md

Acknowledgments

This project was designed and built in collaboration with Claude Code (Anthropic's CLI for Claude). Architecture, design decisions, and release management were driven by the human; implementation, testing, code review, and documentation were delegated conversationally, with Claude writing code, catching stale docs, and filling test coverage gaps across every commit.

License

Apache 2.0. See LICENSE.

Available Tools

7 tools
clipboard_copyA
DestructiveIdempotent

Copy text to the user's system clipboard. Replaces whatever is currently on the clipboard with the provided content.

WHEN TO CALL THIS TOOL:

Call this tool when the user says "copy this", "put this on my clipboard", "copy to clipboard", "send to clipboard", or any phrase that implies writing content to the clipboard.

Also call this tool when you have produced formatted output (cleaned-up JSON, a markdown table, reformatted code, an HTML table, etc.) and the user wants to use it outside the conversation — copying to clipboard lets them paste it elsewhere.

Args: content: The text to place on the clipboard. Any string is accepted. mime_type: MIME type for the clipboard content (default: "text/plain"). Use "text/html" to write HTML that applications can paste as rich text. Use "text/rtf" to write RTF content. Use "image/svg+xml" to write an SVG; SVG is XML, so it rides this text-write path rather than clipboard_copy_image. Binary image MIME types (image/png, image/jpeg, etc.) and audio/* / video/* are rejected — for PNG or JPEG, use clipboard_copy_image. Note: On Wayland and X11, any text/* MIME type is accepted, plus image/svg+xml. On macOS and Windows, only text/plain, text/html, text/rtf, and image/svg+xml are supported.

Returns: A confirmation message with the number of characters copied and the MIME type written.

Inputs: content (required), mime_type. Returns: result

clipboard_copy_imageA
DestructiveIdempotent

Write an image to the user's system clipboard. Replaces whatever is currently on the clipboard with the provided image so it can be pasted into other applications (Slack, Gmail, Figma, image editors, etc.).

WHEN TO CALL THIS TOOL:

Call this tool when the user says "copy this image", "put this on my clipboard", or any phrase that implies writing an image to the clipboard.

Also call it when you have produced or fetched an image (a chart, a screenshot, a generated image) and the user wants to paste it elsewhere. For text content, use clipboard_copy instead.

Args: image_data: Base64-encoded image bytes. The same encoding that clipboard_paste returns for image content can be passed back in. mime_type: Either "image/png" or "image/jpeg". Pass-through, no re-encoding. The image header is verified against the declared MIME type to catch mismatches.

Returns: A confirmation message with the byte count and the MIME type written.

Limits: The image must not exceed MCP_CLIPBOARD_MAX_IMAGE_BYTES (default 10 MB). Set the env var to raise the limit.

Inputs: image_data (required), mime_type. Returns: result

clipboard_copy_markdownA
DestructiveIdempotent

Render markdown to HTML and place both formats on the system clipboard so the user can paste rich text into apps that prefer formatted content (Slack, Gmail, Notion, Word, Google Docs, Discord) AND plain markdown into apps that prefer source (text editors, terminals).

WHEN TO CALL THIS TOOL:

Call this tool when the user wants formatted output to paste into a rich-text target — bulleted lists, headings, links, code, bold/italic emphasis. Examples: "summarize these emails as a list and copy it", "copy this as formatted text", "put this on my clipboard so I can paste it into Slack with formatting", "give me a markdown bullet list and copy it."

For plain text without formatting intent, use clipboard_copy instead.

Args: text: Markdown source. Standard CommonMark syntax (headings, lists, emphasis, code blocks, links, etc.) is rendered to HTML. Raw HTML tags in the source are escaped, not passed through — if you need to write hand-crafted HTML, call clipboard_copy with mime_type="text/html" instead.

Returns: A confirmation message with the input character count and the rendered HTML byte count.

Platform behavior: - macOS and Windows: both text/html and text/plain (the markdown source) land on the clipboard atomically. Each paste target picks the format it prefers — Slack/Gmail/Notion get the rendered HTML; vim/terminal/text editors get the markdown source. - Wayland: wl-copy is single-MIME-per-invocation, so only text/html is set explicitly. However, wl-copy auto-advertises text/plain (and the X-style aliases UTF8_STRING/STRING/TEXT) for UTF-8 content, and the bytes returned for those targets are the rendered HTML markup — NOT the markdown source. A vim user pasting after this tool runs will see <h1>Title</h1>... etc. To get the markdown source on the clipboard, call clipboard_copy with the markdown source directly. - X11: xclip -target text/html -i does NOT auto-advertise additional targets, so apps that only read text/plain see an empty clipboard. Same workaround: call clipboard_copy with the markdown source for a plain-text paste.

Inputs: text (required). Returns: result

clipboard_list_formatsA
Read-onlyIdempotent

List the MIME types / formats currently on the system clipboard. Diagnostic tool — use clipboard_paste to actually read and return clipboard content.

Lists what formats are present. For spreadsheet data, you want to see "text/html" (best) or "text/plain" (fallback with tab-separated values).

Args: selection: Which buffer to list. Defaults to "clipboard". Pass "primary" to list formats on the X11/Wayland PRIMARY selection. macOS and Windows have no PRIMARY analog and will return an error if "primary" is passed.

Returns: A list of available clipboard formats.

Inputs: selection. Returns: result

clipboard_pasteA
Read-onlyIdempotent

Paste clipboard contents. Reads the user's system clipboard and returns the content. This is the primary clipboard tool.

WHEN TO CALL THIS TOOL:

Call this tool when the user says "paste", "paste it", "paste the data", "what's on my clipboard", "read my clipboard", "read what I copied", "what did I copy", "show clipboard", "from my clipboard", "use what I copied", "I copied something", "check my clipboard", or ANY phrase that implies reading from or pasting from the clipboard.

Also call this tool when the user references data that is NOT present in the conversation — for example: "format this list" but no list was given, "clean up this JSON" but no JSON is in the message, "here's a table" but no table was provided, "analyze this data" with nothing attached. In these cases, the data is likely on the clipboard. Check it BEFORE asking the user to provide the data manually.

Do NOT ask the user to paste or provide data — just call this tool.

Handles any clipboard content: tables (from spreadsheets, HTML), plain text, code, JSON, URLs, rich text, and images. Tables are auto-detected and formatted per output_format. Non-tabular content is returned with smart formatting. Images on the clipboard are returned directly as image content.

Args: output_format: Format for table data (case-insensitive). Only applies when the clipboard contains a table. Ignored for non-tabular content. Options: - "markdown" (default): GitHub-flavored Markdown table - "json": Array of objects keyed by header row - "csv": Comma-separated values - "slack": monospace code block with dashed-underline header row (avoids Slack mrkdwn escaping issues) - "jira": ||Header|| / |Cell| wiki markup (also works for Confluence) - "confluence": same as jira - "html": with /// - "notion": GFM pipe table (Notion renders these natively) include_schema: When True and the clipboard contains a table, append a column-type schema table after the data. Inferred types: integer, float, currency, percentage, date, boolean, text. Defaults to False. selection: Which buffer to read. Defaults to "clipboard" (the standard Ctrl-C / Cmd-C clipboard). Pass "primary" to read the X11 PRIMARY selection (middle-click / select-text-to-paste buffer) or the analogous Wayland primary selection. macOS and Windows have no PRIMARY analog and will return an error if "primary" is passed.

Returns: The clipboard content, formatted appropriately for the content type. Images are returned as image content (base64-encoded) for visual analysis.

Inputs: selection, output_format, include_schema.

clipboard_read_rawA
Read-onlyIdempotent

Read raw clipboard content in a specific MIME format. Diagnostic tool only — use clipboard_paste instead for normal clipboard access.

This tool returns the clipboard content as-is without any parsing or restructuring. Use clipboard_list_formats first to see what MIME types are available.

Supports any non-binary MIME type. The most common values are text/* types, plus image/svg+xml (text-readable despite the image/ prefix). application/* types pass through as well (application/json, application/xml, application/xhtml+xml, etc.) because the only blocked prefixes are image/, audio/, video/, and the exact type application/octet-stream. Binary MIME types are rejected; use clipboard_paste for images.

Args: mime_type: The MIME type to read from the clipboard. Common values: "text/plain", "text/html", "image/svg+xml", "application/json" selection: Which buffer to read. Defaults to "clipboard". Pass "primary" to read the X11/Wayland PRIMARY selection (middle-click buffer). macOS and Windows have no PRIMARY analog and will return an error if "primary" is passed.

Returns: The raw clipboard content in the requested format, or an error message.

Inputs: mime_type, selection. Returns: result

clipboard_versionA
Read-onlyIdempotent

Return the version of mcp-clipboard currently running.

Use this when you need to record or report which mcp-clipboard build is serving the current MCP session — for example, in test harnesses, diagnostic dumps, or when the user asks which version is installed. The version is read from the package metadata at runtime, so it always matches the wheel actually serving the call.

Returns: A dict with keys "name" (always "mcp-clipboard") and "version" (the installed version string, e.g. "2.6.1"). If the package metadata cannot be located (uninstalled source checkout), returns "0.0.0+dev" as the version.

Inputs: no named parameters. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.5/5.0

    Scored across 7 tools

    Disambiguation4/5

    The read/write split is clear, and copy vs copy_image vs copy_markdown are well distinguished by content type. clipboard_paste vs clipboard_read_raw have the most overlap, but descriptions explicitly frame read_raw as a diagnostic-only escape hatch, reducing confusion.

    Naming Consistency4/5

    Nearly all tools follow a clean clipboard_<verb>_<noun> pattern (paste, read_raw, list_formats, copy, copy_image, copy_markdown). clipboard_version is a minor deviation since it drops the verb, but it remains readable and predictable.

    Tool Count4/5

    Seven tools is a well-scoped set for clipboard operations. Most earn their place, though clipboard_version is borderline trivial and could arguably be folded into diagnostics.

    Completeness5/5

    The surface covers the full lifecycle: read (paste/raw/list_formats), write text, write rich text/markdown, write images, plus version introspection. No obvious gaps in clipboard read/write workflows.

    Maintenance

    ActivityMaintained
    ResponsivenessLimited data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      An MCP server that gives Claude and other AI assistants access to your Maccy clipboard history, allowing search, retrieval, and management of copied content through natural conversation.
      9
      MIT
    • F
      license
      A
      quality
      D
      maintenance
      A Windows-native MCP server that enables users to paste images, Excel tables, rich text, and plain text directly into Claude via a dedicated popup interface. It supports multi-item management and format conversion to streamline sharing complex clipboard data with the model.
      1
      -