Skip to main content
Glama

generic-mcp-server

Generic MCP Server Template

A modular, extensible Model Context Protocol (MCP) server template designed for easy customization and extension.

Features

  • Modular Architecture: Clear separation of concerns with a well-defined structure
  • Small, Focused Files: Better maintainability and easier for AI to ingest
  • Easy Extension Points: Simple patterns for adding new tools and services
  • Comprehensive Error Handling: Robust error management throughout the codebase
  • Type Safety: Full TypeScript support with proper typing

Project Structure

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

Getting Started

Prerequisites

  • Node.js 18 or higher
  • npm or yarn

Installation

  1. Clone this repository:
    git clone https://github.com/v4lheru/generic-mcp-template.git cd generic-mcp-template
  2. Install dependencies:
    npm install
  3. Create a .env file based on .env.example:
    cp .env.example .env
  4. Edit the .env file with your API keys and configuration.

Building and Running

  1. Build the project:
    npm run build
  2. Run the server:
    npm start

Extending the Template

Adding a New Service

  1. Create a new service file in 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. Add any necessary types in src/types/.

Adding New Tools

  1. Define your tools in a new file or extend the existing one in 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. Implement handlers for your tools:
    // 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. Register your tools and handlers in src/index.ts.

Configuration

The template uses a centralized configuration system in src/config.ts. Configuration can be provided through:

  • Environment variables
  • Command line arguments (with --env KEY=VALUE)
  • Default values in the code

Error Handling

The template includes comprehensive error handling:

  • Service-level error handling with rate limiting support
  • Tool-level error handling with proper error messages
  • MCP protocol error handling

License

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
              A
              license
              A
              quality
              An MCP server that generates AI agent tools from Postman collections and requests. This server integrates with the Postman API to convert API endpoints into type-safe code that can be used with various AI frameworks.
              Last updated -
              13
              MIT License
            • -
              security
              A
              license
              -
              quality
              Generate an MCP server for any OpenAPI documented endpoint.
              Last updated -
              295
              MIT License
              • Apple
              • Linux
            • A
              security
              A
              license
              A
              quality
              A tool that creates MCP (Model Context Protocol) servers from OpenAPI/Swagger specifications, enabling AI assistants to interact with your APIs.
              Last updated -
              3
              9
              22
              MIT License
              • Apple
            • -
              security
              F
              license
              -
              quality
              An auto-generated MCP server that enables interaction with the OpenAI API, allowing users to access OpenAI's models and capabilities through the Multi-Agent Conversation Protocol.
              Last updated -

            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