npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mcp-widgets

v0.0.5

Published

UI widgets for MCP integrations (OpenAI, etc.)

Readme

MCP Widgets

UI widgets for rendering MCP (Model Context Protocol) tool responses in AI assistants like ChatGPT.

Overview

When an MCP tool returns data, AI assistants can display it using custom UI widgets instead of plain text. This package provides ready-to-use widgets that can be embedded via a simple <script> tag.

Installation

npm install mcp-widgets
# or
pnpm add mcp-widgets

Widgets

| Widget | Framework | Size | Description | | ---------------- | ---------- | ------ | ------------------------------------------ | | data-card | Web Widget | ~3KB | Simple key-value data display | | rich-data-card | React | ~148KB | Enhanced card with sections, icons, footer |

Usage

CDN Embedding (for MCP tools)

Load widgets via CDN and use them as custom HTML elements:

<!-- Load the widget -->
<script src="https://unpkg.com/mcp-widgets/cdn/data-card.js"></script>

<!-- Use it -->
<mcp-data-card
  title="Weather"
  data='{"temperature": "72°F", "conditions": "Sunny"}'
  status="success"
></mcp-data-card>

As a React Library

import { RichDataCard } from 'mcp-widgets'

function MyWidget() {
  return (
    <RichDataCard
      title="Order Summary"
      icon="🛒"
      data={{ orderId: '#12345', total: '$89.99' }}
      sections={[{ title: 'Shipping', data: { method: 'Express' } }]}
      status="success"
    />
  )
}

How Embedding Works

The MCP Tool Response Flow

  1. User asks a question in ChatGPT (e.g., "What's the weather?")
  2. ChatGPT calls your MCP tool which returns structured data
  3. Your tool response includes HTML with a <script> tag pointing to a CDN-hosted widget
  4. ChatGPT renders the HTML in a sandboxed iframe
  5. The widget loads and displays the data visually

Example MCP Tool Response

When your MCP server handles a tool call, return HTML that embeds a widget:

// In your MCP server tool handler
function handleWeatherTool(location) {
  const data = fetchWeather(location)

  return {
    content: [
      {
        type: 'text',
        text: `
        <script src="https://unpkg.com/mcp-widgets/cdn/data-card.js"></script>
        <mcp-data-card
          title="Weather in ${location}"
          data='${JSON.stringify(data)}'
          status="success"
        ></mcp-data-card>
      `,
      },
    ],
  }
}

OpenAI Skybridge API

The loader handles communication with the ChatGPT host via window.openai. Widgets themselves should NOT call these APIs directly - the loader manages height notifications and prop extraction.

Available host APIs (used by the loader):

// Notify ChatGPT of widget height (takes a number)
window.openai.notifyIntrinsicHeight(document.body.scrollHeight)

// Access tool response metadata for props
window.openai.toolResponseMetadata._meta

See the OpenAI Apps SDK docs for the full window.openai API reference.

Security Considerations

  • Widgets run in a sandboxed iframe with limited capabilities
  • Data is passed via HTML attributes (must be JSON-stringified)
  • No direct access to the parent page or user session
  • CDN URLs should use HTTPS

Widget Reference

<mcp-data-card>

A lightweight Web Widget (no React dependency).

| Attribute | Type | Description | | --------- | ------------------------------------------- | -------------------------- | | title | string | Card title | | data | JSON string | Key-value pairs to display | | status | success | error | warning | info | Status indicator styling |

<mcp-rich-data-card>

A React-based widget with more features.

| Attribute | Type | Description | | ------------- | ------------------------------------------- | --------------------------------- | | title | string | Card title | | description | string | Subtitle text | | icon | string | Emoji or icon character | | data | JSON string | Main data section | | sections | JSON string | Array of {title, data} sections | | footer | string | Footer text | | status | success | error | warning | info | Status styling |

Development

# Install dependencies
pnpm install

# Start Storybook
pnpm dev

# Run tests
pnpm test

# Build everything
pnpm build

# Build CDN bundles only
pnpm build:cdn

Creating New Widgets

  1. Create a folder in src/widgets/{widget-name}/
  2. Add required files:
    • WidgetName.ts (Web Widget) or WidgetName.tsx (React)
    • manifest.json - Widget metadata
    • cdn.ts or cdn.tsx - CDN entry point
    • index.ts - Library export
  3. Export from src/widgets/index.ts
  4. Run pnpm build to generate bundles

Forking & Custom Collections

This repository is designed to be forked! You have two options:

Option 1: Private Widget Collection

Fork this repo to create your own private widget library:

  1. Fork this repository to your GitHub account/organization
  2. Add your widgets following the structure above
  3. Host privately by publishing to a private npm registry or serving CDN bundles from your own infrastructure
  4. Use in your MCP tools by pointing to your private CDN URLs

This is ideal for:

  • Proprietary UI widgets with custom branding
  • Internal tools with sensitive designs
  • Widgets that integrate with private APIs

Option 2: Contribute Back

We welcome community contributions! If you build a widget that could benefit others:

  1. Fork this repository
  2. Create your widget following the existing patterns
  3. Add tests and Storybook stories
  4. Submit a Pull Request with a description of your widget

Good candidates for community widgets:

  • Generic data visualizations (charts, tables, maps)
  • Common tool response patterns (search results, confirmations)
  • Accessibility improvements
  • Performance optimizations

Hosting Your Own CDN

If you fork and want to self-host your CDN bundles:

# Build the CDN bundles
pnpm build:cdn

# The cdn/ directory contains all bundles
# Upload to your preferred hosting:
# - GitHub Pages
# - Cloudflare R2/Pages
# - AWS S3 + CloudFront
# - Vercel/Netlify

Then reference your hosted bundles in MCP tool responses:

<script src="https://your-cdn.example.com/widgets/my-widget.js"></script>

License

MIT