From e0290955343ffff51f3c30ff106cf27ea497b6c3 Mon Sep 17 00:00:00 2001 From: Drew Whittle Date: Thu, 20 Aug 2026 09:54:09 +1200 Subject: [PATCH] fix(mcp): register IHttpClientFactory so EmbeddingClient can activate 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 --- src/Equibles.Mcp.Server/Program.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Equibles.Mcp.Server/Program.cs b/src/Equibles.Mcp.Server/Program.cs index d4cd44a21..6b5f87994 100644 --- a/src/Equibles.Mcp.Server/Program.cs +++ b/src/Equibles.Mcp.Server/Program.cs @@ -84,6 +84,10 @@ public static void ConfigureServices(WebApplicationBuilder builder) builder.Services.Configure( builder.Configuration.GetSection("Embedding") ); + // EmbeddingClient resolves IHttpClientFactory unconditionally in its constructor, + // even when embeddings are disabled -- without this, any Sec search tool + // (ListCompanyDocuments, SearchDocuments, SearchCompanyDocuments) fails to activate. + builder.Services.AddHttpClient(); builder.Services.Configure( builder.Configuration.GetSection("FileStorage") );