MCP.so
登录

MCP Server in Node.js

@lucianoayres

基本信息

分类

开发工具

许可证

MIT

传输方式

stdio

作者

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 Server in Node.js 配置

使用下面的配置,将此服务器添加到你的 MCP 客户端。

{
  "mcpServers": {
    "mcp-server-node": {
      "command": "npx",
      "args": [
        "@modelcontextprotocol/inspector",
        "node",
        "./mcp-server.js"
      ]
    }
  }
}

MCP Server in Node.js 工具

工具列表暂未提供

当前收录暂时没有可展示的工具列表,不代表服务没有工具。请查阅项目文档了解支持的能力。

点击上方按钮,在临时沙箱中运行此服务器并实时获取工具列表。

概览

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 getApiKey tool.
  • 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.

常见问题

1

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.

2

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).

3

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.

4

What are the runtime requirements?

Node.js version 20 or higher is required.

5

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 服务器