Clipboard Mcp Server

io.github.cyanheads由 GitHub 帳號 cyanheads 發布v0.3.0更新於 Oct 29, 2026

Read, write, and inspect the system clipboard on macOS, Linux (X11/Wayland), and Windows via MCP.

已驗證STDIO僅桌面效率與工作流檔案與儲存

概覽

AI 產生的概覽

本機 MCP 伺服器,讓助理在 macOS、Linux 與 Windows 上讀取、寫入和檢視系統剪貼簿。

可以做什麼
  • 以文字、HTML、RTF 或圖片格式讀取剪貼簿內容,可自動選擇最豐富的格式,並對大內容以 offset/limit 分段讀取
  • 將純文字或 HTML 寫入剪貼簿以取代目前內容,或直接清空
  • 檢視目前可用的剪貼簿格式及各自位元組大小,而不必讀取完整內容
  • 寫入後回傳先前的純文字,方便還原不慎的覆寫
適用情境
適合在自己的桌面上讓助理在剪貼簿與對話之間搬移內容,例如把複製的文字或圖片交給助理處理,或把產生的文字、HTML 放到剪貼簿以便貼到別處。
執行需求
透過 npx 以本機程序執行(需 Bun 1.4.0+ 或 Node.js 24+)。需要平台剪貼簿工具:macOS 內建 osascript;Linux X11 需 xclip(清空另需 xsel);Linux Wayland 需 wl-clipboard;Windows 需 PowerShell 5.1+。選用變數涵蓋傳輸方式、HTTP 主機/連接埠/路徑、驗證模式、日誌等級與唯讀模式。
安裝前請注意
剪貼簿可能含有密碼、權杖等敏感資訊,讀取即會把內容交給助理,且失敗工具酬載日誌不會對剪貼簿內容中的機密進行遮蔽。寫入與清空會覆寫使用者已複製的內容,可啟用 CLIPBOARD_READ_ONLY 移除寫入工具。使用 HTTP 傳輸且 MCP_AUTH_MODE 為 none 時,端點沒有驗證保護。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Clipboard Mcp Server,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

@cyanheads/clipboard-mcp-server

Read, write, and inspect the system clipboard across macOS, Linux (X11/Wayland), and Windows via MCP. STDIO or Streamable HTTP.

3 Tools


Overview

The system clipboard across macOS, Linux (X11/Wayland), and Windows. Read, write, and inspect text, HTML, RTF, and image content.

Tools

ToolDescription
clipboard_readRead clipboard contents in a specified format (text, HTML, RTF, image, or auto-select richest)
clipboard_writeWrite plain text or HTML to the clipboard, replacing current contents, or clear it outright
clipboard_inspectList available clipboard formats and byte sizes without reading full content

Capability reference

clipboard_read tool

  • Read text, html, rtf, or image; auto selects the richest present format (image > html > rtf > text). Whole-read limits: 512 KB text/HTML/RTF, 5 MB image
  • Returns format, content, byte sizes, complete, and representationId; images are base64 PNG with optional width/height. Failures carry format_unavailable, content_too_large, representation_changed, clipboard_unavailable, or inspect_unreadable
  • For larger values, use byte offset/limit (minimum limit 4, capped per format), then pass each nextOffset as offset along with representationId until complete. Image slices are byte chunks: decode each separately and concatenate in order; only a whole image attaches an image block

clipboard_write tool

  • Supply non-empty content or clear: true, exclusively; format accepts text or html, with a 1 MB write limit. HTML gets a stripped plain-text fallback on macOS/Windows; Linux plain-text pastes can receive markup
  • Returns format/byteSize, or cleared: true with zero bytes; optional previousContent holds prior plain text within the 512 KB read limit. Failures carry content_too_large or clipboard_unavailable; X11 clear requires xsel
  • CLIPBOARD_READ_ONLY disables both writes and clears by removing the tool from tools/list

clipboard_inspect tool

  • Returns primaryFormat (image > html > rtf > text, or empty) and availableFormats for choosing a read format
  • rawTypes lists platform identifiers with measured bytes, or measurementFailed when unreadable. Failures carry inspect_unreadable or clipboard_unavailable

Features

Built on @cyanheads/mcp-ts-core: stdio and Streamable HTTP transports, pluggable auth (none / jwt / oauth), swappable storage (in-memory, filesystem, Supabase, Cloudflare KV/R2/D1), structured logging with optional OpenTelemetry tracing.

Clipboard-specific:

  • Cross-platform backend detection at startup — macOS (osascript/JXA), Linux X11 (xclip), Linux Wayland (wl-clipboard), Windows (PowerShell 5.1+)
  • Semantic format mapping — platform-native type identifiers (UTIs, TARGETS, Windows format names) mapped to text, html, rtf, image across all backends
  • Platform-aware HTML writes — macOS and Windows publish HTML plus a stripped plain-text fallback; on Linux the HTML is the only payload, which plain-text paste targets can also receive
  • Image support — every backend returns PNG as base64, with width/height when the returned bytes carry a readable PNG header (Linux backends read them from that header, so only a whole image or a slice starting at offset 0 has them)

Agent-friendly output:

  • Size-guarded I/O — reads and writes over the format limit fail with a typed content_too_large error carrying byte/limit metadata, rather than truncating silently
  • Bounded continuation — clipboard_read slices oversized content with offset/limit and nextOffset instead of forcing a single all-or-nothing read, and representationId makes a clipboard change between slices fail loudly instead of splicing two values together
  • Undo support — clipboard_write returns previousContent so an unintended overwrite can be reverted
  • Discriminated failure — format_unavailable, content_too_large, representation_changed, inspect_unreadable, and clipboard_unavailable are typed reasons with recovery hints, not generic errors; each backend classifies its helper's outcomes itself (across wl-clipboard and xclip release spellings), so an empty clipboard, an absent format, and an unreachable helper never blur together

Getting started

Add it to Claude Code:

sh
claude mcp add clipboard-mcp-server -- npx -y @cyanheads/clipboard-mcp-server

For other clients, add this to the MCP config file:

json
{  "mcpServers": {    "clipboard-mcp-server": {      "command": "npx",      "args": ["-y", "@cyanheads/clipboard-mcp-server"]    }  }}

Linux needs a clipboard helper installed first — see Prerequisites. For a source build or Streamable HTTP, see Running the server.


Configuration

VariableDescriptionDefault
MCP_TRANSPORT_TYPETransport: stdio or http.stdio
MCP_HTTP_PORTPort for HTTP server.3010
MCP_HTTP_HOSTHostname for HTTP server.127.0.0.1
MCP_HTTP_ENDPOINT_PATHEndpoint path for the HTTP server./mcp
MCP_HTTP_MAX_BODY_BYTESMax inbound JSON-RPC request body, in bytes. Raised above the framework's 1 MiB default so a full-size clipboard_write survives JSON escaping (worst case costs 6 wire bytes per source byte). 0 disables the guard and defers to the reverse proxy.7340032
MCP_SESSION_MODEHTTP session mode: auto, stateful, or stateless. auto resolves to stateful. This server defaults to stateless — it keeps no per-session state.stateless
MCP_AUTH_MODEAuth mode: none, jwt, or oauth.none
MCP_LOG_LEVELLog level (debug, info, notice, warning, error).info
LOG_TOOL_FAILURE_PAYLOADSLog failed tool arguments/results, capped at LOG_TOOL_FAILURE_PAYLOAD_MAX_BYTES (16384). Redaction is by key name; secrets inside clipboard content are not redacted.false
OTEL_ENABLEDEnable OpenTelemetry instrumentation.false
CLIPBOARD_READ_ONLYServe the clipboard read-only. When true, clipboard_write is absent from tools/list and uncallable, but listed as disabled in the server manifest, landing page, and startup log. Accepts true/false/1/0/yes/no/on/off; an unrecognized value fails startup.false

See .env.example for the full list of optional overrides.


Running the server

Prerequisites

Requires Bun v1.4.0 or higher (or Node.js v24+), plus the platform's clipboard helper:

macOS: No additional tools required — osascript is built in.

Linux X11: xclip must be installed. xsel is additionally required for clipboard_write's clear mode — it is the only one of the two that can hand the selection back rather than owning an empty one.

sh
apt install xclip xsel      # Debian/Ubuntupacman -S xclip xsel        # Arch

Linux Wayland: wl-clipboard must be installed.

sh
apt install wl-clipboard    # Debian/Ubuntupacman -S wl-clipboard      # Arch

Windows: PowerShell 5.1+ (built-in on Windows 10 and later).

Local development

  • Clone and install:

    sh
    git clone https://github.com/cyanheads/clipboard-mcp-server.gitcd clipboard-mcp-server && bun install
  • Build and run:

    sh
    # One-time buildbun run rebuild
    # Run the built serverbun run start:stdio# orbun run start:http   # listens at http://127.0.0.1:3010/mcp
  • Run checks and tests:

    sh
    bun run devcheck   # Lint, format, typecheck, securitybun run test       # Vitest test suitebun run lint:mcp   # Validate MCP definitions against spec

Project structure

PathPurpose
src/index.tsEntry point — registers tools via createApp()
src/mcp-server/tools/definitions/Tool definitions: clipboard_read, clipboard_write, clipboard_inspect
src/services/clipboard/Platform backends (macOS, Linux X11, Wayland, Windows) and service facade
tests/Vitest tests for tools and backends
framework-skills/Agent workflow skills (add-tool, field-test, polish-docs-meta, etc.)

Development guide

See CLAUDE.md for the full developer protocol — tool patterns, service patterns, error handling, logging conventions, and the checklist for shipping changes. The short version:

  • Handlers throw, framework catches — tool logic catches only to act on a backend's typed outcome: map it to a declared error reason, or move auto on to the next format
  • Use ctx.log for request-scoped logging
  • No Docker — this server needs direct host OS access (JXA/NSPasteboard, xclip, wl-clipboard, PowerShell), none of which work inside a container

Contributing

Issues welcome at github.com/cyanheads/clipboard-mcp-server. Run checks and tests before submitting:

sh
bun run devcheckbun run test

License

Apache 2.0 — see LICENSE.

來源:README.md,提交 047799a

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

5
  1. v0.3.0最新Oct 29, 2026
  2. v0.2.6Oct 7, 2026
  3. v0.2.5Sep 25, 2026
  4. v0.2.2Sep 20, 2026
  5. v0.2.1Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分