Build a Custom MCP Server in TypeScript

A minimal stdio MCP server using @modelcontextprotocol/sdk with a zod-validated tool.

mcptypescriptnodesdk
Setup time20-30 minutes (estimate)
Estimated costFree (open-source SDK).
VerificationLast verified 2026-10-14

Install

npm init -y && npm i @modelcontextprotocol/sdk zod
npm i -D typescript @types/node && npx tsc --init

Set "type": "module" in package.json.

src/index.ts

import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { z } from "zod";

const server = new McpServer({ name: "unit-converter", version: "1.0.0" });

server.registerTool(
  "celsius_to_fahrenheit",
  {
    description: "Convert a temperature from Celsius to Fahrenheit",
    inputSchema: { celsius: z.number() },
  },
  async ({ celsius }) => ({
    content: [{ type: "text", text: String(celsius * 9 / 5 + 32) }],
  })
);

await server.connect(new StdioServerTransport());

Notes

Failure modes

Markdown version: /blueprints/mcp-typescript-server.md

Want a deeper build of this?

Vote for an extended, fully tested version (more tools, a full workflow file). Votes decide what we build next.

– votes

Get one fully built blueprint a week

A weekly email: one blueprint with config, cost, setup time and failure modes, plus a vote on what we build next.

Related blueprints