A feature-complete Model Context Protocol (MCP) server template in TypeScript. This starter demonstrates all major MCP features with clean, production-ready code.
| Category | Feature | Description |
|---|---|---|
| Tools | hello |
Basic tool with annotations |
get_weather |
Tool with structured output schema | |
ask_llm |
Tool that invokes LLM sampling | |
long_task |
Tool with 5-second progress updates | |
load_bonus_tool |
Dynamically loads a new tool | |
| Resources | info://about |
Static informational resource |
file://example.md |
File-based markdown resource | |
| Templates | greeting://{name} |
Personalized greeting |
data://items/{id} |
Data lookup by ID | |
| Prompts | greet |
Greeting in various styles |
code_review |
Code review with focus areas |
- Node.js 20+
- npm or pnpm
# Clone the repository
git clone https://github.com/SamMorrowDrums/mcp-typescript-starter.git
cd mcp-typescript-starter
# Install dependencies
npm install
# Build
npm run buildstdio transport (for local development):
npm run start:stdioHTTP transport (for remote/web deployment):
npm run start:http
# Server runs on http://localhost:3000This project includes VS Code configuration for seamless development:
- Open the project in VS Code
- The MCP configuration is in
.vscode/mcp.json - Build with
Ctrl+Shift+B(orCmd+Shift+Bon Mac) - Test the server using VS Code's MCP tools
- Install the Dev Containers extension
- Open command palette: "Dev Containers: Reopen in Container"
- Everything is pre-configured and ready to use!
.
โโโ src/
โ โโโ tools.ts # Tool definitions (hello, get_weather, ask_llm, etc.)
โ โโโ resources.ts # Resource and template definitions
โ โโโ prompts.ts # Prompt definitions
โ โโโ server.ts # Server orchestration (combines all modules)
โ โโโ stdio.ts # stdio transport entrypoint
โ โโโ http.ts # HTTP transport entrypoint
โโโ .vscode/
โ โโโ mcp.json # MCP server configuration
โ โโโ tasks.json # Build/run tasks
โ โโโ extensions.json
โโโ .devcontainer/
โ โโโ devcontainer.json
โโโ package.json
โโโ tsconfig.json
โโโ .prettierrc # Prettier configuration
โโโ eslint.config.js
# Development mode with live reload
npm run dev
# Build for production
npm run build
# Format code
npm run format
# Lint
npm run lint
# Clean build
npm run clean && npm run buildThe npm run dev command uses tsx watch for instant reloads during development.
Changes to any .ts file will automatically restart the server.
The MCP Inspector is an essential development tool for testing and debugging MCP servers.
npx @modelcontextprotocol/inspector -- npx tsx src/stdio.ts- Tools Tab: List and invoke all registered tools with parameters
- Resources Tab: Browse and read resources and templates
- Prompts Tab: View and test prompt templates
- Logs Tab: See JSON-RPC messages between client and server
- Schema Validation: Verify tool input/output schemas
- Start Inspector before connecting your IDE/client
- Use the "Logs" tab to see exact request/response payloads
- Test tool annotations are exposed correctly
- Verify progress notifications appear for
long_task
server.tool(
"hello",
{
title: "Say Hello",
description: "A friendly greeting tool",
annotations: { readOnlyHint: true },
},
{ name: z.string() },
async ({ name }) => ({
content: [{ type: "text", text: `Hello, ${name}!` }],
})
);server.resourceTemplate(
"greeting://{name}",
{ name: "Personalized Greeting", mimeType: "text/plain" },
async ({ name }) => ({
contents: [{
uri: `greeting://${name}`,
text: `Hello, ${name}!`,
}],
})
);server.tool(
"long_task",
{ title: "Long Task" },
{ taskName: z.string() },
async ({ taskName }, { sendProgress }) => {
for (let i = 0; i < 5; i++) {
await sendProgress({ progress: i / 5, total: 1.0 });
await sleep(1000);
}
return { content: [{ type: "text", text: "Done!" }] };
}
);Copy .env.example to .env and configure:
cp .env.example .env| Variable | Description | Default |
|---|---|---|
PORT |
HTTP server port | 3000 |
Contributions welcome! Please ensure your changes maintain feature parity with other language starters.
MIT License - see LICENSE for details.