MCP Server Boilerplate
by Falkicon
A well-structured boilerplate for building Model Context Protocol (MCP) servers using TypeScript. It aims to accelerate development and promote consistency for MCP integrations.
Last updated: N/A
What is MCP Server Boilerplate?
This is a boilerplate project for creating Model Context Protocol (MCP) servers using TypeScript. It provides a foundation with best practices for building MCP integrations.
How to use MCP Server Boilerplate?
Clone the repository, install dependencies using npm install
, configure the environment (optional), and then run the server in development mode using npm run dev
or build for production with npm run build
and then npm start
. You can also run it with Docker. Extend the boilerplate by adding tools, resources, and prompts as described in the documentation.
Key features of MCP Server Boilerplate
TypeScript
MCP SDK
Focused Implementation with stdio transport
Example Primitives (Tools, Resources, Prompts)
Configuration via .env files and environment variables
Argument Validation with Zod
Structured Logging with Pino
Error Handling with custom error classes
Containerization with Docker
Linting/Formatting with ESLint and Prettier
Testing with Vitest
Use cases of MCP Server Boilerplate
Building custom integrations for AI assistants
Creating tools that can be invoked by AI models
Providing resources to AI models
Developing prompts for AI models
FAQ from MCP Server Boilerplate
What is the MCP SDK?
What is the MCP SDK?
The MCP SDK is the official @modelcontextprotocol/sdk
used for interacting with the Model Context Protocol.
How do I configure the server?
How do I configure the server?
Configuration is managed via environment variables, which can be loaded from a .env
file for local development.
How do I add a new tool?
How do I add a new tool?
Define a Zod schema for the arguments, use server.tool(name, schemaDefinition, handler)
, and implement the handler logic.
Why are my logs not showing up?
Why are my logs not showing up?
When running in stdio mode, all logging must go to stderr, never stdout. Stdout is strictly reserved for JSON-RPC messages. Use a custom logger that writes to stderr.
Why is my tool name prefixed?
Why is my tool name prefixed?
Cursor automatically prefixes tool names for AI assistant calls. Register tools with simple names (e.g., 'add'), and the AI will see them with prefixed names (e.g., 'mcp_mcp_minimal_add').