MCP Claude Context Server

MCP Claude Context Server

A powerful MCP server that extracts, stores, searches, and analyzes Claude.ai conversations with SQLite database, semantic search, and multiple export formats including Obsidian and PDF.

Category
访问服务器

README

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.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选