npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@iflow-mcp/generic-mcp-template

v0.1.0

Published

Generic MCP Server Template - A modular foundation for building MCP servers

Downloads

9

Readme

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