Power your agent
การติดตั้งจากผู้เผยแพร่ ไม่ใช่เอนด์พอยต์ของ PlugMCP
URL แบบรีโมตหรือคำสั่งบนเครื่องของคุณ? การติดตั้งสองแบบต่างกันอย่างไร
รันบน PlugMCP
A new server you create. It is not this listing's official endpoint. Use the publisher install when you want their URL and their credentials.
เปิดจากผู้เผยแพร่
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.
Overview · Features · Installation · Testing with MCP Inspector · Setting Environment Variables for Testing · Integrating with Cursor AI · Using the MCP Tool in Cursor (Agent Mode) · Code Overview · References & Resources · License
MCP (Model Context Protocol) is a framework that allows you to integrate custom tools into AI-assisted development environments—such as Cursor AI. MCP servers expose functionality (like data retrieval or code analysis) so that an LLM-based IDE can call these tools on demand. Learn more about MCP in the Model Context Protocol Introduction.
This project demonstrates an MCP server implemented in JavaScript using Node.js. It defines two tools: add, which takes two numeric inputs and returns their sum, and getApiKey, which retrieves the API key from the API_KEY environment variable. It also provides a predefined prompt add_numbers that allows AI models to infer the usage of the addition tool.
StdioServerTransport for integration with development environments.Clone the Repository
git clone <repository_url>
cd <repository_directory>
Install Dependencies
You can install the project dependencies in one of two ways:
Option 1: Install using the existing package.json
Simply run:
npm install
Option 2: Install dependencies manually
If you prefer, delete the existing package.json and install the required packages manually:
npm install @modelcontextprotocol/sdk zod
Then, update the newly generated package.json file to include the following lines, which enables ES Modules and adds the mcp inspector command:
"type": "module",
"scripts": {
"inspector": "npx @modelcontextprotocol/inspector node ./mcp-server.js"
}
The MCP Inspector is a debugging tool that lets you test your server's tools interactively before integrating with an IDE.
Option 1: Run directly with npx
npx @modelcontextprotocol/inspector node ./mcp-server.js
Option 2: Use the npm script
npm run inspector
This will:
Open the MCP Server Inspector on the browser: http://localhost:6274/
To test the getApiKey tool with different API keys, you can set environment variables before running the inspector:
Linux/macOS (Bash/Zsh):
# Temporary (current session only)
export API_KEY="your-test-key"
npm run inspector
# Or set for single command
API_KEY="your-test-key" npm run inspector
Windows (Command Prompt):
# Set for current session
set API_KEY=your-test-key
npm run inspector
Windows (PowerShell):
# Set for current session
$env:API_KEY="your-test-key"
npm run inspector
# Or set for single command
$env:API_KEY="your-test-key"; npm run inspector
To integrate this MCP server with Cursor IDE, you need to add the configuration through Cursor's settings interface:
Important: If you already have other MCP servers configured, don't overwrite the entire configuration. Instead, add the "MCP Server Boilerplate" object to the existing "mcpServers" object.
Sample Configuration File: This project includes a sample configuration file at ./cursor/mcp.json that you can reference or copy from.
Below is the configuration you need to add:
Linux/macOS example:
{
"MCP Server Boilerplate": {
"command": "node",
"args": ["/home/john/mcp-server-node/mcp-server.js"],
"env": {
"API_KEY": "abc-1234567890"
}
}
}
Windows example:
{
"MCP Server Boilerplate": {
"command": "node",
"args": ["C:\\Users\\john\\mcp-server-node\\mcp-server.js"],
"env": {
"API_KEY": "abc-1234567890"
}
}
}
If you have existing MCP servers configured, your full configuration might look like this:
{
"mcpServers": {
"existing-server": {
"command": "python",
"args": ["/path/to/existing/server.py"]
},
"MCP Server Boilerplate": {
"command": "node",
"args": ["/home/john/mcp-server-node/mcp-server.js"],
"env": {
"API_KEY": "abc-1234567890"
}
}
}
}
MCP Server Boilerplate:
This is the key for your server configuration. You can name it as you like.
command:
The Node.js executable to run your server. You can use either:
"node" (if Node.js is in your PATH)Finding your Node.js path:
Linux/macOS:
which node
# Example output: /home/john/.nvm/versions/node/v20.13.1/bin/node
Windows (Command Prompt):
where node
# Example output: C:\Program Files\nodejs\node.exe
Windows (PowerShell):
Get-Command node
# Example output: C:\Program Files\nodejs\node.exe
args:
An array containing the absolute path to your MCP server file.
Linux/macOS examples:
["/home/john/mcp-server-node/mcp-server.js"]
Windows examples:
["C:\\Users\\john\\mcp-server-node\\mcp-server.js"]
env: (Optional)
Defines environment variables for your MCP server process. In this example, the API_KEY is set to "abc-1234567890". Adjust this value as needed for your environment.
The project comprises the following key parts:
MCP Server Initialization:
The MCP server is instantiated using McpServer from the MCP SDK and connected via StdioServerTransport.
Tool Definitions:
a and b) and returns their sum as text.API_KEY and returns it as text.Prompt Definition:
Important Note: It's not required to have a prompt defined for a tool. This example just demonstrates one of the capabilities of prompts, allowing the AI model to infer which tool to use based on your input. The AI can also use tools directly when it determines they're needed for a task.
With the MCP server integrated into Cursor IDE and with Agent mode enabled, you can use the tools in several ways:
Method 1: Natural Language Prompt Simply use a natural language prompt like:
add 3 and 5
or
what is 7 plus 12?
Method 2: Prompt-Based Tool Invocation Type the following prompt in the chat:
/add_numbers
When you press Enter after typing this prompt, Cursor will automatically:
add tool from the Node Serveradd tool to calculate the resultParameters for the Addition Tool:
a: First number to addb: Second number to addFor the getApiKey tool, you can use:
what is my API key?
or
get my API key
The AI agent will automatically infer the appropriate tool to use based on your request.
This project is licensed under the MIT License.
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 configura
ภาพรวม
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.
เครื่องมือ
ยังไม่มีรายการเครื่องมือ เซิร์ฟเวอร์แบบรีโมตจะได้รายการหลังการตรวจสอบสถานะครั้งแรก
FAQ
คัดลอกคอนฟิก stdio สำหรับ Cursor, Claude Desktop, Claude Code หรือ VS Code ได้ในหน้านี้ คอนฟิกนี้ใช้การติดตั้งของผู้เผยแพร่ ไม่ใช่พร็อกซีของ PlugMCP
ระเบียนนี้ไม่ได้ระบุตัวแปรสภาพแวดล้อมที่จำเป็น
MCP Server Node ทำงานแบบโลคัลผ่าน stdio
ตรวจสอบล่าสุดเมื่อ 2026-10-27 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.