lucianoayres_mcp_server_node

lucianoayres_mcp_server_node

by lucianoayres
A Node.js MCP server that integrates custom tools into AI-assisted development environments like Cursor AI.

AI-Assisted Development Integration Server

Overview

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.

Requirements

  • Node.js: Version 20 or higher is required.

Features

  • MCP Integration: Exposes tool functionality to LLM-based IDEs.
  • Addition Tool: Accepts two numeric parameters and returns their sum.
  • Env Var Retrieval: Demonstrates how to load an example environment variable from the configuration file.
  • Input Validation: Uses Zod for schema validation.
  • Standard I/O Transport: Connects via StdioServerTransport for integration with development environments.

Installation

  1. Clone the Repository

    shell git clone <repository_url> cd <repository_directory>

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

Integrating with Cursor AI

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:

The ./cursor/mcp.json Structure

{
  "mcpServers": {
    "MCP Server Boilerplate": {
      "command": "/path/to/node",
      "args": ["/path/to/mcp-server.js"],
      "env": {
        "API_KEY": "abc-1234567890"
      }
    }
  }
}
  • mcpServers: An object mapping server names to their configuration.
  • MCP Server Boilerplate: This is the key for your server configuration. You can name it as you like.
  • command: Specifies the absolute path to your Node.js executable.
  • args: An array containing the absolute path to your MCP server file.
  • env: (Optional) Defines environment variables for your MCP server process.

Optional: Configuration Automation Scripts

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

Optional: Global Cursor settings

You can also move the mcp.json file to your global Cursor AI configuration directory located at ~/.cursor to make the configuration available globally.

Using the MCP Tool in Cursor Composer (Agent Mode)

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.

Code Overview

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:
  • add: Defined with a Zod schema that accepts two numbers (a and b) and returns their sum as text.
  • getApiKey: Retrieves the API key from the environment variable API_KEY and returns it as text.

What is MCP?

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.

References & Resources

License

This project is licensed under the MIT License.

About

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.

Topics

ai cursor mcp-server

Resources

Readme

License

MIT license

Activity

Stars

2 stars

Watchers

1 watching

Forks

0 forks

Report repository

Languages

Features & Capabilities

Categories
mcp_server model_context_protocol nodejs javascript cursor_ai api_integration zod schema_validation

Implementation Details

Stats

0 Views
2 GitHub Stars

Repository Info

lucianoayres Organization

Similar MCP Servers

continuedev_continue by continuedev
25049
21423
9300