Home / Blog / how to build an MCP server

How to Build an MCP Server: A Developer's Guide

July 7, 20266 min readBy Roopesh LR
Build AI tools that work

Knowing how to build an MCP server is becoming one of the highest-leverage skills for developers working with AI. The Model Context Protocol (MCP) is the open standard that lets AI assistants reach outside their context window and interact with real systems — your databases, APIs, file systems, and internal tools. Once you ship your own MCP server, your AI stops being a chatbot and starts being a worker with actual access to your stack.

What an MCP Server Actually Does

An MCP server exposes capabilities to an AI host. The host — Claude Desktop, Claude Code, or any MCP-compatible client — connects to your server at startup, discovers what it can do, and invokes those capabilities during a conversation or agentic task.

The protocol defines three primitive types:

Think of it as an API purpose-built for AI consumption. The difference from a normal REST API is discovery: the AI can inspect your server and understand what it can do without any documentation. The tool descriptions you write are what the AI reads when deciding which tool to call.

How to Build an MCP Server: The Core Structure

The official MCP SDK supports TypeScript and Python. TypeScript is the more mature option. The setup is minimal: install the SDK via npm (@modelcontextprotocol/sdk), create a Server instance with a name and version string, register your tools with server.tool(), then connect to a transport — usually stdio for local development, HTTP for production deployments.

Your server is a process. The AI host spawns it and communicates over stdio. There is no persistent HTTP server to manage in the simple case — the host starts your process, exchanges JSON messages, and terminates it when done. For production, you can run an HTTP/SSE server and let multiple clients connect, but starting with stdio keeps the surface area small while you prototype.

The full protocol is well-specified and public. Read the spec once — it will save you debugging time later when you hit edge cases around content types or error codes.

Defining Tools Your AI Can Use

Each tool definition has three parts: a name, a description, and an input schema. The name is used internally. The description is what the AI reads to decide whether to call your tool — it is the most important field you will write. Be specific: Search the order database by customer email, returning up to 10 recent orders with status and total outperforms a vague one-liner by a wide margin. The AI is doing fuzzy intent-matching against your description, not keyword lookup.

Input schemas use JSON Schema. Annotate every field with a description — these become the AI guide for how to populate arguments correctly.

Tool Design Principles

Running and Testing Your MCP Server

Use the MCP Inspector for early testing. Run it with npx @modelcontextprotocol/inspector and point it at your server binary. You get a UI to list all registered tools, invoke them with test arguments, and inspect raw responses — without needing any AI involved. This is the fastest way to validate that your tool schemas are correct and your handlers return the right shape.

For live testing, wire it into Claude Desktop by editing its config file. Specify your server command and entry point path. Restart Claude Desktop and your tools appear immediately. The edit-restart-test loop is fast enough to iterate tool descriptions and schemas in real time.

Common Issues

What to Build First

The highest-ROI first server is one that connects AI to data you already have but cannot currently access from your AI tools. Practical starting points:

Start with read-only tools. They are safe, fast to build, and immediately useful. After you have seen how the AI uses them in practice, you will have clear intuition for where write operations add real value versus introduce real risk.

Building MCP servers is the practical path from prompting AI to deploying AI. Your data, your tools, your rules — the protocol handles the plumbing.

Go deeper

AI CEO — How AI Will Replace the Tech Industry

This is the surface. The full argument — with the data, the case studies, and the playbook — is in the book. Roopesh LR's AI CEO is available to learn more.

Get the book →
MCP server tutorialmodel context protocol serverbuild MCP serverMCP server developmentClaude MCP serverAI tool integrationMCP protocol implementation
© 2026 Roopesh LR · AI CEOAll articles · aiceo.me