fix(search): accept dhi type and hardened badge - #87
Merged
Conversation
Docker Hub search v4 now boosts a Docker Hardened Image to the top of the results for any query that has one, returning type "dhi" and badge "hardened". Neither value was in the search tool's output schema, so the MCP SDK rejected the whole response and the tool errored out for common queries such as curl, nginx, node and python. Passing type "image" does not avoid it, since the API returns the boosted DHI entry regardless of that filter. Add both values to the output schema, and add "hardened" to the badges input filter so the tool can request only Docker Hardened Images. The Hub API already supports badges=hardened. Regenerate tools.json accordingly. Signed-off-by: Julian Perge <3217992+julian-perge@users.noreply.github.com>
lucadruda
approved these changes
Aug 26, 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.
Description
The
searchtool errors out for common queries because its output schemarejects two values the Docker Hub search v4 API now returns:
type: "dhi"and
badge: "hardened".Hub boosts a Docker Hardened Image to rank 1 for any query that has one, so
search{query: "curl"},nginx,nodeandpythonall fail output schemavalidation in the MCP SDK before the client sees any result.
Tool Details
search(Docker Hub MCP server)tools.jsontypeenum: addeddhibadgeenum: addedhardenedbadgesfilter enum: addedhardenedtools.jsonvianpm run list-tools:updateMotivation and Context
Reproduced against the live API:
Same shape for
query=nginx(dhi/nginxfirst, ahead of the officialnginx).Two notes on the failure mode:
type: "image"does not work around it. The API returns theboosted DHI entry regardless of that filter, verified with and without
custom_boosted_results=true, so the boost flag atsrc/search.ts:175is not the trigger.
badges: ["official"]happens to work, because that filter drops the DHIrow server-side and validation then passes. This masks the bug for some
queries.
badges=hardenedis already supported by the Hub API and returns only DHIrepositories, so it is exposed on the input filter as well:
There is no existing issue for this, so the branch is not named
XXXX-somethingper CONTRIBUTING. Happy to open one and rename if you would prefer that.
How Has This Been Tested?
Built with
npm run buildand driven over stdio against the rebuiltdist/index.jswith a raw JSON-RPCtools/call:search{query:"curl",size:3}dhi/curl,rapidfort/curl,rancher/curlsearch{query:"curl",badges:["hardened"]}dhi/curlAlso verified in Claude Code with this server configured, where the same two
calls previously failed.
Repo checks all pass:
npm run lint,npm run format:check,npm run test(8/8),npm run list-tools:check.Breaking Changes
None. Both changes are additive enum widenings. No client configuration
changes are needed.
Types of changes
Checklist
README is unchanged because it does not enumerate the search tool's schema
values. The tool descriptions are the surface that changed, and those are
updated in
src/search.tsand regenerated intotools.json.Additional context
The enums went stale rather than being wrong when written. DHI is a newer
result type on Hub search, and the schema predates it. Since the API can add
result types independently of this server, a looser output schema for
typeand
badgewould fail open instead of erroring the whole call, but I keptthis change minimal and additive.