UNPKG

@web-interact-mcp/client

Version:

A production-ready TypeScript library that transforms web applications into MCP (Model Context Protocol) servers with robust two-way communication via SignalR

219 lines (164 loc) • 8.08 kB
# WebInteractMCP > Transform any web application into an MCP server with real-time two-way communication [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE) [![Development Status](https://img.shields.io/badge/Status-Active%20Development-orange)](https://github.com/Vijay-Nirmal/WebInteractMCP) [![Version](https://img.shields.io/badge/Version-Pre--1.0-red)](https://github.com/Vijay-Nirmal/WebInteractMCP) WebInteractMCP is an innovative MCP (Model Context Protocol) ecosystem that enables any web application to become an MCP server, allowing chatbots and other MCP clients to control client sessions and complete intended actions on behalf of users. > **šŸ“¢ Check out the preview version available now!** This project is in active development. Expect breaking changes in future releases as we evolve toward version 1.0. ## šŸš€ Overview WebInteractMCP consists of two tightly integrated components that work together to create a seamless MCP experience: - **šŸ“š [@web-interact-mcp/client](lib/web-interact-mcp)** - TypeScript library for client-side integration - **šŸ–„ļø [WebInteractMCPServer](server/WebInteractMCPServer)** - Ready to deploy Docker MCP server image for protocol handling ## ✨ Key Features - **šŸ”§ Support full MCP Tool protocol** - including tool discovery, invocation, and all type of response Text, Image, Audio others - **šŸ”„ Real-time Communication** - Robust bidirectional communication using SignalR which support WebSockets, ServerSentEvents, LongPolling - **šŸ› ļø Dynamic Tool Registration** - Configure tools with simple JSON files - **šŸŽÆ Session-based Control** - Per-user session management for secure isolation - **🌐 Framework Agnostic** - Works with any JavaScript framework (React, Angular, Vue, etc.) - **⚔ Production Ready** - Comprehensive error handling and performance optimization - **šŸ”§ Simple Configuration** - Easy setup with JSON-based tool definitions - **šŸ“¦ Docker Support** - Ready-to-use Docker image for easy deployment - **šŸ“„ Page-specific Tools** - Define tools that can interact with specific pages or elements - **šŸŽØ Visual Feedback** - Provides visual feedback for tool execution and user actions ## šŸŽ¬ Demo https://github.com/user-attachments/assets/bf9d15a6-fa4a-40a0-8543-cb0fd92bffac *Click to view the demonstration of WebInteractMCP transforming a web application into an MCP server* ## šŸ—ļø Architecture ```mermaid sequenceDiagram participant U as šŸ‘¤ User participant W as 🌐 Website participant C as šŸ“¦ @web-interact-mcp/client participant CB as šŸ¤– MCP Client<br/>(ChatBot Server) participant MS as šŸ–„ļø WebInteractMCPServer %% Styling Note over U,MS: WebInteractMCP Communication Flow rect rgba(135, 206, 235, 0.1) Note over U,MS: šŸš€ Session Initialization Phase U->>+W: šŸ’¬ Opens chat session W->>+C: šŸ”§ Initialize MCP session C->>+MS: šŸ”— Establish 2-way connection<br/>(SignalR WebSocket) MS-->>-C: āœ… Connection established C->>+MS: šŸ› ļø Send tools configuration MS-->>-C: šŸ†” Return session ID C-->>-W: šŸ“‹ Provide session ID W-->>-U: 🟢 Session ready end rect rgba(144, 238, 144, 0.1) Note over U,MS: šŸ“ Task Processing Phase U->>+W: āŒØļø Enters task/query W->>+CB: šŸ“¤ Send request with session ID CB->>+MS: šŸ”Œ Connect & register tools MS-->>-CB: šŸ› ļø Return available tools CB->>CB: 🧠 LLM processes task<br/>& selects tools end rect rgba(255, 182, 193, 0.1) Note over U,MS: ⚔ Tool Execution Phase CB->>+MS: šŸŽÆ Invoke tool with parameters MS->>+C: šŸ“Ø Forward tool invocation C->>+W: šŸ–±ļø Execute actions<br/>(DOM manipulation, clicks) W-->>-C: šŸ“Š Return execution result C-->>-MS: šŸ“¤ Send tool response MS-->>-CB: šŸ“„ Forward response to LLM CB->>+W: šŸŽØ Return processed result W-->>-U: šŸ“ŗ Display response end ``` ## šŸš€ Quick Start ### 1. Install the Client Library ```bash # Install the stable version (Not available yet) npm install @web-interact-mcp/client # Or install the latest preview version npm install @web-interact-mcp/client@preview ``` ### 2. Configure Your Tools Create a `mcp-tools.json` file: ```json [ { "toolId": "click-button", "title": "Click Button", "description": "Clicks a specific button on the page", "mode": "silent", "steps": [ { "targetElement": "#submit-btn", "action": { "type": "click", "element": "#submit-btn" } } ] } ] ``` ### 3. Initialize in Your Web App ```typescript import { createWebInteractMCPController } from '@web-interact-mcp/client'; const controller = createWebInteractMCPController(); await controller.loadTools('/mcp-tools.json'); await controller.createSession('http://localhost:8080'); ``` ### 4. Run the MCP Server ```bash # Using Docker docker run -p 8080:8080 webinteract-mcp-server # Or build from source cd server/WebInteractMCPServer dotnet run ``` ## šŸ“ Project Structure ``` WebInteractMCP/ ā”œā”€ā”€ lib/web-interact-mcp/ # TypeScript MCP Library │ ā”œā”€ā”€ src/ # Source code │ └── README.md # Library documentation ā”œā”€ā”€ server/WebInteractMCPServer/ # .NET MCP Server │ ā”œā”€ā”€ Program.cs # Server entry point │ └── README.md # Server documentation ā”œā”€ā”€ sample/ # Reference implementations │ └── angular-dotnetnet-semantic-kernel/ ``` ## šŸŽÆ Use Cases - **Automated Testing** - Control web applications for E2E testing - **User Onboarding** - Create guided tours and tutorials - **Process Automation** - Automate repetitive web-based tasks - **Accessibility** - Provide AI-powered navigation assistance - **Data Entry** - Automate form filling and data collection ## šŸ”§ Technology Stack | Component | Technologies | |-----------|-------------| | **Client Library** | TypeScript 5.8+, SignalR, Shepherd.js | | **MCP Server** | .NET 9, ASP.NET Core, SignalR | | **Sample App** | Angular 20, Semantic Kernel | ## āš ļø Development Status **Initial preview version will be published soon. This project is in active development and has not yet reached version 1.0.** - āœ… Core functionality is working - āœ… Production-ready components available - šŸš€ Check out the preview version available now - āš ļø Breaking changes expected in future releases - āš ļø API is subject to change before 1.0 release Feel free to use it in your projects, but be prepared for potential breaking changes as we approach the initial preview release. ## šŸ“– Documentation - [Client Library Guide](lib/web-interact-mcp/README.md) - Complete TypeScript library documentation - [Server Setup Guide](server/README.md) - MCP server configuration and deployment - [Sample Implementation](sample/angular-dotnetnet-semantic-kernel/README.md) - Working example with Angular and .NET ## šŸ¤ Contributing We welcome contributions! Please see our [contributing guidelines](.github/copilot-instructions.md) for development standards and workflow. ### Development Workflow ```bash # Setup npm install cd lib/web-interact-mcp && npm install cd sample/angular-dotnetnet-semantic-kernel && npm install # Start development environment with sample app cd sample/angular-dotnetnet-semantic-kernel npm run start:server # Web Interact MCP server npm run start:client # .NET client backend sample app npm run start # Angular frontend sample app ``` ## šŸ“„ License This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. ## šŸ”— Links - [GitHub Issues](https://github.com/Vijay-Nirmal/WebInteractMCP/issues) - Report bugs or request features - [Discussions](https://github.com/Vijay-Nirmal/WebInteractMCP/discussions) - Community discussions --- **Built with ā¤ļø for the MCP ecosystem**