Get the FREE Ultimate OpenClaw Setup Guide →

mcp-template

A comprehensive Model Context Protocol (MCP) server template for Node.js with TypeScript, supporting both stdio and SSE transports

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio pshaddel-mcp-template node --env-file=/path/to/your/project/.env /path/to/your/project/build/main.js

How to use

The MCP Template server provides a Node.js-based implementation of the Model Context Protocol with TypeScript support. It supports multiple transport modes including stdio, SSE (Server-Sent Events), and HTTP streams, enabling flexible integration with desktop clients, automation tools, and web services. The template includes an authentication mechanism and a sample weather tool to illustrate how tools are implemented, validated, and exposed through the MCP interface. To get started, configure your environment with a .env file, install dependencies, and run the server in your preferred transport mode. You can then use tools like the MCP Inspector to test tool schemas, or integrate with Claude Desktop or n8n via the provided integration guides in the README.

How to install

Prerequisites:

  • Node.js 18+ installed on your system
  • npm or pnpm for package management

Installation steps:

  1. Clone the repository: git clone https://github.com/pshaddel/mcp-template.git cd mcp-template

  2. Install dependencies: npm install

    or

    pnpm install

  3. Build the project (TypeScript to JavaScript): npm run build

  4. Create and configure a .env file based on the sample provided in the repository (cp .sample.env .env)

  5. Run the server in your chosen transport mode (examples):

    • STDIO (default for Claude Desktop): npm run start:stdio or npm start
    • SSE: MODE=sse npm run start
    • HTTP streams: MODE=http-streams API_KEYS=your_key APP_PORT=3000 npm run start
  6. Optional: Run the MCP Inspector to test tools during development: npx @modelcontextprotocol/inspector

Note: Ensure that your environment variables (MODE, API_KEYS, APP_PORT) are set correctly for your target mode before starting the server.

Additional notes

Tips and notes:

  • The server supports multiple transport modes; choose stdio for local development, SSE for server-sent events over HTTP, or HTTP streams for full stream-based MCP communication.
  • In HTTP streams mode, use the x-api-key header for authentication and manage sessions with mcp-session-id as documented in the README.
  • The provided Claude Desktop and n8n integration sections in the README show example configurations; adapt paths and URLs to your environment.
  • If you modify TypeScript source, ensure you rebuild with npm run build before running the server.
  • The MCP Inspector is a useful debugging tool to visually inspect tool schemas and test interactions during development.

Related MCP Servers

Sponsor this space

Reach thousands of developers