Build customizable MCP server templates for AI external data integration with TypeScript and scalable architecture
Boilerplate MCP Server serves as a foundational framework for developers looking to integrate Model Context Protocol (MCP) into their AI applications, facilitating secure and seamless connections between AI assistants and external data sources or APIs. Built on a clean, layered architecture pattern, this server not only adheres to the MCP standard but also offers a comprehensive set of tools and infrastructure designed for extensibility.
The Boilerplate MCP Server excels in providing robust and production-ready architecture that adheres closely to the same design used in published MCP servers. Key features include:
The Boilerplate MCP Server is built around a clean, layered architecture that ensures maintainability and ease of extension. Key layers include:
src/cli/*.cli.ts
, responsible for command-line interfaces that parse arguments and call controllers.src/tools/*.tool.ts
, defines MCP tools with schemas and descriptions, leveraging zod for argument validation.src/controllers/*.controller.ts
, implements business logic, handles errors, and formats responses using standardized ControllerResponse
objects.src/services/*.service.ts
, interacts with external APIs or data sources while maintaining minimalistic API interactions.logger.util.ts
, error.util.ts
, and formatter.util.ts
.To start using the Boilerplate MCP Server, follow these steps:
# Clone the repository
git clone https://github.com/aashari/boilerplate-mcp-server.git
cd boilerplate-mcp-server
# Install dependencies
npm install
Start the server in development mode:
npm run dev:server
This starts the MCP server with hot-reloading and enables the MCP Inspector at http://localhost:5173.
Run the example IP lookup tool from the CLI:
# Using CLI in development mode
npm run dev:cli -- get-ip-details
# Or with a specific IP
npm run dev:cli -- get-ip-details 8.8.8.8
In this scenario, the Boilerplate MCP Server is used to fetch real-time weather data from an external API and provide it as a tool within Claude Desktop. The server handles authentication, query parsing, API interaction, and response formatting.
Technical Implementation:
// src/services/weather.service.ts
import { Logger } from '../utils/logger.util.js';
const logger = Logger.forContext('services/weather.service.ts');
export async function retrieveWeatherData(zipCode: string): Promise<any> {
logger.debug(`Retrieving weather data for ${zipCode}`);
// API interaction code here
return { data: 'example weather data' };
}
// src/controllers/weather.controller.ts
import { Logger } from '../utils/logger.util.js';
import * as weatherService from '../services/weather.service.js';
import { z } from 'zod';
import { ControllerResponse } from '../types/common.types.js';
const logger = Logger.forContext('controllers/weather.controller.ts');
export type WeatherDataOptions = {
zipCode: string;
};
async function getWeatherData(options: WeatherDataOptions): Promise<ControllerResponse> {
try {
logger.debug(`Getting weather data for ${options.zipCode}`);
const weatherData = await weatherService.retrieveWeatherData(options.zipCode);
return { content: [weatherData] };
} catch (error) {
logger.error(error);
return {
success: false,
message: 'Failed to fetch weather data',
};
}
}
// src/tools/weather.tool.ts
import { z } from 'zod';
export const getWeatherDataTool = z.object({
zipCode: z.string(),
});
This use case involves integrating custom tasks such as email notifications and task reminders within an AI system like Continue. The server handles the automation workflow, interacting with external tools and systems.
Technical Implementation:
// src/services/task.service.ts
import { Logger } from '../utils/logger.util.js';
const logger = Logger.forContext('services/task.service.ts');
export async function sendEmailNotification(to: string, subject: string, body: string): Promise<any> {
logger.debug(`Sending email to ${to}`);
// API interaction code here
}
// src/controllers/task.controller.ts
import { Logger } from '../utils/logger.util.js';
import * as taskService from '../services/weather.service.js';
import { z } from 'zod';
import { ControllerResponse } from '../types/common.types.js';
const logger = Logger.forContext('controllers/task.controller.ts');
export type NotificationOptions = {
to: string;
subject: string;
body: string;
};
async function triggerNotification(options: NotificationOptions): Promise<ControllerResponse> {
try {
logger.debug(`Triggering notification to ${options.to}`);
await taskService.sendEmailNotification(options.to, options.subject, options.body);
return { success: true };
} catch (error) {
logger.error(error);
return { success: false, message: 'Failed to send email' };
}
}
// src/tools/notification.tool.ts
import { z } from 'zod';
export const sendNotificationTool = z.object({
to: z.string(),
subject: z.string(),
body: z.string(),
});
The Boilerplate MCP Server is compatible with several popular MCP clients, including:
MCP Client | Resources | Tools | Prompts | Status |
---|---|---|---|---|
Claude Desktop | ✅ | ✅ | ✅ | Full Support |
Continue | ✅ | ✅ | ❌ | Limited Tool Integration |
Cursor | ❌ | ✅ | ❌ | No Prompt or Resource Support |
The Boilerplate MCP Server is designed for efficiency and reliability, ensuring seamless performance across a wide range of AI applications.
To configure the Boilerplate MCP Server, use the following steps:
DEBUG=true npm run dev:server
~/.mcp/configs.json
:{
"mcpServers": {
"[server-name]": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-[name]"],
"env": {
"API_KEY": "your-api-key"
}
}
}
}
The Boilerplate MCP Server leverages environment variables and secure authentication mechanisms to protect sensitive information, ensuring that only authorized clients can interact with the server.
Yes, by configuring multiple instances of the server in ~/.mcp/configs.json
, you can manage connections for different AI applications seamlessly.
While the Boilerplate MCP Server is generally compatible with most clients, some have limited support due to the nature of their APIs and functionalities.
You can test your custom tools using the MCP Inspector available at http://localhost:5173. This allows you to view logs and debug interactions directly in the user interface.
Yes, you can deploy the Boilerplate MCP Server on Kubernetes by creating a Docker image and configuring the necessary Kubernetes resources like Deployment and Service configurations.
Contributions are welcome from developers aiming to expand MCP server capabilities. To contribute:
npm install
to set up dependencies.For more information on Model Context Protocol and its ecosystem, refer to the official documentation:
By using this server, developers can significantly enhance the capabilities of their AI applications through standardized MCP integration.
RuinedFooocus is a local AI image generator and chatbot image server for seamless creative control
Simplify MySQL queries with Java-based MysqlMcpServer for easy standard input-output communication
Learn to set up MCP Airflow Database server for efficient database interactions and querying airflow data
Build stunning one-page websites track engagement create QR codes monetize content easily with Acalytica
Explore CoRT MCP server for advanced self-arguing AI with multi-LLM inference and enhanced evaluation methods
Access NASA APIs for space data, images, asteroids, weather, and exoplanets via MCP integration