Get the FREE Ultimate OpenClaw Setup Guide →

MCP-JS

A simple boilerplate for building Model Context Protocol (MCP) servers in Node.js

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio helmi97-mcp-js-server node src/server.js \
  --env DEBUG="Enable verbose logging (e.g., set to 1)" \
  --env MCP_API_KEY="Optional API key for authentication"

How to use

This MCP server provides an HTTP MCP transport with an auto-generated JSON schema for tools via a single tools.config.js file. Tools are registered in the registry and exposed under the /tools endpoint, which lists available tools and their schemas. The server exposes an MCP JSON-RPC interface at /mcp, allowing clients to call registered tools using the standard JSON-RPC format. An optional API key can be enforced via the MCP_API_KEY environment variable, and all requests can be logged and error-handled centrally by the server's middleware. To add functionality, you edit src/tools.config.js to define new tools; the tool loader will generate the appropriate JSON schemas from Zod shapes and expose them automatically on startup.

How to install

Prerequisites:

  • Node.js and npm installed
  • Git installed

Step-by-step:

  1. Clone the repository git clone https://github.com/Helmi97/MCP-JS-Server.git cd mcp-js-server

  2. Install dependencies npm install

  3. Configure optional authentication (recommended)

    • Create a .env or set the environment variable MCP_API_KEY in your deployment to enable API key protection.
  4. Start the server npm start

  5. Verify endpoints

If you modify tools.config.js, restart the server to register new tools.

Additional notes

Tips and common considerations:

  • Tools are defined in src/tools.config.js; after adding or updating a tool, restart the server to reload the registry.
  • The server auto-generates JSON schemas from Zod shapes, ensuring consistent validation for tool inputs.
  • If MCP_API_KEY is set, all requests to /mcp must include the x-api-key header with the matching value.
  • Debug logging can be enabled by setting DEBUG=1 in the environment.
  • The /tools endpoint provides both tool metadata and schemas; use this to build client integrations or test tools before wiring them into applications.

Related MCP Servers

Sponsor this space

Reach thousands of developers