Fire in da houseTop Tip:Paying $100+ per month for Perplexity, MidJourney, Runway, ChatGPT and other tools is crazy - get all your AI tools in one site starting at $15 per month with Galaxy AI Fire in da houseCheck it out free

mcp-client-demo

MCP.Pizza Chef: yonaka15

mcp-client-demo is a TypeScript-based demo implementation of a Model Context Protocol client leveraging Web Workers and Server-Sent Events (SSE) for real-time communication. It features an interactive UI built with Vite and React, enabling users to connect to MCP servers, list available tools, and execute them with JSON inputs. Designed for developers, it facilitates testing and experimentation with MCP client capabilities in a modular, type-safe environment.

Use This MCP client To

Connect to MCP servers using Web Worker-based clients Interactively test MCP tools via a web UI Execute MCP tools with JSON input through SSE transport Develop and prototype MCP client implementations in TypeScript Experiment with real-time MCP context and tool invocation List and explore available MCP tools from connected servers

README

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

mcp-client-demo FAQ

How do I start the mcp-client-demo development server?
Run 'npm run dev' after installing dependencies to start the development server.
What prerequisites are needed to run mcp-client-demo?
Node.js 18.x or later and an MCP-compatible server running on localhost:3020 are required.
How does mcp-client-demo communicate with MCP servers?
It uses Server-Sent Events (SSE) for transport and Web Workers for client implementation.
Can I test MCP tools interactively with this client?
Yes, the demo includes an interactive UI to list and execute MCP tools with JSON input.
Is mcp-client-demo production-ready?
No, it is a work in progress intended for demonstration and prototyping purposes.
What technologies is mcp-client-demo built with?
It is built with TypeScript, Vite, React, Web Workers, and SSE.
How do I connect the client to an MCP server?
Open 'test.html' in a browser and click 'Connect' to establish a connection.
Does mcp-client-demo support type safety?
Yes, it is implemented in TypeScript to ensure type-safe MCP client interactions.