fix(mcp): keep zero-result lookups out of isError - #1
Merged
fahreddinozcan merged 1 commit intoAug 6, 2026
Merged
Conversation
The API reports "nothing matched" as a 404 carrying a machine-readable
code (no_libraries_found, no_relevant_snippets), so status alone cannot
separate it from a real failure. parseErrorResponse discarded that code
and returned only the message, so every 404 became isError: true.
That contradicted the changeset ("an empty search result set is still a
success"). It also works against both tools' instructions: their
messages ask the model to refine its query, while isError tells the
client the call failed, and the SDK's own callTool example returns early
on isError without showing the content.
parseErrorResponse now returns { message, isError }; the status fallback
moves to a helper so its branches stay unchanged. Benign outcomes are no
longer logged to stderr as errors.
Tests cover both empty-result codes, library_not_found sharing the same
404 status, and searchLibraries, which had none.
fahreddinozcan
force-pushed
the
fix/iserror-empty-results
branch
from
August 6, 2026 08:06
4c8efbd to
4dc8477
Compare
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.
Stops
resolve-library-idandquery-docsfrom flagging "nothing matched" as a tool execution error, which upstash#2989 currently does despite its changeset promising otherwise.no_libraries_found/no_relevant_snippets.parseErrorResponsediscarded that code and kept only the message, so every 404 becameisError: true.parseErrorResponsenow returns{ message, isError }. The status fallback moves to a helper so its branches stay byte-identical.SearchResponsegainsisError, soresolve-library-idstops inferring failure from the presence of display text.library_not_foundon the same 404 status, andsearchLibraries, which had no tests.library_not_foundstays an error. Error text is unchanged everywhere, so the model still sees "Try a different search term".Why
The spec does not address empty result sets. It says
isErroris for tool calls that failed, and also that it exists so the LLM can self-correct, which cuts both ways. The tiebreaker is what clients do: the v2 SDK's owncallToolexample returns early onisErrorwithout showing content. Leaving the flag unset is safe under every host because the message text already tells the model to retry, whereas setting it risks swallowing that guidance on the most common benign outcome.Verified
typecheck,lint,build,test(54/54). Live against the real Context7 API over stdio:truetruetruetruetruetrue