
MCP Client Demo
A demo implementation of a Model Context Protocol (MCP) client using Web Workers and Server-Sent Events (SSE).
what is MCP Client Demo?
MCP Client Demo is a demonstration of a Model Context Protocol (MCP) client that utilizes Web Workers and Server-Sent Events (SSE) for real-time communication.
how to use MCP Client Demo?
To use the MCP Client Demo, clone the repository, install the dependencies, and start the development server. Then, open the test.html file in your browser to interact with the MCP server.
key features of MCP Client Demo?
- Web Worker-based MCP client implementation
- Server-Sent Events (SSE) transport for real-time updates
- Interactive testing UI for easy tool execution
- Type-safe implementation using TypeScript
- Built with Vite and React for modern web development
use cases of MCP Client Demo?
- Testing and demonstrating the functionality of an MCP client.
- Developing applications that require real-time communication with an MCP-compatible server.
- Learning and experimenting with Web Workers and SSE in a practical context.
FAQ from MCP Client Demo?
- What is the purpose of the MCP Client Demo?
The MCP Client Demo serves as a practical example of how to implement a Model Context Protocol client using modern web technologies.
- Do I need any special software to run this project?
You need Node.js 18.x or later and an MCP-compatible server running on localhost:3020.
- Is this project complete?
No, this project is currently a work in progress (WIP) and features may change significantly.
MCP Client Demo
Note: This project is currently a work in progress (WIP). Features and implementations may change significantly.
A demo implementation of a Model Context Protocol (MCP) client using Web Workers and Server-Sent Events (SSE).
Features
- Web Worker-based MCP client implementation
- Server-Sent Events (SSE) transport
- Interactive testing UI
- Type-safe implementation with TypeScript
- Built with Vite + React
Getting Started
Prerequisites
- Node.js 18.x or later
- An MCP-compatible server running on
localhost:3020
Installation
- Clone the repository
- Install dependencies:
npm install
Development
Start the development server:
npm run dev
Testing the Worker
- Open
test.html
in your browser - Click "Connect" to establish connection with the MCP server
- Use "List Tools" to see available tools
- Select a tool and provide input in JSON format
- Click "Execute Tool" to run the selected tool
Project Structure
src/
├── worker.ts # MCP client worker implementation
├── worker-test.ts # Worker test interface
├── types.ts # Type definitions
└── App.tsx # Main React application
Key Components
- worker.ts: Main Web Worker implementation of the MCP client
- worker-test.ts: Testing interface for the worker
- types.ts: Shared type definitions for worker commands and responses
Implementation Details
Worker Commands
The worker accepts the following commands:
connect
: Establish connection with MCP serverdisconnect
: Close the connectionlistTools
: Get list of available toolscallTool
: Execute a specific tool
Worker Responses
The worker sends responses in the following format:
type WorkerResponse =
| {
type: "status";
status: WorkerStatus;
}
| {
type: "result";
result: ListToolsResult | CallToolResult;
}
| {
type: "error";
error: string;
details?: Record<string, unknown>;
};
Development
Building
Build the project:
npm run build
Linting
Run ESLint:
npm run lint
Contributing
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request