Express MCP Server

Express MCP Server

A modular Model Context Protocol server implementation using Express.js that provides example mathematical and echo tools with HTTP streaming support and easy extensibility for adding custom tools.

Category
Visit Server

README

Express MCP Server

A clean, modular implementation of the Model Context Protocol (MCP) using Express.js and TypeScript.

Quick Start

# Install dependencies
npm install

# Development (with file watching)
npm run dev

# Production
npm run build
npm start

# Type checking
npm run type-check

Server runs on http://localhost:3001

Endpoints

  • Health: GET /mcp/health - Server health status
  • Info: GET /mcp/info - Server information and capabilities
  • MCP Protocol: POST/GET/DELETE /mcp - Main MCP endpoints with streaming support

Project Structure

src/
├── index.ts              Entry point - starts the server
├── app.ts                Express app factory
├── server/
│   └── mcp.ts            Core MCP server logic
├── routes/
│   └── mcp.ts            HTTP route handlers
└── tools/
    └── index.ts          Tool definitions

Total: 201 lines of focused, readable code

Architecture

Single Responsibility Principle

Each module has one clear purpose:

  • index.ts (10 lines) - Server startup
  • app.ts (20 lines) - Express setup
  • server/mcp.ts (60 lines) - MCP protocol handling
  • routes/mcp.ts (69 lines) - HTTP routing
  • tools/index.ts (42 lines) - Tool catalog

Features

✓ Official MCP SDK integration (StreamableHTTPServerTransport) ✓ HTTP streaming (chunked encoding + Server-Sent Events) ✓ Session management with automatic UUID generation ✓ Zod schema validation for tool inputs ✓ Comprehensive error handling ✓ Health check and info endpoints ✓ TypeScript strict mode

Tools

Three example tools are included:

  1. add(a, b) - Add two numbers
  2. multiply(x, y) - Multiply two numbers
  3. echo(message) - Echo a message

Adding a New Tool

Edit src/tools/index.ts and add to the array:

{
  name: "my-tool",
  description: "What this tool does",
  inputSchema: {
    param1: z.string().describe("Parameter description"),
    param2: z.number().describe("Another parameter"),
  },
  handler: async (args) => {
    const p1 = args.param1 as string;
    const p2 = args.param2 as number;
    // Tool logic here
    return `Result: ${p1} ${p2}`;
  },
}

Then rebuild:

npm run build
npm start

Testing

# Health check
curl http://localhost:3001/mcp/health

# Server info
curl http://localhost:3001/mcp/info

# MCP protocol request (with proper headers)
curl -X POST http://localhost:3001/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'

Development

# Watch mode (recompiles on file changes)
npm run dev

# Type checking only
npm run type-check

# Build production bundle
npm run build

Environment Variables

  • PORT (default: 3001) - Server port
PORT=4000 npm start

Stack

  • Express.js - Web framework
  • TypeScript - Type safety
  • Zod - Schema validation
  • MCP SDK - Protocol implementation
  • Node.js 18+ - Runtime

Standards

  • MCP Protocol Version: 2024-11-05
  • HTTP Streaming: Chunked encoding + SSE
  • Schema Validation: Zod
  • Code Format: TypeScript with strict mode
  • Code Style: Tabs, consistent formatting

Documentation

License

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured