一个高性能、无锁的模型上下文协议(MCP)服务器,提供AI助手的剪贴板访问。特别设计用于解决在使用Claude时,VSCode与WSL2环境中的图像剪贴板限制问题。
VSCode + WSL2 + Claude图像剪贴板问题:当在Windows上的VSCode中运行Claude并使用WSL2时,由于沙盒环境的原因,从剪贴板粘贴图像不起作用。此MCP服务器提供了一个桥梁,使用户能够在WSL2环境中访问Windows剪贴板的内容(包括图像)。
npm install -g @standardbeagle/mcp-clip
go install github.com/standardbeagle/mcp-clip@latest
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桌面claude_desktop_config.json:
{
"mcpServers": {
"clipboard": {
"command": "mcp-clip",
"args": []
}
}
}
配置文件位置:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.json~/.config/Claude/claude_desktop_config.json# 在你的WSL2终端中
npm install -g @standardbeagle/mcp-clip
添加到你的VSCode设置或工作区.vscode/settings.json:
{
"claude-dev.mcpServers": {
"clipboard": {
"command": "mcp-clip",
"args": []
}
}
}
确保可以从WSL2访问PowerShell:
# 测试PowerShell访问
/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -Command "Get-Clipboard"
read_clipboard读取当前剪贴板内容,并自动检测格式。
在Claude中的示例用法:
"读取我的剪贴板并分析内容"
支持的格式:
大内容处理:
当剪贴板内容发生变化时,服务器会发送实时通知:
{
"method": "notifications/resources/updated",
"params": {
"uri": "clipboard://current"
}
}
这允许Claude主动知道何时有新的内容可用,而无需轮询。
MCP_DEBUG=1 - 启用详细调试日志MCP_CLEANUP_TTL=2h - 设置临时文件清理TTL(默认:1小时)MCP_DEBUG=1 mcp-clip
显示关于以下方面的详细信息:
mcp-clip test
# 使用竞态检测器运行测试
go test -race -v ./...
# 使用竞态检测器构建
go build -race .
未找到PowerShell:
# 在WSL2中安装Windows PowerShell
sudo apt update && sudo apt install powershell
权限被拒绝:
# 将Windows PowerShell添加到PATH
echo 'export PATH="/mnt/c/Windows/System32/WindowsPowerShell/v1.0:$PATH"' >> ~/.bashrc
source ~/.bashrc
WSL2中剪贴板为空:
# 测试Windows剪贴板访问
powershell.exe "Get-Clipboard"
MCP连接失败:
mcp-clip是否在您的PATH中大型图像无法工作:
MCP_DEBUG=1性能问题:
git clone https://github.com/standardbeagle/mcp-clip.git
cd mcp-clip
go mod download
go build -race .
go test -race -v ./...
go test -race -v ./...MIT许可证 - 详情见LICENSE文件。