ts-template
TypeScript MCP Server Template - Production-ready template for building Model Context Protocol servers with Docker, Fastify, and comprehensive documentation in English & Spanish.
claude mcp add --transport stdio dhinojosac-ts-template-mcp node src/server.ts \ --env HOST="Host to bind HTTP server (default 0.0.0.0)" \ --env PORT="Port to run HTTP server (default 3000)" \ --env LOG_LEVEL="Logging level (e.g., info, debug, warn, error)" \ --env MCP_STDIO="Enable STDIO mode for CLI clients (true/false)" \ --env CORS_ORIGINS="Comma-separated allowed origins for HTTP API" \ --env SESSION_TIMEOUT="MCP session timeout in seconds" \ --env WEATHER_API_KEY="API key for weather plugin (if using external weather service)"
How to use
This MCP server template implements a TypeScript-based MCP server using Fastify and the official MCP Server SDK. It exposes an HTTP API for web clients and can run in STDIO mode for CLI-based MCP clients. The server wires together tools like a weather plugin and a hello plugin, validates inputs with Zod, and provides a MCP endpoint at /mcp for JSON-RPC 2.0 style interactions. You can also access a lightweight REST example endpoint and dedicated weather endpoints to illustrate tool usage. The included client-example.js demonstrates how to connect to the MCP server, list tools and resources, and invoke prompts. Use the HTTP mode for web integrations and switch to STDIO mode when integrating with desktop AI applications or command-line workflows.
How to install
Prerequisites:
- Node.js (12.x or newer) and npm installed
- Git installed (optional for cloning)
-
Clone or download the repository
-
Install dependencies
npm install
- Configure environment
- Copy the environment template and edit values
cp env.example .env
- Edit .env to configure server ports, session timeouts, CORS, and external API keys (e.g., weather API key)
- Start the development server (HTTP mode by default)
npm run dev
- Optional production build
# Clean previous build artifacts (if applicable)
npm run clean
# Build TypeScript to JavaScript
npm run build
# Run the production server
npm start
To run STDIO mode for CLI clients:
npm run dev:stdio
For debugging with verbose logs:
npm run dev:debug
Additional notes
- The template includes HTTP and STDIO MCP transport modes; choose the mode via environment flags or npm scripts.
- Ensure your environment (.env) contains correct MCP_STDIO and SESSION_TIMEOUT values to avoid unexpected disconnects.
- The Weather plugin requires a valid API key if you enable external weather services; omit or neutralize the key if not using the feature.
- If you modify or add new tools/plugins, update the MCP info endpoint and ensure Zod schemas cover new inputs.
- When running in Docker, use the provided docker-compose.yml to streamline local development and testing.
Related MCP Servers
Remote
A type-safe solution to remote MCP communication, enabling effortless integration for centralized management of Model Context.
pluggedin-app
The Crossroads for AI Data Exchanges. A unified, self-hostable web interface for discovering, configuring, and managing Model Context Protocol (MCP) servers—bringing together AI tools, workspaces, prompts, and logs from multiple MCP sources (Claude, Cursor, etc.) under one roof.
codemesh
The Self-Improving MCP Server - Agents write code to orchestrate multiple MCP servers with intelligent TypeScript execution and auto-augmentation
mcp-frontend
Frontend for MCP (Model Context Protocol) Kit for Go - A Complete MCP solutions for ready to use
mcp-ipfs
🪐 MCP IPFS Server
vscode-context
MCP Server to Connect with VS Code IDE