Skip to main content
Glama

MCP Server

MCP Server — пакет Node In Layers для построения MCP-серверов

Эта библиотека добавляет возможность легкого создания серверов MCP с помощью Node In Layers.

У него есть сопутствующая библиотека под названием '@node-in-layers/mcp-client', которая используется для создания клиентов MCP. Эти две библиотеки используют одни и те же функции для определения моделей и инструментов.

Новый слой

Эта библиотека добавляет в систему новый слой mcp . Он должен располагаться после слоя express .

Использование

Чтобы использовать эту библиотеку, вам необходимо внести дополнения в свою конфигурацию, а также создать и экспортировать слои «mcp» из ваших приложений/доменов.

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

вы добавляете это приложение/домен в свой файл конфигурации. Вы должны сделать это до ваших приложений, которые добавят инструменты на сервер MCP.

Затем вы настраиваете приложение/домен mcp следующим образом:

const mcpConfig = { // (optional) The name of your MCP server. name: 'mcp', // (optional) The version of your MCP server. version: '1.0.0', // The server config from @l4t/mcp-ai/simple-server/types.js server: { connection: { type: 'http', host: 'localhost', port: 3000, }, }, logging: { // optional // If you want to change the default. Its 'info' by default. requestLogLevel: 'info', // If you want to change the default. Its 'info' by default. responseLogLevel: 'info', }, } const config = { ['@node-in-layers/mcp-server']: mcpConfig, }

Создание слоя MCP

Вы можете создать слой MCP, экспортировав функцию из вашего приложения/домена, которая возвращает слой.

// /src/yourDomain/mcp.ts import { McpContext, McpNamespace } from '@node-in-layers/mcp-server' import { Config } from '@node-in-layers/core' import { YourFeaturesLayer } from './features.js' const create = (context: McpContext<Config, YourFeaturesLayer>) => { // Adds your tool. context.mcp[McpNamespace].addTool({ name: 'my-hello-world-tool', description: 'My Tool', execute: async (input: any) => { return 'Hello, world!' }, }) // Create a tool from your feature context.mcp[McpNamespace].addTool({ name: 'my-hello-world-tool', description: 'My Tool', inputSchema: { type: 'object', properties: { name: { type: 'string', }, }, required: ['name'], }, execute: (input: any) => { // You get an object, pass it back to your feature. Handles async for you. return context.features.yourDomain.yourFeature(input) }, }) return {} } export { create }

Добавление моделей

Вы можете обернуть свои модели функциями CRUDS и добавить их на сервер MCP с помощью слоя mcp. ПРИМЕЧАНИЕ. Чтобы это работало, ваш слой должен иметь как слой служб, так и слой функций. (В дополнение к вашим моделям.) Узел в слоях автоматически создаст для вас свойство cruds с вашими моделями, и вы сможете добавить их.

Вот пример того, как это сделать по одному за раз. (Обычно не рекомендуется, но выполнимо).

// /src/yourDomain/mcp.ts import { McpContext, McpNamespace } from '@node-in-layers/mcp-server' import { Config } from '@node-in-layers/core' import { YourFeaturesLayer } from './features.js' const create = (context: McpContext<Config, YourFeaturesLayer>) => { // Adds your models cruds through features. context.mcp[McpNamespace].addModelCruds( context.features.yourFeature.cruds.Cars ) return {} }

Вот способ, с помощью которого вы действительно сможете готовить на газе. (Настоятельно рекомендуется)

// /src/yourDomain/mcp.ts import { McpContext, McpNamespace, mcpModels } from '@node-in-layers/mcp-server' import { Config } from '@node-in-layers/core' import { YourFeaturesLayer } from './features.js' const create = (context: McpContext<Config, YourFeaturesLayer>) => { // This automatically adds ALL of your models from features. mcpModels('yourDomain')(context) return {} }

Другой способ организовать добавление моделей — из централизованного домена mcp. Поставьте его в качестве самого последнего домена после того, как все остальные домены будут загружены.

// /src/mcp/mcp.ts import { McpContext, McpNamespace, mcpModels } from '@node-in-layers/mcp-server' import { Config } from '@node-in-layers/core' const create = (context: McpContext<Config>) => { // Add all your models for your whole system in one go. mcpModels('yourDomain')(context) mcpModels('yourDomain2')(context) mcpModels('yourDomain3')(context) mcpModels('yourDomain4')(context) return {} }
-
security - not tested
F
license - not found
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Пакет Node In Layers, который упрощает создание серверов MCP (Model-Control-Protocol) с инструментами для определения моделей, добавления операций CRUD и взаимодействия с клиентами.

  1. Новый слой
    1. Использование
      1. Конфигурация
      2. Создание слоя MCP
      3. Добавление моделей

    Related MCP Servers

    • -
      security
      A
      license
      -
      quality
      Node.js server implementing Model Context Protocol (MCP) for filesystem operations.
      Last updated -
      41,921
      57,505
      TypeScript
      MIT License
      • Linux
      • Apple
    • A
      security
      A
      license
      A
      quality
      A beginner-friendly Model Context Protocol (MCP) server that helps users understand MCP concepts, provides interactive examples, and lists available MCP servers. This server is designed to be a helpful companion for developers working with MCP. Also comes with a huge list of servers you can install.
      Last updated -
      3
      9
      36
      JavaScript
      Apache 2.0
    • A
      security
      A
      license
      A
      quality
      An MCP server enabling secure interaction with n8n workflows, executions, and settings via the Model Context Protocol, designed for integration with Large Language Models (LLMs).
      Last updated -
      33
      65
      34
      TypeScript
      MIT License
      • Apple
    • A
      security
      A
      license
      A
      quality
      A comprehensive Model Context Protocol server that provides advanced Node.js development tooling for automating project creation, component generation, package management, and documentation with AI-powered assistance.
      Last updated -
      7
      2
      JavaScript
      MIT License

    View all related MCP servers

    MCP directory API

    We provide all the information about MCP servers via our MCP API.

    curl -X GET 'https://glama.ai/api/mcp/v1/servers/Node-In-Layers/mcp-server'

    If you have feedback or need assistance with the MCP directory API, please join our Discord server