Get the FREE Ultimate OpenClaw Setup Guide →

mcp -node

MCP Server implemented in JavaScript using Node.js that demonstrates how to build an MCP server with a custom prompt and custom tools, including one that loads an environment variable from a configuration file, to integrate seamlessly with AI-assisted environments like Cursor IDE.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio lucianoayres-mcp-server-node node /path/to/mcp-server.js \
  --env API_KEY="your-api-key"

How to use

This MCP server is implemented in Node.js and exposes two tools for use by LLM-enabled IDEs or tooling ecosystems: add and getApiKey. The add tool accepts two numeric inputs (a and b) and returns their sum, while getApiKey retrieves the API key from the API_KEY environment variable. A predefined prompt add_numbers is also provided to help models infer how to invoke the addition tool. The server communicates over standard I/O via StdioServerTransport, making it compatible with common developer workflows and inspector tooling for testing and integration. To use it with Cursor or similar environments, configure the MCP server in the Tools & Integrations section and reference the provided configuration layout, which includes the env var example for API_KEY usage.

How to install

Prerequisites:

  • Node.js version 20 or higher installed on your machine
  • npm (comes with Node.js)

Installation steps:

  1. Clone the repository:
git clone <repository_url>
cd <repository_directory>
  1. Install dependencies:
npm install
  • If you prefer, you can install dependencies manually and add the needed package.json entries:
npm install @modelcontextprotocol/sdk zod
  • Ensure the package.json uses ES Modules and includes the inspector script, for example:
"type": "module",
"scripts": {
  "inspector": "npx @modelcontextprotocol/inspector node ./mcp-server.js"
}
  1. Run tests or start the inspector to validate your MCP server:
npx @modelcontextprotocol/inspector node ./mcp-server.js

or

npm run inspector
  1. If you need to test with Cursor or another IDE, ensure your mcp_config matches your server path and environment variables (e.g., API_KEY).

Additional notes

Tips and considerations:

  • The server defines two tools: add and getApiKey. Use the add_numbers prompt to help models infer the add tool usage.
  • Environment variables (like API_KEY) can be set per environment or via the Cursor configuration sample; ensure you do not expose secrets in public configs.
  • The configuration uses StdioServerTransport, so integrate with IDEs or tooling that support MCP via standard I/O.
  • If you modify the path to mcp-server.js, update the mcp_config args accordingly.
  • When testing with the MCP Inspector, you can load the sample configuration at ./cursor/mcp.json as a reference for Cursor integration.

Related MCP Servers

Sponsor this space

Reach thousands of developers