MCP SSE Server and Client Example
This repository contains a complete example implementation of an SSE (Server-Sent Events) based MCP (Model Context Protocol) server and client.
Overview
The Model Context Protocol (MCP) is a communication protocol designed for AI systems. This implementation demonstrates how to create an MCP server that uses Server-Sent Events (SSE) for real-time communication with clients.
Features
- SSE-based MCP Server: Implements a server using Express.js and the MCP SDK's SSEServerTransport
- Interactive MCP Client: Provides a client implementation that connects to the SSE server
- Tool Implementations: Includes example tools (add, multiply) with proper descriptions
- Dynamic Resources: Demonstrates dynamic resource templates with URI patterns
- Debugging Support: Includes detailed logging and debugging configurations
Components
server.js
- A basic MCP server using StdioServerTransportsse-server.js
- An MCP server using SSEServerTransport with Express.jsclient.js
- A client for the basic serversse-client.js
- A client for the SSE server
Getting Started
- Install dependencies:
- Start the SSE server:
- In another terminal, run the SSE client:
Server Features
The SSE server provides:
- Tool endpoints for addition and multiplication
- A dynamic greeting resource with template support
- Proper session management for multiple clients
- Detailed logging for debugging
Client Features
The SSE client demonstrates:
- Connecting to the SSE server
- Listing available tools and resources
- Calling tools with parameters
- Reading resources with dynamic parameters
URI Templates
The server demonstrates how to expose URI templates to clients, allowing them to understand how to construct resource URIs dynamically:
License
MIT
Related MCP Servers
- -securityAlicense-qualityMCP Server simplifies the implementation of the Model Context Protocol by providing a user-friendly API to create custom tools and manage server workflows efficiently.Last updated -24MIT License
- -securityAlicense-qualityThis server implements the Model Context Protocol (MCP) to handle asynchronous tasks with real-time status tracking, robust error handling, and automatic resource management.Last updated -1MIT License
- AsecurityFlicenseAqualityA specialized server that helps users create new Model Context Protocol (MCP) servers by providing tools and templates for scaffolding projects with various capabilities.Last updated -82
- AsecurityFlicenseAqualityA Model Context Protocol (MCP) server that interacts with system APIs, allowing users to check connections, search employees, register breakfast, and update chemical information by shifts.Last updated -219