Skip to main content
Glama
v4lheru

generic-mcp-server

by v4lheru

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

Related MCP server: Swagger MCP

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)

Install Server
F
license - not found
C
quality
C
maintenance

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

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

Related MCP Servers

View all related MCP servers

Related MCP Connectors

  • MCP server for AI access to Swagger by SmartBear.

  • Self-hosted MCP gateway: turn any API, database or MCP server into AI connectors — no code.

  • MCP (Model Context Protocol) server for Appwrite

View all MCP Connectors

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

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