From e768999c78d9486366c12b7ebfcd859a34e5146b Mon Sep 17 00:00:00 2001 From: Andre Landgraf Date: Wed, 18 Nov 2026 15:29:57 -0800 Subject: [PATCH 1/2] feat: add a live social image for /mcp-server/stats --- src/app/mcp-server/stats/og/route.jsx | 119 ++++++++++++++++++++++++++ src/app/mcp-server/stats/page.jsx | 7 +- 2 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 src/app/mcp-server/stats/og/route.jsx diff --git a/src/app/mcp-server/stats/og/route.jsx b/src/app/mcp-server/stats/og/route.jsx new file mode 100644 index 0000000000..f9c518056a --- /dev/null +++ b/src/app/mcp-server/stats/og/route.jsx @@ -0,0 +1,119 @@ +import { readFile } from 'node:fs/promises'; +import { join } from 'node:path'; + +import { ImageResponse } from 'next/og'; + +import { buildClientShares } from 'components/pages/mcp-server-stats/share-series'; +import { formatWeekRange } from 'components/pages/mcp-server-stats/weeks'; +import { getMcpStats } from 'utils/api-mcp-stats'; + +export const revalidate = 3600; + +const TOP_AGENTS = 5; + +const assets = Promise.all([ + readFile(join(process.cwd(), 'src', 'fonts', 'geist-mono', 'GeistMono-Regular.ttf')), + readFile(join(process.cwd(), 'src', 'fonts', 'inter', 'Inter-Regular.ttf')), + readFile(join(process.cwd(), 'public', 'images', 'og-image', 'logo.png')), +]); + +const toDataUri = (buffer, contentType) => + `data:${contentType};base64,${Buffer.from(buffer).toString('base64')}`; + +export async function GET() { + const stats = await getMcpStats(); + if (!stats) return new Response('Not found', { status: 404 }); + + const { latestWeek, ranked } = buildClientShares(stats.clients); + const agents = ranked.filter(({ isGrouped }) => !isGrouped).slice(0, TOP_AGENTS); + const leaderShare = agents[0].share; + const [fontDataMono, fontDataInter, logoBuffer] = await assets; + + return new ImageResponse( +
+ + +
+ Neon MCP Stats +
+
+ {`Top agents by share of weekly active users, ${formatWeekRange(latestWeek)}`} +
+ +
+ {agents.map(({ key, label, color, share }) => ( +
+
+ {label} +
+
+
+
+
+ {`${share.toFixed(1)}%`} +
+
+ ))} +
+
, + { + width: 1200, + height: 630, + fonts: [ + { name: 'Geist Mono', data: fontDataMono, style: 'normal', weight: 400 }, + { name: 'Inter', data: fontDataInter, style: 'normal', weight: 400 }, + ], + } + ); +} diff --git a/src/app/mcp-server/stats/page.jsx b/src/app/mcp-server/stats/page.jsx index 8042caa1d5..5dcd1bd22b 100644 --- a/src/app/mcp-server/stats/page.jsx +++ b/src/app/mcp-server/stats/page.jsx @@ -2,11 +2,16 @@ import { notFound } from 'next/navigation'; import McpServerStats from 'components/pages/mcp-server-stats/mcp-server-stats'; import Layout from 'components/shared/layout'; +import VERCEL_URL from 'constants/base'; +import LINKS from 'constants/links'; import SEO_DATA from 'constants/seo-data'; import { getMcpStats } from 'utils/api-mcp-stats'; import getMetadata from 'utils/get-metadata'; -export const metadata = getMetadata(SEO_DATA.mcpServerStats); +export const metadata = getMetadata({ + ...SEO_DATA.mcpServerStats, + imagePath: `${VERCEL_URL}${LINKS.mcpServerStats}/og`, +}); export const revalidate = 3600; From fc7e1613f1c7c46fe19827e9534c8f60fe665906 Mon Sep 17 00:00:00 2001 From: Andre Landgraf Date: Wed, 18 Nov 2026 15:32:21 -0800 Subject: [PATCH 2/2] fix: trace the MCP stats social image's fonts and logo into its bundle --- next.config.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/next.config.js b/next.config.js index bfad81c5ca..8c3840fcea 100644 --- a/next.config.js +++ b/next.config.js @@ -39,6 +39,11 @@ const defaultConfig = { './public/images/og-image/docs-background.jpg', './public/images/technology-logos/neon-dark.svg', ], + '/mcp-server/stats/og': [ + './src/fonts/geist-mono/GeistMono-Regular.ttf', + './src/fonts/inter/Inter-Regular.ttf', + './public/images/og-image/logo.png', + ], // The blog `.md` route handler reads the blog snapshot from disk at request // time (unlike the blog pages, which are statically generated at build). // Its read path is dynamic (process.cwd() + join), so nft can't detect the