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. This project demonstrates an MCP server built in Node.js that provides two basic tools: add and getApiKey.
StdioServerTransport
for integration with development environments.Clone the Repository
shell
git clone <repository_url>
cd <repository_directory>
Install Dependencies
Option 1: Install using the existing package.json
shell
npm install
Option 2: Install dependencies manually
shell
npm install @modelcontextprotocol/sdk @coinpaprika/api-nodejs-client zod
Then, update the newly generated package.json
file to include the following line, which enables ES Modules:
json
"type": "module"
This project includes a ./cursor
subdirectory that contains an mcp.json
file for configuring the MCP server. Cursor AI uses this file to automatically discover and launch your MCP server. Open the file and update the fields as follows:
./cursor/mcp.json
Structure{
"mcpServers": {
"MCP Server Boilerplate": {
"command": "/path/to/node",
"args": ["/path/to/mcp-server.js"],
"env": {
"API_KEY": "abc-1234567890"
}
}
}
}
Easily configure your local environment by automatically updating the mcp.json file with the correct absolute paths. To apply your local settings, run the following commands from your project root:
chmod +x ./scripts/update_config.sh
./scripts/update_config.sh
You can also move the mcp.json
file to your global Cursor AI configuration directory located at ~/.cursor
to make the configuration available globally.
With the MCP server integrated into Cursor AI and with Agent mode enabled in Cursor Composer, simply use a natural language prompt like:
add 3 and 5
or
what is my API key?
The AI agent will infer the available add
or getApiKey
tool from your MCP server and execute it accordingly.
The project comprises the following key parts:
McpServer
from the MCP SDK and connected via StdioServerTransport
.a
and b
) and returns their sum as text.API_KEY
and returns it as text.Model Context Protocol (MCP) provides a standardized approach to integrate custom tools into AI-assisted development environments. With MCP, you can define tools that perform specific tasks—such as retrieving external data, validating code, or enforcing coding standards—and the AI assistant in your IDE can call these tools automatically based on context. This helps improve developer productivity, ensures consistent quality, and streamlines workflows.
This project is licensed under the MIT License.
MCP Server built in Node.js that demonstrates how to build an MCP server with a custom tool, including one that loads an environment variable from a configuration file, to integrate seamlessly with AI-assisted environments like Cursor AI.