Repository navigation
fix(mcp): pass the credential store to web_fetch and the classifier - #144
Merged
Merged
Conversation
web_fetch and the prompt-injection classifier built their LLM with llmprovider.New, which passes no credential store. Providers whose API key was stored by `nib login` (regolo, openai, anthropic, …) were resolved with an empty key, so every web_fetch extraction call sent no Authorization header and got 401. The sub-agent reasoning path was unaffected: newAgentLLM builds its LLM with NewWithTemperatureAndStore, passing s.credStore. Build the store from cfg.BaseDir at the same path as NewSession (filepath.Join(plugin.BaseDirIn(cfg.BaseDir), "credentials.json")) and pass it to llmprovider.NewWithStore in StartWebMCPServer and ClassifierForConfig. The store is a path, not shared state, so an independent instance is safe.
mudler
approved these changes
Oct 13, 2026
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
web_fetchand the prompt-injection classifier built their LLM withllmprovider.New, which passes no credential store. Providers whose API key was stored bynib login(regolo, openai, anthropic, …) were resolved with an empty key, so everyweb_fetchextraction call sent noAuthorizationheader and got401 Unauthorized: An authentication key is required.The sub-agent reasoning path was unaffected:
newAgentLLMbuilds its LLM withNewWithTemperatureAndStore, passings.credStore.Why
Two LLM-construction paths in nib resolve credentials differently:
newAgentLLM)s.credStore)web_fetchextraction (StartWebMCPServer)/login-managed onlyClassifierForConfig)/login-managed onlyProviders configured with an inline
api_keyin the YAML never hit this, because the resolver finds the key in config. Only providers authenticated vianib login(key in the credential store, not in config or env) were affected.How
Build the store from
cfg.BaseDirat the same path asNewSession:and pass it to
llmprovider.NewWithStoreinStartWebMCPServerandClassifierForConfig. The store is a path (reads the file on each call), not shared state, so an independent instance is safe.Verify
go build ./...go test ./provenance/ ./mcp/ ./auth/ ./llmprovider/go test ./chat/ -timeout 120sTestWebFetchLLMUsesCredentialStoreproves that a key stored only in the credential store is resolved with the store and is empty without it.TestWebFetchCredentialStorePathproves the store path matchesNewSession's.