MCP ExplorerExplorer

Mcp Sse Client

@rohithtpon a year ago
1 MIT
FreeCommunity
AI Systems
A JavaScript client for MCP Server with SSE support for real-time updates.

Overview

What is Mcp Sse Client

mcp-sse-client is a JavaScript client designed for interacting with the MCP (Model Context Protocol) Server, providing support for Server-Sent Events (SSE) to receive real-time updates.

Use cases

Use cases for mcp-sse-client include implementing a real-time calculator that adds numbers, creating a personalized greeting service, or any application that needs to respond dynamically to user inputs or server events.

How to use

To use mcp-sse-client, include it in your project by importing the necessary functions. The SSE connection is established automatically upon loading the client, allowing you to listen for events and execute tools like adding numbers or fetching personalized greetings.

Key features

Key features of mcp-sse-client include automatic establishment of SSE connections, real-time message listening, and utility functions for performing operations such as arithmetic calculations and retrieving personalized messages.

Where to use

mcp-sse-client can be used in web applications that require real-time data updates, such as chat applications, live notifications, or any interactive platform that benefits from immediate feedback.

Content

MCP SSE Client

A JavaScript client implementation for interacting with the MCP (Model Context Protocol) Server with Server-Sent Events (SSE) support.

Overview

This client provides functionality to:

  • Connect to SSE stream for real-time updates
  • Execute tools (like adding numbers)
  • Fetch resources (like personalized greetings)

The server implementation can be found at mcp-python-sse.

Setup

  1. Include the client in your project:
import { addNumbers, getGreeting } from './sse_client.js';
  1. The SSE connection will be automatically established when the client is loaded.

Usage

Listening to SSE Events

The client automatically sets up an SSE connection and listens for messages:

// The connection is automatically established
// Messages will be logged to console

Using Tools

Add Numbers

const result = await addNumbers(5, 3);
console.log('Sum:', result); // Will output the sum

Using Resources

Get Greeting

const greeting = await getGreeting('Alice');
console.log('Greeting:', greeting); // Will output a personalized greeting

API Reference

Functions

addNumbers(a: number, b: number)

  • Parameters:
    • a: First number
    • b: Second number
  • Returns: Promise with the sum result

getGreeting(name: string)

  • Parameters:
    • name: Name to include in greeting
  • Returns: Promise with the greeting message

Server Configuration

By default, the client connects to http://localhost:8000. The server implementation should be running and accessible at this address.

For server setup and configuration, please refer to the mcp-python-sse repository.

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers