Add icon support to server.json schema #620
Merged
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.
Implements icon support based on the Model Context Protocol specification, allowing servers to specify display icons with optional size, MIME type, and theme variants.
Changes
Icontype topkg/model/types.gowith struct tags for automatic API validationiconsfield toServerJSONinpkg/api/v0/types.gointernal/validators/validators.go:websiteUrlvalidation to HTTPS-only for consistencyImplementation Details
The implementation uses a two-layer validation architecture:
required,maxLength,enum,pattern) and returns 422 for violationsThis approach leverages Huma's automatic validation while keeping business-specific rules in the validator layer.
Icon Field Specification
src(required): HTTPS URL to icon resource, max 255 charactersmimeType(optional): One ofimage/png,image/jpeg,image/jpg,image/svg+xml,image/webpsizes(optional): Array of size strings in "WxH" format or "any" for scalable formatstheme(optional): Either "light" or "dark" to indicate intended backgroundMultiple icons can be provided (e.g., for different themes or sizes).