Skip to content

feat(mcp): activate configurable provider and model reranking - #1949

Open
abouchard11 wants to merge 7 commits into
getzep:mainfrom
abouchard11:codex/mcp-reranker-ready
Open

abouchard11 wants to merge 7 commits into
getzep:mainfrom
abouchard11:codex/mcp-reranker-ready

Conversation

@abouchard11

@abouchard11 abouchard11 commented Oct 2, 2026 •

Copy link
Copy Markdown

The MCP server constructs a cross-encoder, but ordinary node and fact searches use RRF and never call it. This change makes provider and model selection explicit and lets operators enable cross-encoder ranking independently for each search tool.

Behavior

  • reranker.provider: auto (existing inference), openai, azure_openai, gemini, or local bge; explicit providers look for configuration in both LLM and embedder blocks, trying entries that carry an API key first (LLM before embedder), and fail at startup when unavailable.
  • reranker.model: optional API-backed model override.
  • graphiti.fact_reranker / graphiti.node_reranker: rrf by default, or cross_encoder to invoke the selected client.
  • The Docker configs (config-docker-*.yaml) carry the same settings as config.yaml, so these environment variables also work in the published images.
  • With cross_encoder, the recipes also add breadth-first graph expansion, and an API-backed reranker makes one call per candidate: up to 2x the result limit for facts and up to 6x for nodes. The config comments say so.
  • Centered searches retain node-distance ranking. Per-request limits copy the recipe instead of mutating shared constants. Defaults preserve existing behavior and reranker-call cost.

Verification

Based on upstream main at 3c42764.

  • 90 focused MCP tests pass: configuration (including every shipped config file), factories (including credential precedence and each explicit provider), core parity, recipe selection, and eight cases running MCP tools through the real core ranking pipeline with retrieval/API calls stubbed.
  • Those eight cases produce four failures on unchanged upstream (the four enabled-reranker cases make zero rank calls) and all pass with this change. Default RRF cases make zero reranker calls; enabled cases call the selected OpenAI or Gemini client and follow its returned order.
  • Changed source and search tests pass Pyright.
  • Repository lint and format checks pass with the CI-pinned Ruff 0.14.11; git diff --check passes.
  • No paid provider calls or live database integration are claimed by these tests.

Contribution history

This carries forward my July 28 provider-selection implementation from #1698 and my model and recipe implementation from #1859. I kept the original commits and their author dates. It supersedes those two closed PRs.

JohnPark4One identified the RRF bypass and proposed the model and recipe controls in the RFC discussion. Both are his contributions, and I'm acknowledging them here. His node/community summary-ranking work in #1846 is separate from this change.

I submitted this from a clean public contribution fork. It includes no private operational changes.

Closes #1697.

Copilot AI balanced review requested due to automatic review settings October 2, 2026 23:51
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

An empty LLM provider entry can mask valid embedder credentials and cause startup failure.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds configurable reranking to MCP searches while preserving default RRF behavior.

Changes:

  • Adds explicit reranker provider and model selection.
  • Enables independent fact and node reranking, preserving centered-search behavior.
  • Documents configuration and adds factory and search-pipeline tests.
File Description
mcp_server/​tests/​test_search_reranker_config.py Tests recipe selection and reranker invocation.
mcp_server/​tests/​test_cross_encoder_factory.py Tests provider/model selection and service wiring.
mcp_server/​src/​services/​factories.py Constructs explicitly configured rerankers.
mcp_server/​src/​graphiti_mcp_server.py Applies configured search recipes and request limits.
mcp_server/​src/​config/​schema.py Defines reranker and search-strategy settings.
mcp_server/​README.md Documents configuration and environment overrides.
mcp_server/​config/​config.yaml Supplies backward-compatible defaults.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread mcp_server/src/services/factories.py Outdated
An explicitly selected reranker used the first matching provider entry,
LLM before embedder, as soon as it existed. An unset ${VAR} leaves an
entry with api_key=None, so an empty LLM entry hid a configured embedder
entry and startup failed with a missing-key error. Try entries with a key
first, keeping LLM-before-embedder order; keyless entries remain a
fallback for clients that read the key from the environment.

Also cover the remaining explicit paths: local bge, Azure's v1 endpoint
with a model override, and the startup error when no entry matches.
The Docker images load the config-docker-*.yaml files, which had no
reranker block or search recipe keys, so RERANKER_PROVIDER, RERANKER_MODEL,
FACT_RERANKER, and NODE_RERANKER were silently ignored there. Carry the
same settings as config.yaml into all three, and test that every shipped
config reads them from the environment.

Note in the config comments that the cross-encoder recipes also add
breadth-first graph expansion and make one reranker call per candidate:
up to 2x the result limit for facts and up to 6x for nodes.

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RFC: allow explicit MCP reranker provider configuration

2 participants