A comprehensive template for building Model Context Protocol (MCP) servers with TypeScript.
- ✅ TypeScript - Full type safety and modern JavaScript features
- ✅ Example Implementations - Tools, resources, and prompts examples
- ✅ Comprehensive Documentation - Detailed CLAUDE.md for Claude Code
- ✅ Testing Setup - Vitest configuration and example tests
- ✅ ESLint Configuration - Code quality and consistency
- ✅ Production Ready - Built-in error handling and logging
# 1. Use this template
Click "Use this template" button on GitHub
# 2. Clone your new repository
git clone https://github.com/yourusername/your-mcp-server.git
cd your-mcp-server
# 3. Install dependencies
npm install
# 4. Build the project
npm run build
# 5. Test with MCP Inspector
npx @modelcontextprotocol/inspector dist/index.jsThis template includes working examples of:
-
Tools - Functions Claude can call
example_tool- Processes and transforms text
-
Resources - Data Claude can access
example://resource- JSON data resource
-
Prompts - Reusable prompt templates
example_prompt- Topic-based prompt generation
mcp-server-template/
├── src/
│ ├── index.ts # Main server entry point
│ ├── tools/ # Tool implementations
│ │ └── example.ts
│ ├── resources/ # Resource implementations
│ │ └── example.ts
│ └── prompts/ # Prompt implementations
│ └── example.ts
├── dist/ # Compiled output (generated)
├── package.json
├── tsconfig.json
├── CLAUDE.md # Comprehensive Claude Code documentation
└── README.md # This file
npm run build
claude mcp add my-server node /absolute/path/to/dist/index.jsnpm publish
claude mcp add my-server npx -y your-package-namenpm install # Install dependencies
npm run build # Build TypeScript
npm run dev # Watch mode for development
npm test # Run tests
npm run lint # Lint code
npm run lint:fix # Fix linting issuesAfter installation, your MCP server will be available in Claude Code:
# Claude can now use your tools
User: "Use the example_tool to process 'hello world'"
# Claude can access your resources
User: "Read the example resource"
# Claude can use your prompts
User: "Use the example_prompt for 'MCP servers'"
Edit package.json:
{
"name": "your-mcp-server",
"version": "1.0.0",
"description": "Your server description",
"author": "Your Name"
}Create new tool files in src/tools/:
// src/tools/myTool.ts
export async function myTool(args: { input: string }) {
// Your implementation
return {
content: [
{
type: "text",
text: `Result: ${args.input}`,
},
],
};
}Register in src/index.ts:
import { myTool } from "./tools/myTool.js";
// Add to tools list and call handlerCreate resource files in src/resources/ following the same pattern.
Create prompt files in src/prompts/ following the same pattern.
All documentation for working with Claude Code is in CLAUDE.md:
- Core Concepts (Tools, Resources, Prompts)
- Development Guide with step-by-step instructions
- Testing strategies
- Deployment procedures
- Troubleshooting guide
- Best practices
This template is perfect for building:
- 🔧 API Integrations - Connect Claude to external APIs
- 📁 File System Tools - Custom file operations
- 🗄️ Database Access - Query and manage databases
- 🌐 Web Scrapers - Fetch and process web content
- 📊 Data Processors - Transform and analyze data
- 🤖 Automation Tools - Automate workflows
npm run build
npx @modelcontextprotocol/inspector dist/index.jsThe inspector provides an interactive UI for testing tools, resources, and prompts.
npm test # Run all tests
npm test -- --watch # Watch mode
npm test -- --coverage # Coverage report- TypeScript 5.3.3
- MCP SDK 1.0.4
- Vitest 1.1.0 (testing)
- ESLint 8.56.0 (linting)
MIT
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Version: 1.0.0 Last Updated: 2025 Template Purpose: Building Model Context Protocol (MCP) servers
⭐ Star this template if you find it useful!
📝 Check CLAUDE.md for comprehensive documentation when working with Claude Code