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-interaction

v1.0.2

Published

Dynamic interaction 动态交互mcp,用于cursor、windsurf、trae 等 AI 智能编辑器 Agent 运行时交互使用

Downloads

91

Readme

Dynamic Interaction MCP

Node.js TypeScript License

中文文档 | English

A Node.js/TypeScript-based interactive AI agent system that provides a rich Web UI for real-time, multimodal interaction between AI models and users. This tool implements the Model Context Protocol (MCP) and is designed for use with AI editors like Cursor, Windsurf, and other intelligent development environments.

✨ Features

  • Multi-modal Interaction: Support for text and image inputs with real-time feedback
  • Web Notifications: Browser-native notifications ensure you never miss important messages, even when the tab is in the background
  • Dual MCP Tools:
    • solicit-input: Interactive mode that collects user feedback through a web interface
    • notify-user: Notification mode that sends information to users without waiting for response
  • Lazy Server Start: HTTP server only starts when needed to avoid port conflicts
  • Session Management: Smart session handling with timeouts and auto-reconnection
  • Real-time Communication: WebSocket-based live updates between frontend and backend
  • Responsive UI: Modern, clean interface with dark/light theme support
  • Page Visibility Detection: Automatically detects when users switch to background tabs

🛠️ Tech Stack

  • Backend: Node.js, Express.js, TypeScript, WebSocket, Winston
  • Frontend: TypeScript, HTML5, CSS3, Web Notifications API, Page Visibility API
  • Protocol: Model Context Protocol (MCP)
  • Libraries: marked.js, highlight.js, lucide icons

⚡ Quick Start

Prerequisites

  • Node.js (version 18+ required)
  • pnpm (recommended package manager)

Installation

  1. Install the package globally:

    npm install -g dynamic-interaction
  2. Or install from source:

    git clone https://github.com/stone2401/dynamic-interaction.git
    cd dynamic-interaction
    pnpm install
    pnpm run build
    make link  # Links as global CLI tool

Usage

As MCP Server: Add to your MCP client configuration (e.g., Claude Desktop):

{
  "mcpServers": {
    "dynamic-interaction": {
      "command": "dynamic-interaction"
    }
  }
}

AI Rule add below content:

- **Interaction Channel**: All interactions with the user must be conducted through the `dynamic-interaction` interface.
  - **Solicit Input (`solicit-input`)**: This is the **only** way for the AI to initiate any interaction. Whether it's requesting approval, reporting an obstacle, seeking guidance, or asking to conclude the conversation after a task is complete, it must be done through this interface. After calling it, the AI must pause and wait for the user's response.
  - **Notify User (`notify-user`)**: This interface is used to send one-way notifications to the user that do not require an immediate response, such as mid-task progress updates. After calling it, the AI can continue its execution without waiting.
  - **Task Closure Constraint**: The AI is **strictly prohibited** from unilaterally deciding to end the current conversation or task. After all tasks are completed, it must use the `solicit-input` interface.

View2

Direct CLI Usage:

# Start the MCP server
dynamic-interaction

# Development mode
pnpm run dev

# Build project
pnpm run build

🔧 Configuration

Environment variables can be configured via .env file or direct export:

Basic Configuration

| Variable | Description | Default | | ----------------- | --------------------------------- | ------------ | | PORT | HTTP server port | 10086 | | SESSION_TIMEOUT | Session timeout in seconds | 300 | | TIMEOUT_PROMPT | Default prompt on session timeout | "continue" |

Logging Configuration

| Variable | Description | Default | | ------------------- | ---------------------------------------------------------- | ----------------------------- | | LOG_ENABLED | Enable logging system | false | | LOG_DIR | Log files storage directory | ~/.dynamic-interaction/logs | | LOG_ERROR_FILE | Error log filename | error.log | | LOG_COMBINED_FILE | Combined log filename | combined.log | | LOG_LEVEL | Log level (error, warn, info, http, verbose, debug, silly) | info | | LOG_COLORIZE | Colorized console output | true | | LOG_TO_FILE | Output logs to file (requires LOG_ENABLED=true) | true |

Example:

PORT=8080 LOG_ENABLED=true dynamic-interaction

🌟 Key Features

Web Notifications

The system provides comprehensive notification support:

  • Browser Notifications: Native browser notifications when the tab is in background
  • Permission Management: Automatic permission requests and status checking
  • Page Visibility Detection: Uses Page Visibility API to detect when users switch tabs
  • Smart Notification Logic: Only shows browser notifications when the page is not visible

MCP Tools

  1. solicit-input

    • Opens interactive web interface
    • Supports text and image inputs
    • Real-time session management
    • Automatic cleanup on timeout
  2. notify-user

    • Sends notifications without waiting for user input
    • Shows browser notifications for background users
    • Customizable notification content

Architecture Highlights

  • Modular Design: Clean separation between MCP server, HTTP server, and WebSocket transport
  • Session Management: Smart session handling with timeouts and cleanup
  • State Management: Centralized server state management
  • Error Handling: Comprehensive error handling and graceful degradation
  • Security: Input validation and sanitization

📁 Project Structure

src/
├── mcp/           # MCP server implementation
├── server/        # HTTP server and WebSocket handling
├── public/        # Frontend assets
│   ├── ts/        # TypeScript frontend code
│   ├── css/       # Stylesheets
│   └── index.html # Main UI
├── types/         # Shared TypeScript interfaces
├── utils/         # Utility functions
└── config.ts      # Configuration management

🚀 Development

Build Commands

# Install dependencies
pnpm install

# Development mode with hot reload
pnpm run dev

# Build for production
pnpm run build

# Start built application
pnpm start

# Alternative build using Makefile
make build
make start

Frontend Development

The frontend uses a modular TypeScript architecture:

  • Services: WebSocket communication, notifications, themes
  • Components: UI components like modals, status bars, feedback forms
  • Utils: Helper functions and DOM utilities
  • Core: Application core, event system, and type definitions

📚 Documentation

For detailed documentation, see the docs/ directory:

  • Architecture overview
  • API documentation
  • Deployment guides
  • Configuration options

🤝 Contributing

We welcome contributions! Please feel free to submit a Pull Request or create an Issue.

📄 License

This project is licensed under the MIT License.

🙏 Acknowledgments

Built for the AI development community to enhance human-AI interaction in modern development workflows.