Building a Production‑Ready MCP Server with TypeScript
Set up a TypeScript MCP server with JSON Schema validation to expose tools for Claude Code.
Build a TypeScript MCP server exposing a code‑review tool, validate with JSON Schema, and test with MCP Inspector.
Summary
The Model Context Protocol (MCP) standardizes how AI agents communicate with external tools, and a production MCP server exposes typed tools with JSON Schema validation, uses streamable HTTP transport, handles errors gracefully, and includes authentication. The TypeScript SDK is the most widely adopted way to build MCP servers, as used by Claude Desktop, Cursor, and Windsurf. A typical server registers tools such as a code‑review tool with input schema validation using Zod, and exposes capabilities via a ListTools endpoint.
The guide covers the three MCP primitives—tools, resources, and prompts—highlighting that tools are the most common production pattern. It also explains how to test the server with the MCP Inspector and how to structure request handlers for robust error handling and authentication.
Key changes
- MCP defines tools, resources, and prompts
- Production server exposes typed tools with JSON Schema validation
- Streamable HTTP transport is the 2026 recommended standard
- Structured error responses enable graceful handling of tool failures
- Authentication is required for sensitive operations
- TypeScript SDK is the most widely adopted way to build MCP servers
- Server example registers a code‑review tool with repoPath, prNumber, and strictness
- MCP Inspector can test servers for compliance and correctness