express-mcp-server-echo
An example of using express-mcp-handler to serve an mcp serve via http
Documentation
Express MCP Server
A stateless Model Context Protocol (MCP) server built with Express and TypeScript.
Features
- Stateless MCP server implementation with modern Streamable HTTP transport
- TypeScript for type safety
- Express.js for HTTP handling
Requirements
- Node.js 18+
- npm or yarn
Installation
# 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 installDevelopment
# Build the TypeScript code
npm run build
# Run in development mode with auto-reloading
npm run dev
# Run tests (when added)
npm testServer Structure
src/
├── index.ts # Main application entry point
└── server.ts # MCP server definition with resource, tool, and promptAvailable Functionality
This server implements a simple echo endpoint with three MCP components:
- Resource: `echo://{message}` - Returns the message as a resource
- Tool: `echo` - Echoes the provided message back as a tool response
- Prompt: `echo` - Creates a user prompt with the provided message
MCP Protocol
This 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.
API Usage
Send a POST request to `/mcp` with a JSON-RPC payload:
Initialize
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"
}
}
}'Call Echo Tool
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
}'License
Frequently asked questions
What is express-mcp-server-echo?
express-mcp-server-echo is An example of using express-mcp-handler to serve an mcp serve via http
How do I install express-mcp-server-echo?
Open the GitHub repository and follow its README. Most MCP servers are added to your client's MCP config, then called by your agent.
Is express-mcp-server-echo open source?
Yes — it is hosted on GitHub at https://github.com/jhgaylor/express-mcp-server-echo and has 1 stars.
Related MCP tools
Playwright MCP server TypeScript-based implementation. Trusted by 22000+ developers. Trusted by 22000+ developers. Trusted by 22000+ developers.
Official Notion MCP Server TypeScript-based implementation. Trusted by 3400+ developers. Trusted by 3400+ developers. Trusted by 3400+ developers.
Directory for Awesome MCP Servers TypeScript-based implementation. Trusted by 1900+ developers. Trusted by 1900+ developers.
🧩 MCP Gateway - A lightweight gateway service that instantly transforms existing MCP Servers and APIs into MCP servers with zero code changes.
MCP Aggregator, Orchestrator, Middleware, Gateway in one docker TypeScript-based implementation. Trusted by 1400+ developers.
MCP Server for kubernetes management commands TypeScript-based implementation. Trusted by 1100+ developers. Trusted by 1100+ developers.
Run your own MCP server? See who uses it and what to fix.
Measure it with TrackMCP