Skip to content

fix(search): accept dhi type and hardened badge - #87

Merged
lucadruda merged 2 commits into
docker:mainfrom
julian-perge:fix-search-dhi-enums
Aug 27, 2026
Merged

fix(search): accept dhi type and hardened badge#87
lucadruda merged 2 commits into
docker:mainfrom
julian-perge:fix-search-dhi-enums

Conversation

@julian-perge

Copy link
Copy Markdown
Contributor

Description

The search tool errors out for common queries because its output schema
rejects 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, node and python all fail output schema
validation in the MCP SDK before the client sees any result.

Tool Details

  • Tool: search (Docker Hub MCP server)
  • Changes to: output schema, input schema, descriptions, tools.json
    • output type enum: added dhi
    • output badge enum: added hardened
    • input badges filter enum: added hardened
    • regenerated tools.json via npm run list-tools:update

Motivation and Context

Reproduced against the live API:

GET /api/search/v4?custom_boosted_results=true&query=curl&size=5
  dhi        hardened            dhi/curl
  image      verified_publisher  rapidfort/curl
  image      verified_publisher  rancher/curl
  image      open_source         alpine/curl

Same shape for query=nginx (dhi/nginx first, ahead of the official
nginx).

Two notes on the failure mode:

  • Passing type: "image" does not work around it. The API returns the
    boosted DHI entry regardless of that filter, verified with and without
    custom_boosted_results=true, so the boost flag at src/search.ts:175
    is not the trigger.
  • badges: ["official"] happens to work, because that filter drops the DHI
    row server-side and validation then passes. This masks the bug for some
    queries.

badges=hardened is already supported by the Hub API and returns only DHI
repositories, so it is exposed on the input filter as well:

GET /api/search/v4?query=curl&badges=hardened
  total 1
  dhi  hardened  dhi/curl

There is no existing issue for this, so the branch is not named XXXX-something
per CONTRIBUTING. Happy to open one and rename if you would prefer that.

How Has This Been Tested?

Built with npm run build and driven over stdio against the rebuilt
dist/index.js with a raw JSON-RPC tools/call:

Call Before After
search{query:"curl",size:3} output validation error dhi/curl, rapidfort/curl, rancher/curl
search{query:"curl",badges:["hardened"]} input rejected dhi/curl

Also 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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Protocol Documentation
  • My changes follows MCP security best practices
  • I have updated the server README accordingly
  • I have tested this with an LLM client
  • My code follows the repository's style guidelines
  • I have added appropriate error handling
  • I have documented all environment variables and configuration options

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.ts and regenerated into tools.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 type
and badge would fail open instead of erroring the whole call, but I kept
this change minimal and additive.

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>
@julian-perge
julian-perge requested a review from a team as a code owner August 20, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants