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-chat-widget

v1.1.0

Published

A reusable React chat widget for Model Context Protocol (MCP) interactions

Readme

mcp-chat-widget

A reusable React chat widget for Model Context Protocol (MCP) interactions. This package provides a complete chat interface that can be embedded in any React application as a floating dialog that opens when clicked.

✨ Features

  • 🎯 Easy Integration - Drop-in component with minimal setup
  • 💬 Dialog Interface - Clean floating chat dialog that doesn't interfere with your app
  • 🎨 Customizable - Configurable styling, positioning, and behavior
  • 📱 Responsive - Works great on desktop and mobile devices
  • 🔧 MCP Integration - Built-in support for Model Context Protocol
  • 📝 TypeScript - Full TypeScript support with comprehensive type definitions
  • 🎭 Flexible API - Multiple ways to integrate and customize

📦 Installation

npm install mcp-chat-widget

Peer Dependencies

Make sure you have the required peer dependencies installed:

npm install react react-dom

🚀 Quick Start

Basic Usage

import React from "react";
import { ChatWidget } from "mcp-chat-widget";

function App() {
  return (
    <div>
      <h1>My App</h1>
      {/* Chat widget will appear as a floating button in bottom-right corner */}
      <ChatWidget />
    </div>
  );
}

export default App;

Custom Configuration

import { ChatWidget } from "mcp-chat-widget";

function App() {
  return (
    <ChatWidget
      trigger={{
        label: "Help & Support",
        size: "lg",
        variant: "primary",
        position: "bottom-left",
      }}
      dialog={{
        title: "AI Assistant",
        size: "xl",
        closeOnOverlayClick: false,
      }}
      chat={{
        hideSidebar: true,
        height: "500px",
      }}
      mcpConfig={{
        serverUrl: "your-mcp-server-url",
        clientName: "MyApp",
        authToken: "your-auth-token",
      }}
    />
  );
}

📚 API Reference

ChatWidget Props

| Prop | Type | Default | Description | | ------------- | --------------------------- | ------- | -------------------------------- | | mcpConfig | McpConfig | - | MCP server configuration | | trigger | TriggerProps | - | Trigger button configuration | | dialog | DialogProps | - | Dialog configuration | | chat | ChatProps | - | Chat interface configuration | | defaultOpen | boolean | false | Whether dialog starts open | | showTrigger | boolean | true | Whether to show trigger button | | isOpen | boolean | - | External control of dialog state | | onToggle | (isOpen: boolean) => void | - | External dialog state handler | | onOpen | () => void | - | Callback when dialog opens | | onClose | () => void | - | Callback when dialog closes |

TriggerProps

| Prop | Type | Default | Description | | ------------ | -------------------------------------------------------------------------- | ---------------- | ----------------------- | | label | string | "Chat" | Button label/tooltip | | position | 'bottom-right' \| 'bottom-left' \| 'top-right' \| 'top-left' \| 'custom' | 'bottom-right' | Button position | | size | 'sm' \| 'md' \| 'lg' | 'md' | Button size | | variant | 'primary' \| 'secondary' \| 'outline' | 'primary' | Button style variant | | className | string | - | Custom CSS classes | | showBadge | boolean | false | Show notification badge | | badgeCount | number | - | Badge count number |

DialogProps

| Prop | Type | Default | Description | | --------------------- | ---------------------------------------- | ---------------------- | --------------------------- | | title | string | "MCP Chat Assistant" | Dialog title | | size | 'sm' \| 'md' \| 'lg' \| 'xl' \| 'full' | 'lg' | Dialog size | | closeOnOverlayClick | boolean | true | Close when clicking overlay | | showCloseButton | boolean | true | Show close button |

ChatProps

| Prop | Type | Default | Description | | ------------- | --------- | --------- | --------------------- | | hideSidebar | boolean | false | Hide tools sidebar | | height | string | "600px" | Chat interface height | | className | string | - | Custom CSS classes |

McpConfig

| Prop | Type | Description | | ------------ | -------- | -------------------- | | serverUrl | string | MCP server URL | | clientName | string | Client identifier | | authToken | string | Authentication token |

🎨 Styling

The widget uses Tailwind CSS classes internally. If you're using Tailwind in your project, the styles will be inherited. For custom styling:

Using CSS Variables

:root {
  --chat-widget-primary: #3b82f6;
  --chat-widget-secondary: #6b7280;
  --chat-widget-background: #ffffff;
  --chat-widget-border: #e5e7eb;
}

Custom Classes

<ChatWidget
  trigger={{
    className: "my-custom-trigger-styles",
  }}
  chat={{
    className: "my-custom-chat-styles",
  }}
/>

🔧 Advanced Usage

External State Control

import { useState } from "react";
import { ChatWidget } from "mcp-chat-widget";

function App() {
  const [isChatOpen, setIsChatOpen] = useState(false);

  return (
    <div>
      <button onClick={() => setIsChatOpen(true)}>Open Chat</button>

      <ChatWidget
        showTrigger={false}
        isOpen={isChatOpen}
        onToggle={setIsChatOpen}
      />
    </div>
  );
}

Using Individual Components

import {
  Dialog,
  DialogChatInterface,
  ChatTriggerButton,
} from "mcp-chat-widget";

function CustomChatWidget() {
  const [isOpen, setIsOpen] = useState(false);

  return (
    <>
      <ChatTriggerButton
        onClick={() => setIsOpen(true)}
        position="custom"
        className="my-4"
      />

      <Dialog
        isOpen={isOpen}
        onClose={() => setIsOpen(false)}
        title="Support Chat"
      >
        <DialogChatInterface hideSidebar />
      </Dialog>
    </>
  );
}

🔄 Events and Callbacks

<ChatWidget
  onOpen={() => {
    console.log("Chat opened");
    // Track analytics, load data, etc.
  }}
  onClose={() => {
    console.log("Chat closed");
    // Save state, cleanup, etc.
  }}
/>

🛠 Development

Local Development

  1. Clone the repository
  2. Install dependencies: npm install
  3. Start development server: npm run dev
  4. Build library: npm run build:lib

Project Structure

src/lib/
├── components/          # React components
│   ├── ChatWidget.tsx   # Main widget component
│   ├── Dialog.tsx       # Dialog/modal component
│   └── ...
├── hooks/              # React hooks
├── types/              # TypeScript types
├── utils/              # Utility functions
├── config/             # Configuration
└── index.ts            # Main exports

📄 License

MIT License - see LICENSE file for details.

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request

📞 Support

🗺 Roadmap

  • [ ] Theming system
  • [ ] Custom message types
  • [ ] File upload support
  • [ ] Voice input/output
  • [ ] Multiple chat instances
  • [ ] Emoji support
  • [ ] Message persistence

Made with ❤️ by Jetpack