Skip to main content
Glama

MCP Server

MCP-Server – Ein Node-In-Layers-Paket zum Erstellen von MCP-Servern

Diese Bibliothek bietet die Möglichkeit, mit Node In Layers einfach MCP-Server zu erstellen.

Es gibt eine Begleitbibliothek namens „@node-in-layers/mcp-client“, die zum Erstellen von MCP-Clients verwendet wird. Diese beiden Bibliotheken nutzen dieselben Funktionen zum Definieren von Modellen und Tools.

Neue Ebene

Diese Bibliothek fügt dem System eine neue mcp Ebene hinzu. Sie sollte nach der express -Ebene platziert werden.

Verwendung

Um diese Bibliothek zu verwenden, müssen Sie Ergänzungen an Ihrer Konfiguration vornehmen sowie „mcp“-Ebenen aus Ihren Apps/Domänen erstellen und exportieren.

Konfiguration

Sie fügen diese App/Domäne zu Ihrer Konfigurationsdatei hinzu. Sie sollten dies vor Ihren Apps tun, die Tools zum MCP-Server hinzufügen.

Anschließend konfigurieren Sie die mcp -App/Domäne wie folgt:

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, }

Erstellen einer MCP-Ebene

Sie können eine MCP-Ebene erstellen, indem Sie aus Ihrer App/Domäne eine Funktion exportieren, die eine Ebene zurückgibt.

// /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 }

Modelle hinzufügen

Sie können Ihre Modelle mit CRUDS-Funktionen umschließen und sie mit der MCP-Ebene zum MCP-Server hinzufügen. HINWEIS: Damit dies funktioniert, muss Ihre Ebene sowohl eine Service- als auch eine Feature-Ebene enthalten. (Zusätzlich zu Ihren Modellen.) Knoten in Ebenen erstellen automatisch eine CRUDS-Eigenschaft für Ihre Modelle, die Sie hinzufügen können.

Hier ist ein Beispiel, wie man es einzeln durchführt. (Im Allgemeinen nicht empfohlen, aber machbar).

// /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 {} }

Hier ist eine Möglichkeit, wie Sie wirklich mit Gas kochen können. (Sehr empfehlenswert)

// /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 {} }

Eine weitere Möglichkeit, das Hinzufügen von Modellen zu organisieren, ist die Verwendung einer zentralen MCP-Domäne. Setzen Sie diese als letzte Domäne, nachdem alle anderen Domänen geladen wurden.

// /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.

Ein Node-In-Layers-Paket, das die Erstellung von MCP-Servern (Model-Control-Protocol) mit Tools zum Definieren von Modellen, Hinzufügen von CRUD-Operationen und Interagieren mit Clients vereinfacht.

  1. Neue Ebene
    1. Verwendung
      1. Konfiguration
      2. Erstellen einer MCP-Ebene
      3. Modelle hinzufügen

    Related MCP Servers

    • -
      security
      A
      license
      -
      quality
      Node.js server implementing Model Context Protocol (MCP) for filesystem operations.
      Last updated -
      103,292
      57,615
      TypeScript
      MIT License
      • Linux
      • Apple
    • 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
    • A
      security
      A
      license
      A
      quality
      An MCP server enabling secure interaction with n8n workflows, executions, and settings via the Model Context Protocol, designed for integration with Large Language Models (LLMs).
      Last updated -
      33
      65
      34
      TypeScript
      MIT License
      • Apple
    • 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 -
      7
      2
      JavaScript
      MIT License

    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