MCP Server
MCP Server — пакет Node In Layers для построения MCP-серверов
Эта библиотека добавляет возможность легкого создания серверов MCP с помощью Node In Layers.
У него есть сопутствующая библиотека под названием '@node-in-layers/mcp-client', которая используется для создания клиентов MCP. Эти две библиотеки используют одни и те же функции для определения моделей и инструментов.
Новый слой
Эта библиотека добавляет в систему новый слой mcp . Он должен располагаться после слоя express .
Related MCP server: MCP Server
Использование
Чтобы использовать эту библиотеку, вам необходимо внести дополнения в свою конфигурацию, а также создать и экспортировать слои «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 {}
}Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Remote MCP server exposing your Node Command fleet (files, shell, processes, browser) to AI hosts.
Hosted MCP server for AI-driven data ops. Create apps, manage schemas, and CRUD structured data.
Nifty's MCP server — exposes tasks, projects, messages, and files as tools for AI agents.
Create, inspect, validate, and save editable 3D building scenes with Pascal's MCP server.
Related MCP Servers
- AlicenseBqualityDmaintenanceA 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.79MIT
- FlicenseNot gradedqualityFmaintenanceA configurable server implementation that provides MCP (Model-Controller-Protocol) functionality, supporting both Node.js and Docker environments with automated setup and configuration options.-
- AlicenseAqualityDmaintenanceA lightweight framework for building and running Model Context Protocol (MCP) servers using FastMCP, providing tools for development, debugging, and server management.4MIT
- FlicenseNot gradedqualityDmaintenanceA production-ready MCP server built with Node.js and Express that supports remote deployment via HTTP and SSE. It provides a modular framework for building and scaling tools while serving multiple clients concurrently.-