express-mcp-server-echo

express-mcp-server-echo

3.5

A stateless Model Context Protocol (MCP) server built with Express and TypeScript.

The Express MCP Server is a stateless server implementation designed to handle Model Context Protocol (MCP) requests using modern Streamable HTTP transport. Built with Express.js and TypeScript, it ensures type safety and efficient HTTP handling. The server is structured to support MCP components such as resources, tools, and prompts, making it a versatile choice for developers looking to integrate MCP functionalities into their applications. It requires Node.js 18+ and can be easily set up using npm or yarn. The server is designed to be stateless, meaning it does not retain any session information between requests, which simplifies scaling and deployment.

Features

  • Stateless MCP server implementation with modern Streamable HTTP transport
  • TypeScript for type safety
  • Express.js for HTTP handling

MCP Tools

  • echo: Echoes the provided message back as a tool response

MCP Resources

  • {'name': 'echo://{message}', 'description': 'Returns the message as a resource'}

Usage with Different Platforms

initialize

bash
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

bash
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
  }'