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 服务器 - 用于构建 MCP 服务器的 Node In Layers 包

该库增加了使用 Node In Layers 轻松创建 MCP 服务器的功能。

它有一个名为“@node-in-layers/mcp-client”的配套库,用于创建 MCP 客户端。这两个库在定义模型和工具方面共享相同的功能。

新建图层

此库为系统添加了一个新层mcp 。它应放置在express层之后。

用法

为了使用这个库,您必须对您的配置进行添加,以及从您的应用程序/域中创建和导出“mcp”层。

配置

将此应用/域名添加到您的配置文件中。您应该在将工具添加到 MCP 服务器的应用程序之前执行此操作。

然后使用以下内容配置mcp app/domain:

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(模型控制协议)服务器的创建,并提供了用于定义模型、添加 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