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 分