- Upgrade MCP SDK from 1.6.0 to 1.21.0 (latest) - Add backward compatible tool wrappers (search_memory_nodes, etc.) - Fix parameter compatibility (group_id/group_ids, last_n/max_episodes) - Fix HTTP transport fallback to SSE (no more crashes) - Update default transport to stdio for broader compatibility - Add test import fallback for streamable_http - Update documentation with compatibility notes Fixes all issues identified in external code review: ✅ HTTP transport broken → graceful SSE fallback ✅ Tool name mismatches → compatibility wrappers added ✅ Parameter mismatches → dual parameter support ✅ Test imports fail → SSE fallback added ⚠️ Protocol version drift → SDK 1.21.0 installed (2024-11-05) All changes in mcp_server/ only - zero modifications to graphiti_core/ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
10 KiB
MCP Server Tools Documentation
Overview
The Graphiti MCP Server exposes Graphiti functionality through the Model Context Protocol (MCP) for AI assistants (like those in LibreChat). Each tool is decorated with @mcp.tool() and provides a specific capability.
Tool Naming Convention
All tools follow MCP best practices:
- snake_case naming: All lowercase with underscores
- Action-oriented: Start with verbs (add, search, get, compare, delete)
- Concise descriptions: First line describes core action
- Clear parameters: Descriptions specify format and provide examples
Reference: https://modelcontextprotocol.io/specification/2025-06-18/server/tools
Recent Changes
2025-11-09 - Backward Compatibility Wrappers Added
Problem: External code review found tool surface mismatches between server and clients/tests:
- Tests expected
search_memory_nodesbut server only hadsearch_nodes - Tests called tools with singular
group_id(string) but server expectedgroup_ids(list) - Tests used
last_nparameter but server expectedmax_episodes
Solution: Added backward compatibility without breaking changes:
- Created
search_memory_nodeswrapper that delegates tosearch_nodes - Updated
get_episodesto accept bothgroup_id/group_idsandlast_n/max_episodes - Updated
clear_graphto accept bothgroup_id(singular) andgroup_ids(plural)
Impact: All existing clients, tests, and documentation examples now work without modification.
2025-11-08 - UUID Parameter Documentation Enhanced
Problem: LLMs were attempting to generate and provide UUIDs when adding NEW memories, which should never happen - UUIDs must be auto-generated for new episodes.
Solution: Enhanced the uuid parameter documentation in add_memory to be very explicit: "NEVER provide a UUID for new episodes - UUIDs are auto-generated. This parameter can ONLY be used for updating an existing episode by providing its existing UUID."
Impact: Clear guidance for LLMs to prevent them from trying to generate UUIDs for new memories while preserving the ability to update existing episodes.
Tool List
Core Memory Management
- add_memory - Add episodes to the knowledge graph ✨ IMPROVED DOCS
- clear_graph - Clear all data for specified group IDs ✨ BACKWARD COMPATIBLE
- get_status - Get server and database connection status
Search and Retrieval Tools
- search_nodes - Search for nodes/entities using semantic search
- search_memory_nodes - ⭐ NEW Alias for search_nodes (backward compatibility)
- search_memory_facts - Search for facts/relationships using semantic search
- get_entities_by_type - Retrieve entities by their type classification
- compare_facts_over_time - Compare facts between two time periods
Entity and Episode Management
- get_entity_edge - Retrieve a specific entity edge by UUID
- delete_entity_edge - Delete an entity edge from the graph
- get_episodes - Retrieve episodes from the graph ✨ BACKWARD COMPATIBLE
- delete_episode - Delete an episode from the graph
Tool Details
search_memory_nodes (NEW - Backward Compatibility Wrapper)
Added: 2025-11-09
Purpose: Backward compatibility alias for search_nodes
MCP-Compliant Description: "Search for nodes in the graph memory (compatibility wrapper)."
Parameters:
query: str - The search querygroup_id: Optional[str] - Single group ID (backward compatibility)group_ids: Optional[List[str]] - List of group IDs (preferred)max_nodes: int = 10 - Maximum number of nodes to returnentity_types: Optional[List[str]] - Entity types to filter by
Implementation Notes:
- Converts singular
group_idto[group_id]list if provided - Delegates to
search_nodesfor actual implementation - Maintains backward compatibility with existing clients
Location: After search_nodes in mcp_server/src/graphiti_mcp_server.py
get_episodes (Updated - Backward Compatible)
Updated: 2025-11-09 Purpose: Get episodes from the graph memory
Parameters (now accepts both old and new formats):
group_id: Optional[str] - Single group ID (backward compatibility)group_ids: Optional[List[str]] - List of group IDs (preferred)last_n: Optional[int] - Max episodes to return (backward compatibility)max_episodes: int = 10 - Max episodes to return (preferred)
Backward Compatibility:
- Old:
get_episodes(group_id="test", last_n=5)✅ Works - New:
get_episodes(group_ids=["test"], max_episodes=5)✅ Works - Both parameters provided:
group_idsandmax_episodestake precedence
clear_graph (Updated - Backward Compatible)
Updated: 2025-11-09 Purpose: Clear all data from the graph for specified group IDs
Parameters (now accepts both old and new formats):
group_id: Optional[str] - Single group ID (backward compatibility)group_ids: Optional[List[str]] - List of group IDs (preferred)
Backward Compatibility:
- Old:
clear_graph(group_id="test")✅ Works - New:
clear_graph(group_ids=["test1", "test2"])✅ Works - Both provided:
group_idstakes precedence
add_memory (Updated Documentation)
Purpose: Add episodes to the knowledge graph
MCP-Compliant Description: "Add an episode to memory. This is the primary way to add information to the graph."
Parameters:
name: str - Name of the episodeepisode_body: str - Content to persist (JSON string for source='json')group_id: Optional[str] - Group ID for this graph (uses default if not provided)source: str = 'text' - Source type ('text', 'json', or 'message')source_description: str = '' - Optional description of the sourceuuid: Optional[str] = None - NEVER provide for NEW episodes. Can ONLY be used to update an existing episode by providing its UUID.
UUID Parameter Behavior:
- For NEW episodes: Do NOT provide - auto-generated
- For UPDATING episodes: Provide the existing episode's UUID to replace/update it
- Other uses: Idempotent operations or external system integration (advanced)
Implementation Notes:
- Returns immediately, processes in background
- Episodes for same group_id processed sequentially
- Providing a UUID updates the episode with that UUID if it exists
get_entities_by_type
Added: 2025-11-08 Purpose: Essential for PKM (Personal Knowledge Management) - enables browsing entities by their type classification
MCP-Compliant Description: "Retrieve entities by their type classification."
Parameters:
entity_types: List[str] - Entity types to retrieve (e.g., ["Pattern", "Insight", "Preference"])group_ids: Optional[List[str]] - Filter by group IDsmax_entities: int = 20 - Maximum entities to returnquery: Optional[str] - Optional search query to filter entities
Implementation Notes:
- Uses
SearchFilters(node_labels=entity_types)from graphiti_core - Uses
NODE_HYBRID_SEARCH_RRFsearch config - When query is provided: semantic search with type filter
- When query is empty: uses space (' ') as generic query to retrieve all of the type
- Returns
NodeSearchResponse(same format as search_nodes)
Use Cases:
- "Show me all my Preferences"
- "List Patterns I've identified"
- "Get Insights about productivity"
- "Find all documented Procedures"
compare_facts_over_time
Added: 2025-11-08 Purpose: Track how knowledge/understanding evolved over time - critical for seeing how Patterns, Insights, and understanding changed
MCP-Compliant Description: "Compare facts between two time periods."
Parameters:
query: str - Search query for facts to comparestart_time: str - ISO 8601 timestamp (e.g., "2024-01-01" or "2024-01-01T10:30:00Z")end_time: str - ISO 8601 timestampgroup_ids: Optional[List[str]] - Filter by group IDsmax_facts_per_period: int = 10 - Max facts per time category
Returns: Dictionary with:
facts_from_start: Facts valid at start_timefacts_at_end: Facts valid at end_timefacts_invalidated: Facts that were invalidated between start and endfacts_added: Facts that became valid between start and endsummary: Count statistics
Implementation Constraints
Safe Design Principles
All tools follow strict constraints to maintain upstream compatibility:
- Only use public Graphiti APIs - No custom Cypher queries, no internal methods
- MCP server only changes - No modifications to graphiti_core/
- Existing patterns - Follow same structure as existing tools
- Standard imports - Only use imports already in the file or from stable public APIs
- MCP compliance - Follow MCP specification for tool naming and descriptions
- LLM-friendly documentation - Clear guidance to prevent LLM confusion (e.g., UUID usage)
- Backward compatibility - New parameters don't break existing clients
Dependencies
All required imports are either:
- Already present in the file (SearchFilters, format_fact_result)
- From stable public APIs (DateFilter, ComparisonOperator, search configs)
No new dependencies added to pyproject.toml.
Validation Tests
Automated Tests Passed (2025-11-09)
- ✅ Python syntax check (py_compile)
- ✅ Ruff formatting (auto-formatted)
- ✅ Ruff linting (all checks passed)
- ✅ No custom Cypher or internal APIs used
- ✅ Follows project code style conventions
- ✅ MCP specification compliance verified
- ✅ UUID documentation enhanced to prevent LLM misuse
- ✅ Backward compatibility maintained
Manual Testing Required
Before production use, test:
- search_memory_nodes with both group_id and group_ids parameters
- get_episodes with old format (group_id, last_n) and new format (group_ids, max_episodes)
- clear_graph with both group_id and group_ids parameters
- add_memory without LLM trying to provide UUIDs for NEW episodes
- add_memory with UUID for UPDATING existing episodes
- get_entities_by_type with various entity type combinations
- compare_facts_over_time with various date ranges
File Location
mcp_server/src/graphiti_mcp_server.py
Current tool locations (after 2025-11-09 updates):
add_memory: lines 320-403search_nodes: lines 406-483search_memory_nodes: After line 483 (new wrapper)get_entities_by_type: lines 486-583search_memory_facts: lines 587-640compare_facts_over_time: lines 641-829delete_entity_edge: lines 832-856delete_episode: lines 858-882get_entity_edge: lines 884-908get_episodes: lines 939-1004 (updated for backward compat)clear_graph: lines 1018-1050 (updated for backward compat)get_status: lines 1014-1089