/ Каталог / Песочница / MCP-Nest
● Сообщество rekog-labs ⚡ Сразу

MCP-Nest

автор rekog-labs · rekog-labs/MCP-Nest

NestJS module that turns your existing services into an MCP server — DI, guards, and validation you already use, now exposed to AI.

MCP-Nest is a NestJS module (not a standalone MCP) that adds MCP capabilities to any Nest application. Exposes tools, resources, and prompts via decorators; supports stdio/HTTP+SSE/Streamable HTTP transports; integrates with NestJS guards for auth. Ideal when your backend is already Nest and you want agents to call it.

Зачем использовать

Ключевые функции

Живое демо

Как выглядит на практике

nest.replay ▶ готово
0/0

Установка

Выберите клиент

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "nest": {
      "command": "npx",
      "args": [
        "-y",
        "MCP-Nest"
      ],
      "_inferred": true
    }
  }
}

Откройте Claude Desktop → Settings → Developer → Edit Config. Перезапустите после сохранения.

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "nest": {
      "command": "npx",
      "args": [
        "-y",
        "MCP-Nest"
      ],
      "_inferred": true
    }
  }
}

Cursor использует ту же схему mcpServers, что и Claude Desktop. Конфиг проекта приоритетнее глобального.

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "nest": {
      "command": "npx",
      "args": [
        "-y",
        "MCP-Nest"
      ],
      "_inferred": true
    }
  }
}

Щёлкните значок MCP Servers на боковой панели Cline, затем "Edit Configuration".

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "nest": {
      "command": "npx",
      "args": [
        "-y",
        "MCP-Nest"
      ],
      "_inferred": true
    }
  }
}

Тот же формат, что и Claude Desktop. Перезапустите Windsurf для применения.

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "nest",
      "command": "npx",
      "args": [
        "-y",
        "MCP-Nest"
      ]
    }
  ]
}

Continue использует массив объектов серверов, а не map.

~/.config/zed/settings.json
{
  "context_servers": {
    "nest": {
      "command": {
        "path": "npx",
        "args": [
          "-y",
          "MCP-Nest"
        ]
      }
    }
  }
}

Добавьте в context_servers. Zed перезагружается автоматически.

claude mcp add nest -- npx -y MCP-Nest

Однострочная команда. Проверить: claude mcp list. Удалить: claude mcp remove.

Сценарии использования

Реальные сценарии: MCP-Nest

Expose your existing NestJS backend as an MCP

👤 NestJS teams whose agents need to call internal APIs ⏱ ~45 min intermediate

Когда использовать: You don't want to rewrite service logic in Python or TS MCP SDK — reuse what's already tested.

Предварительные требования
  • NestJS 10+ app — Your existing project
  • Install @rekog/mcp-nest — npm i @rekog/mcp-nest
Поток
  1. Register the module
    Add McpModule.forRoot({name: 'acme', version: '1.0'}) to app.module.ts.✓ Скопировано
    → App starts; /mcp endpoint present
  2. Decorate a service method as a tool
    In TicketsService, decorate searchTickets with @Tool({name:'search_tickets', description:'...'}) and a Zod schema. Existing auth guards still apply.✓ Скопировано
    → Tool shows in Claude's tool list
  3. Hook up auth
    Apply the existing JwtAuthGuard on the MCP controller so agents need a valid bearer token.✓ Скопировано
    → Unauth'd calls return 401

Итог: Your agents consume your real backend — same validation, same auth, no service duplication.

Подводные камни
  • Mixing user-scoped and service-scoped tools creates auth confusion — Split into two MCP modules: one with user JWT, one with service token

Build an interactive tool that asks the user for input mid-call

👤 Nest developers building advanced agent flows ⏱ ~30 min advanced

Когда использовать: Your tool needs confirmation or a secret that the agent shouldn't have by default.

Поток
  1. Use the elicitation API inside a tool
    In the delete_account tool, before deleting, elicit a typed confirmation from the user (the real human, not the agent).✓ Скопировано
    → Agent prompts the user in chat; proceeds only on confirmation

Итог: Irreversible actions gated behind human input even through an agent.

Serve dynamic Nest data as MCP resources

👤 Teams that want agents to read fresh data, not stale snapshots ⏱ ~35 min advanced

Когда использовать: Agents need to see live status (build, deploy, ticket queue) as context, not via a tool call.

Поток
  1. Declare a resource template
    Create a @Resource('ticket://{id}') that returns the ticket JSON by id.✓ Скопировано
    → Agent can reference ticket://123 and get live content
  2. Subscribe to updates
    Emit updates when the ticket changes so subscribers see fresh state without polling✓ Скопировано
    → MCP push notifications to subscribed clients

Итог: Live context instead of snapshots — the agent sees what the user sees.

Комбинации

Сочетайте с другими MCP — эффект x10

nest + golf

Python shop + TS shop both build MCPs the same framework-first way

Port our Python Golf MCP features to the Nest team's MCP-Nest server — compare ergonomics.✓ Скопировано
nest + mcptools

Verify tool schemas during CI before deploy

In CI, spin up the Nest MCP and run mcp tools to assert expected tool list.✓ Скопировано

Инструменты

Что предоставляет этот MCP

ИнструментВходные данныеКогда вызыватьСтоимость
@Tool({...}) decorator method args validated via Zod schema Mark any Nest service method as an MCP tool standard Nest method cost
@Resource({...}) decorator URI template params Expose dynamic/static resources standard Nest cost
@Prompt({...}) decorator prompt vars Ship prompts as versioned code 0

Стоимость и лимиты

Во что обходится

Квота API
Depends on your services
Токенов на вызов
Depends on tool output
Деньги
Free, MIT
Совет
Add response size guards on tools that return lists — an unbounded list of tickets will blow token budgets fast

Безопасность

Права, секреты, радиус поражения

Хранение учётных данных: Standard Nest config; use @nestjs/config + secret managers
Исходящий трафик: Wherever your Nest services go

Устранение неполадок

Частые ошибки и исправления

Tool not appearing in Claude

Ensure the class is registered in a module provider and the decorator import is from @rekog/mcp-nest not a stale copy

Проверить: curl http://localhost:3000/mcp tools/list
Zod validation errors at runtime

Your schema doesn't match actual inputs the agent sends — tighten descriptions so the model fills the right fields

SSE connection drops every 30s

Upstream proxy timeout; set keepalive in nginx to 60s+ or use Streamable HTTP transport instead

Альтернативы

MCP-Nest в сравнении

АльтернативаКогда использоватьКомпромисс
TS MCP SDK (official)You don't use NestJS and want the raw SDKNo DI, no guards, you wire everything
GolfPython backendDifferent language; similar framework ambitions
FastMCPPython, simpler than GolfLess enterprise tooling

Ещё

Ресурсы

📖 Читать официальный README на GitHub

🐙 Открытые задачи

🔍 Все 400+ MCP-серверов и Skills