MCP Server Starter (TypeScript)
A minimal, production-ready TypeScript starter template for building Model Context Protocol (MCP) servers.
🎯 Motivation
The Model Context Protocol (MCP) is an open protocol that standardizes how AI applications connect to data sources and tools. Think of it as "USB-C for AI" - a universal standard that allows any AI model to connect with any data source or tool through a consistent interface.
This starter template provides:
✅ Minimal boilerplate to get you started quickly
✅ Auto-loading architecture for tools, resources, and prompts
✅ TypeScript best practices with strict typing
✅ Production-ready structure that scales with your project
✅ Working example (echo tool) to demonstrate the pattern
Whether you're building integrations for databases, APIs, file systems, or custom business tools, this template helps you create MCP servers that can be used by any MCP-compatible client (like Claude Desktop, IDEs, or custom applications).
📋 Table of Contents
✨ Features
�� Auto-loading Module System - Drop new tools, resources, or prompts into their directories and they're automatically registered
🛠️ TypeScript First - Full type safety with strict TypeScript configuration
📦 Minimal Dependencies - Only essential packages included
🧪 Built-in Testing - Uses Node.js native test runner
🔍 MCP Inspector Support - Test your server with the official MCP Inspector
📝 Extensible Architecture - Clear patterns for adding new capabilities
🎯 Example Implementation - Working echo tool demonstrates the pattern
⚡ Code Generators - Hygen scaffolding for rapid module creation
🌐 Dual Transport Support - Both stdio and HTTP (SSE + JSON-RPC) transports
🐳 Docker Ready - Containerized deployment with multi-stage builds
📚 Prerequisites
Ensure you have Node.js version 20.11.0 or higher installed before proceeding.
Node.js >= 20.11.0
npm or yarn
Basic understanding of TypeScript
Familiarity with the Model Context Protocol concepts
📦 Installation
Clone and Setup
Using as a Template
You can also use this as a GitHub template:
Click "Use this template" on GitHub
Create your new repository
Clone and start building your MCP server
🚀 Quick Start
Use the MCP Inspector to test your server interactively during development!
Build the server:
npm run buildTest with MCP Inspector:
npm run inspectThis opens the MCP Inspector where you can interact with your server's tools, resources, and prompts.
Run tests:
npm test
🚀 Transport Modes
This server supports two transport modes: stdio (default) and HTTP (Streamable SSE + JSON-RPC).
Stdio Mode (Default)
Traditional stdio transport for local development and desktop clients:
HTTP Mode (SSE + JSON-RPC)
Streamable HTTP transport for web deployments and remote access:
The HTTP transport exposes:
SSE endpoint (GET):
http://localhost:3000/mcp
- For server-sent eventsJSON-RPC endpoint (POST):
http://localhost:3000/mcp
- For requests
Environment Variables
Configure the server behavior using environment variables:
Variable | Description | Default |
| Transport mode:
or
|
|
| HTTP server port (HTTP mode only) |
|
| CORS allowed origins (HTTP mode only) |
|
Configuration Examples
VS Code (mcp.json
or .vscode/mcp.json
)
Claude Desktop
Add to your Claude Desktop configuration:
🐳 Docker Support
The server includes Docker support for easy deployment:
Quick Start with Docker
Docker Configuration
The Docker container runs in HTTP mode by default. Override settings with environment variables:
Development with Docker
Use the development profile for hot reload:
This mounts your source code and enables live reloading on port 3001.
📁 Project Structure
How Auto-Loading Works
Simply drop your module files into the appropriate directory (tools/
, resources/
, or prompts/
) and they'll be automatically loaded when the server starts!
🛠️ Development Guide
Using Code Generators
The fastest way to create new modules is using the built-in Hygen generators!
This project includes Hygen scaffolding for rapid module creation. Each generator creates both the implementation file and a corresponding test file.
Generate a New Tool
You'll be prompted for:
Name: Enter in kebab-case (e.g.,
text-transform
)Description: Brief description of what the tool does
Generate a New Prompt
You'll be prompted for:
Name: Enter in kebab-case (e.g.,
code-review
)Description: Brief description of the prompt template
Generate a New Resource
You'll be prompted for:
Name: Enter in kebab-case (e.g.,
app-status
)Description: Brief description of the resource
Command Line Usage
You can also provide parameters directly:
Generated files:
Implementation:
src/{tools|prompts|resources}/[name].ts
Test:
tests/[name].test.ts
The auto-loader automatically discovers and registers all generated modules - no additional configuration needed!
Module Types Overview
Adding a New Tool
Tools are functions that can be called by the AI to perform specific actions or computations.
Tools allow your MCP server to perform actions. Create a new file in src/tools/
:
Adding a Resource
Resources provide read-only access to data that can be consumed by AI clients.
Resources provide data that can be read by clients. Create a new file in src/resources/
:
Adding a Prompt
Prompts are reusable templates that help structure interactions with the AI model.
Prompts are reusable prompt templates. Create a new file in src/prompts/
:
🔍 Testing with MCP Inspector
The MCP Inspector is a powerful tool for testing your server:
This command:
Builds your TypeScript code
Launches the MCP Inspector
Connects to your server
Provides an interactive UI to test tools, resources, and prompts
Interactive Development Mode
For rapid testing and development, use the interactive dev mode:
This starts an interactive REPL where you can paste JSON-RPC messages directly and see responses in real-time. Perfect for testing your MCP server during development!
JSON-RPC Examples for Dev Mode
Once you run npm run dev
, you can paste these JSON-RPC messages directly.
MCP Protocol Handshake Required
The MCP protocol requires a specific initialization sequence before you can use tools, resources, or prompts:
Initialize Request - Client sends capabilities and receives server capabilities
Initialized Notification - Client confirms it's ready (no response expected)
Why is the initialized notification needed?
It confirms the client has processed the initialization response and is ready
It enables bidirectional communication - after this, the server can send requests to the client
Without it, the server won't send notifications (like
tools/list_changed
) or make requests (likesampling/createMessage
)This follows a pattern similar to TCP's handshake, ensuring both parties are ready before actual communication begins
The dev server does NOT automatically perform this handshake. You must send these messages manually first.
1. Initialize Connection (Required First!)
Step 1 - Send initialize request:
Step 2 - After receiving the response, send initialized notification:
Now the server is ready to handle requests!
2. List Available Tools
3. Call the Echo Tool
4. List Resources
5. Read a Resource
6. List Prompts
7. Get a Prompt
Using Dev Mode:
Run
npm run dev
to start the interactive serverCopy any JSON-RPC message above and paste it into the terminal
The server will show the response with syntax highlighting
Type
help
for available commands orexit
to quit
Important: Always send the initialize message first to establish the connection!
⚙️ Configuration
TypeScript Configuration
The project uses strict TypeScript settings for maximum type safety. Key configurations in tsconfig.json
:
Target: ES2022
Module: ES2022 with Node module resolution
Strict mode enabled
Source maps for debugging
Available Scripts
Command | Description |
| Compile TypeScript to JavaScript |
| Run ESLint checks |
| Auto-fix ESLint issues |
| Type-check without building |
| Run tests |
| Run tests in watch mode |
| Launch MCP Inspector |
| Interactive development mode |
| Generate a new tool with test |
| Generate a new prompt with test |
| Generate a new resource with test |
🔌 Integration
How MCP Integration Works
With VS Code (Recommended)
The easiest way to use your MCP server is through VS Code with MCP support extensions.
Build your server:
npm run buildOpen the project in VS Code:
code .Use the included
The project includes an
mcp.json
file that VS Code MCP extensions can use to automatically start your server:{ "servers": { "starter": { "type": "stdio", "command": "node", "args": [ "./build/index.js" ] } } }Install a VS Code MCP extension:
Open VS Code Extensions (⇧⌘X on macOS, Ctrl+Shift+X on Windows/Linux)
Search for "MCP" or "Model Context Protocol"
Install an MCP-compatible extension
The extension will automatically detect and use your
mcp.json
configuration
Themcp.json
file tells VS Code how to start your MCP server. When you open a project with this file, compatible extensions will automatically recognize it as an MCP server project.
With Claude Desktop
Make sure to build your server before configuring Claude Desktop. The server must be compiled to JavaScript.
Build your server:
npm run buildAdd to Claude Desktop configuration:
WARNINGConfiguration file location varies by operating system:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
Windows:
%APPDATA%\Claude\claude_desktop_config.json
Linux:
~/.config/Claude/claude_desktop_config.json
{ "mcpServers": { "my-server": { "command": "node", "args": ["/path/to/your/server/build/index.js"] } } }Restart Claude Desktop
Always use absolute paths in your configuration. Relative paths may not work correctly.
With Custom Clients
Use the MCP SDK to connect to your server:
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
Fork the repository
Create your feature branch (
git checkout -b feature/AmazingFeature
)Commit your changes (
git commit -m 'Add some AmazingFeature'
)Push to the branch (
git push origin feature/AmazingFeature
)Open a Pull Request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🔗 Resources
🐛 Troubleshooting
Common issues and their solutions:
Issue | Solution |
errors | Ensure you've run
before starting the server |
Server not connecting | Check that you're using absolute paths in configuration |
Tools not loading | Verify your module exports match the
interface |
TypeScript errors | Run
to identify type issues |
Auto-loading fails | Check file names and ensure modules are in correct directories |
Development
✅ Type Safety: Use TypeScript's strict mode for catching errors early
✅ Modular Design: Keep tools, resources, and prompts focused on single responsibilities
✅ Error Handling: Always handle errors gracefully and provide meaningful messages
✅ Validation: Use Zod schemas to validate all inputs
✅ Testing: Write tests for critical functionality
Built with ❤️ for the MCP community
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
A minimal, production-ready TypeScript starter template for building Model Context Protocol (MCP) servers with auto-loading architecture for tools, resources, and prompts. Provides boilerplate code, generators, and examples to quickly create MCP servers that can connect AI applications to any data source or tool.