Skip to main content
Glama

generic-mcp-server

Plantilla genérica de servidor MCP

Una plantilla de servidor de Protocolo de Contexto de Modelo (MCP) modular y extensible, diseñada para una fácil personalización y extensión.

Características

  • Arquitectura modular : clara separación de preocupaciones con una estructura bien definida
  • Archivos pequeños y enfocados : mejor capacidad de mantenimiento y más fácil de ingerir para la IA
  • Puntos de extensión fáciles : patrones simples para agregar nuevas herramientas y servicios
  • Manejo integral de errores : gestión robusta de errores en todo el código base
  • Seguridad de tipos : compatibilidad total con TypeScript con tipificación adecuada

Estructura del proyecto

generic-mcp-template/ ├── src/ │ ├── services/ # Service classes for API interactions │ │ ├── base-service.ts # Abstract base service with common functionality │ │ └── example-service.ts # Example service implementation │ ├── tools/ # MCP tool definitions and handlers │ │ ├── example-tools.ts # Tool definitions (name, description, schema) │ │ └── example-tool-handlers.ts # Tool handler implementations │ ├── types/ # TypeScript type definitions │ │ └── example-types.ts # Example type definitions │ ├── config.ts # Configuration management │ └── index.ts # Main entry point ├── .env.example # Example environment variables ├── package.json # Project dependencies and scripts ├── tsconfig.json # TypeScript configuration └── README.md # Project documentation

Empezando

Prerrequisitos

  • Node.js 18 o superior
  • npm o hilo

Instalación

  1. Clonar este repositorio:
    git clone https://github.com/v4lheru/generic-mcp-template.git cd generic-mcp-template
  2. Instalar dependencias:
    npm install
  3. Cree un archivo .env basado en .env.example :
    cp .env.example .env
  4. Edite el archivo .env con sus claves API y configuración.

Construyendo y funcionando

  1. Construir el proyecto:
    npm run build
  2. Ejecutar el servidor:
    npm start

Ampliación de la plantilla

Agregar un nuevo servicio

  1. Cree un nuevo archivo de servicio en src/services/ :
    // src/services/my-service.ts import { BaseService } from './base-service.js'; import config from '../config.js'; export class MyService extends BaseService { // Implement your service... }
  2. Agregue cualquier tipo necesario en src/types/ .

Agregar nuevas herramientas

  1. Define tus herramientas en un nuevo archivo o amplía el existente en src/tools/ :
    // src/tools/my-tools.ts export const myTools = [ { name: "my_tool", description: "Description of my tool", inputSchema: { // JSON Schema for the tool's input } } ];
  2. Implemente controladores para sus herramientas:
    // src/tools/my-tool-handlers.ts import { MyService } from '../services/my-service.js'; export function createMyToolHandlers(myService: MyService) { return { my_tool: async (args: any) => { // Implement your tool handler } }; }
  3. Registre sus herramientas y controladores en src/index.ts .

Configuración

La plantilla utiliza un sistema de configuración centralizado en src/config.ts . La configuración se puede realizar mediante:

  • Variables de entorno
  • Argumentos de la línea de comandos (con --env KEY=VALUE )
  • Valores predeterminados en el código

Manejo de errores

La plantilla incluye un manejo integral de errores:

  • Manejo de errores a nivel de servicio con soporte de limitación de velocidad
  • Manejo de errores a nivel de herramienta con mensajes de error adecuados
  • Manejo de errores del protocolo MCP

Licencia

Instituto Tecnológico de Massachusetts (MIT)

-
security - not tested
A
license - permissive license
-
quality - not tested

Un framework para usar con IA y crear fácilmente un servidor para cualquier servicio. Simplemente inserta la documentación de la API y solicita la creación del MCP.

  1. Características
    1. Estructura del proyecto
      1. Empezando
        1. Prerrequisitos
        2. Instalación
        3. Construyendo y funcionando
      2. Ampliación de la plantilla
        1. Agregar un nuevo servicio
        2. Agregar nuevas herramientas
      3. Configuración
        1. Manejo de errores
          1. Licencia

            Related MCP Servers

            • A
              security
              F
              license
              A
              quality
              An MCP server implementation that enables interaction with the Unstructured API, providing tools to list, create, update, and manage sources, destinations, and workflows.
              Last updated -
              39
              28
              • Apple
            • -
              security
              A
              license
              -
              quality
              An MCP server that connects to a Swagger specification and helps an AI to build all the required models to generate a MCP server for that service.
              Last updated -
              19
              TypeScript
              MIT License
              • Linux
              • Apple
            • -
              security
              -
              license
              -
              quality
              This MCP server provides tools to interact with the Salesforce Agentforce API, allowing authentication, session creation, and message exchange with Salesforce agents.
              Last updated -
              1
              Python
            • A
              security
              F
              license
              A
              quality
              An MCP server that allows AI assistants to interact with the ServiceTitan API, requiring client credentials for authentication.
              Last updated -
              454
              TypeScript

            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/v4lheru/generic-mcp-template'

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