Skip to content

fix: auto-inject portal logo into platform-info MCP app#210

Merged
cjimti merged 1 commit intomainfrom
fix/platform-info-logo-injection
Mar 9, 2026
Merged

fix: auto-inject portal logo into platform-info MCP app#210
cjimti merged 1 commit intomainfrom
fix/platform-info-logo-injection

Conversation

@cjimti
Copy link
Member

@cjimti cjimti commented Mar 9, 2026

Summary

  • Platform-info MCP app shows default graph icon instead of operator logo. registerBuiltinPlatformInfo passes the operator's mcpapps.apps.platform-info.config verbatim to the embedded HTML. The HTML renders CFG.logo_svg || DEFAULT_LOGO, but operators typically configure their logo via portal.logo (a URL), not by duplicating an inline SVG into mcpapps.apps.platform-info.config.logo_svg. The result: the portal, admin UI, and login page all show the correct logo, but the platform-info MCP app falls back to the default data-graph icon.

Root cause

No bridging between portal.logo and the platform-info app config. The two config paths were completely disconnected:

portal.logo: "https://example.com/logo.svg"     ← used by portal/admin UI
mcpapps.apps.platform-info.config.logo_svg: ""   ← used by platform-info app (empty → default icon)

Fix

Auto-inject portal logo (pkg/platform/platform.go)

New injectPortalLogo() method called at the end of registerBuiltinPlatformInfo. When the operator hasn't explicitly set logo_svg or logo_url in the app config, it auto-populates logo_url from portal.logo. This means any deployment that already has portal.logo configured gets the correct logo in the platform-info app with zero config changes.

Precedence chain (highest to lowest):

  1. mcpapps.apps.platform-info.config.logo_svg — inline SVG markup (explicit override)
  2. mcpapps.apps.platform-info.config.logo_url — image URL (explicit override)
  3. portal.logo — auto-injected as logo_url (new behavior)
  4. Default data-graph icon (built into HTML)

URL logo support (apps/platform-info/index.html)

The HTML previously only supported logo_svg (inline SVG markup). Added logo_url support that renders with <img> tag, including object-fit: contain styling to handle various aspect ratios. The logo markup selection is now:

if (logoSvg) { logoMarkup = logoSvg; }
else if (logoUrl) { logoMarkup = '<img src="...">'; }
else { logoMarkup = DEFAULT_LOGO; }

Lint fix (pkg/middleware/mcp.go)

Extracted repeated "tool" slog key string literal (4 occurrences) to logKeyTool constant, fixing a pre-existing revive/add-constant lint finding.

Test plan

  • TestInjectPortalLogo/injects_logo_url_from_portal.logo — portal.logo auto-injected as logo_url
  • TestInjectPortalLogo/does_not_overwrite_explicit_logo_svg — explicit logo_svg preserved, no logo_url added
  • TestInjectPortalLogo/does_not_overwrite_explicit_logo_url — explicit logo_url preserved unchanged
  • TestInjectPortalLogo/no-op_when_portal_logo_is_empty — no injection when portal.logo is unset
  • TestInjectPortalLogo/creates_map_when_config_is_nil — handles nil config (no mcpapps config block)
  • injectPortalLogo — 100% coverage
  • make verify — all checks pass (fmt, test, lint, security, coverage, dead-code, mutate, release-check)
  • Deploy and verify platform-info app shows portal logo via <img> tag

The platform-info app was showing the default graph icon instead of the
operator's logo because registerBuiltinPlatformInfo passed through the
mcpapps config verbatim — operators had to duplicate their logo as
logo_svg in the mcpapps config even when portal.logo was already set.

Add injectPortalLogo() which auto-populates logo_url from portal.logo
when neither logo_svg nor logo_url are explicitly set. Update the
platform-info HTML to support logo_url (renders with <img>) as a
fallback between inline SVG and the default icon.

Also extract repeated "tool" slog key to logKeyTool constant to fix
a pre-existing revive lint finding.
@codecov
Copy link

codecov bot commented Mar 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.15%. Comparing base (6204ccc) to head (522b7cb).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #210   +/-   ##
=======================================
  Coverage   90.15%   90.15%           
=======================================
  Files         135      135           
  Lines       14032    14044   +12     
=======================================
+ Hits        12650    12662   +12     
  Misses       1007     1007           
  Partials      375      375           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cjimti cjimti merged commit a04c5da into main Mar 9, 2026
8 checks passed
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.

1 participant