-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Problem
When using hierarchical group_ids like evadenta:business, evadenta:procedures, etc., the MCP server's search functions (search_nodes, search_memory_facts, get_episodes) return no results when called without explicit group_ids.
Current Behavior
# Config: --group-id evadenta
# Data stored in: evadenta:business, evadenta:procedures, evadenta:architecture
search_nodes(query="deployment") # Returns: No relevant nodes foundThe enforce_group_scope() function returns ["evadenta"] when no group_ids are provided, but the search performs an exact match, missing all evadenta:* subgroups.
Expected Behavior
search_nodes(query="deployment") # Returns: nodes from evadenta:business, evadenta:procedures, etc.Proposed Solution
Add a helper function that queries the database for all group_ids matching the configured prefix:
async def get_matching_group_ids(prefix: str) -> list[str]:
"""Query database for all group_ids that equal prefix OR start with prefix:"""
# Query: WHERE n.group_id = $prefix OR n.group_id STARTS WITH $prefix_colon
# Returns: ["evadenta:business", "evadenta:procedures", "evadenta:architecture", ...]Then modify search_nodes, search_memory_facts, and get_episodes to use this when no group_ids are explicitly provided.
Use Case
Multi-category knowledge storage where data is organized into subgroups:
project:architecture- design decisionsproject:procedures- deployment/dev workflowsproject:debugging- troubleshooting lessonsproject:business- domain rules
Users expect default queries to search across all their subgroups, not require explicit enumeration.
Implementation
I have a working implementation (~50 lines) that:
- Adds
get_matching_group_ids()async function - Modifies the three search functions to auto-expand subgroups
- Maintains backward compatibility (only affects queries with no explicit group_ids)
- Preserves existing scope enforcement for security
Happy to submit a PR if this approach aligns with the project's direction.
Environment
- graphiti-core version: latest
- MCP server transport: stdio
- Database: Neo4j