MCP.so
ログイン

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

基本情報

カテゴリ

開発者ツール

ライセンス

MIT

ランタイム

node

トランスポート

stdio

公開者

lucianoayres

設定

以下の設定を使って、このサーバーを 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 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.

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

コメント

「開発者ツール」の他のコンテンツ