✨ From vibe coding to vibe deployment. UBOS MCP turns ideas into infra with one message.

Learn more

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

Generic MCP Server Template

347 GitHub stars

Project Details

Recomended MCP Servers

🧩
MCP-ShellJS
🧩
World Bank Data Server

An implementation of the Model Context Protocol for the World Bank open data API

Super Windows CLI Server
Super Windows CLI Server

Model Context Protocol server for secure command-line interactions on Windows systems

🧩
ManusMCP

ManusMCP is a project that implements AI agent workflows using Flowise. It features specialized AI agents with distinct...

🧩
Delve MCP

MCP server for Delve debugger integration

🧩
Containerd CRI Interface Server

Use mcp to manage containerd(developing)

🧩
Unified MCP Server

Collection of Model Context Protocol (MCP) servers for Cursor IDE integration

🧩
SeaTunnel MCP Server

A Model Context Protocol (MCP) server for Apache Seatunnel. This provides access to your Apache Seatunnel RESTful API...

🧩
Media Processing Server

A Node.js server implementing Model Context Protocol (MCP) for media processing operations, providing powerful video and image manipulation...

Local MCP Server
Local MCP Server

大家好!我是功能丰富的 MCP 服务,旨在打破设备与服务的隔阂,为用户带来便捷体验。 天气工具和气象平台联动,快速为用户推送全球实时天气,助力大家规划出行。控制浏览器工具模拟人工操作,自动搜索、浏览网页,大幅节省时间。摄像头工具调用本地摄像头拍照、录像,实现人脸识别,保障家庭安防。 为实现工具协同,我搭建了稳定框架,开发者可以基于现有服务进行拓展

🧩
Logseq Tools

mcp server for logseq graph

🧩
Salesforce

MCP Salesforce connector

Featured Templates

View More
AI Assistants
Talk with Claude 3
159 1523
Customer service
AI-Powered Product List Manager
153 868
AI Characters
Your Speaking Avatar
169 928

Start your free trial

Build your solution today. No credit card required.

Sign In

Register

Reset Password

Please enter your username or email address, you will receive a link to create a new password via email.