A JavaScript client implementation for interacting with the MCP (Model Context Protocol) Server with Server-Sent Events (SSE) support.
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.
- Include the client in your project:
import { addNumbers, getGreeting } from './sse_client.js';
- The SSE connection will be automatically established when the client is loaded.
The client automatically sets up an SSE connection and listens for messages:
// The connection is automatically established // Messages will be logged to console
const result = await addNumbers(5, 3); console.log('Sum:', result); // Will output the sum
const greeting = await getGreeting('Alice'); console.log('Greeting:', greeting); // Will output a personalized greeting
- Parameters:
a: First numberb: Second number
- Returns: Promise with the sum result
- Parameters:
name: Name to include in greeting
- Returns: Promise with the greeting message
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.