ChatGPT · Apps in ChatGPTDashboards
A/B experiments dashboard
KPI cards with A/B experiments grouped by status.
by Prompt Studio
apps-sdkwidgeta-b-experiments
License: MITView original
Contents
Where it goes: server.ts
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { z } from 'zod';
const server = new McpServer({ name: 'experiments-panel', version: '1.0.0' });
const html = `<div id="root"></div>
<style>
body { font-family: system-ui, sans-serif; margin: 0; }
table { width: 100%; border-collapse: collapse; }
td, th { padding: 6px 8px; border-bottom: 1px solid #e5e5e5; text-align: left; }
.card { border: 1px solid #e5e5e5; border-radius: 12px; padding: 12px; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #eef; font-size: 12px; }
</style>
<script type="module">
const { total = 0, byStatus = {} } = window.openai?.toolOutput ?? {};
document.getElementById('root').innerHTML =
'<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(120px,1fr));gap:8px">' +
'<div class="card"><small>Total</small><h2>' + total + '</h2></div>' +
Object.entries(byStatus).map(([s, n]) => '<div class="card"><small>' + s + '</small><h2>' + n + '</h2></div>').join('') +
'</div>';
</script>`;
// Widget que ChatGPT muestra dentro de la conversación.
server.registerResource('widget', 'ui://widget/experiments-dashboard.html', {}, async () => ({
contents: [{ uri: 'ui://widget/experiments-dashboard.html', mimeType: 'text/html+skybridge', text: html }],
}));
server.registerTool(
'panel_a_b_experiment',
{
title: 'Panel de experimentos A/B',
description: 'Muestra totales de experimentos A/B por estado en un rango de fechas',
inputSchema: { from: z.string().describe('YYYY-MM-DD'), to: z.string().describe('YYYY-MM-DD') },
_meta: { 'openai/outputTemplate': 'ui://widget/experiments-dashboard.html' },
},
async ({ from, to }) => {
const res = await fetch(`https://api.tu-dominio.com/v1/experiments/summary?from=${from}&to=${to}`, { headers: { authorization: `Bearer ${process.env.API_TOKEN}` } });
const summary = await res.json();
return { structuredContent: summary, content: [{ type: 'text', text: `${summary.total} experimentos A/B entre ${from} y ${to}` }] };
},
);
// Expón el servidor por HTTP (Streamable HTTP) y agrégalo en ChatGPT → Configuración → Apps y conectores.
More in Apps in ChatGPT
Product carousel
MCP server with a tool that returns products and a carousel widget.
Appointment booking
Shows available slots and confirms the booking inside the chat.
KPI dashboard
Widget with KPI cards that reads data from window.openai.
Contacts table
Widget that lists contacts and their status inside ChatGPT.
Contact card
Card with the full details of one contact.
Contact form
In-chat form that creates a contact in your API.