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.
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:
- Clone the repository:
git clone <repository_url>
cd <repository_directory>
- 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"
}
- Run tests or start the inspector to validate your MCP server:
npx @modelcontextprotocol/inspector node ./mcp-server.js
or
npm run inspector
- 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
browser-tools
Monitor browser logs directly from Cursor and other MCP compatible IDEs.
mcp-nodejs-debugger
🐞 MCP Node.js debugger
n8n-workflow-builder
MCP server that allow LLM in agent mode builds n8n workflows for you
midnight
Midnight MCP server giving AI assistants access to Midnight blockchain — search contracts, analyze code, explore docs
lichess
A Model Context Protocol (MCP) server that enables Claude Desktop to interact with Lichess chess platform through natural language. Play games, analyze positions, manage your account, and participate in tournaments—all by simply talking to Claude.
xgmem
Global Memory MCP server, that manage all projects data.