Minimal echo example of an MCP server built with express-mcp-handler.
  • TypeScript 70.2%
  • Dockerfile 29.8%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-10-13 09:12:08 +00:00
.forgejo/workflows Move to home-cloud's app platform 2026-10-13 05:11:47 -04:00
k8s deploy: render and pin sha-84f3c9a 2026-10-13 09:12:08 +00:00
src Move to home-cloud's app platform 2026-10-13 05:11:47 -04:00
.dockerignore add dockerfile 2025-04-28 00:33:48 -05:00
.eslintrc.js init 2025-04-27 21:42:07 -05:00
.gitignore init 2025-04-27 21:42:07 -05:00
app.yaml Move to home-cloud's app platform 2026-10-13 05:11:47 -04:00
docker-compose.yml add dockerfile 2025-04-28 00:33:48 -05:00
Dockerfile Move to home-cloud's app platform 2026-10-13 05:11:47 -04:00
package-lock.json Move to home-cloud's app platform 2026-10-13 05:11:47 -04:00
package.json update package name 2025-04-28 00:34:19 -05:00
README.md Move to home-cloud's app platform 2026-10-13 05:11:47 -04:00
tsconfig.json add dockerfile 2025-04-28 00:33:48 -05:00

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 install

Development

# Build the TypeScript code
npm run build

# Run in development mode with auto-reloading
npm run dev

# Run tests (when added)
npm test

Server Structure

src/
  ├── index.ts                # Main application entry point
  └── server.ts               # MCP server definition with resource, tool, and prompt

Available 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

ISC

Deploy

This runs on home-cloud's app platform at https://mcp-echo.apps.inevitable.fyi (MCP endpoint /mcp). app.yaml says what it needs; every push to main builds the image, renders k8s/ from app.yaml and pins the image, and Flux deploys it from its pointer in Forgejo jhgaylor/apps.