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

dynamic-ui-mcp

v0.1.0

Published

MCP server and library for rendering dynamic React UI components in AI conversations

Readme

dynamic-ui-mcp

A library that enables AI models to render interactive UI components inline during conversations. Works as both an MCP server and a direct library for Vercel AI SDK.

Features

  • Built-in Components: Charts, forms, code blocks, image viewers, multi-choice questions, multi-page wizards
  • Custom Components: Models can generate custom React components on-the-fly
  • Two Deployment Modes:
    • MCP Server: Run standalone for Claude Desktop or other MCP clients
    • Library Mode: Import directly into Next.js/React apps with Vercel AI SDK

Installation

npm install dynamic-ui-mcp

Peer Dependencies

npm install react sucrase
# Optional for charts and syntax highlighting:
npm install recharts prismjs

Quick Start (Library Mode)

1. API Route

// app/api/chat/route.ts
import { anthropic } from "@ai-sdk/anthropic";
import { streamText, tool, convertToModelMessages } from "ai";
import {
  renderSchema,
  renderCustomSchema,
  executeRender,
  executeRenderCustom,
  generateSystemPrompt,
  getComponentIds,
} from "dynamic-ui-mcp";

const SYSTEM_PROMPT = generateSystemPrompt();

export async function POST(req: Request) {
  const { messages } = await req.json();
  const modelMessages = await convertToModelMessages(messages);

  const result = streamText({
    model: anthropic("claude-sonnet-4-20250514"),
    system: SYSTEM_PROMPT,
    messages: modelMessages,
    tools: {
      render: tool({
        description: `Render a UI component. Available: ${getComponentIds().join(", ")}`,
        inputSchema: renderSchema,
        execute: async (args) => executeRender(args),
      }),
      renderCustom: tool({
        description: "Render custom React TSX code",
        inputSchema: renderCustomSchema,
        execute: async (args) => executeRenderCustom(args),
      }),
    },
  });

  return result.toUIMessageStreamResponse();
}

2. React Component

// app/page.tsx
"use client";

import { useChat } from "@ai-sdk/react";
import { DefaultChatTransport } from "ai";
import { DynamicUIRenderer } from "dynamic-ui-mcp/react";
import Prism from "prismjs";
import * as Recharts from "recharts";

// Load Prism languages you need
import "prismjs/components/prism-python";
import "prismjs/components/prism-typescript";

const libraries = { prismjs: Prism, recharts: Recharts };
const transport = new DefaultChatTransport({ api: "/api/chat" });

export default function Chat() {
  const { messages, sendMessage, status } = useChat({ transport });

  return (
    <div>
      {messages.map((message) => (
        <div key={message.id}>
          {message.parts.map((part, index) => {
            if (part.type === "text") {
              return <p key={index}>{part.text}</p>;
            }

            if (part.type.startsWith("tool-")) {
              const toolName = part.type.replace("tool-", "");
              return (
                <DynamicUIRenderer
                  key={index}
                  toolInvocation={{
                    toolCallId: part.toolCallId,
                    toolName,
                    args: part.input,
                    state: part.state === "output-available" ? "result" : "call",
                    result: part.output,
                  }}
                  libraries={libraries}
                  onSubmit={(data) => sendMessage({ text: JSON.stringify(data) })}
                />
              );
            }
            return null;
          })}
        </div>
      ))}
    </div>
  );
}

Built-in Components

| Component | Type | Description | |-----------|------|-------------| | bar-chart | visualization | Bar, line, and pie charts | | multi-choice | input | Single/multiple choice questions | | code-block | display | Syntax-highlighted code | | pager | input | Multi-page wizard with tabs | | wizard-form | input | Multi-step forms with validation | | feedback-form | input | Simple feedback collection | | file-picker | input | File upload with drag & drop | | image-viewer | media | Image display with zoom | | web-view | media | Embed YouTube, Vimeo, websites |

Custom Components

Models can create custom components that import built-in ones:

import Pager from 'pager';
import MultiChoice from 'multi-choice';

export default function Quiz({ onSubmit }) {
  return (
    <Pager
      pages={[
        {
          title: "Question 1",
          content: <MultiChoice
            question="What is 2 + 2?"
            options={[{ value: "4", label: "4" }, { value: "5", label: "5" }]}
          />
        },
      ]}
      onSubmit={onSubmit}
    />
  );
}

MCP Server Mode

Run as a standalone MCP server:

npx dynamic-ui-mcp

Configure in Claude Desktop's claude_desktop_config.json:

{
  "mcpServers": {
    "dynamic-ui": {
      "command": "npx",
      "args": ["dynamic-ui-mcp"]
    }
  }
}

Publishing

To publish your own version:

npm login
npm publish

Development

# Install dependencies
npm install

# Build
npm run build

# Type check
npm run typecheck

# Lint
npm run lint

# Run demo
cd demo && npm install && npm run dev

License

MIT