Skip to content

feat(mcp): configurable search tuning — reranker choice, stale-fact filtering, result counts, relevance scores#1647

Open
brentkearney wants to merge 6 commits into
getzep:mainfrom
brentkearney:feat/mcp-search-tuning
Open

feat(mcp): configurable search tuning — reranker choice, stale-fact filtering, result counts, relevance scores#1647
brentkearney wants to merge 6 commits into
getzep:mainfrom
brentkearney:feat/mcp-search-tuning

Conversation

@brentkearney

@brentkearney brentkearney commented Jul 13, 2026

Copy link
Copy Markdown

Summary

Implements #1645: makes the MCP server's search behavior configurable instead of hardcoded. Adds a search config block (with SEARCH__* 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_core is untouched.

What changes for users

search:
  reranker: rrf            # rrf | mmr | cross_encoder
  mmr_lambda: 0.5          # only used by mmr
  reranker_min_score: 0.0  # only meaningful for cross_encoder
  max_facts: 6             # default result count for search_memory_facts
  max_nodes: 6             # default result count for search_nodes
  exclude_invalidated: true
  • search_memory_facts and search_nodes order results with the configured reranker. The default stays rrf, so out-of-the-box ordering is unchanged. When a center_node_uuid is given, the node-distance recipe still wins, as today.
  • Facts that Graphiti's temporal model has marked invalid (superseded or expired) are excluded by default. Callers who want history back pass include_invalidated=true on the call.
  • max_facts / max_nodes become 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.
  • Each returned fact/node now carries a score field from the reranker, so clients can apply their own cutoffs or weight results by confidence.

Design notes (learned on a live graph)

Files

  • mcp_server/src/config/schema.py — new SearchTuningConfig block
  • mcp_server/src/utils/search_tuning.py — builds the core SearchConfig for the chosen reranker; liveness filter for invalidated facts
  • mcp_server/src/graphiti_mcp_server.py — search tools wired to the config, per-call overrides
  • mcp_server/src/models/response_types.py, mcp_server/src/utils/formatting.pyscore field on results
  • mcp_server/README.md — env-var reference and cross-encoder caveat

Tests

  • 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

@zep-cla-assistant

Copy link
Copy Markdown
Contributor


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. For privacy information, see our Privacy Notice. You can sign the CLA by just posting a Pull Request Comment same as the below format.


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.

@brentkearney

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA behalf on myself, e-mail: 02cirque_ladles@icloud.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP server: search behavior is hardcoded — proposal: configurable reranker, stale-fact filtering, result counts, relevance scores

1 participant