MCP TypeScript Template
Enables containerization of the MCP server with Docker support, including build and run configurations and Docker Compose setup for deployment.
Provides code quality checking with ESLint integration, including linting configuration and commands for checking and fixing code quality issues.
Uses Express as the web framework for handling HTTP connections, providing the transport layer for MCP communication with comprehensive middleware support.
Offers code formatting capabilities with Prettier integration, including formatting configuration and commands for checking and applying consistent code style.
Provides full TypeScript support with strict configuration for type safety and tooling integration when building MCP servers.
Utilizes Vite as the build system to compile TypeScript code with ES modules output for fast development and optimized production builds.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP TypeScript Templateshow me how to add a new tool to my MCP server"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP TypeScript Template
A TypeScript template for building remote Model Context Protocol (MCP) servers with modern tooling and best practices while leveraging the MCP TypeScript SDK.
Features
This template provides:
TypeScript 7 - Native compiler with strict configuration; TypeScript 6 remains available for
typescript-eslint's compiler APIEffect - Typed configuration, validation, logging, error handling, and async workflows
Vite - Fast build system with ES modules output
Express - Fast, unopinionated web framework for HTTP server
ESLint + Prettier - Code quality and formatting
Docker - Containerization support
Example Tools -
echoandelicit_echotools demonstrating tool implementation, structured output, annotations, and MCP elicitation
Related MCP server: MCP Server Boilerplate
Getting Started
The easiest way to get started is using degit:
Create a new project from this template
npx degit nickytonline/mcp-typescript-template my-mcp-server cd my-mcp-serverInstall dependencies
npm installBuild the project
npm run buildStart the server
npm start
The server will be available at http://localhost:3000 for MCP connections.
Alternative: Using GitHub Template
You can also click the "Use this template" button on GitHub to create a new repository, then clone it:
git clone <your-repo-url>
cd my-mcp-server
npm installDevelopment
Type checking
npm run typecheck uses the TypeScript 7 compiler. The typescript package is an npm alias for the TypeScript 6 compatibility package because typescript-eslint still depends on TypeScript's legacy compiler API; the compatibility package is available as tsc6 when needed.
Watch mode for development (with hot reloading)
npm run devBuild the project
npm run buildLinting
Lint the project
npm run lintFix all auto-fixable lint errors
npm run lint:fixFormatting
Format files in the project
npm run formatCheck formatting
npm run format:checkTesting Your MCP Server
You can test your MCP server using the MCP Inspector:
npx @modelcontextprotocol/inspectorThis will launch a web interface that allows you to:
Connect to your MCP server
Test your tools interactively
View request/response messages
Debug your MCP implementation
Make sure your server is running (using npm start or npm run dev) before connecting with the inspector.
Available Tools
The template includes two example tools:
echo
Echoes back the provided message - a simple example to demonstrate MCP tool implementation.
Parameters:
message(string) - The message to echo back
elicit_echo
Demonstrates MCP elicitation: the tool takes no input, asks the connected client to prompt the user for a message, then echoes it back. Handles all three elicitation outcomes (accept, decline, cancel) and errors when the client doesn't support elicitation.
Both tools declare an outputSchema and return structuredContent alongside the text result, and carry annotations (readOnlyHint, idempotentHint, openWorldHint) describing their safety profile.
Customizing Your MCP Server
Update package.json - Change name, description, and keywords
Modify src/tools.ts - Replace the
echo/elicit_echotools with your custom toolsAdd your logic - Create additional TypeScript files for your business logic
Update README - Document your specific MCP server functionality
Docker
Build and run using Docker:
Build the Docker image
docker build -t my-mcp-server .Run the container
docker run -p 3000:3000 my-mcp-serverDocker Compose
A docker-compose.yml is included with a health check pre-configured:
docker compose up --buildProject Structure
mcp-typescript-template/
├── src/
│ ├── app.ts # Express app and MCP Node adapter wiring
│ ├── app.test.ts # HTTP boundary integration tests
│ ├── index.ts # Effect startup and shutdown
│ ├── tools.ts # Tool registration (registerTools) and logic
│ ├── tools.test.ts # Integration tests (in-memory client/server)
│ ├── config.ts # Env var loading and validation (Effect Config)
│ ├── logger.ts # Effect structured logging
│ └── lib/
│ ├── utils.ts # MCP response helpers
│ ├── mcp-schema.ts # Effect Schema → MCP Standard Schema adapter
│ ├── utils.test.ts # Unit tests
│ └── mcp-schema.test.ts # Schema adapter and dialect tests
├── dist/ # Built output (generated)
├── tsconfig.json # TypeScript configuration
├── vite.config.ts # Vite build configuration
├── eslint.config.js # ESLint configuration
├── Dockerfile # Docker configuration
└── package.json # Dependencies and scriptsArchitecture
This template follows a simple architecture:
HTTP Transport - Uses Express with
createMcpHandler(@modelcontextprotocol/server) for remote MCP connectionsStateless - Per the MCP 2026-07-28 spec: no session handshake or session ID; the app creates a fresh server per request and supports older clients through the SDK fallback
Tool Registration -
registerTools(server)insrc/tools.tsis the single source of truth for tool wiring;getServer()and the tests both use itTyped I/O - Effect Schema
inputSchema/outputSchemavalues adapted to MCP Standard Schema, plusstructuredContentfor typed resultsJSON Schema Dialects - The adapter supports both MCP-requested
draft-07anddraft-2020-12outputError Handling - Genuine tool execution failures return
isError: trueviacreateErrorResultrather than being thrown; protocol, transport, and capability failures (e.g. an unsupported elicitation) can still reject the client callHealth Check -
GET /healthis a plain liveness endpoint (used by the Docker health check);GET /mcpis routed to the MCP handler itself
Example: Adding a New Tool
Add the registration inside registerTools() in src/tools.ts. See the create-mcp-tool skill (.agents/skills/create-mcp-tool) for the full walkthrough.
import type { CallToolResult, ServerContext } from "@modelcontextprotocol/server";
import { Effect, Schema } from "effect";
import { toMcpSchema } from "./lib/mcp-schema.ts";
import { createTextResult, runMcpEffect } from "./lib/utils.ts";
server.registerTool(
"my_tool",
{
title: "My Custom Tool",
description: "Description of what this tool does",
inputSchema: toMcpSchema(
Schema.Struct({
param1: Schema.String,
param2: Schema.optional(Schema.Number),
}),
),
outputSchema: toMcpSchema(Schema.Struct({ output: Schema.String })),
annotations: { readOnlyHint: true, openWorldHint: false },
},
(args, ctx) => runMcpEffect(myTool(args, ctx)),
);
function myTool(
args: { param1: string; param2?: number },
_ctx: ServerContext,
): Effect.Effect<CallToolResult> {
return Effect.succeed(createTextResult({ output: args.param1 }));
}Keep the tool workflow in Effect and use runMcpEffect() only where it crosses back into the MCP SDK callback API. For asynchronous work, use Effect.tryPromise; for independent parallel work, use Effect.all with explicit concurrency.
Why Express?
This template uses Express for the HTTP server, which provides:
MCP SDK Compatibility - Full compatibility with
@modelcontextprotocol/server'screateMcpHandler, adapted to Node/Express via@modelcontextprotocol/node'stoNodeHandlerMature & Stable - Battle-tested HTTP server with extensive ecosystem
TypeScript Support - Excellent TypeScript support with comprehensive type definitions
Middleware Ecosystem - Rich ecosystem of middleware for common tasks
Documentation - Comprehensive documentation and community support
Reliability - Proven reliability for production applications
Repository Guidelines
Contributors should review AGENTS.md for project structure, coding standards, and pull request expectations before opening changes.
This server cannot be deployed
Maintenance
Related MCP Connectors
A simple Typescript MCP server built using the official MCP Typescript SDK and smithery/cli. This…
Kickstart development with a customizable TypeScript template featuring sample tools for greeting,…
A TypeScript MCP server for Home Assistant, enabling programmatic management of entities, automati…
Model Context Protocol server for the Apideck Unified API. Connect any MCP-compatible agent framework to 100+ accounting systems, HRIS platforms, file storage providers, and more through one integration. More information https://www.apideck.com/mcp-server
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA template repository for building Model Context Protocol (MCP) servers with TypeScript, featuring full TypeScript support, testing setup, CI/CD pipelines, and modular architecture for easy extension.7 npm-
- FlicenseDqualityDmaintenanceA basic TypeScript starter template for building Model Context Protocol (MCP) servers with example function implementation and development tooling.1-
- FlicenseNot gradedqualityDmaintenanceA template project for quickly building Model Context Protocol (MCP) servers using TypeScript and the official SDK. It includes pre-configured examples for tools and resources to help developers jumpstart their custom MCP server development.52 npm-
- FlicenseAqualityDmaintenanceA starter project for rapidly developing Model Context Protocol servers using TypeScript and the official SDK. It includes pre-implemented examples of tools and resources to help developers jumpstart their custom MCP server development.6-