--- 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 Learn about available MCP tools Use MCP in n8n workflows