Skip to main content
Glama

MCP Server

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

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

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

新しいレイヤー

このライブラリは、システムに新しいレイヤーmcpを追加します。express 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サーバーに追加できます。注:この処理を実行するには、レイヤーにサービスレイヤーと機能レイヤーの両方が必要です(モデルに加えて)。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 {} }
-
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.

モデルの定義、CRUD 操作の追加、クライアントとの対話のためのツールを使用して MCP (Model-Control-Protocol) サーバーの作成を簡素化する Node In Layers パッケージ。

  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 7 months ago
      3
      9
      36
      JavaScript
      Apache 2.0
    • 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 3 months ago
      7
      2
      JavaScript
      MIT License
    • A
      security
      A
      license
      A
      quality
      A Model Context Protocol server providing utility tools for development and testing, offering functionalities like personalized greetings, random card drawing, and datetime formatting with an extensible architecture.
      Last updated 14 days ago
      19
      208
      2
      TypeScript
      MIT License
      • Apple
      • Linux
    • A
      security
      F
      license
      A
      quality
      An all-in-one Model Context Protocol (MCP) server that connects your coding AI to numerous databases, data warehouses, data pipelines, and cloud services, streamlining development workflow through seamless integrations.
      Last updated a month ago
      2
      Python
      • Apple
      • Linux

    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