Add MCP HTTP/SSE server and complete n8n integration
Major Changes: - Implemented MCP HTTP/SSE transport server for n8n and web clients - Created mcp_server/http_server.py with FastAPI for JSON-RPC 2.0 over HTTP - Added health check endpoint (/health) for container monitoring - Refactored mcp-server/ to mcp_server/ (Python module structure) - Updated Dockerfile.mcp to run HTTP server with health checks MCP Server Features: - 7 memory tools exposed via MCP (add, search, get, update, delete) - HTTP/SSE transport on port 8765 for n8n integration - stdio transport for Claude Code integration - JSON-RPC 2.0 protocol implementation - CORS support for web clients n8n Integration: - Successfully tested with AI Agent workflows - MCP Client Tool configuration documented - Working webhook endpoint tested and verified - System prompt optimized for automatic user_id usage Documentation: - Created comprehensive Mintlify documentation site - Added docs/mcp/introduction.mdx - MCP server overview - Added docs/mcp/installation.mdx - Installation guide - Added docs/mcp/tools.mdx - Complete tool reference - Added docs/examples/n8n.mdx - n8n integration guide - Added docs/examples/claude-code.mdx - Claude Code setup - Updated README.md with MCP HTTP server info - Updated roadmap to mark Phase 1 as complete Bug Fixes: - Fixed synchronized delete operations across Supabase and Neo4j - Updated memory_service.py with proper error handling - Fixed Neo4j connection issues in delete operations Configuration: - Added MCP_HOST and MCP_PORT environment variables - Updated .env.example with MCP server configuration - Updated docker-compose.yml with MCP container health checks Testing: - Added test scripts for MCP HTTP endpoint verification - Created test workflows in n8n - Verified all 7 memory tools working correctly - Tested synchronized operations across both stores Version: 1.0.0 Status: Phase 1 Complete - Production Ready 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
159
README.md
159
README.md
@@ -4,9 +4,13 @@ Comprehensive memory system based on mem0.ai featuring MCP server integration, R
|
||||
|
||||
## Features
|
||||
|
||||
- **MCP Server**: Model Context Protocol integration for Claude Code and other AI tools
|
||||
- **MCP Server**: HTTP/SSE and stdio transports for universal AI integration
|
||||
- ✅ n8n AI Agent workflows
|
||||
- ✅ Claude Code integration
|
||||
- ✅ 7 memory tools (add, search, get, update, delete)
|
||||
- **REST API**: Full HTTP API for memory operations (CRUD)
|
||||
- **Hybrid Storage**: Supabase (pgvector) + Neo4j (graph relationships)
|
||||
- **Synchronized Operations**: Automatic sync across vector and graph stores
|
||||
- **AI-Powered**: OpenAI embeddings and LLM processing
|
||||
- **Multi-Agent Support**: User and agent-specific memory isolation
|
||||
- **Graph Visualization**: Neo4j Browser for relationship exploration
|
||||
@@ -15,13 +19,21 @@ Comprehensive memory system based on mem0.ai featuring MCP server integration, R
|
||||
## Architecture
|
||||
|
||||
```
|
||||
Clients (Claude, N8N, Apps)
|
||||
Clients (n8n, Claude Code, Custom Apps)
|
||||
↓
|
||||
MCP Server (8765) + REST API (8080)
|
||||
┌─────────────────┬───────────────────┐
|
||||
│ MCP Server │ REST API │
|
||||
│ Port 8765 │ Port 8080 │
|
||||
│ HTTP/SSE+stdio │ FastAPI │
|
||||
└─────────────────┴───────────────────┘
|
||||
↓
|
||||
Mem0 Core Library
|
||||
Mem0 Core Library (v0.1.118)
|
||||
↓
|
||||
Supabase (Vector) + Neo4j (Graph) + OpenAI (LLM)
|
||||
┌─────────────────┬───────────────────┬───────────────────┐
|
||||
│ Supabase │ Neo4j │ OpenAI │
|
||||
│ Vector Store │ Graph Store │ Embeddings+LLM │
|
||||
│ pgvector │ Cypher Queries │ text-embedding-3 │
|
||||
└─────────────────┴───────────────────┴───────────────────┘
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
@@ -49,6 +61,7 @@ docker compose up -d
|
||||
|
||||
# Verify health
|
||||
curl http://localhost:8080/v1/health
|
||||
curl http://localhost:8765/health
|
||||
```
|
||||
|
||||
### Configuration
|
||||
@@ -67,8 +80,17 @@ NEO4J_URI=neo4j://neo4j:7687
|
||||
NEO4J_USER=neo4j
|
||||
NEO4J_PASSWORD=your-password
|
||||
|
||||
# API
|
||||
# REST API
|
||||
API_KEY=your-secure-api-key
|
||||
|
||||
# MCP Server
|
||||
MCP_HOST=0.0.0.0
|
||||
MCP_PORT=8765
|
||||
|
||||
# Mem0 Configuration
|
||||
MEM0_COLLECTION_NAME=t6_memories
|
||||
MEM0_EMBEDDING_DIMS=1536
|
||||
MEM0_VERSION=v1.1
|
||||
```
|
||||
|
||||
## Usage
|
||||
@@ -87,40 +109,93 @@ curl -X GET "http://localhost:8080/v1/memories/search?query=food&user_id=alice"
|
||||
-H "Authorization: Bearer YOUR_API_KEY"
|
||||
```
|
||||
|
||||
### MCP Server (Claude Code)
|
||||
### MCP Server
|
||||
|
||||
Add to Claude Code configuration:
|
||||
**HTTP/SSE Transport (for n8n, web clients):**
|
||||
|
||||
```bash
|
||||
# MCP endpoint
|
||||
http://localhost:8765/mcp
|
||||
|
||||
# Test tools/list
|
||||
curl -X POST http://localhost:8765/mcp \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'
|
||||
```
|
||||
|
||||
**stdio Transport (for Claude Code, local tools):**
|
||||
|
||||
Add to `~/.config/claude/mcp.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"t6-mem0": {
|
||||
"url": "http://localhost:8765/mcp/claude/sse/user-123"
|
||||
"command": "python",
|
||||
"args": ["-m", "mcp_server.main"],
|
||||
"cwd": "/path/to/t6_mem0_v2",
|
||||
"env": {
|
||||
"OPENAI_API_KEY": "${OPENAI_API_KEY}",
|
||||
"SUPABASE_CONNECTION_STRING": "${SUPABASE_CONNECTION_STRING}",
|
||||
"NEO4J_URI": "neo4j://localhost:7687",
|
||||
"NEO4J_USER": "neo4j",
|
||||
"NEO4J_PASSWORD": "${NEO4J_PASSWORD}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**n8n Integration:**
|
||||
|
||||
Use the MCP Client Tool node in n8n AI Agent workflows:
|
||||
|
||||
```javascript
|
||||
{
|
||||
"endpointUrl": "http://172.21.0.14:8765/mcp", // Use Docker network IP
|
||||
"serverTransport": "httpStreamable",
|
||||
"authentication": "none",
|
||||
"include": "all"
|
||||
}
|
||||
```
|
||||
|
||||
See [n8n integration guide](docs/examples/n8n.mdx) for complete workflow examples.
|
||||
|
||||
## Documentation
|
||||
|
||||
Full documentation available at: `docs/` (Mintlify)
|
||||
|
||||
- [MCP Server Introduction](docs/mcp/introduction.mdx)
|
||||
- [MCP Installation Guide](docs/mcp/installation.mdx)
|
||||
- [MCP Tool Reference](docs/mcp/tools.mdx)
|
||||
- [n8n Integration Guide](docs/examples/n8n.mdx)
|
||||
- [Claude Code Integration](docs/examples/claude-code.mdx)
|
||||
- [Architecture](ARCHITECTURE.md)
|
||||
- [Project Requirements](PROJECT_REQUIREMENTS.md)
|
||||
- [API Reference](docs/api/)
|
||||
- [Deployment Guide](docs/deployment/)
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
t6_mem0_v2/
|
||||
├── api/ # REST API (FastAPI)
|
||||
├── mcp-server/ # MCP server implementation
|
||||
├── migrations/ # Database migrations
|
||||
├── docker/ # Docker configurations
|
||||
├── docs/ # Mintlify documentation
|
||||
├── tests/ # Test suites
|
||||
└── docker-compose.yml
|
||||
├── api/ # REST API (FastAPI)
|
||||
│ ├── main.py # API entry point
|
||||
│ ├── memory_service.py # Memory operations
|
||||
│ └── routes.py # API endpoints
|
||||
├── mcp_server/ # MCP server implementation
|
||||
│ ├── main.py # stdio transport (Claude Code)
|
||||
│ ├── http_server.py # HTTP/SSE transport (n8n, web)
|
||||
│ ├── tools.py # MCP tool definitions
|
||||
│ └── server.py # Core MCP server logic
|
||||
├── docker/ # Docker configurations
|
||||
│ ├── Dockerfile.api # REST API container
|
||||
│ └── Dockerfile.mcp # MCP server container
|
||||
├── docs/ # Mintlify documentation
|
||||
│ ├── mcp/ # MCP server docs
|
||||
│ └── examples/ # Integration examples
|
||||
├── tests/ # Test suites
|
||||
├── config.py # Configuration management
|
||||
├── requirements.txt # Python dependencies
|
||||
└── docker-compose.yml # Service orchestration
|
||||
```
|
||||
|
||||
## Technology Stack
|
||||
@@ -135,24 +210,30 @@ t6_mem0_v2/
|
||||
|
||||
## Roadmap
|
||||
|
||||
### Phase 1: Foundation (Current)
|
||||
### Phase 1: Foundation ✅ COMPLETED
|
||||
- ✅ Architecture design
|
||||
- ⏳ REST API implementation
|
||||
- ⏳ MCP server implementation
|
||||
- ⏳ Supabase integration
|
||||
- ⏳ Neo4j integration
|
||||
- ⏳ Documentation site
|
||||
- ✅ REST API implementation (FastAPI with Bearer auth)
|
||||
- ✅ MCP server implementation (HTTP/SSE + stdio transports)
|
||||
- ✅ Supabase integration (pgvector for embeddings)
|
||||
- ✅ Neo4j integration (graph relationships)
|
||||
- ✅ Documentation site (Mintlify)
|
||||
- ✅ n8n AI Agent integration
|
||||
- ✅ Claude Code integration
|
||||
- ✅ Docker deployment with health checks
|
||||
|
||||
### Phase 2: Local LLM
|
||||
- Local Ollama integration
|
||||
- Model switching capabilities
|
||||
- Performance optimization
|
||||
### Phase 2: Local LLM (Next)
|
||||
- ⏳ Local Ollama integration
|
||||
- ⏳ Model switching capabilities (OpenAI ↔ Ollama)
|
||||
- ⏳ Performance optimization
|
||||
- ⏳ Embedding model selection
|
||||
|
||||
### Phase 3: Advanced Features
|
||||
- Memory versioning
|
||||
- Advanced graph queries
|
||||
- Multi-modal memory support
|
||||
- Analytics dashboard
|
||||
- ⏳ Memory versioning and history
|
||||
- ⏳ Advanced graph queries and analytics
|
||||
- ⏳ Multi-modal memory support (images, audio)
|
||||
- ⏳ Analytics dashboard
|
||||
- ⏳ Memory export/import
|
||||
- ⏳ Custom embedding models
|
||||
|
||||
## Development
|
||||
|
||||
@@ -187,6 +268,14 @@ Proprietary - All rights reserved
|
||||
|
||||
---
|
||||
|
||||
**Status**: In Development
|
||||
**Version**: 0.1.0
|
||||
**Last Updated**: 2025-10-13
|
||||
**Status**: Phase 1 Complete - Production Ready
|
||||
**Version**: 1.0.0
|
||||
**Last Updated**: 2025-10-15
|
||||
|
||||
## Recent Updates
|
||||
|
||||
- **2025-10-15**: MCP HTTP/SSE server implementation complete
|
||||
- **2025-10-15**: n8n AI Agent integration tested and documented
|
||||
- **2025-10-15**: Complete Mintlify documentation site
|
||||
- **2025-10-15**: Synchronized delete operations across stores
|
||||
- **2025-10-13**: Initial project setup and architecture
|
||||
|
||||
Reference in New Issue
Block a user