MCP Server

Integrations
  • Integrates with Express web framework, allowing the MCP server to be placed after the Express layer in the application stack and leverage Express for HTTP connections.

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

    • 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
    • -
      security
      A
      license
      -
      quality
      MCP Server simplifies the implementation of the Model Context Protocol by providing a user-friendly API to create custom tools and manage server workflows efficiently.
      Last updated -
      4
      3
      TypeScript
      MIT License
    • -
      security
      -
      license
      -
      quality
      A specialized server that helps users create new Model Context Protocol (MCP) servers by providing tools and templates for scaffolding projects with various capabilities.
      Last updated -
      1
      TypeScript
    • -
      security
      F
      license
      -
      quality
      A starter template for building Model Context Protocol (MCP) servers, enabling developers to create and add custom tools that can be integrated with Claude Desktop.
      Last updated -
      TypeScript
      • Apple

    View all related MCP servers

    ID: k0fzi30a7o