Skip to content

Commit ee9df07

Browse files
RuyaaCapital-adminTaher
andauthored
fix(ui): prefer human-readable server title in registry cards (#1573)
## Summary - prefer the optional `server.title` as the primary heading in Registry cards - keep `server.name` visible as a smaller secondary identity when the values differ - preserve the existing `server.name` heading when `title` is absent or identical - apply the same compact layout to normal results and Recently Updated cards ## Why The Registry schema defines `title` as a human-readable display name, but collapsed cards currently headline only the reverse-DNS `name`. That makes browsing harder for users who do not recognize programmatic MCP identifiers. Generic example: ```text Before io.example/weather-server After Weather Planner io.example/weather-server ``` The technical identity remains visible for namespace verification. All user-provided values continue to pass through the existing `escapeHtml(...)` helper, and long values use the existing Tailwind wrapping utilities. ## Scope This is presentation-only and backward-compatible. It does not change schemas, API responses, search behavior, publishing, authentication, or protocol behavior. The API `search` parameter currently matches only `server_name`; title and description search are not included here. Icon rendering is also intentionally out of scope and is already tracked by #784. ## Testing - `git diff --check` - real-browser Playwright smoke coverage with controlled fixtures: - title different from name - no title - title equal to name, without duplicate identity text - very long title and technical name, with no card overflow - Recently Updated card - normal result cards - expanded details still open and display the title Local `make check` was unavailable because this Windows environment does not have Go, Make, Docker, or a WSL distribution installed. The upstream PR CI is configured to run lint, schema validation, build, vulnerability scanning, and all tests. Co-authored-by: Taher <[email protected]>
1 parent 6f44157 commit ee9df07

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

‎internal/api/handlers/v0/ui_index.html‎

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ <h3 class="text-lg font-semibold mb-4">API Base URL</h3>
310310
recentServers.forEach(item => {
311311
const server = item.server;
312312
const meta = item._meta?.['io.modelcontextprotocol.registry/official'];
313+
const identity = getServerCardIdentity(server);
313314

314315
const card = document.createElement('div');
315316
card.className = 'bg-blue-50 border border-blue-200 rounded-lg overflow-hidden hover:border-blue-400 hover:shadow-md transition-all flex flex-col';
@@ -320,7 +321,10 @@ <h3 class="text-lg font-semibold mb-4">API Base URL</h3>
320321
header.innerHTML = `
321322
<div class="flex items-start justify-between gap-3 mb-2">
322323
${renderIcon(server)}
323-
<h3 class="font-semibold text-gray-900 text-base flex-1 min-w-0 break-all">${escapeHtml(server.name)}</h3>
324+
<div class="flex-1 min-w-0">
325+
<h3 class="font-semibold text-gray-900 text-base ${identity.titleWrapClass}">${escapeHtml(identity.displayTitle)}</h3>
326+
${identity.technicalName ? `<p class="text-xs text-gray-500 leading-tight mt-0.5 break-all">${escapeHtml(identity.technicalName)}</p>` : ''}
327+
</div>
324328
<span class="text-xs text-gray-500 font-medium whitespace-nowrap">v${escapeHtml(server.version)}</span>
325329
</div>
326330
<p class="text-sm text-gray-600 leading-relaxed line-clamp-2 mb-2 break-words">${escapeHtml(server.description || '')}</p>
@@ -336,6 +340,16 @@ <h3 class="font-semibold text-gray-900 text-base flex-1 min-w-0 break-all">${esc
336340
applyRecentExpanded();
337341
}
338342

343+
function getServerCardIdentity(server) {
344+
const hasDistinctTitle = Boolean(server.title && server.title !== server.name);
345+
346+
return {
347+
displayTitle: hasDistinctTitle ? server.title : server.name,
348+
technicalName: hasDistinctTitle ? server.name : null,
349+
titleWrapClass: hasDistinctTitle ? 'break-words' : 'break-all'
350+
};
351+
}
352+
339353
// Fetch servers
340354
async function fetchServers(cursor = null, search = '', latestOnly = null) {
341355
const requestSequence = ++serverRequestSequence;
@@ -397,6 +411,7 @@ <h3 class="font-semibold text-gray-900 text-base flex-1 min-w-0 break-all">${esc
397411
servers.forEach(item => {
398412
const server = item.server;
399413
const meta = item._meta?.['io.modelcontextprotocol.registry/official'];
414+
const identity = getServerCardIdentity(server);
400415

401416
const card = document.createElement('div');
402417
card.className = 'bg-white border border-gray-200 rounded-lg overflow-hidden hover:border-blue-300 hover:shadow-md transition-all flex flex-col';
@@ -407,7 +422,10 @@ <h3 class="font-semibold text-gray-900 text-base flex-1 min-w-0 break-all">${esc
407422
header.innerHTML = `
408423
<div class="flex items-start justify-between gap-3 mb-2">
409424
${renderIcon(server)}
410-
<h3 class="font-semibold text-gray-900 text-base flex-1 min-w-0">${escapeHtml(server.name)}</h3>
425+
<div class="flex-1 min-w-0">
426+
<h3 class="font-semibold text-gray-900 text-base ${identity.titleWrapClass}">${escapeHtml(identity.displayTitle)}</h3>
427+
${identity.technicalName ? `<p class="text-xs text-gray-500 leading-tight mt-0.5 break-all">${escapeHtml(identity.technicalName)}</p>` : ''}
428+
</div>
411429
<span class="text-xs text-gray-500 font-medium whitespace-nowrap">v${escapeHtml(server.version)}</span>
412430
</div>
413431
<p class="text-sm text-gray-600 leading-relaxed line-clamp-2 mb-2">${escapeHtml(server.description || '')}</p>

0 commit comments

Comments
 (0)