fix(mcp): register IHttpClientFactory so EmbeddingClient can activate - #4413
Open
DrewWhittleNZ wants to merge 1 commit into
Open
fix(mcp): register IHttpClientFactory so EmbeddingClient can activate#4413DrewWhittleNZ wants to merge 1 commit into
DrewWhittleNZ wants to merge 1 commit into
Conversation
EmbeddingClient's constructor resolves IHttpClientFactory unconditionally (before it even checks whether embeddings are enabled), but Equibles.Mcp.Server/Program.cs never calls AddHttpClient(), unlike Equibles.Web/Program.cs which does. This leaves ListCompanyDocuments, SearchDocuments, and SearchCompanyDocuments unable to activate at all -- every call fails with: System.InvalidOperationException: Unable to resolve service for type 'System.Net.Http.IHttpClientFactory' while attempting to activate 'Equibles.Sec.BusinessLogic.Embeddings.EmbeddingClient'. Reproduces regardless of ticker, filing-data availability, or the Embedding__Enabled setting (confirmed with it both unset and explicitly enabled with a working Ollama endpoint), since EmbeddingClient always calls httpClientFactory.CreateClient() before checking its own config. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
What
Equibles.Mcp.Server/Program.csnever registersIHttpClientFactory, so any tool whose dependency graph reachesEmbeddingClientfails to activate — regardless of ticker, filing-data availability, or theEmbedding__Enabledsetting.EmbeddingClient's constructor callshttpClientFactory.CreateClient()unconditionally, before it checks_config.IsConfigured:Equibles.Web/Program.csalready callsbuilder.Services.AddHttpClient();— this PR adds the same call to the MCP host, which was missing it.Repro
Calling
ListCompanyDocuments,SearchDocuments, orSearchCompanyDocumentsfor any ticker fails at MCP tool construction time with this error. Reproduced against a self-hosted instance:Embedding__Enabledunset (the documented default) — fails.Embedding__Enabled=trueand a working Ollamaqwen3-embedding:0.6bendpoint configured — still fails identically. Rules out a feature-flag gating explanation; the dependency is unconditional.Likely introduced by 49ad9aa (hybrid BM25+semantic retrieval + pluggable embedding provider), which appears to be where
IHttpClientFactorywas first plumbed intoEmbeddingClient. Same general class of bug as #4019 and #4058 — a business-logic assembly's dependency changes or gets auto-wired into a host, and that host'sProgram.csis missing the one extra explicit registration the dependency needs.Testing
Verified live against a running instance with real ingested data (SEC filings + insider transactions for OGC/RKLB/NVDA/CRWD):
ListCompanyDocuments,SearchDocuments,SearchCompanyDocumentsall failed with theIHttpClientFactoryexception above, on every ticker, every parameter combination.ListCompanyDocumentsfor CRWD returns a correct, well-formed document list — 99 documents, correctly typed and dated (recent 8-Ks, a 10-Q filed 2026-06-04 for the period ending 2026-04-30, a DEF 14A, a 10-K, etc.). No error.SearchDocuments/SearchCompanyDocumentsno longer error post-fix either, though they currently return no matches for queries that should hit real content (e.g. "revenue" against a company with a 10-Q on file) — this looks like the search index still catching up with a recently-populated document backlog rather than anything related to this fix, since it's a distinct symptom (empty result vs. exception) from what this PR addresses. Happy to dig into that separately if it persists once ingestion settles.