MCP Server in Node.js
@lucianoayres
关于 MCP Server in Node.js
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
基本信息
配置
使用下面的配置,将此服务器添加到你的 MCP 客户端。
{
"mcpServers": {
"mcp-server-node": {
"command": "npx",
"args": [
"@modelcontextprotocol/inspector",
"node",
"./mcp-server.js"
]
}
}
}工具
未检测到工具
工具是从 README 中自动提取的。维护者可以在 ## Tools 标题下列出工具,即可填充这部分内容。
概览
What is MCP Server in Node.js?
MCP Server in Node.js is a demonstration project that implements a Model Context Protocol (MCP) server using JavaScript and Node.js. It exposes two tools—add and getApiKey—plus a predefined add_numbers prompt, allowing LLM-based IDEs like Cursor AI to call these tools on demand.
How to use MCP Server in Node.js?
Clone the repository, install dependencies with npm install, then test via the MCP Inspector using npm run inspector or npx @modelcontextprotocol/inspector node ./mcp-server.js. To integrate with Cursor IDE, add the server configuration in Cursor’s Settings → Tools & Integrations using the sample JSON provided in the README.
Key features of MCP Server in Node.js
- MCP Integration exposes tool functionality to LLM-based IDEs.
- Addition Tool accepts two numeric parameters and returns their sum.
- MCP Prompt (“add_numbers”) helps AI models infer tool usage.
- Environment variable retrieval via the
getApiKeytool. - Input validation uses Zod for schema checking.
- Standard I/O transport via
StdioServerTransport.
Use cases of MCP Server in Node.js
- Testing an MCP server interactively with MCP Inspector.
- Integrating custom tools into Cursor AI for code generation.
- Performing arithmetic operations through natural language prompts.
- Retrieving environment variables (e.g., API keys) on demand.
- Learning how to structure an MCP server with prompts and tools.
FAQ from MCP Server in Node.js
What is the MCP framework?
MCP (Model Context Protocol) is a framework that allows you to integrate custom tools into AI-assisted development environments such as Cursor AI, enabling LLMs to call these tools on demand.
What tools are defined in this server?
Two tools are defined: add (takes two numbers a and b and returns their sum) and getApiKey (retrieves the value of the API_KEY environment variable).
How can I test the server before integrating with an IDE?
Use the MCP Inspector by running npm run inspector or npx @modelcontextprotocol/inspector node ./mcp-server.js, then open http://localhost:6274/ in your browser to test tools, resources, and prompts.
What are the runtime requirements?
Node.js version 20 or higher is required.
How do I integrate this server with Cursor AI?
In Cursor IDE, go to Settings → Tools & Integrations → Add Custom MCP Server and add the JSON configuration specifying command ("node" or full path), args (absolute path to the server file), and optional env (e.g., "API_KEY").
开发工具 分类下的更多 MCP 服务器
test
prysmaticlabsGo implementation of Ethereum proof of stake
Unity MCP (Server + Plugin)
IvanMurzakAI Skills, MCP Tools, and CLI for Unity Engine. Full AI develop and test loop. Use cli for quick setup. Efficient token usage, advanced tools. Any C# method may be turned into a tool by a single line. Works with Claude Code, Gemini, Copilot, Cursor and any other absolutely for fr
Serena
oraiosA powerful MCP toolkit for coding, providing semantic retrieval and editing capabilities - the IDE for your agent
DevDocs by CyberAGI 🚀
cyberagiincCompletely free, private, UI based Tech Documentation MCP server. Designed for coders and software developers in mind. Easily integrate into Cursor, Windsurf, Cline, Roo Code, Claude Desktop App
nuxt-mcp / vite-plugin-mcp
antfuMCP server helping models to understand your Vite/Nuxt app better.
评论