Node.js MCP server boilerplate

Node.js MCP server boilerplate

mcp-server-node•bylucianoayres

A sample Model Context Protocol server in Node.js that offers an addition tool, an API key retrieval tool, and a predefined addition prompt.

License: MIT License•Runtime: Awaiting documentation review•Category: developer tools

WHAT IT DOES

  • •Provides an add tool that accepts two numeric parameters and returns their sum as text.
  • •Provides a getApiKey tool that returns the value of the API_KEY environment variable.
  • •Provides an add_numbers prompt to help AI models infer use of the addition tool.
  • •Uses Zod for schema validation of tool inputs.

BEST FOR

  • •Demonstrating or prototyping a custom MCP server in Node.js.
  • •Testing MCP tools interactively before integrating with an IDE.
  • •Adding a simple arithmetic and environment-variable tool to an LLM-based IDE such as Cursor.

ABOUT MCP-SERVER-NODE

Node.js MCP server boilerplate is cataloged as an MCP server attributed to lucianoayres. A sample Model Context Protocol server in Node.js that offers an addition tool, an API key retrieval tool, and a predefined addition prompt. It is categorized under developer tools. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.

HOW TO INSTALL

Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.

LICENSE

Catalog license label: MIT License. Check the source repository's current license and terms before using, modifying or distributing this software.

能力检查器

能力定义尚未审核。未核验的采集内容不会作为可信接口展示。

Tools (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Resources (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Prompts (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

NEWSLETTER - COMING LATER

Newsletter subscriptions are not open yet

Email delivery is not connected. This page does not collect email addresses or create subscriptions.

Browse the registry for current listings instead.

Community Reviews

Coming later

Reviews for Node.js MCP server boilerplate are not available yet

Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.

FREQUENTLY ASKED QUESTIONS

How does the server connect to development environments?

It connects via standard input/output transport using StdioServerTransport.

What Node.js version is required?

Node.js version 20 or higher is required.

上游原版 README

在 GitHub 查看同一版本原文

README.md · fb4603787f5d · 采集于 2026-11-13 09:05:40 UTC

保留上游原文,不做 AI 改写。为安全起见过滤脚本、表单和不安全链接。

当前显示最后一次成功采集的文档快照,请以来源页面为准。

🟢 MCP Server in Node.js

MCP Server in Node.js banner

Build and run a custom MCP Server in Node.js in just 2 minutes ⏱️

Overview · Features · Installation · Testing with MCP Inspector · Setting Environment Variables for Testing · Integrating with Cursor AI · Using the MCP Tool in Cursor (Agent Mode) · Code Overview · References & Resources · License

Overview

MCP (Model Context Protocol) is a framework that allows you to integrate custom tools into AI-assisted development environments—such as Cursor AI. MCP servers expose functionality (like data retrieval or code analysis) so that an LLM-based IDE can call these tools on demand. Learn more about MCP in the Model Context Protocol Introduction.

This project demonstrates an MCP server implemented in JavaScript using Node.js. It defines two tools: add, which takes two numeric inputs and returns their sum, and getApiKey, which retrieves the API key from the API_KEY environment variable. It also provides a predefined prompt add_numbers that allows AI models to infer the usage of the addition tool.

Requirements

  • Node.js: Version 20 or higher is required.

Features

  • MCP Integration: Exposes tool functionality to LLM-based IDEs.
  • Addition Tool: Accepts two numeric parameters and returns their sum.
  • MCP Prompt: Provides a predefined prompt ("add_numbers") that allow AI models to infer tool usage.
  • Env Var Retrieval: Demonstrates how to load an example environment variable from the configuration file.
  • Input Validation: Uses Zod for schema validation.
  • Standard I/O Transport: Connects via StdioServerTransport for integration with development environments.

Installation

  1. Clone the Repository

    git clone <repository_url>
    cd <repository_directory>
    
  2. Install Dependencies

    You can install the project dependencies in one of two ways:

    Option 1: Install using the existing package.json

    Simply run:

    npm install
    

    Option 2: Install dependencies manually

    If you prefer, delete the existing package.json and install the required packages manually:

    npm install @modelcontextprotocol/sdk zod
    

    Then, update the newly generated package.json file to include the following lines, which enables ES Modules and adds the mcp inspector command:

    "type": "module",
    "scripts": {
     "inspector": "npx @modelcontextprotocol/inspector node ./mcp-server.js"
    }
    

Testing with MCP Inspector

The MCP Inspector is a debugging tool that lets you test your server's tools interactively before integrating with an IDE.

Option 1: Run directly with npx

npx @modelcontextprotocol/inspector node ./mcp-server.js

Option 2: Use the npm script

npm run inspector

This will:

  1. Start the MCP inspector server
  2. Open your browser to the inspector interface
  3. Allow you to test tools, resources, and prompts

Open the MCP Server Inspector on the browser: http://localhost:6274/

Setting Environment Variables for Testing

To test the getApiKey tool with different API keys, you can set environment variables before running the inspector:

Linux/macOS (Bash/Zsh):

# Temporary (current session only)
export API_KEY="your-test-key"
npm run inspector

# Or set for single command
API_KEY="your-test-key" npm run inspector

Windows (Command Prompt):

# Set for current session
set API_KEY=your-test-key
npm run inspector

Windows (PowerShell):

# Set for current session
$env:API_KEY="your-test-key"
npm run inspector

# Or set for single command
$env:API_KEY="your-test-key"; npm run inspector

Integrating with Cursor AI

To integrate this MCP server with Cursor IDE, you need to add the configuration through Cursor's settings interface:

  1. Open Cursor IDE
  2. Go to Settings → Tools & Integrations
  3. Click on Add Custom MCP Server
  4. Add the configuration below

Important: If you already have other MCP servers configured, don't overwrite the entire configuration. Instead, add the "MCP Server Boilerplate" object to the existing "mcpServers" object.

Sample Configuration File: This project includes a sample configuration file at ./cursor/mcp.json that you can reference or copy from.

Configuration Structure

Below is the configuration you need to add:

Linux/macOS example:

{
  "MCP Server Boilerplate": {
    "command": "node",
    "args": ["/home/john/mcp-server-node/mcp-server.js"],
    "env": {
      "API_KEY": "abc-1234567890"
    }
  }
}

Windows example:

{
  "MCP Server Boilerplate": {
    "command": "node",
    "args": ["C:\\Users\\john\\mcp-server-node\\mcp-server.js"],
    "env": {
      "API_KEY": "abc-1234567890"
    }
  }
}

If you have existing MCP servers configured, your full configuration might look like this:

{
  "mcpServers": {
    "existing-server": {
      "command": "python",
      "args": ["/path/to/existing/server.py"]
    },
    "MCP Server Boilerplate": {
      "command": "node",
      "args": ["/home/john/mcp-server-node/mcp-server.js"],
      "env": {
        "API_KEY": "abc-1234567890"
      }
    }
  }
}

Configuration Parameters

  • MCP Server Boilerplate:
    This is the key for your server configuration. You can name it as you like.

  • command:
    The Node.js executable to run your server. You can use either:

    • "node" (if Node.js is in your PATH)
    • The full path to your Node.js executable (if needed)

    Finding your Node.js path:

    Linux/macOS:

    which node
    # Example output: /home/john/.nvm/versions/node/v20.13.1/bin/node
    

    Windows (Command Prompt):

    where node
    # Example output: C:\Program Files\nodejs\node.exe
    

    Windows (PowerShell):

    Get-Command node
    # Example output: C:\Program Files\nodejs\node.exe
    
  • args:
    An array containing the absolute path to your MCP server file.

    Linux/macOS examples:

    ["/home/john/mcp-server-node/mcp-server.js"]
    

    Windows examples:

    ["C:\\Users\\john\\mcp-server-node\\mcp-server.js"]
    
  • env: (Optional)
    Defines environment variables for your MCP server process. In this example, the API_KEY is set to "abc-1234567890". Adjust this value as needed for your environment.

Code Overview

The project comprises the following key parts:

  • MCP Server Initialization:
    The MCP server is instantiated using McpServer from the MCP SDK and connected via StdioServerTransport.

  • Tool Definitions:

    • add:
      Defined with a Zod schema that accepts two numbers (a and b) and returns their sum as text.
    • getApiKey:
      Retrieves the API key from the environment variable API_KEY and returns it as text.
  • Prompt Definition:

    • add_numbers:
      A predefined prompt that allows AI models to infer the usage of the addition tool.

Important Note: It's not required to have a prompt defined for a tool. This example just demonstrates one of the capabilities of prompts, allowing the AI model to infer which tool to use based on your input. The AI can also use tools directly when it determines they're needed for a task.

Using the MCP Tool in Cursor (Agent Mode)

With the MCP server integrated into Cursor IDE and with Agent mode enabled, you can use the tools in several ways:

Addition Tool Usage

Method 1: Natural Language Prompt Simply use a natural language prompt like:

add 3 and 5

or

what is 7 plus 12?

Method 2: Prompt-Based Tool Invocation Type the following prompt in the chat:

/add_numbers

When you press Enter after typing this prompt, Cursor will automatically:

  1. Recognize that you want to use the add tool from the Node Server
  2. Display a GUI prompt asking for the two number parameters
  3. The AI model will infer that it needs to use the add tool to calculate the result

Parameters for the Addition Tool:

  • Parameter a: First number to add
  • Parameter b: Second number to add
  • Returns: The sum of the two numbers as text

API Key Tool Usage

For the getApiKey tool, you can use:

what is my API key?

or

get my API key

The AI agent will automatically infer the appropriate tool to use based on your request.

References & Resources

License

This project is licensed under the MIT License.

Install configuration

Are you the maintainer?

Claim this server with your GitHub account to request manual ownership verification.

README Embed Badge
Markdown

Link to the catalog listing for Node.js MCP server boilerplate from your README. This badge does not certify ownership, compatibility or security.

[![MCP catalog listing](https://img.shields.io/badge/MCP-awesome--mcp-orange?style=flat-square)](https://awesome-mcp.com/servers/mcp-server-node)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.

下载与拉取统计

来源、范围和时段分别列出;不相加,不代表安装人数、活跃用户或安全审核。

尚无已审核的包 / 镜像标识,暂不展示下载统计。

Related developer tools MCP Servers

Alternative and complementary servers in the same category

View all in developer tools →
Postbye
postbye-mcp•postbye-team

A directory listing describing a cancellation-letter and mailing-address service. The configured public GitHub repository returned 404 during source verification.

Repository stats unavailable
Developer Tools
Singapore Proxy MCP
singapore-proxy-mcp•Xavierfok

A hosted MCP service for browsing and searching through Singapore mobile-network proxies.

0
Developer Tools

A directory listing describing a Markdown-to-PDF service. The configured public GitHub repository returned 404 during source verification.

Repository stats unavailable
Developer Tools