Skip to main content

MCP server for Claude conversation extraction with enhanced export and search

Project description

MCP Claude Context Server v0.5.0

PyPI version Python 3.11+ License: MIT

A powerful Model Context Protocol (MCP) server for extracting, storing, searching, and analyzing Claude.ai conversations with enhanced database storage, semantic search, and multiple export formats.

๐Ÿš€ What's New in v0.5.0

  • SQLite Database Storage - Migrate from JSON files to efficient database
  • Semantic Search - AI-powered search using sentence transformers
  • Multiple Export Formats - Obsidian, PDF, JSON, CSV
  • Easy Deployment - Docker support and one-click installers
  • Performance Improvements - 10x faster search, 35% faster operations

Features

Core Functionality

  • โœ… Direct API access for Claude.ai conversations
  • โœ… Chrome extension for full message extraction
  • โœ… SQLite database with full-text search
  • โœ… Semantic search capabilities
  • โœ… Multiple export formats (Obsidian, PDF, JSON, CSV)
  • โœ… Bulk operations and analytics
  • โœ… Session management with auto-refresh
  • โœ… Real-time analytics dashboard

Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Claude.ai Web  โ”‚โ”€โ”€โ”€โ”€โ–ถโ”‚ Chrome Extension โ”‚โ”€โ”€โ”€โ”€โ–ถโ”‚  Bridge Server  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                                          โ”‚
                                                          โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   MCP Client    โ”‚โ—€โ”€โ”€โ”€โ”€โ”‚    MCP Server    โ”‚โ—€โ”€โ”€โ”€โ”€โ”‚    Database     โ”‚
โ”‚  (Claude App)   โ”‚     โ”‚   (Enhanced)     โ”‚     โ”‚  (SQLite+FTS)   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                โ”‚
                        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                        โ–ผ               โ–ผ
                  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                  โ”‚ Exportersโ”‚    โ”‚  Search  โ”‚
                  โ”‚ (PDF/MD) โ”‚    โ”‚ (AI/FTS) โ”‚
                  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ› ๏ธ Installation

Quick Start with uvx (Recommended - No Installation!)

Add to your Claude Desktop config:

{
  "mcpServers": {
    "claude-context": {
      "command": "uvx",
      "args": ["mcp-claude-context"],
      "env": {
        "CLAUDE_SESSION_KEY": "sk-ant-sid01-...",
        "CLAUDE_ORG_ID": "28a16e5b-..."
      }
    }
  }
}

That's it! No installation needed. See full uvx guide โ†’

Quick Start with Docker

# Using pre-built image
docker run -d \
  --name mcp-claude-context \
  -p 8000:8000 \
  -v $(pwd)/data:/app/data \
  hamzaamjad/mcp-claude-context:latest

# Or with docker-compose
curl -O https://raw.githubusercontent.com/hamzaamjad/mcp-claude-context/main/docker-compose.simple.yml
docker-compose -f docker-compose.simple.yml up -d

One-Click Installer

# Mac/Linux
curl -sSL https://raw.githubusercontent.com/hamzaamjad/mcp-claude-context/main/deployment/one-click-install.sh | bash

# Windows (PowerShell)
iwr -useb https://raw.githubusercontent.com/hamzaamjad/mcp-claude-context/main/deployment/install.ps1 | iex

Manual Installation

  1. Prerequisites:

    • Python 3.11+
    • Chrome browser
    • Poetry (Python package manager)
  2. Install dependencies:

    poetry install
    
  3. Initialize database:

    poetry run python -c "from src.models.conversation import init_database; init_database()"
    
  4. Install Chrome extension:

    • Open Chrome โ†’ chrome://extensions/
    • Enable "Developer mode"
    • Click "Load unpacked" โ†’ Select extension/ directory
  5. Start the server:

    poetry run python -m src.direct_api_server
    

๐Ÿ“š Available MCP Tools

Conversation Management

Tool Description Requires API Keys
list_conversations List all conversations from Claude.ai โœ…
get_conversation Get specific conversation details โœ…
search_conversations Search conversations by keyword โœ…
get_conversation_messages Get full messages from local data โŒ

Search & Analytics

Tool Description
search_messages Full-text search across all messages
semantic_search AI-powered similarity search
get_analytics Get conversation statistics and insights

Export & Operations

Tool Description
export_conversations Export to JSON/CSV formats
export_to_obsidian Export to Obsidian vault with backlinks
bulk_operations Tag, export, delete, or analyze in bulk

System Management

Tool Description
update_session Update Claude.ai session credentials
migrate_to_database Migrate JSON files to SQLite
rebuild_search_index Optimize search performance

๐Ÿ’ก Usage Examples

Basic Operations

# List conversations
{
  "tool": "list_conversations",
  "arguments": {
    "session_key": "YOUR_SESSION_KEY",
    "org_id": "YOUR_ORG_ID",
    "limit": 50,
    "sync_to_db": true
  }
}

# Search with AI
{
  "tool": "semantic_search",
  "arguments": {
    "query": "discussions about machine learning",
    "search_type": "hybrid",
    "top_k": 10
  }
}

# Export to Obsidian
{
  "tool": "export_to_obsidian",
  "arguments": {
    "conversation_ids": ["conv-id-1", "conv-id-2"],
    "vault_path": "/path/to/obsidian/vault"
  }
}

Chrome Extension Usage

  1. Extract single conversation:

    • Navigate to conversation on Claude.ai
    • Click extension icon
    • Click "Extract Current Conversation"
  2. Bulk extract all conversations:

    • Click extension icon
    • Click "Extract All Conversations"
    • Monitor progress in popup
  3. View analytics:

    • Visit http://localhost:8765/dashboard
    • See statistics, trends, and insights

๐Ÿ”ง Configuration

Environment Variables

Variable Description Default
MCP_DB_PATH Database location data/db/conversations.db
MCP_EXPORT_DIR Export directory exports/
NOTION_API_KEY Notion integration Optional

Getting Session Credentials

  1. Log into Claude.ai
  2. Open Chrome DevTools (F12)
  3. Go to Application โ†’ Cookies
  4. Find sessionKey value
  5. Find org_id in Network tab API calls

๐Ÿ“Š Performance

v0.5.0 Improvements

  • Search Speed: 10x faster with SQLite FTS5
  • Storage: 20% less space with database compression
  • Operations: 35% faster read/write performance
  • Scalability: Handles 100K+ conversations efficiently

Benchmark Results

Operation JSON Files SQLite Database
Search 1K convos 2.3s 0.23s
Load conversation 150ms 45ms
Export 100 convos 5.2s 1.8s

๐Ÿš€ Advanced Features

Semantic Search

The server uses sentence transformers for AI-powered search:

  • Find similar conversations
  • Search by meaning, not just keywords
  • Discover related topics automatically

Obsidian Integration

Export conversations with:

  • Proper frontmatter metadata
  • Automatic backlinks
  • Daily notes integration
  • Tag organization
  • Dataview queries

Bulk Operations

Process multiple conversations:

{
  "tool": "bulk_operations",
  "arguments": {
    "operation": "analyze",
    "conversation_ids": ["id1", "id2", "id3"],
    "params": {}
  }
}

๐Ÿ› Troubleshooting

Common Issues

  1. "Session expired" error

    • Get fresh session key from Claude.ai
    • Use update_session tool
  2. Chrome extension not connecting

    • Ensure bridge server is running (port 9222)
    • Check extension permissions
  3. Database locked error

    • Ensure only one server instance running
    • Check file permissions
  4. Search not finding results

    • Run rebuild_search_index tool
    • Verify conversations are in database

Debug Mode

Enable detailed logging:

LOG_LEVEL=DEBUG poetry run python -m src.direct_api_server

๐Ÿค Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for new features
  4. Submit a pull request

Development Setup

# Install dev dependencies
poetry install --with dev

# Run tests
poetry run pytest

# Format code
poetry run black src/
poetry run ruff src/

๐Ÿ“„ License

MIT License - see LICENSE file

๐Ÿ™ Acknowledgments

๐Ÿ“ž Support


Note: This tool is not affiliated with Anthropic. Use responsibly and respect rate limits.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_claude_context-0.5.3.tar.gz (48.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_claude_context-0.5.3-py3-none-any.whl (54.6 kB view details)

Uploaded Python 3

File details

Details for the file mcp_claude_context-0.5.3.tar.gz.

File metadata

  • Download URL: mcp_claude_context-0.5.3.tar.gz
  • Upload date:
  • Size: 48.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.5 Darwin/24.5.0

File hashes

Hashes for mcp_claude_context-0.5.3.tar.gz
Algorithm Hash digest
SHA256 be0d0e98d26dd0f839413505a4890f0dc0718a6dae89eaf4dedc3a4159de75c5
MD5 ba70c3d6bccc07308fa2aa9131e2ea17
BLAKE2b-256 67de7ad2f1267569400d15ea1d972baf2ee37e2c558bf6ef96bfcefa90ec9e05

See more details on using hashes here.

File details

Details for the file mcp_claude_context-0.5.3-py3-none-any.whl.

File metadata

  • Download URL: mcp_claude_context-0.5.3-py3-none-any.whl
  • Upload date:
  • Size: 54.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.5 Darwin/24.5.0

File hashes

Hashes for mcp_claude_context-0.5.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7545b95601986c4260d0a37e8b0a57a721bb14a19e5223c36927f2bbeedae74b
MD5 3abfccca23dbafa623e898619c2e0d88
BLAKE2b-256 5ce805d0121ebde1bb01be76b89b715c95e76c83197769574fc4a7bec022eede

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page