MCP MITM Mem0

MCP MITM Mem0

Intercepts Claude conversations via MITM proxy and stores them in Mem0, enabling Claude to search and recall past conversations, learn user preferences, and maintain context across sessions.

Category
访问服务器

README

MCP MITM Mem0

[!WARNING] This project is experimental and deprecated. A new, improved version is being developed at https://github.com/terrymunro/mcp-claude-memories. Please consider using the new version for future projects.

A simplified memory service for Claude that intercepts conversations via MITM proxy and provides memory access through MCP.

Overview

This project provides three core components:

  1. MITM Addon - Intercepts Claude API conversations and stores them in Mem0
  2. MCP Server - Provides tools for Claude to query and manage memories
  3. Reflection Agent - Analyzes conversations to identify patterns and provide insights

What This Project IS For

✅ Core Use Cases

  1. Personal AI Assistant Memory

    • Give Claude memory of your past conversations
    • Enable continuity across sessions
    • Example: "Claude, what was that Docker command we used last week?"
  2. Project Context Persistence

    • Maintain project-specific knowledge across conversations
    • Track decisions, approaches, and solutions
    • Example: Claude remembers your preferred coding style and project structure
  3. Learning and Adaptation

    • Claude learns your preferences over time
    • Identifies patterns in your questions and needs
    • Example: Claude notices you prefer concise answers and adapts accordingly
  4. Development Workflow Enhancement

    • Remember debugging sessions and solutions
    • Track what approaches worked or failed
    • Example: Claude recalls "We tried approach X for this error before, it didn't work because..."

🎯 Real-World Examples

Example 1: Continuing Work

User: "Let's continue working on that authentication system"
Claude: *searches memories* "I found our previous discussion about JWT authentication.
We were implementing refresh tokens and had decided to store them in HTTP-only cookies..."

Example 2: Learning Preferences

Claude: *after analyzing conversations* "I've noticed you prefer functional programming
patterns and often ask about TypeScript. Should I prioritize these in my responses?"

Example 3: Debugging History

User: "I'm getting that CORS error again"
Claude: *searches memories* "We encountered this CORS error before with your React app.
The solution was to add the proxy configuration in package.json..."

What This Project is NOT For

❌ Not Designed For

  1. Enterprise Knowledge Management

    • ❌ Multi-tenant memory isolation with RBAC
    • ❌ Compliance features (GDPR right-to-be-forgotten, HIPAA, SOC2)
    • ❌ Complex retention policies and data governance
    • Instead: Simple user-based memory storage
  2. Team Collaboration

    • ❌ Shared memory pools across team members
    • ❌ Real-time sync between multiple Claude instances
    • ❌ Collaborative knowledge base editing
    • Instead: Personal memory for individual users
  3. Structured Data Systems

    • ❌ CRM replacement for tracking contacts/customers
    • ❌ Project management tool with tasks and deadlines
    • ❌ Documentation platform with versioning
    • Instead: Conversational memory storage
  4. High-Performance Requirements

    • ❌ Sub-millisecond memory retrieval
    • ❌ Real-time streaming of memories
    • ❌ High-frequency trading or gaming applications
    • Instead: Async cloud-based memory suitable for conversations
  5. Complex Analytics

    • ❌ Business intelligence dashboards
    • ❌ Advanced NLP analysis pipelines
    • ❌ Machine learning model training
    • Instead: Simple pattern recognition for conversation insights

🚫 Anti-Patterns to Avoid

  • Don't try to use this as a general-purpose database
  • Don't expect ACID transactions or complex queries
  • Don't store sensitive data without understanding Mem0's security model
  • Don't assume memories are instantly available after storage

Features

  • 🎯 Simple & Focused - Just memory capture and retrieval, no enterprise complexity
  • 🌐 Mem0 SaaS - Uses Mem0's cloud service, no local infrastructure needed
  • 🔍 Memory Search - Natural language search across conversation history
  • 📊 Reflection Analysis - Identifies patterns and suggests improvements
  • 🛠️ MCP Tools - Direct integration with Claude via MCP protocol
  • 📚 Memory Resources - Browse memories as MCP resources

Setup

1. Get a Mem0 API Key

Sign up at https://app.mem0.ai and get your API key.

2. Configure Environment

cp .env.example .env
# Edit .env and add your MEM0_API_KEY

3. Install Dependencies

uv sync

Usage

Running the MITM Proxy

# Start mitmproxy with the memory addon
mitmdump -s memory_addon.py

Configure your Claude client to use the proxy (typically localhost:8080).

Running the MCP Server

# Start the MCP server
uv run mcp-mitm-mem0

Configure Claude Code

Add to your .mcp.json:

{
  "mcpServers": {
    "memory-service": {
      "command": "uv",
      "args": ["run", "mcp-mitm-mem0"],
      "cwd": "/path/to/mcp-mitm-mem0"
    }
  }
}

MCP Tools

  • search_memories(query, user_id?, limit?) - Search memories using natural language
  • list_memories(user_id?) - List all memories for a user
  • add_memory(messages, user_id?, metadata?) - Manually add memories
  • delete_memory(memory_id) - Delete a specific memory
  • analyze_conversations(user_id?, limit?) - Analyze patterns in recent conversations
  • suggest_next_actions(user_id?) - Get suggestions based on conversation history

MCP Resources

  • memory://{user_id} - Browse all memories for a specific user
  • memory://recent - View the 10 most recent memories

Architecture

┌─────────────────┐     ┌─────────────────┐     ┌─────────────────┐
│  Claude Client  │────▶│   MITM Proxy    │────▶│  Anthropic API  │
└─────────────────┘     └────────┬────────┘     └─────────────────┘
                                 │
                                 ▼
                         ┌───────────────┐
                         │   Mem0 SaaS   │
                         └───────▲───────┘
                                 │
┌─────────────────┐     ┌───────┴───────┐
│      Claude     │────▶│  MCP Server   │
│    (via MCP)    │     │ + Reflection  │
└─────────────────┘     └───────────────┘

Concrete Use Case Examples

🔧 Software Development Assistant

Scenario: Working on a complex refactoring across multiple sessions

Day 1:
User: "I need to refactor the authentication system to use JWT"
Claude: "I'll help you refactor to JWT. Let's start by..."
[Discussion about JWT implementation]

Day 3:
User: "What was our plan for the refresh token rotation?"
Claude: _search_memories("JWT refresh token rotation")_
"From our discussion 2 days ago, we planned to implement refresh token rotation with
a 15-minute access token lifetime and 7-day refresh token lifetime..."

🐛 Debug Session Continuity

Scenario: Debugging an intermittent production issue

Week 1:
User: "Production is throwing intermittent 504 errors"
Claude: "Let's investigate. Can you share the logs?"
[Long debugging session]

Week 2:
User: "Those 504 errors are back"
Claude: _analyze_conversations()_
"I see we've encountered this issue before. Last time, we found it correlated with
database connection pool exhaustion during peak hours. We should check if the connection
pool settings we adjusted have reverted..."

📚 Learning & Mentorship

Scenario: Learning a new technology with Claude as a mentor

Session 1:
User: "Can you teach me React hooks?"
Claude: "Let's start with useState..."

Session 5:
Claude: _analyze_conversations()_
"Based on our previous sessions, you've mastered useState and useEffect. You struggled
with useCallback dependencies. Today, let's focus on custom hooks which will reinforce
those concepts..."

🏗️ Project Architecture Evolution

Scenario: Building a startup MVP over several months

Month 1:
User: "Should we use microservices or monolith for our MVP?"
Claude: "For an MVP, I recommend starting with a monolith..."

Month 3:
User: "We need to scale the payment processing"
Claude: _search_memories("architecture monolith microservices")_
"Three months ago, we chose a monolithic architecture for your MVP. Now that you need
to scale payment processing, we could extract just that service following the plan we
outlined where payments would be the first candidate for extraction..."

💡 Personal Coding Preferences

Scenario: Claude learns and adapts to your style

After multiple sessions:
Claude: _analyze_conversations()_
Insights detected:

- User prefers functional components over class components
- User consistently asks for TypeScript examples
- User values comprehensive error handling
- User prefers explicit types over inference

Claude: "I'll prioritize functional TypeScript examples with explicit typing and robust
error handling in my responses."

Development

Running Tests

uv run pytest

Linting

uv run ruff check .
uv run ruff format .

Configuration

All configuration is done via environment variables:

  • MEM0_API_KEY - Your Mem0 SaaS API key (required)
  • DEBUG - Enable debug logging (default: false)
  • DEFAULT_USER_ID - Default user ID for memories (default: "default_user")
  • MITM_HOST - MITM proxy host (default: "localhost")
  • MITM_PORT - MITM proxy port (default: 8080)
  • MCP_NAME - MCP server name (default: "memory-service")

License

MIT

推荐服务器

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

官方
精选