A framework to use with AI to easily create a server for any service. Just drop the API Documentation in it and ask to create the MCP.
A modular, extensible Model Context Protocol (MCP) server template designed for easy customization and extension.
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
Clone this repository:
git clone https://github.com/v4lheru/generic-mcp-template.git cd generic-mcp-template
Install dependencies:
npm install
Create a .env
file based on .env.example
:
cp .env.example .env
Edit the .env
file with your API keys and configuration.
Build the project:
npm run build
Run the server:
npm start
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... }
Add any necessary types in src/types/
.
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 } } ];
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 } }; }
Register your tools and handlers in src/index.ts
.
The template uses a centralized configuration system in src/config.ts
. Configuration can be provided through:
--env KEY=VALUE
)The template includes comprehensive error handling:
MIT
Discover shared experiences
Shared threads will appear here, showcasing real-world applications and insights from the community. Check back soon for updates!