Implement: Create a helper function for normalizing group_ids parameter#1384
Open
tross-agent wants to merge 1 commit intogetzep:mainfrom
Open
Implement: Create a helper function for normalizing group_ids parameter#1384tross-agent wants to merge 1 commit intogetzep:mainfrom
tross-agent wants to merge 1 commit intogetzep:mainfrom
Conversation
Member
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The issue is that MCP read tools (search_memory_facts, search_nodes, get_episodes, clear_graph) currently only accept
group_idsas a list[str] | None, rejecting scalar string inputs likegroup_ids="ideadb". This breaks clients that surface scalar inputs for simple tool calls.Key findings:
mcp_server/src/graphiti_mcp_server.py:486-search_memory_factshasgroup_ids: list[str] | None = Nonegraphiti_core/helpers.pycontainsvalidate_group_id(line 135) for single strings andvalidate_group_ids(line 161) for listsgraphiti_core/errors.pydefinesGroupIdValidationErrorfor invalid characters_validate_entity_labelsingraphiti_core/models/nodes/node_db_queries.py:22that accepts both string and list inputsmcp_server/tests/test_comprehensive_integration.py:247containsTestSearchOperationsclass for testing search functionalityThe solution requires modifying the MCP tool functions to accept both
strandlist[str]forgroup_idsparameter and normalizing scalar strings to single-element lists internally.Tasks Completed:
normalize_group_idsfunction ingraphiti_core/helpers.py. The function:str | list[str] | Noneas input and returnslist[str] | NoneNoneif input isNonevalidate_group_idfunctionThe function follows the same pattern as
_validate_entity_labelsfromgraphiti_core/models/nodes/node_db_queries.py:22and includes proper docstring documentation, type hints, and error handling.search_memory_factsfunction inmcp_server/src/graphiti_mcp_server.pyto accept scalar group_ids. The changes include:group_ids: list[str] | None = Nonetogroup_ids: str | list[str] | None = Nonenormalize_group_idshelper function fromgraphiti_core.helpersnormalize_group_idsto normalize the input parameter (handles str, list[str], or None)The function maintains backward compatibility with existing list inputs while now also accepting scalar string inputs.
mcp_server/src/graphiti_mcp_server.py:search_nodes (line 408):
group_ids: list[str] | None = Nonetogroup_ids: str | list[str] | None = Nonenormalize_group_idshelper function for normalizationget_episodes (line 625):
group_ids: list[str] | None = Nonetogroup_ids: str | list[str] | None = Nonenormalize_group_idshelper function for normalizationclear_graph (line 693):
group_ids: list[str] | None = Nonetogroup_ids: str | list[str] | None = Nonenormalize_group_idshelper function for normalizationAll four MCP read tools (search_memory_facts, search_nodes, get_episodes, clear_graph) now consistently accept scalar group_ids for consistency as specified in the bug report.
mcp_server/tests/test_comprehensive_integration.py. Added four new test methods:test_scalar_group_ids_acceptanceinTestSearchOperationsclass:search_memory_factsandsearch_memory_nodeswith scalar string, list, and None inputs forgroup_idstest_get_episodes_scalar_group_idsinTestEpisodeManagementclass:get_episodeswith scalar string, list, and None inputs forgroup_idstest_clear_graph_scalar_group_idsinTestEntityAndEdgeOperationsclass:clear_graphwith scalar string, list, and None inputs forgroup_idstest_invalid_group_ids_validationinTestErrorHandlingclass:The tests follow existing test patterns in the
TestSearchOperationsclass and verify that all four MCP tools accept both scalar string and list inputs for group_ids, handle None input, and still raise appropriate validation errors for invalid group_ids.