MCP Express Server
A Model Context Protocol (MCP) server implementation using TypeScript, Express.js, and Server-Sent Events (SSE) for real-time communication.
Features
MCP Protocol Support: Implements the Model Context Protocol specification
SSE Transport: Real-time communication using Server-Sent Events
TypeScript: Fully typed for better developer experience
Express.js: Robust HTTP server framework
Environment Configuration: Using dotenv for configuration management
Project Structure
Installation
Configuration
Create a .env file in the root directory:
Edit .env with your configuration:
Development
Run in development mode with auto-reload:
Build
Compile TypeScript to JavaScript:
Production
Run the compiled server:
API Endpoints
GET /
Server information and available endpoints
GET /health
Health check endpoint
Returns server status and active connection count
GET /sse
Server-Sent Events endpoint
Establishes a persistent connection for real-time notifications
Clients should connect here to receive server updates
POST /message
MCP message endpoint
Send JSON-RPC 2.0 formatted MCP requests
Receives MCP responses
Available Tools
The server comes with three example tools:
echo: Echoes back a message
add: Adds two numbers together
get_time: Returns the current server time
MCP Protocol Usage
Initialize Connection
List Available Tools
Call a Tool
Adding New Tools
Edit src/tools.ts to add new tools:
License
MIT