LM

lucianoayres/mcp-server-node

Developer tools

Эта страница переведена автоматически. Технические детали смотрите в оригинале. Открыть оригинал

76 stars 19 forks Качество 68 Тренд 14MIT

lucianoayres/mcp-серверный узел - кандидат на сервер MCP, импортированный из https://github.com/lucianoayres/mcp-server-node.

Обзор

lucianoayres/mcp-серверный узел - кандидат на сервер MCP, импортированный из https://github.com/lucianoayres/mcp-server-node.

Обзор (машинный перевод)

Создайте и запустите пользовательский MCP-сервер в Node.js всего за 2 минуты

Обзор · Особенности · Установка · Тестирование с помощью MCP Inspector · Настройка переменных среды для тестирования · Интеграция с Cursor AI · Использование инструмента MCP в Cursor (режим агента) · Обзор кода · Ссылки и ресурсы · Лицензия

Обзор

MCP (Model Context Protocol) - это фреймворк, который позволяет интегрировать пользовательские инструменты в среды разработки с поддержкой ИИ, такие как Cursor AI. Серверы MCP предоставляют функциональность (например, поиск данных или анализ кода), чтобы IDE на основе LLM могла вызывать эти инструменты по требованию. Узнайте больше о MCP во введении протокола контекста.

Этот проект демонстрирует MCP-сервер, реализованный в JavaScript с использованием Node.js. Он определяет два инструмента: add, который принимает два числовых входа и возвращает их сумму, и getApiKey, который извлекает ключ API из переменной среды API_KEY. Он также предоставляет предопределенную подсказку add numbers, которая позволяет моделям ИИ делать выводы об использовании инструмента добавления.

Требования

Node.js: Требуется версия 20 или выше.

Особенности

**Интеграция с MCP: ** Выставляет функциональность инструмента для IDE на основе LLM.

Эта страница переведена автоматически. Технические детали смотрите в оригинале.

README

Показан фрагмент оригинального README. Открыть оригинал.

🟢 MCP Server in Node.js

Build and run a custom MCP Server in Node.js in just 2 minutes ⏱️

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

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

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.
  • MCP Prompt: Provides a predefined prompt (“add_numbers”) that allow AI models to infer tool usage.
  • 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

    git clone 
    cd 
    
  2. 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"
    }
    

Testing with MCP Inspector

Открыть полный README на GitHub

Установка

npx @modelcontextprotocol/inspector node ./mcp-server.js
Новичок в MCP? Начните с руководства на mcpskill.org →

Конфигурация

{ "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" } } } }