Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(mcp-host): tie the renderers' fonts to the packages that ship them

marcoteb05f7771edfa7
diff --git a/.github/workflows/ci-public.yml b/.github/workflows/ci-public.yml
index 14de96267..47e8d6534 100644
--- a/.github/workflows/ci-public.yml
+++ b/.github/workflows/ci-public.yml
@@ -863,6 +863,20 @@ jobs:
- name: Every image shipping a TLS tool installs ca-certificates
run: bash scripts/check-dockerfile-ca-certificates.sh
+ # ─── Dockerfile font guard ────────────────────────────────────────────────
+ # The renderers find their faces by file name and the packages that ship
+ # them are listed in each Dockerfile; an image missing one builds and runs,
+ # and its Arabic, Hebrew or Han text silently loses its face.
+ dockerfile-font-guard:
+ name: Validate mcp-host font packages
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
+ - name: Every mcp-host image and CI job installs the renderers' fonts
+ run: bash scripts/check-dockerfile-fonts.sh
+ - name: The font check passes complete lists and names what one misses
+ run: bash scripts/tests/test-check-dockerfile-fonts.sh
+
# ─── Deploy manifest check (public overlays) ──────────────────────────────
# The public repo carries base + minikube overlays only; the gcp-dev/gcp-prod
# overlays live in keyper-labs/evenfire-infra and are rendered by infra CI.
diff --git a/mcp-host/src/workflow/__tests__/fonts.test.ts b/mcp-host/src/workflow/__tests__/fonts.test.ts
index a8e8dd5f2..35438d301 100644
--- a/mcp-host/src/workflow/__tests__/fonts.test.ts
+++ b/mcp-host/src/workflow/__tests__/fonts.test.ts
@@ -15,6 +15,7 @@ import {
asciiStandIn,
canRender,
ensureFontsReady,
+ missingScripts,
pdfFontDescriptors,
pdfGlyphSource,
sanitizeForFont,
@@ -72,6 +73,28 @@ describe('font provisioning', () => {
})
})
+describe('missingScripts', () => {
+ const ALL = (_prefix: string) => true
+
+ it('reports no script whose preferred face alone is missing', () => {
+ // Debian ships Noto Sans Arabic but not its UI build.
+ expect(missingScripts(prefix => prefix !== 'NotoSansArabicUI', true)).toEqual([])
+ expect(missingScripts(ALL, true)).toEqual([])
+ })
+
+ it('reports a script none of whose faces is installed', () => {
+ expect(missingScripts(prefix => !prefix.includes('Arabic'), true)).toEqual(['Arabic'])
+ expect(missingScripts(ALL, false)).toEqual(['CJK'])
+ })
+
+ it('reports the sixteen further scripts on an image with only the Arabic and Hebrew faces', () => {
+ const alpine = (prefix: string) => /Arabic|Hebrew/.test(prefix)
+ const missing = missingScripts(alpine, true)
+ expect(missing).toHaveLength(16)
+ expect(missing).toEqual(expect.arrayContaining(['Devanagari', 'Thai', 'Ethiopic']))
+ })
+})
+
describe('glyph coverage', () => {
it('reports ASCII as always renderable without measuring', () => {
expect(canRender('x')).toBe(true)
diff --git a/mcp-host/src/workflow/fonts.ts b/mcp-host/src/workflow/fonts.ts
index 3d7293cf3..c8f41e5eb 100644
--- a/mcp-host/src/workflow/fonts.ts
+++ b/mcp-host/src/workflow/fonts.ts
@@ -549,6 +549,26 @@ const MORE_SCRIPT_PREFIXES = [
'NotoSansEthiopic',
]
+/** The scripts the fallback faces are there for, each with the faces that draw it. */
+const SCRIPT_FACES: ReadonlyArray<readonly [script: string, prefixes: readonly string[]]> = [
+ ['Arabic', SCRIPT_FALLBACK_PREFIXES.filter(prefix => prefix.includes('Arabic'))],
+ ['Hebrew', SCRIPT_FALLBACK_PREFIXES.filter(prefix => prefix.includes('Hebrew'))],
+ ...MORE_SCRIPT_PREFIXES.map(prefix => [prefix.slice('NotoSans'.length), [prefix]] as const),
+]
+
+/**
+ * The scripts no installed face draws, given which face prefixes resolve and
+ * whether a CJK collection is installed. A script with any face of its own is
+ * not missing, so an image without only the preferred one (Debian has no Noto
+ * Sans Arabic UI) is not reported.
+ */
+export function missingScripts(hasFace: (prefix: string) => boolean, hasCjk: boolean): string[] {
+ const missing = SCRIPT_FACES.filter(([, prefixes]) => !prefixes.some(hasFace)).map(
+ ([script]) => script
+ )
+ return hasCjk ? missing : ['CJK', ...missing]
+}
+
interface FallbackFamily {
family: string
faces: PdfFaces
@@ -622,6 +642,14 @@ function discoverFallbacks(exclude: Set<string>): FallbackFamily[] {
}
FALLBACK_PREFIXES.forEach(add)
MORE_SCRIPT_PREFIXES.forEach(add)
+ const missing = missingScripts(prefix => facesForPrefix(prefix) !== undefined, cjk !== undefined)
+ if (missing.length > 0) {
+ // Once per process: the faces are looked up once (glyphSource).
+ logger.warn(
+ { component: 'fonts', scripts: missing },
+ 'No installed face draws these scripts, so PDFs leave their characters out'
+ )
+ }
return out
}
diff --git a/scripts/check-dockerfile-fonts.sh b/scripts/check-dockerfile-fonts.sh
new file mode 100755
index 000000000..fb0652edc
--- /dev/null
+++ b/scripts/check-dockerfile-fonts.sh
@@ -0,0 +1,173 @@
+#!/usr/bin/env bash
+# Lint: every mcp-host image, and the CI job that tests mcp-host, installs the
+# font packages the chart and document renderers look for.
+#
+# Why: the renderers find their faces by file name (mcp-host/src/workflow/
+# fonts.ts: PDF_FAMILY_PREFIXES, SCRIPT_FALLBACK_PREFIXES, FALLBACK_PREFIXES
+# and the CJK collections), and the packages that ship those files are listed
+# separately in each Dockerfile. Nothing else ties the two: an image that
+# drops a package still builds and starts, and the faces it carried fall
+# through to the next prefix or to none, so Arabic, Hebrew or Han text comes
+# out in the wrong face or not at all, with no error.
+#
+# The packages, per package manager, and the faces they ship:
+# DejaVu Sans and Sans Mono apk font-dejavu apt fonts-dejavu-core
+# Noto Sans and its script faces apk font-noto apt fonts-noto-core
+# Noto Sans Arabic apk font-noto-arabic (in fonts-noto-core)
+# Noto Sans Hebrew apk font-noto-hebrew (in fonts-noto-core)
+# Noto Sans CJK collections apk font-noto-cjk apt fonts-noto-cjk
+# Alpine has no package for the further script faces (Devanagari, Thai,
+# Ethiopic and the rest of MORE_SCRIPT_PREFIXES), which Debian's
+# fonts-noto-core ships; the renderer logs the scripts it has no face for.
+#
+# Only the final stage of a Dockerfile counts: fonts installed in a builder
+# stage do not reach the image. Exempt a deliberate, reviewed case with a
+# `# FONTS-OK: <reason>` comment anywhere in the final stage.
+#
+# Usage: check-dockerfile-fonts.sh [--workflow FILE] [DOCKERFILE...]
+# With no arguments it checks mcp-host/Dockerfile* and
+# .github/workflows/ci-public.yml.
+set -euo pipefail
+
+ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
+cd "$ROOT_DIR"
+
+APK_FONTS="font-dejavu font-noto font-noto-cjk font-noto-arabic font-noto-hebrew"
+APT_FONTS="fonts-dejavu-core fonts-noto-core fonts-noto-cjk"
+
+workflow=""
+dockerfiles=()
+while [ "$#" -gt 0 ]; do
+ case "$1" in
+ --workflow)
+ workflow="$2"
+ shift 2
+ ;;
+ *)
+ dockerfiles+=("$1")
+ shift
+ ;;
+ esac
+done
+if [ "${#dockerfiles[@]}" -eq 0 ] && [ -z "$workflow" ]; then
+ while IFS= read -r f; do dockerfiles+=("$f"); done < <(find mcp-host -maxdepth 1 -type f -name 'Dockerfile*' | sort)
+ workflow=".github/workflows/ci-public.yml"
+fi
+
+violations=0
+report() {
+ echo "VIOLATION: $1" >&2
+ violations=$((violations + 1))
+}
+
+for dockerfile in ${dockerfiles[@]+"${dockerfiles[@]}"}; do
+ output="$(awk -v file="$dockerfile" -v apk_fonts="$APK_FONTS" -v apt_fonts="$APT_FONTS" '
+ # Packages each install command of `cmd` names, added to installed[] by manager.
+ function collect(cmd, rest, list, cut, n, tok, i, mgr) {
+ rest = cmd
+ while (1) {
+ if (match(rest, /apt(-get)?[ \t]+(-[^ \t]+[ \t]+)*install/)) {
+ mgr = "apt"
+ } else if (match(rest, /apk[ \t]+add/)) {
+ mgr = "apk"
+ } else {
+ break
+ }
+ list = substr(rest, RSTART + RLENGTH)
+ rest = list
+ cut = match(list, /(&&|\|\||[;|])/)
+ if (cut > 0) list = substr(list, 1, cut - 1)
+ managers[mgr] = 1
+ n = split(list, tok, /[ \t]+/)
+ for (i = 1; i <= n; i++) {
+ if (tok[i] == "" || substr(tok[i], 1, 1) == "-") continue
+ sub(/=.*$/, "", tok[i])
+ installed[mgr, tok[i]] = 1
+ }
+ }
+ }
+
+ function missing(mgr, wanted, n, pkg, i, out) {
+ n = split(wanted, pkg, " ")
+ out = ""
+ for (i = 1; i <= n; i++) {
+ if (!((mgr, pkg[i]) in installed)) out = (out == "" ? pkg[i] : out " " pkg[i])
+ }
+ return out
+ }
+
+ {
+ line = $0
+ sub(/\r$/, "", line)
+ stripped = line
+ gsub(/^[ \t]+|[ \t]+$/, "", stripped)
+
+ if (stripped ~ /^FROM[ \t]/) {
+ # A new stage: what earlier stages installed does not reach the image.
+ delete installed
+ delete managers
+ exempt = 0
+ stage = NR
+ buf = ""
+ next
+ }
+ if (substr(stripped, 1, 1) == "#") {
+ if (stripped ~ /FONTS-OK:/) exempt = 1
+ next
+ }
+ buf = buf " " line
+ if (line ~ /\\[ \t]*$/) {
+ sub(/\\[ \t]*$/, " ", buf)
+ next
+ }
+ if (buf ~ /FONTS-OK:/) exempt = 1
+ collect(buf)
+ buf = ""
+ }
+
+ END {
+ if (exempt) exit
+ if (!("apk" in managers) && !("apt" in managers)) {
+ printf "%s:%d: the final stage installs no packages, so no fonts\n", file, stage
+ exit
+ }
+ if ("apk" in managers) {
+ gone = missing("apk", apk_fonts)
+ if (gone != "") printf "%s:%d: the final stage does not install %s\n", file, stage, gone
+ }
+ if ("apt" in managers) {
+ gone = missing("apt", apt_fonts)
+ if (gone != "") printf "%s:%d: the final stage does not install %s\n", file, stage, gone
+ }
+ }
+ ' "$dockerfile")"
+ if [ -n "$output" ]; then
+ while IFS= read -r v; do report "$v"; done <<<"$output"
+ fi
+done
+
+if [ -n "$workflow" ]; then
+ # The apt install of the job that runs the mcp-host tests: the one naming fonts.
+ lines="$(grep -n 'apt-get install' "$workflow" | grep 'fonts-' || true)"
+ if [ -z "$lines" ]; then
+ report "$workflow: no apt-get install of the mcp-host fonts"
+ else
+ while IFS= read -r entry; do
+ lineno="${entry%%:*}"
+ gone=""
+ for pkg in $APT_FONTS; do
+ if ! grep -qE "(^|[[:space:]])${pkg}([[:space:]]|$)" <<<"${entry#*:}"; then
+ gone="${gone:+$gone }$pkg"
+ fi
+ done
+ [ -z "$gone" ] || report "$workflow:$lineno: the font install does not name $gone"
+ done <<<"$lines"
+ fi
+fi
+
+if [ "$violations" -ne 0 ]; then
+ echo "FAIL: $violations font package list(s) miss a package the renderers look for." >&2
+ echo " Install them in the final stage, or annotate it with '# FONTS-OK: <reason>'." >&2
+ exit 1
+fi
+echo "PASS: every mcp-host image and the mcp-host CI job install the renderers' font packages."
diff --git a/scripts/tests/test-check-dockerfile-fonts.sh b/scripts/tests/test-check-dockerfile-fonts.sh
new file mode 100755
index 000000000..a7c9d43cf
--- /dev/null
+++ b/scripts/tests/test-check-dockerfile-fonts.sh
@@ -0,0 +1,95 @@
+#!/usr/bin/env bash
+# Contract for scripts/check-dockerfile-fonts.sh: it passes the font package
+# lists the renderers need and names the package a list misses, in the final
+# stage of a Dockerfile and in the CI job's install.
+set -euo pipefail
+
+REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
+CHECK="$REPO_ROOT/scripts/check-dockerfile-fonts.sh"
+WORK="$(mktemp -d)"
+trap 'rm -rf "$WORK"' EXIT
+failures=0
+
+fail() {
+ echo "FAIL: $*" >&2
+ failures=$((failures + 1))
+}
+
+passes() {
+ local name="$1"
+ shift
+ if ! bash "$CHECK" "$@" >"$WORK/out" 2>&1; then
+ fail "$name should pass: $(cat "$WORK/out")"
+ fi
+}
+
+fails_naming() {
+ local name="$1" expected="$2"
+ shift 2
+ if bash "$CHECK" "$@" >"$WORK/out" 2>&1; then
+ fail "$name should fail"
+ elif ! grep -q -- "$expected" "$WORK/out"; then
+ fail "$name should name '$expected': $(cat "$WORK/out")"
+ fi
+}
+
+cat >"$WORK/alpine.Dockerfile" <<'EOF'
+FROM node:24-alpine AS builder
+RUN npm ci
+FROM node:24-alpine
+RUN apk add --no-cache font-dejavu font-noto font-noto-cjk font-noto-arabic font-noto-hebrew
+EOF
+passes "an Alpine image with every font package" "$WORK/alpine.Dockerfile"
+
+cat >"$WORK/debian.Dockerfile" <<'EOF'
+FROM node:24-alpine AS builder
+FROM node:24-slim
+RUN apt-get update \
+ && apt-get install -y --no-install-recommends \
+ # The fonts the renderers look for.
+ fonts-dejavu-core fonts-noto-core fonts-noto-cjk \
+ && rm -rf /var/lib/apt/lists/*
+EOF
+passes "a Debian image installing them over continuation lines" "$WORK/debian.Dockerfile"
+
+cat >"$WORK/no-hebrew.Dockerfile" <<'EOF'
+FROM node:24-alpine
+RUN apk add --no-cache font-dejavu font-noto font-noto-cjk font-noto-arabic
+EOF
+fails_naming "an Alpine image without the Hebrew faces" "font-noto-hebrew" "$WORK/no-hebrew.Dockerfile"
+
+cat >"$WORK/builder-only.Dockerfile" <<'EOF'
+FROM node:24-alpine AS builder
+RUN apk add --no-cache font-dejavu font-noto font-noto-cjk font-noto-arabic font-noto-hebrew
+FROM node:24-alpine
+COPY --from=builder /app /app
+EOF
+fails_naming "fonts installed only in a builder stage" "installs no packages" "$WORK/builder-only.Dockerfile"
+
+cat >"$WORK/no-cjk.Dockerfile" <<'EOF'
+FROM node:24-slim
+RUN apt-get install -y fonts-dejavu-core fonts-noto-core && apt-get clean
+EOF
+fails_naming "a Debian image without the CJK collections" "fonts-noto-cjk" "$WORK/no-cjk.Dockerfile"
+
+cat >"$WORK/exempt.Dockerfile" <<'EOF'
+FROM node:24-alpine
+# FONTS-OK: this image renders no documents
+RUN apk add --no-cache git
+EOF
+passes "an exempt final stage" "$WORK/exempt.Dockerfile"
+
+cat >"$WORK/workflow.yml" <<'EOF'
+ - name: Install the mcp-host image fonts
+ run: |
+ sudo apt-get install -y --no-install-recommends fonts-dejavu-core fonts-noto-core
+EOF
+fails_naming "a CI install without the CJK collections" "fonts-noto-cjk" --workflow "$WORK/workflow.yml"
+
+passes "the repository's own images and CI job"
+
+if [ "$failures" -ne 0 ]; then
+ echo "FAIL: $failures check-dockerfile-fonts case(s)." >&2
+ exit 1
+fi
+echo "PASS: check-dockerfile-fonts passes complete lists and names what a list misses."