MCP Clipboard Server

MCP Clipboard Server

A high-performance server that provides clipboard access for AI assistants, specifically designed to solve the VSCode + WSL2 image clipboard limitation when using Claude.

Category
访问服务器

README

MCP Clipboard Server

Go Version License: MIT MCP Compatible

A high-performance, lock-free Model Context Protocol (MCP) server that provides clipboard access for AI assistants. Specifically designed to solve the VSCode + WSL2 image clipboard limitation when using Claude.

🎯 Problem Solved

VSCode + WSL2 + Claude Image Clipboard Issue: When running Claude in VSCode on Windows with WSL2, pasting images from the clipboard doesn't work due to the sandboxed environment. This MCP server provides a bridge to access Windows clipboard content (including images) from within the WSL2 environment.

✨ Features

  • 🔒 Lock-free concurrent design - High performance with zero race conditions
  • 🖼️ Image clipboard support - PNG, JPEG, GIF, WebP, BMP detection and handling
  • 🛡️ WSL2 compatibility - Seamless Windows clipboard access from WSL2
  • 📁 Large content handling - Automatic temp file creation for content >25KB
  • 🔄 Real-time monitoring - Clipboard change notifications
  • 🧹 Smart cleanup - TTL-based temp file management
  • 🚀 Race condition free - Comprehensive atomic operations and CAS loops
  • 🔍 Rich debugging - Detailed error context and optional debug logging

🚀 Quick Start

NPM Installation (Recommended)

npm install -g @standardbeagle/mcp-clip

Go Installation

go install github.com/standardbeagle/mcp-clip@latest

Manual Installation

git clone https://github.com/standardbeagle/mcp-clip.git
cd mcp-clip
go build -o mcp-clip
sudo cp mcp-clip /usr/local/bin/

📋 Claude Desktop Configuration

Add to your Claude Desktop claude_desktop_config.json:

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

Config file locations:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

🔧 VSCode + WSL2 Setup

1. Install in WSL2

# In your WSL2 terminal
npm install -g @standardbeagle/mcp-clip

2. Configure Claude Code Extension

Add to your VSCode settings or workspace .vscode/settings.json:

{
  "claude-dev.mcpServers": {
    "clipboard": {
      "command": "mcp-clip",
      "args": []
    }
  }
}

3. WSL2 PowerShell Access

Ensure PowerShell is accessible from WSL2:

# Test PowerShell access
/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -Command "Get-Clipboard"

🛠️ Available Tools

read_clipboard

Reads current clipboard content with automatic format detection.

Example usage in Claude:

"Read my clipboard and analyze the content"

Supported formats:

  • Plain text
  • Images (PNG, JPEG, GIF, WebP, BMP)
  • Binary data (base64 encoded)

Large content handling:

  • Content >25KB automatically saved to temp files
  • Images always saved as files with proper extensions
  • File paths provided for external access

📊 Resource Notifications

The server sends real-time notifications when clipboard content changes:

{
  "method": "notifications/resources/updated",
  "params": {
    "uri": "clipboard://current"
  }
}

This allows Claude to proactively know when new content is available without polling.

⚙️ Configuration

Environment Variables

  • MCP_DEBUG=1 - Enable detailed debug logging
  • MCP_CLEANUP_TTL=2h - Set temp file cleanup TTL (default: 1h)

Debug Mode

MCP_DEBUG=1 mcp-clip

Shows detailed information about:

  • Clipboard monitoring status
  • Temp file creation and cleanup
  • WSL2 PowerShell integration
  • Race condition fallbacks (extremely rare)

🧪 Testing

Test Installation

mcp-clip test

Development Testing

# Run tests with race detector
go test -race -v ./...

# Build with race detector
go build -race .

🏗️ Architecture

Lock-Free Design

  • Atomic operations for all shared state
  • Compare-and-swap loops with retry limits
  • Zero mutexes in hot paths
  • Race-condition free under all loads

Concurrency Safety

  • Atomic clipboard state updates
  • Thread-safe session file tracking
  • Graceful shutdown with cleanup
  • TOCTOU-safe temp file creation

Platform Integration

  • WSL2: PowerShell bridge for Windows clipboard
  • Linux: Direct clipboard integration via atotto/clipboard
  • macOS: Native clipboard support
  • Windows: Native clipboard support

🔧 Troubleshooting

WSL2 Issues

PowerShell not found:

# Install Windows PowerShell in WSL2
sudo apt update && sudo apt install powershell

Permission denied:

# Add Windows PowerShell to PATH
echo 'export PATH="/mnt/c/Windows/System32/WindowsPowerShell/v1.0:$PATH"' >> ~/.bashrc
source ~/.bashrc

Clipboard empty in WSL2:

# Test Windows clipboard access
powershell.exe "Get-Clipboard" 

General Issues

MCP connection failed:

  • Verify mcp-clip is in your PATH
  • Check Claude Desktop config JSON syntax
  • Restart Claude Desktop after config changes

Large images not working:

  • Check available disk space in temp directory
  • Verify temp directory permissions
  • Enable debug mode: MCP_DEBUG=1

Performance issues:

  • Monitor with debug mode enabled
  • Check for antivirus interference
  • Verify WSL2 resource allocation

📝 Development

Building from Source

git clone https://github.com/standardbeagle/mcp-clip.git
cd mcp-clip
go mod download
go build -race .

Running Tests

go test -race -v ./...

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Run tests: go test -race -v ./...
  4. Submit a pull request

📄 License

MIT License - see LICENSE file for details.

🙏 Acknowledgments

🔗 Links

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选