MCP Client Demo

by yonaka15

MCP Client 8 stars
  • agent-framework

A demo implementation of a Model Context Protocol (MCP) client using Web Workers and Server-Sent Events (SSE).

About

What is MCP Client Demo?

MCP Client Demo is a work-in-progress demo implementation of a Model Context Protocol (MCP) client using Web Workers and Server-Sent Events (SSE). It is built with Vite + React and TypeScript, intended for developers to test and explore MCP client-server communication.

How to use MCP Client Demo?

Ensure Node.js 18.x or later is installed and an MCP-compatible server is running on localhost:3020. Clone the repository, run npm install, then npm run dev to start the development server. Open test.html in a browser, click “Connect” to establish a connection, use “List Tools” to see available tools, select a tool, provide input in JSON format, and click “Execute Tool” to run it.

Key features of MCP Client Demo

- Web Worker-based MCP client implementation
- Server-Sent Events (SSE) transport
- Interactive testing UI
- Type-safe implementation with TypeScript
- Built with Vite + React

Use cases of MCP Client Demo

- Demonstrating how an MCP client communicates with a server over SSE
- Testing available tools from an MCP server in a browser interface
- Learning the MCP protocol through hands-on interaction

FAQ from MCP Client Demo

Is MCP Client Demo production-ready?

No. The project is currently a work in progress (WIP); features and implementations may change significantly.

What MCP servers does MCP Client Demo support?

It works with any MCP-compatible server that communicates over SSE and runs on localhost:3020.

What are the prerequisites to run MCP Client Demo?

Node.js 18.x or later and a running MCP server on localhost:3020 are required.

Can I use MCP Client Demo with a different server host or port?

The README does not specify configuration options; the demo is hardcoded to localhost:3020.

How do I execute a tool in the demo?

After connecting, click “List Tools”, select a tool, enter its input in JSON format, and click “Execute Tool”.

Details

Author
yonaka15
GitHub stars
8
Category
agent-framework
Repository
yonaka15/mcp-client-demo

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

1. Clone the repository
2. Install dependencies:

npm install

Development

Start the development server:

npm run dev

Testing the Worker

1. Open test.html in your browser
2. Click "Connect" to establish connection with the MCP server
3. Use "List Tools" to see available tools
4. Select a tool and provide input in JSON format
5. 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 server
- disconnect: Close the connection
- listTools: Get list of available tools
- callTool: 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

1. Fork the repository
2. Create your feature branch
3. Commit your changes
4. Push to the branch
5. Create a new Pull Request