clipboard-mcp

samhann/clipboard-mcp

3.3

If you are the rightful owner of clipboard-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

An intelligent clipboard companion for AI assistants, transforming clipboard operations into a rich, persistent data source for smarter AI interactions.

Tools
  1. get_clipboard_contents

    Get current clipboard content

  2. copy_to_clipboard

    Copy text to clipboard

  3. get_clipboard_info

    Detailed clipboard metadata with URL detection

  4. search_clipboard_history

    Full-text search through clipboard history

  5. get_recent_clipboard_entries

    Recent items with smart filtering

๐Ÿ“‹ clipboard-mcp

An intelligent clipboard companion for AI assistants

Transform your clipboard into a powerful, searchable knowledge base that your AI can access and leverage. This enhanced Model Context Protocol (MCP) server turns simple copy-paste operations into a rich, persistent data source for smarter AI interactions.

Version Python License

๐ŸŒŸ What is clipboard-mcp?

clipboard-mcp is an enhanced MCP server that makes your clipboard intelligent and accessible to AI assistants like Claude in Cursor IDE. Instead of just basic copy-paste, it provides:

  • ๐Ÿง  Smart History: Every copied item is automatically saved and categorized
  • ๐Ÿ” Instant Search: Find any previously copied text, URL, or image instantly
  • ๐ŸŒ URL Intelligence: Automatically fetches and extracts content from copied links
  • ๐Ÿ“Š Usage Analytics: Track your clipboard patterns and most-used content
  • ๐Ÿ–ผ๏ธ Image Support: Handle copied images with full metadata
  • โšก Real-time: Background monitoring with zero user intervention required

๐ŸŽฏ Use Cases

For Developers

  • Code Snippet Library: Build a searchable database of copied code snippets
  • API Research: Copy API docs URLs and have full content available to your AI
  • Debug History: Keep track of error messages and stack traces you've copied
  • Documentation Mining: Extract and organize information from various sources

For Researchers & Writers

  • Research Collection: URLs you copy are automatically fetched and full-text indexed
  • Quote Database: Search through previously copied text passages
  • Reference Management: Build a knowledge base from copied academic content
  • Content Curation: Organize and retrieve copied content by topic or type

For AI-Assisted Workflows

  • Context Building: Your AI can access your entire clipboard history for better context
  • Dynamic References: AI can pull in previously copied URLs, code, or text mid-conversation
  • Pattern Recognition: AI can identify useful patterns in your clipboard usage
  • Smart Suggestions: Based on clipboard history, AI can suggest relevant past content

โœจ Features

๐Ÿ”ง Core Clipboard Operations

ToolDescription
get_clipboard_contentsGet current clipboard content
copy_to_clipboardCopy text to clipboard
get_clipboard_infoDetailed clipboard metadata with URL detection

๐Ÿ“š Enhanced History & Intelligence

ToolDescription
search_clipboard_historyFull-text search through clipboard history
get_recent_clipboard_entriesRecent items with smart filtering
get_clipboard_entryRetrieve specific entry with full metadata
get_url_entriesURLs with automatically fetched content
get_clipboard_statsUsage analytics and database insights

๐Ÿš€ Advanced Capabilities

  • ๐Ÿ—„๏ธ SQLite Persistence: Local database stores everything securely
  • ๐ŸŒ Intelligent URL Processing: Auto-fetches titles, descriptions, and full content
  • ๐Ÿ–ผ๏ธ Image Handling: Supports copied images with size and format detection
  • ๐Ÿ” Powerful Search: Find content across text, URLs, titles, and descriptions
  • ๐Ÿ“Š Usage Analytics: Track patterns and frequently used content
  • โšก Background Monitoring: Automatic real-time clipboard monitoring
  • ๐Ÿ”’ Privacy-First: All data stored locally, no cloud dependencies

๐Ÿš€ Quick Start

Installation

# Clone the repository
git clone https://github.com/samhann/clipboard-mcp.git
cd clipboard-mcp

# Install with dependencies
pip install -e .

Running the Server

# Using the startup script (recommended)
./scripts/run-server-quiet.sh

# Or directly with Python
python -m clipboard_mcp.server

# Or using the console script
clipboard-mcp

Testing Everything Works

# Run comprehensive tests
./scripts/test-server.sh

# Test specific functionality
python tests/test_enhanced_clipboard.py

๐Ÿ”ง Cursor IDE Integration

Add this MCP server to Cursor for seamless AI integration:

Step 1: Configuration

Create or edit ~/.cursor/mcp.json:

{
  "mcpServers": {
    "clipboard-mcp": {
      "command": "/absolute/path/to/clipboard-mcp/scripts/run-server-quiet.sh",
      "args": []
    }
  }
}

Step 2: Verify Setup

  1. Restart Cursor completely
  2. Go to Settings โ†’ MCP Servers
  3. Look for green indicator next to "clipboard-mcp"
  4. Verify "8 tools enabled" appears

Step 3: Start Using

Once configured, your AI can:

Ask: "What URLs have I copied recently?"
Ask: "Search my clipboard history for 'API key'"
Ask: "What's the most recent code I copied?"
Ask: "Show me clipboard statistics"

๐Ÿ“– Detailed Usage

Automatic Background Monitoring

The server automatically monitors your clipboard and:

  • Detects URLs and fetches their content in the background
  • Handles images copied from screenshots or image files
  • Deduplicates content to avoid storing the same thing twice
  • Tracks usage for analytics and optimization

Smart URL Processing

When you copy a URL like https://docs.python.org/3/library/json.html:

  1. Immediate Storage: URL is saved to history
  2. Background Fetch: Page content is downloaded asynchronously
  3. Content Extraction: Title, description, and main text extracted
  4. Search Integration: All content becomes searchable
  5. AI Access: Your AI can reference the full page content

Database Location

All data is stored locally in:

~/.clipboard-mcp/clipboard_history.db

๐Ÿ—๏ธ Architecture

graph TD
    A[Clipboard Monitor] --> B[SQLite Database]
    A --> C[URL Fetcher]
    C --> D[Content Extractor]
    D --> B
    E[MCP Server] --> B
    F[Cursor/AI] --> E
    G[Image Handler] --> B

๐Ÿ”ง Configuration Options

Alternative Cursor Configurations

Using Python directly:

{
  "mcpServers": {
    "clipboard-mcp": {
      "command": "/path/to/venv/bin/python",
      "args": ["-m", "clipboard_mcp.server"],
      "env": {
        "PYTHONPATH": "/path/to/clipboard-mcp/src"
      }
    }
  }
}

Using uv package manager:

{
  "mcpServers": {
    "clipboard-mcp": {
      "command": "uv", 
      "args": ["run", "--directory", "/path/to/clipboard-mcp", "python", "-m", "clipboard_mcp.server"]
    }
  }
}

๐Ÿงช Testing

Quick Validation

# Test server response
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{"tools":{}}}}' | ./scripts/run-server-quiet.sh

Comprehensive Testing

# Full test suite with database, URL fetching, and MCP protocol
./scripts/test-server.sh

Manual Testing

# Test individual components
python tests/test_enhanced_clipboard.py

๐Ÿ“Š Example AI Interactions

Once configured, you can have conversations like:

๐Ÿ” Search & Discovery:

You: "Find all the GitHub URLs I've copied this week"
AI: Uses search_clipboard_history and get_url_entries to find and display GitHub URLs with their repo descriptions

You: "What was that error message I copied earlier?"  
AI: Searches clipboard history for recent text entries containing error patterns

๐Ÿ“š Knowledge Retrieval:

You: "I copied a Stack Overflow link about async/await - what did it say?"
AI: Finds the URL entry and displays the full fetched content

You: "Show me all the API documentation I've collected"
AI: Filters URL entries for documentation sites and shows titles/descriptions

๐Ÿ“ˆ Analytics & Insights:

You: "What do I copy most often?"
AI: Uses get_clipboard_stats to show usage patterns

You: "How much clipboard data do I have stored?"
AI: Displays database statistics and storage information

๐Ÿ› ๏ธ Development

Project Structure

clipboard-mcp/
โ”œโ”€โ”€ src/clipboard_mcp/           # Main source code
โ”‚   โ”œโ”€โ”€ server.py               # MCP server implementation  
โ”‚   โ”œโ”€โ”€ database.py             # SQLite operations
โ”‚   โ”œโ”€โ”€ monitor.py              # Clipboard monitoring
โ”‚   โ”œโ”€โ”€ url_fetcher.py          # URL content extraction
โ”‚   โ””โ”€โ”€ schema.sql              # Database schema
โ”œโ”€โ”€ scripts/                    # Utility scripts
โ”‚   โ”œโ”€โ”€ run-server-quiet.sh     # Production server launcher
โ”‚   โ””โ”€โ”€ test-server.sh          # Test runner
โ”œโ”€โ”€ tests/                      # Comprehensive test suite
โ””โ”€โ”€ docs/                       # Documentation

Dependencies

Core:

  • pyperclip - Cross-platform clipboard access
  • aiosqlite - Async SQLite operations
  • aiohttp - Async HTTP client for URL fetching
  • beautifulsoup4 - HTML content extraction
  • pillow - Image processing (optional)

Development:

  • pytest + pytest-asyncio - Testing framework
  • black, isort, flake8 - Code formatting and linting

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes and add tests
  4. Run the test suite: ./scripts/test-server.sh
  5. Submit a pull request

๐Ÿ“ Troubleshooting

Common Issues

IssueSolution
"0 tools enabled" in CursorCheck absolute paths in config, restart Cursor
Database errorsDelete ~/.clipboard-mcp/clipboard_history.db to reset
Import errorsEnsure virtual environment activated: source venv/bin/activate
URL fetching failsCheck network connectivity, some sites block automated requests

Debug Mode

Enable verbose logging:

# Set environment variable before running
export CLIPBOARD_MCP_DEBUG=1
./scripts/run-server-quiet.sh

๐Ÿ“„ License

MIT License - see file for details.

๐Ÿ™ Acknowledgments

  • Built on the Model Context Protocol standard
  • Inspired by the need for smarter AI-human interaction workflows
  • Designed for seamless integration with Cursor IDE

โญ Star this repo if you find it useful!

Made with โค๏ธ for the AI-assisted development community