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

コメント

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