Repository navigation
Commit 8c478cd
committed
feat(ui): display server icons in the registry web client
Servers can declare `icons` in server.json and the schema has supported it
for some time, but the web client never rendered them, so every card looked
identical apart from its text. Closes modelcontextprotocol#784.
Selection, in order:
- HTTPS only. The publish API already rejects other schemes, but this UI can
be pointed at a staging, local or custom API base URL from its own settings,
so the scheme is re-checked at render time rather than trusted.
- `theme: "dark"` icons are used only when nothing else is offered, since this
UI has a light background.
- Scalable icons (`sizes: ["any"]`) win outright. Otherwise the smallest icon
at least as wide as the rendered size is chosen, so it stays crisp without
fetching a needlessly large file.
Rendering notes:
- `src` goes through the existing `escapeAttr`, so a quote in a URL cannot
break out of the attribute.
- `alt` is empty on purpose. The icon sits directly beside the server name, so
announcing it again is noise for screen readers.
- `loading="lazy"` keeps a grid of cards from fetching every icon at once, and
`referrerpolicy="no-referrer"` avoids leaking registry URLs to icon hosts.
- A broken or blocked image removes itself instead of leaving a placeholder.
Verified against the first 100 servers in the production registry, which
exercises every shape currently published: no `sizes` field, a single 512x512,
`["any"]`, and a 256/512 pair. Also checked that http, `javascript:`, `data:`
and null sources render nothing, and that a quote injected into `src` is
escaped.
Unit tests pass, including internal/api/handlers/v0, which is the package that
embeds this file. `make validate` and `make lint` both fail identically on a
clean checkout of upstream main with these changes absent, so those failures
are pre-existing rather than introduced here; the lint ones are gofmt objecting
to CRLF from a Windows checkout. Tests ran without `-race`, which needs cgo and
a C toolchain this machine does not have.1 parent 6036804 commit 8c478cd
1 file changed
Lines changed: 54 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
288 | 288 | | |
289 | 289 | | |
290 | 290 | | |
| 291 | + | |
291 | 292 | | |
292 | 293 | | |
293 | 294 | | |
| |||
353 | 354 | | |
354 | 355 | | |
355 | 356 | | |
| 357 | + | |
356 | 358 | | |
357 | 359 | | |
358 | 360 | | |
| |||
511 | 513 | | |
512 | 514 | | |
513 | 515 | | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
514 | 568 | | |
515 | 569 | | |
516 | 570 | | |
| |||
0 commit comments