What You’ll Learn

  • How to create a reusable MCP server starter template in TypeScript
  • The minimum project structure for a useful local MCP server
  • How to register tools cleanly with schemas
  • How to connect the server to Claude Code over stdio
  • What to include in a starter template and what to leave out

If you are looking for an MCP server tutorial with a TypeScript starter template, the fastest path is not building a giant framework first. It is creating a small starter that already has the right seams.

That means:

  • one server entrypoint
  • one or two example tools
  • schema validation
  • build scripts
  • a working local Claude Code configuration

The goal is not just to make your first MCP server run once. It is to create a template you can reuse for future tools.

Project Structure

This is the starter shape I like:

mcp-starter/
  src/
    index.ts
    tools/
      summarizeText.ts
  package.json
  tsconfig.json

You do not need more than this to start.

Install the Dependencies

The official TypeScript examples use the MCP server package with Zod.

npm init -y
npm install @modelcontextprotocol/server zod
npm install -D typescript @types/node

Then add a simple tsconfig.json:

{
  "compilerOptions": {
    "target": "ES2022",
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "rootDir": "src",
    "outDir": "build",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true
  },
  "include": ["src"]
}

Create the MCP Server Entrypoint

Here is a practical starter src/index.ts:

import { McpServer, StdioServerTransport } from '@modelcontextprotocol/server';
import * as z from 'zod/v4';

const server = new McpServer({
  name: 'mcp-starter',
  version: '1.0.0',
});

server.registerTool(
  'summarize-text',
  {
    description: 'Summarize a block of text into a smaller response.',
    inputSchema: z.object({
      text: z.string().min(1),
      maxSentences: z.number().int().min(1).max(5).default(3),
    }),
  },
  async ({ text, maxSentences }) => {
    const cleaned = text.replace(/\s+/g, ' ').trim();
    const sentences = cleaned.split(/(?<=[.!?])\s+/).filter(Boolean);

    return {
      content: [
        {
          type: 'text',
          text: sentences.slice(0, maxSentences).join(' '),
        },
      ],
    };
  },
);

async function main() {
  const transport = new StdioServerTransport();
  await server.connect(transport);
  console.error('mcp-starter server running on stdio');
}

main().catch((error) => {
  console.error('Fatal error:', error);
  process.exit(1);
});

This is enough for a real starter template.

It includes:

  • server metadata
  • one tool
  • schema validation
  • stdio transport
  • safe logging with console.error()

That last point matters because stdio transport depends on stdout for protocol messages.

Add Build Scripts

Your package.json should include at least this:

{
  "type": "module",
  "scripts": {
    "build": "tsc",
    "start": "node build/index.js"
  }
}

Then build the server:

npm run build

Connect the MCP Server to Claude Code

For local use in a project, I like a project-scoped .mcp.json file:

{
  "mcpServers": {
    "mcp-starter": {
      "type": "stdio",
      "command": "node",
      "args": ["./build/index.js"]
    }
  }
}

This works well because the setup can live with the project and be reused by the team.

You can also add a local stdio server through the Claude CLI, but for a starter template I usually prefer the explicit file.

What to Add Next

Once the template works, these are the best next steps:

  • split tools into separate files
  • add a small shared utility layer
  • add environment variable handling
  • add one domain-specific tool instead of more toy tools

For example, after summarize-text, I might add:

  • get-release-summary
  • find-customer-by-email
  • list-recent-errors

That is where the starter turns into something operationally useful.

What Not to Add Too Early

I would avoid these in the very first MCP server template:

  • HTTP transport complexity if you only need local use
  • plugin packaging
  • many unrelated tools
  • a giant abstraction layer
  • clever middleware before you know what the server needs

A starter template should reduce friction, not introduce a mini-framework.

Final Thought

The best MCP server TypeScript starter template is the one you can understand, run locally, and reuse in your next project with minimal changes.

Start with one working tool, one clean server entrypoint, and one reliable Claude Code connection. That is enough to build from.

If you need help building MCP servers, TypeScript AI tooling, or Claude Code integrations that are actually useful in real workflows, take a look at my portfolio: voidcraft-site.vercel.app.