Tutorial August 16, 2026 · 10 min read

How to Build an MCP Server: Complete Guide

The Model Context Protocol (MCP) is the standard for connecting AI agents to tools. This guide shows you how to build your own MCP server from scratch.

What You'll Build

By the end of this guide, you'll have a working MCP server that exposes custom tools to any MCP client (Cursor, Claude Desktop, Windsurf).

Prerequisites

Python 3.10+ and the MCP SDK:

pip install mcp

Step 1: Create the Server

from mcp.server import Server
from mcp.server.stdio import stdio_server
from mcp.types import Tool, TextContent

app = Server("my-server")

@app.list_tools()
async def list_tools():
    return [Tool(name="my_tool", ...)]

@app.call_tool()
async def call_tool(name, args):
    return [TextContent(type="text", text="result")]

Step 2: Add to Your Client

Add your server to your MCP client config:

{
  "mcpServers": {
    "my-server": {
      "command": "python",
      "args": ["server.py"]
    }
  }
}

Conclusion

That's it! You've built an MCP server. Now any MCP client can use your tools. To go further, check out AgentBrain's open-source implementation on GitHub.