Skip to main content
Glama

MCP Declarative Server

by johnhenry

Servidor declarativo MCP

Un módulo de utilidad para crear servidores de Protocolo de Contexto de Modelo (MCP) de forma declarativa.

Instalación

npm install mcp-client-router

Uso

import { DeclarativeMCPServer } from "mcp-client-router/declarative-server"; // Create a server declaratively const server = new DeclarativeMCPServer({ name: "my-server", version: "1.0.0", // Define tools as arrays of arguments tools: [ [ "greeting", { message: "string" }, async ({ message }) => ({ content: [{ type: "text", text: `Hello, ${message}!` }], }), ], [ "farewell", { name: "string" }, async ({ name }) => ({ content: [{ type: "text", text: `Goodbye, ${name}!` }], }), ], ], // Define prompts prompts: [ [ "welcome", { name: "string", formality: { type: "string", default: "CASUAL" } }, async ({ name, formality }) => { const text = formality === "FORMAL" ? `Dear ${name}, welcome to our service.` : `Hi ${name}! Welcome aboard!`; return { messages: [{ role: "assistant", content: { text } }], }; }, "A welcome prompt template", ], ], // Define resources resources: [ [ "docs/readme", async () => ({ contents: [ { uri: "docs/readme", text: "This is the documentation readme file.", }, ], }), ], ], }); // Connect to a transport await server.connect(transport);

Referencia de API

DeclarativeMCPServer

new DeclarativeMCPServer(options);
Opciones
  • name (cadena): el nombre del servidor
  • version (cadena): La versión del servidor
  • tools (matriz): una matriz de definiciones de herramientas
  • prompts (matriz): una matriz de definiciones de indicaciones
  • resources (matriz): una matriz de definiciones de recursos
Formato de definición de herramienta
[ name, // string: name of the tool paramSchema, // object: parameter schema handler, // function: async function to handle the tool call description, // string (optional): description of the tool ];
Formato de definición de indicaciones
[ name, // string: name of the prompt paramSchema, // object: parameter schema handler, // function: async function to handle the prompt description, // string (optional): description of the prompt ];
Formato de definición de recursos
[ uri, // string: URI of the resource handler, // function: async function to handle the resource request ];

Licencia

ISC

-
security - not tested
F
license - not found
-
quality - not tested

Un módulo de utilidad para crear servidores de Protocolo de Contexto de Modelo de forma declarativa, permitiendo a los desarrolladores definir fácilmente herramientas, indicaciones y recursos con una sintaxis simplificada.

  1. Instalación
    1. Uso
      1. Referencia de API
        1. DeclarativeMCPServer
      2. Licencia

        Related MCP Servers

        • -
          security
          F
          license
          -
          quality
          A Model Context Protocol server built with mcp-framework that allows users to create and manage custom tools for processing data, integrating with the Claude Desktop via CLI.
          Last updated -
          48
          4
          TypeScript
          • Apple
        • A
          security
          A
          license
          A
          quality
          A Model Context Protocol server that provides tools for code modification and generation via Large Language Models, allowing users to create, modify, rewrite, and delete files using structured XML instructions.
          Last updated -
          12
          Python
          MIT License
          • Linux
          • Apple
        • 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 -
          19
          215
          2
          TypeScript
          MIT License
          • Apple
          • Linux
        • -
          security
          F
          license
          -
          quality
          A sample implementation of Model Context Protocol server demonstrating core functionality with simple arithmetic tools and greeting resources.
          Last updated -
          Python

        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/johnhenry/mcp-declarative-server'

        If you have feedback or need assistance with the MCP directory API, please join our Discord server