feat(mcp): use a provider-matched cross-encoder to avoid a hard OpenAI dependency#1669
feat(mcp): use a provider-matched cross-encoder to avoid a hard OpenAI dependency#1669abouchard11 wants to merge 1 commit into
Conversation
…pendency The MCP server never passed a cross_encoder to Graphiti(), so graphiti-core fell back to OpenAIRerankerClient() and required OPENAI_API_KEY even when the LLM and embedder were configured for a different provider (e.g. an all-Gemini stack). Add a CrossEncoderFactory that mirrors the existing LLM/Embedder factories: for the gemini provider it returns a GeminiRerankerClient built from the configured Gemini API key; every other provider returns None, which preserves the current default (OpenAIRerankerClient). Wire the result into both the FalkorDB and Neo4j Graphiti() constructors. This lets a fully non-OpenAI deployment run without an OPENAI_API_KEY, with no behavior change for existing OpenAI users.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA behalf on myself, e-mail: alex@midnightdev.dev |
|
I have read the CLA Document and I hereby sign the CLA |
|
@abouchard11 Tested the factory: Gemini gets a proper reranker, but Anthropic/other providers return None and still fall back to the OpenAI reranker, so the hard OPENAI_API_KEY requirement remains for them. #1637 covers all providers with a local BGE fallback and tests, probably best to consolidate there. |
|
Consolidating into #1637 as @Naseem77 suggested — it's a superset of this change (provider inference including the embedder, local BGE fallback, tests) and covers the Anthropic case flagged above. I've tested #1637 against my production Neo4j + all-Gemini stack and left a review with findings there. Closing. |
Problem
The MCP server builds an LLM client and an embedder client from config, but never passes a
cross_encodertoGraphiti(). WhenGraphiti()receives no cross-encoder it hard-defaults toOpenAIRerankerClient(), which requiresOPENAI_API_KEY.The result: a deployment configured entirely for a non-OpenAI provider (e.g. Gemini LLM + Gemini embedder) still fails to start without an OpenAI key, purely because of the reranker default.
Fix
Add a
CrossEncoderFactorythat mirrors the existingLLMClientFactory/EmbedderFactory:geminiprovider it returns aGeminiRerankerClient(already shipped ingraphiti-core) built from the configured Gemini API key;None, which preserves the current default (graphiti-coreappliesOpenAIRerankerClient()).The result is wired into both the FalkorDB and Neo4j
Graphiti()constructors.Compatibility
No behavior change for existing OpenAI users: unmatched providers return
None, sographiti-corekeeps applying itsOpenAIRerankerClient()default exactly as before. An all-Gemini deployment can now start without anOPENAI_API_KEY.Verification
providersextra (HAS_GEMINI_RERANKER = True).gemini→ constructs aGeminiRerankerClient;anthropic/other → returnsNone(default preserved).Scope
Two files, additive:
mcp_server/src/services/factories.py— newCrossEncoderFactory+ a guardedGeminiRerankerClientimport.mcp_server/src/graphiti_mcp_server.py— build the cross-encoder via the factory and pass it into bothGraphiti()constructors.