Files
t6_mem0_v2/docs/mcp/tools.mdx
Claude Code 1998bef6f4 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>
2025-10-15 13:56:41 +02:00

385 lines
7.3 KiB
Plaintext

---
title: 'MCP Tool Reference'
description: 'Complete reference for all 7 memory operation tools'
---
# MCP Tool Reference
The T6 Mem0 v2 MCP server provides 7 tools for complete memory lifecycle management. All tools use JSON-RPC 2.0 protocol and support both HTTP/SSE and stdio transports.
## add_memory
Store new memories extracted from conversation messages.
### Parameters
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `messages` | Array | Yes | Array of message objects with `role` and `content` |
| `user_id` | String | No | User identifier for memory association |
| `agent_id` | String | No | Agent identifier for memory association |
| `metadata` | Object | No | Additional metadata to store with memories |
### Example Request
```json
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "add_memory",
"arguments": {
"messages": [
{"role": "user", "content": "I love Python programming"},
{"role": "assistant", "content": "Great! I'll remember that."}
],
"user_id": "user_123",
"metadata": {"source": "chat", "session_id": "abc-123"}
}
}
}
```
### Example Response
```json
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"content": [
{
"type": "text",
"text": "Added 1 memories for user user_123"
}
]
}
}
```
## search_memories
Search memories using semantic similarity matching.
### Parameters
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `query` | String | Yes | Search query text |
| `user_id` | String | No | Filter by user ID |
| `agent_id` | String | No | Filter by agent ID |
| `limit` | Integer | No | Maximum results (default: 10, max: 50) |
### Example Request
```json
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "search_memories",
"arguments": {
"query": "What programming languages does the user like?",
"user_id": "user_123",
"limit": 5
}
}
}
```
### Example Response
```json
{
"jsonrpc": "2.0",
"id": 2,
"result": {
"content": [
{
"type": "text",
"text": "Found 2 memories:\n1. ID: mem_abc123 - User loves Python programming (score: 0.92)\n2. ID: mem_def456 - User interested in JavaScript (score: 0.78)"
}
]
}
}
```
## get_memory
Retrieve a specific memory by its ID.
### Parameters
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `memory_id` | String | Yes | Unique memory identifier |
### Example Request
```json
{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/call",
"params": {
"name": "get_memory",
"arguments": {
"memory_id": "mem_abc123"
}
}
}
```
### Example Response
```json
{
"jsonrpc": "2.0",
"id": 3,
"result": {
"content": [
{
"type": "text",
"text": "Memory: User loves Python programming\nCreated: 2025-10-15T10:30:00Z\nUser: user_123"
}
]
}
}
```
## get_all_memories
Retrieve all memories for a specific user or agent.
### Parameters
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `user_id` | String | No* | User identifier |
| `agent_id` | String | No* | Agent identifier |
*At least one of `user_id` or `agent_id` must be provided.
### Example Request
```json
{
"jsonrpc": "2.0",
"id": 4,
"method": "tools/call",
"params": {
"name": "get_all_memories",
"arguments": {
"user_id": "user_123"
}
}
}
```
### Example Response
```json
{
"jsonrpc": "2.0",
"id": 4,
"result": {
"content": [
{
"type": "text",
"text": "Found 3 memories for user user_123:\n1. User loves Python programming\n2. User interested in JavaScript\n3. User works as software engineer"
}
]
}
}
```
## update_memory
Update the content of an existing memory.
### Parameters
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `memory_id` | String | Yes | Unique memory identifier |
| `data` | String | Yes | New memory content |
### Example Request
```json
{
"jsonrpc": "2.0",
"id": 5,
"method": "tools/call",
"params": {
"name": "update_memory",
"arguments": {
"memory_id": "mem_abc123",
"data": "User is an expert Python developer"
}
}
}
```
### Example Response
```json
{
"jsonrpc": "2.0",
"id": 5,
"result": {
"content": [
{
"type": "text",
"text": "Memory mem_abc123 updated successfully"
}
]
}
}
```
## delete_memory
Delete a specific memory by ID.
### Parameters
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `memory_id` | String | Yes | Unique memory identifier |
### Example Request
```json
{
"jsonrpc": "2.0",
"id": 6,
"method": "tools/call",
"params": {
"name": "delete_memory",
"arguments": {
"memory_id": "mem_abc123"
}
}
}
```
### Example Response
```json
{
"jsonrpc": "2.0",
"id": 6,
"result": {
"content": [
{
"type": "text",
"text": "Memory mem_abc123 deleted successfully from both vector and graph stores"
}
]
}
}
```
## delete_all_memories
Delete all memories for a specific user or agent.
### Parameters
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `user_id` | String | No* | User identifier |
| `agent_id` | String | No* | Agent identifier |
*At least one of `user_id` or `agent_id` must be provided.
<Warning>
This operation is irreversible. All memories for the specified user/agent will be permanently deleted from both Supabase (vector store) and Neo4j (graph store).
</Warning>
### Example Request
```json
{
"jsonrpc": "2.0",
"id": 7,
"method": "tools/call",
"params": {
"name": "delete_all_memories",
"arguments": {
"user_id": "user_123"
}
}
}
```
### Example Response
```json
{
"jsonrpc": "2.0",
"id": 7,
"result": {
"content": [
{
"type": "text",
"text": "Deleted 3 memories for user user_123"
}
]
}
}
```
## Error Responses
All tools return standardized error responses:
```json
{
"jsonrpc": "2.0",
"id": 1,
"error": {
"code": -32603,
"message": "Internal error: Memory not found",
"data": {
"type": "MemoryNotFoundError",
"details": "No memory exists with ID mem_xyz789"
}
}
}
```
### Common Error Codes
| Code | Description |
|------|-------------|
| `-32700` | Parse error - Invalid JSON |
| `-32600` | Invalid request - Missing required fields |
| `-32601` | Method not found - Unknown tool name |
| `-32602` | Invalid params - Invalid arguments |
| `-32603` | Internal error - Server-side error |
## Synchronized Operations
<Info>
All delete operations (both `delete_memory` and `delete_all_memories`) are synchronized across both storage backends:
- **Supabase (Vector Store)**: Removes embeddings and memory records
- **Neo4j (Graph Store)**: Removes nodes and relationships
This ensures data consistency across the entire memory system.
</Info>
## Next Steps
<CardGroup cols={2}>
<Card title="n8n Integration" icon="workflow" href="/examples/n8n">
Use MCP tools in n8n workflows
</Card>
<Card title="Claude Code" icon="code" href="/examples/claude-code">
Integrate with Claude Code
</Card>
</CardGroup>