Stateless Model Context Protocol (MCP) server built with Express and TypeScript offering JSON-RPC API for echoing messages via resource, tool, and prompt endpoints using modern Streamable HTTP transport.
Unlock the full potential of Express MCP Server Echo through LangDB's AI Gateway. Get enterprise-grade security, analytics, and seamless integration with zero configuration.
Free tier available • No credit card required
A stateless Model Context Protocol (MCP) server built with Express and TypeScript.
# Clone the repository (or download) git clone https://github.com/your-username/sample-express-mcp-server.git cd sample-express-mcp-server # Install dependencies npm install
# Build the TypeScript code npm run build # Run in development mode with auto-reloading npm run dev # Run tests (when added) npm test
src/
├── index.ts # Main application entry point
└── server.ts # MCP server definition with resource, tool, and prompt
This server implements a simple echo endpoint with three MCP components:
echo://{message}
- Returns the message as a resourceecho
- Echoes the provided message back as a tool responseecho
- Creates a user prompt with the provided messageThis server implements the Model Context Protocol (MCP), a standardized way for LLMs to interact with external data and functionality. It exposes a stateless API endpoint that responds to JSON-RPC requests.
Send a POST request to /mcp
with a JSON-RPC payload:
curl -X POST http://localhost:3001/mcp \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -H "Accept: text/event-stream" \ -d '{ "jsonrpc": "2.0", "id": 1, "method": "initialize", "params": { "protocolVersion": "2024-11-05", "capabilities": { "roots": { "listChanged": true }, "sampling": {} }, "clientInfo": { "name": "ExampleClient", "version": "1.0.0" } } }'
curl -X POST http://localhost:3001/mcp \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -H "Accept: text/event-stream" \ -d '{ "jsonrpc": "2.0", "method": "tools/call", "params": { "name": "echo", "arguments": { "message": "Hello, World!" } }, "id": 1 }'
ISC
Discover shared experiences
Shared threads will appear here, showcasing real-world applications and insights from the community. Check back soon for updates!