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>
231 lines
4.3 KiB
Plaintext
231 lines
4.3 KiB
Plaintext
---
|
|
title: 'MCP Server Installation'
|
|
description: 'Install and configure the T6 Mem0 v2 MCP server'
|
|
---
|
|
|
|
# Installing the MCP Server
|
|
|
|
The MCP server can be run in two modes: HTTP/SSE for web integrations, or stdio for local tool usage.
|
|
|
|
## Prerequisites
|
|
|
|
- Python 3.11+
|
|
- Running Supabase instance (vector store)
|
|
- Running Neo4j instance (graph store)
|
|
- OpenAI API key
|
|
|
|
## Environment Setup
|
|
|
|
Create a `.env` file with required configuration:
|
|
|
|
```bash
|
|
# OpenAI
|
|
OPENAI_API_KEY=your_openai_key_here
|
|
|
|
# Supabase (Vector Store)
|
|
SUPABASE_CONNECTION_STRING=postgresql://user:pass@host:port/database
|
|
|
|
# Neo4j (Graph Store)
|
|
NEO4J_URI=neo4j://localhost:7687
|
|
NEO4J_USER=neo4j
|
|
NEO4J_PASSWORD=your_neo4j_password
|
|
|
|
# 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
|
|
```
|
|
|
|
## Installation Methods
|
|
|
|
### Method 1: Docker (Recommended)
|
|
|
|
The easiest way to run the MCP server is using Docker Compose:
|
|
|
|
```bash
|
|
# Clone the repository
|
|
git clone https://git.colsys.tech/klas/t6_mem0_v2
|
|
cd t6_mem0_v2
|
|
|
|
# Copy and configure environment
|
|
cp .env.example .env
|
|
# Edit .env with your settings
|
|
|
|
# Start all services
|
|
docker compose up -d
|
|
|
|
# MCP HTTP server will be available at http://localhost:8765
|
|
```
|
|
|
|
**Health Check**:
|
|
```bash
|
|
curl http://localhost:8765/health
|
|
# {"status":"healthy","service":"t6-mem0-v2-mcp-http","transport":"http-streamable"}
|
|
```
|
|
|
|
### Method 2: Local Python
|
|
|
|
For development or local usage:
|
|
|
|
```bash
|
|
# Install dependencies
|
|
pip install -r requirements.txt
|
|
|
|
# Run HTTP server
|
|
python -m mcp_server.http_server
|
|
|
|
# Or run stdio server (for Claude Code)
|
|
python -m mcp_server.main
|
|
```
|
|
|
|
## Verify Installation
|
|
|
|
### Test HTTP Endpoint
|
|
|
|
```bash
|
|
curl -X POST "http://localhost:8765/mcp" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"jsonrpc": "2.0",
|
|
"id": 1,
|
|
"method": "tools/list",
|
|
"params": {}
|
|
}'
|
|
```
|
|
|
|
Expected response:
|
|
```json
|
|
{
|
|
"jsonrpc": "2.0",
|
|
"id": 1,
|
|
"result": {
|
|
"tools": [
|
|
{
|
|
"name": "add_memory",
|
|
"description": "Add new memory from messages...",
|
|
"inputSchema": {...}
|
|
},
|
|
// ... 6 more tools
|
|
]
|
|
}
|
|
}
|
|
```
|
|
|
|
### Test stdio Server
|
|
|
|
```bash
|
|
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}' | python -m mcp_server.main
|
|
```
|
|
|
|
## Docker Configuration
|
|
|
|
The MCP server is configured in `docker-compose.yml`:
|
|
|
|
```yaml
|
|
mcp-server:
|
|
build:
|
|
context: .
|
|
dockerfile: docker/Dockerfile.mcp
|
|
container_name: t6-mem0-mcp
|
|
restart: unless-stopped
|
|
ports:
|
|
- "8765:8765"
|
|
environment:
|
|
- OPENAI_API_KEY=${OPENAI_API_KEY}
|
|
- SUPABASE_CONNECTION_STRING=${SUPABASE_CONNECTION_STRING}
|
|
- NEO4J_URI=neo4j://neo4j:7687
|
|
- NEO4J_USER=${NEO4J_USER}
|
|
- NEO4J_PASSWORD=${NEO4J_PASSWORD}
|
|
- MCP_HOST=0.0.0.0
|
|
- MCP_PORT=8765
|
|
depends_on:
|
|
neo4j:
|
|
condition: service_healthy
|
|
networks:
|
|
- localai
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "curl -f http://localhost:8765/health || exit 1"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
```
|
|
|
|
## Network Configuration
|
|
|
|
For n8n integration on the same Docker network:
|
|
|
|
```yaml
|
|
# Add to your n8n docker-compose.yml
|
|
networks:
|
|
localai:
|
|
external: true
|
|
|
|
services:
|
|
n8n:
|
|
networks:
|
|
- localai
|
|
```
|
|
|
|
Then use internal Docker network IP in n8n:
|
|
```
|
|
http://172.21.0.14:8765/mcp
|
|
```
|
|
|
|
Find the MCP container IP:
|
|
```bash
|
|
docker inspect t6-mem0-mcp --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'
|
|
```
|
|
|
|
## Troubleshooting
|
|
|
|
### Container Won't Start
|
|
|
|
Check logs:
|
|
```bash
|
|
docker logs t6-mem0-mcp --tail 50
|
|
```
|
|
|
|
Common issues:
|
|
- Missing environment variables
|
|
- Cannot connect to Neo4j or Supabase
|
|
- Port 8765 already in use
|
|
|
|
### Health Check Failing
|
|
|
|
Verify services are reachable:
|
|
```bash
|
|
# Test Neo4j connection
|
|
docker exec t6-mem0-mcp curl http://neo4j:7474
|
|
|
|
# Test from host
|
|
curl http://localhost:8765/health
|
|
```
|
|
|
|
### n8n Can't Connect
|
|
|
|
1. Verify same Docker network:
|
|
```bash
|
|
docker network inspect localai
|
|
```
|
|
|
|
2. Test connectivity from n8n container:
|
|
```bash
|
|
docker run --rm --network localai alpine/curl:latest \
|
|
curl -s http://172.21.0.14:8765/health
|
|
```
|
|
|
|
## Next Steps
|
|
|
|
<CardGroup cols={2}>
|
|
<Card title="Tool Reference" icon="wrench" href="/mcp/tools">
|
|
Learn about available MCP tools
|
|
</Card>
|
|
<Card title="n8n Integration" icon="workflow" href="/examples/n8n">
|
|
Use MCP in n8n workflows
|
|
</Card>
|
|
</CardGroup>
|