Skip to main content
Glama

MCP サーバー - MCP サーバーを構築するための Node In Layers パッケージ

このライブラリは、Node In Layers を使用して MCP サーバーを簡単に作成する機能を追加します。

MCPクライアントの作成に使用される「@node-in-layers/mcp-client」というコンパニオンライブラリがあります。これら2つのライブラリは、モデルとツールを定義するための同じ機能を共有しています。

新しいレイヤー

このライブラリは、システムに新しいレイヤーmcpを追加します。express expressの後に配置する必要があります。

Related MCP server: MCP Bone

使用法

このライブラリを使用するには、設定に追加を行うだけでなく、アプリ/ドメインから「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サーバーに追加できます。注:この処理を実行するには、レイヤーにサービスレイヤーと機能レイヤーの両方が必要です(モデルに加えて)。Node in Layersはモデルに自動的にcrudsプロパティを作成するので、これを追加できます。

1 つずつ実行する例を次に示します。(一般的には推奨されませんが、実行可能です)。

// /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. Dates show when Glama detected each change.

No tool schema history has been recorded yet.

Maintenance

ActivityInactive
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    B
    quality
    F
    maintenance
    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.
    7
    9
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    A Node.js module that provides an MCP Server connecting to MCP Bone online service, allowing users to register other MCP Servers, obtain function calling tools in JSON or XML format, and parse completion text into tool calls.
    21
    MIT
  • A
    license
    Not graded
    quality
    F
    maintenance
    A configurable server implementation that provides MCP (Model-Controller-Protocol) functionality, supporting both Node.js and Docker environments with automated setup and configuration options.
    225
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    A lightweight framework for building and running Model Context Protocol (MCP) servers using FastMCP, providing tools for development, debugging, and server management.
    4
    MIT

Latest Blog Posts

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