feat(web): display package icons in server list#1208
Open
MukundaKatta wants to merge 1 commit intomodelcontextprotocol:mainfrom
Open
feat(web): display package icons in server list#1208MukundaKatta wants to merge 1 commit intomodelcontextprotocol:mainfrom
MukundaKatta wants to merge 1 commit intomodelcontextprotocol:mainfrom
Conversation
Render each server's icon (when present in server.json) in the in-browser UI cards. Falls back to a generic inline-SVG tile when missing or when the remote URL fails to load. Uses lazy-loaded <img> with explicit dimensions to avoid layout shift, restricts URLs to HTTPS to match the schema, and sets referrerpolicy=no-referrer. Closes modelcontextprotocol#784
2827885 to
9c349e8
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.
Why
Closes #784. The in-browser registry UI today renders server cards with no visual at all — even though many
server.jsonfiles already declareicons. Browsing 1,000+ servers as a wall of text makes it hard to spot the one you want at a glance.What
Adds a small icon tile to each card in both lists (
Recently Updatedand the main grid):server.icons[]from the existing API response (already exposed viapkg/api/v0/types.go, no API change).theme: "light"first (page is light-themed), then theme-agnostic, then dark.<img>withwidth="40" height="40"for layout stability (no CLS),loading="lazy"so off-screen icons don't fetch,referrerpolicy="no-referrer"to avoid leaking the page URL to icon hosts./^https:\/\//i), matching the schema requirement onIcon.src. Defends againstjavascript:/data:/http://if a future server slips past validation.onerror(broken URL, mixed content, CORS), swaps in a generic inline-SVG fallback tile. Same fallback is used when the server has no icons at all, so the layout stays consistent.Two files changed:
internal/api/handlers/v0/ui_index.html— addspickIconSrc(),renderIconTile(), the fallback CSS, and the tile slot in both card renderers.internal/api/handlers/v0/ui_test.go(new) — guards the icon wiring (helper function names,loading="lazy", dimensions, HTTPS check) so a future refactor surfaces in CI.Tested
go test ./internal/api/handlers/v0/...(the newTestGetUIHTML_IconSupportplus the existing handler tests) passes locally./, confirmed:iconsrender the generic fallback tile.loading="lazy"confirmed in DevTools, no network requests for icons below the fold until scrolled.