feat(mcp): configurable search tuning — reranker choice, stale-fact filtering, result counts, relevance scores#1647
Conversation
|
I have read the CLA Document and I hereby sign the CLA behalf on myself, e-mail: example@example.com or I have read the CLA Document and I hereby sign the CLA behalf of my company, e-mail: example@example.com Signature is valid for 6 months. This bot will be retriggered when the Contributor License Agreement comment has been provided. Posted by the CLA Assistant Lite bot. |
|
I have read the CLA Document and I hereby sign the CLA behalf on myself, e-mail: 02cirque_ladles@icloud.com |
Summary
Implements #1645: makes the MCP server's search behavior configurable instead of hardcoded. Adds a
searchconfig block (withSEARCH__*env vars) that controls which reranker orders results, whether superseded facts are returned, and the default result counts — and surfaces each result's relevance score so clients can judge match quality.Everything lives in
mcp_server/;graphiti_coreis untouched.What changes for users
search_memory_factsandsearch_nodesorder results with the configured reranker. The default staysrrf, so out-of-the-box ordering is unchanged. When acenter_node_uuidis given, the node-distance recipe still wins, as today.include_invalidated=trueon the call.max_facts/max_nodesbecome deployment-level defaults with per-call overrides. The shipped default is 6, sized for feeding results into an LLM context window — happy to keep it at 10 if you'd rather not change the out-of-the-box count.scorefield from the reranker, so clients can apply their own cutoffs or weight results by confidence.Design notes (learned on a live graph)
reranker_min_scoreonly applies tocross_encoder.cross_encoderis offered but not the default. It needs a configured cross-encoder client, adds a model call per search, and the core edge-search path currently truncates its candidate pool ([BUG] Cross-encoder reranking drops most candidates in edge_search #1642). The option is there for deployments that want it; the default doesn't depend on it.rrf, nothing here requires a cross-encoder client at all.Files
mcp_server/src/config/schema.py— newSearchTuningConfigblockmcp_server/src/utils/search_tuning.py— builds the coreSearchConfigfor the chosen reranker; liveness filter for invalidated factsmcp_server/src/graphiti_mcp_server.py— search tools wired to the config, per-call overridesmcp_server/src/models/response_types.py,mcp_server/src/utils/formatting.py—scorefield on resultsmcp_server/README.md— env-var reference and cross-encoder caveatTests
test_search_tuning.py,test_search_config_schema.py,test_formatting_score.py,test_search_tools_wiring.py— unit tests for the config block, search-config construction, liveness filtering, score formatting, and tool wiring (22 tests)test_search_relevance_int.py— integration test validating result relevance end-to-end (requires a live backend, skipped otherwise)This configuration has been running in production on our deployment (Neo4j backend, OpenAI provider).
Closes #1645