How to Build an MCP Server in 30 Minutes (With a Real Example)
How to Build an MCP Server in 30 Minutes (With a Real Example) MCP (Model Context Protocol) lets Claude Code call your own tools. Once you understand the structure, building one takes less than an ...

Source: DEV Community
How to Build an MCP Server in 30 Minutes (With a Real Example) MCP (Model Context Protocol) lets Claude Code call your own tools. Once you understand the structure, building one takes less than an hour. Here's the complete walkthrough — I'll build a simple weather MCP server from scratch. What You're Building An MCP server is a process that: Runs alongside Claude Code Exposes "tools" that Claude can call Returns structured data Claude can reason about Claude decides when to call your tools based on the user's request. You define what the tools do. Step 1: Set Up the Project mkdir weather-mcp && cd weather-mcp npm init -y npm install @modelcontextprotocol/sdk zod Step 2: Define Your Tools Create server.js: import { Server } from "@modelcontextprotocol/sdk/server/index.js"; import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js"; import { z } from "zod"; co