MCP

    How to Build an MCP Server

    James KillickJames Killick26 Apr 20267 min read
    mcpai toolsclaudetypescriptpython

    TL;DR

    • You can build an MCP server in under an hour with the official SDK.
    • MCP lets Claude and other AI models call your tools, read your data, and take real actions.
    • You define tools with a name, description, and input schema. The SDK handles the rest.
    • Test locally before connecting to Claude Desktop or any MCP-compatible client.
    • If you want a custom server built for your business, Devwiz does exactly that.

    Building an MCP server is one of the most practical things you can do right now if you want AI working inside your actual systems. This guide shows you how to build an MCP server from scratch, step by step. No fluff. Just what you need to know.

    If you are not sure what MCP is yet, start with the Model Context Protocol guide first. Then come back here.


    What do you need before you start?

    Not much. Here is the list.

    You need Node.js version 18 or later if you are using TypeScript. You need Python 3.10 or later if you prefer Python. You need a code editor. VS Code works fine.

    You also need to install the MCP SDK. That is the official package that handles the protocol for you. It is open source and maintained by Anthropic. For TypeScript, install it via npm using the modelcontextprotocol SDK package. For Python, install it via pip using the mcp package.

    That is it. You do not need a server, a database, or anything else to get started. You can run the whole thing locally.


    What is an MCP server, actually?

    An MCP server is a small program that exposes tools, resources, or prompts to an AI model. Claude can connect to it and call those tools the same way a human would use an app.

    The server sits between Claude and your data or systems. When Claude needs to look something up, run a calculation, or trigger an action, it calls your server. Your server does the work and sends the result back. Think of it as giving Claude a set of hands. The hands are your MCP server. Read more about how this works in what is an MCP server.

    MCP is the bridge between AI models and the real world. Build the bridge right, and everything else gets easier.


    How do you build an MCP server step by step?

    Here is the full build process. I will describe it in TypeScript terms, but the Python version follows the same pattern.

    Step 1: Set up your project folder. Create a new folder. Run npm init inside it. Accept the defaults. Then install the SDK. Set your TypeScript config if you are using TypeScript. Add a build script that runs the compiler.

    Step 2: Create your main server file. Create a file called server.ts in your src folder. This is where everything lives. Import the McpServer class and the standard input/output transport from the SDK. McpServer is the class you use to define your server. The transport is how your server communicates. It reads from standard input and writes to standard output. That is the standard way MCP servers work locally.

    Step 3: Initialise the server. Create a new instance of McpServer. Give it a name and a version, something like "my-mcp-server" and "1.0.0". These show up in the client so keep them clear.

    Step 4: Define your tools. This is the most important part. Tools are what Claude can call. Each tool needs three things: a name, a description, and an input schema. The name is what Claude uses to call the tool. Keep it short and clear. The description is what tells Claude when to use the tool. Write it like you are explaining it to a person. Be specific. The input schema defines what data the tool accepts, written in JSON Schema format. When the tool is called, you get those inputs and you do whatever your tool needs to do. Query a database, call an API, read a file, run a calculation. Then return a result as plain text or structured content.

    Step 5: Connect the transport and start the server. Create the transport. Connect it to your server. Then use an async main function to start everything up.

    Step 6: Build your project. Run your build command. You should end up with a compiled JavaScript file in your dist folder.

    Step 7: Test it locally. The easiest way to test is with the MCP Inspector. It is a tool from Anthropic that lets you connect to any MCP server and call its tools manually. Point it at your built server file. You can list tools, call them with test inputs, and see the responses. Fix anything that does not look right before connecting to Claude. See real examples of working servers in MCP server examples.

    Define your tools clearly and Claude will use them correctly. Vague descriptions cause bad calls.


    How do you connect your MCP server to Claude?

    Once your server is working locally, connecting it to Claude Desktop is straightforward.

    Open your Claude Desktop config file. On Mac, it lives in your home Library folder under Application Support, then Claude. On Windows, it is in your AppData Roaming folder. Inside the config file, find the mcpServers section. Add an entry for your server. Give it a key that matches your server name. Set the command to node and the args to the path of your compiled server file.

    Save the file and restart Claude Desktop. Your server will appear in the tools panel. Claude can now call your tools in any conversation. For more on using MCP with Claude Code specifically, read Claude Code and MCP.


    What are the common mistakes?

    A few things trip people up the first time.

    Vague tool descriptions. Claude decides when to call a tool based on the description. If it is unclear, Claude will either call the wrong tool or not call it at all. Be precise.

    Missing required fields in your schema. If you mark a field as required but forget to include it in the required list, Claude may skip it. Always double-check your schema.

    Not handling errors. Your tool handler should catch errors and return a clear message. If Claude gets an unhandled crash, it cannot help the user recover.

    Forgetting to rebuild after changes. If you edit your source but do not run the build step again, you are running old code. Always rebuild before retesting.


    FAQ

    How long does it take to build an MCP server?
    A basic server with one or two tools takes under an hour. A production server with multiple tools, error handling, and external integrations takes a day or two depending on complexity.

    Can I use my MCP server with AI tools other than Claude?
    Yes. MCP is an open protocol. Any client that supports MCP can connect to your server. Claude Desktop, Claude Code, and a growing list of third-party tools all support it.

    Do I need to host my MCP server somewhere?
    For local use with Claude Desktop, no. It runs on your machine. If you want to share it across a team or connect it to a remote AI service, you will need to host it and use a different transport like HTTP.

    What kinds of tools can I build?
    Anything your code can do. Query a database. Call a REST API. Read files. Send notifications. Manage calendar events. If you can write a function for it, you can wrap it as an MCP tool.


    Where to go from here

    You now know how to build an MCP server. The protocol is simple. The SDK does the heavy lifting. The hard part is deciding what tools are actually worth building for your specific situation.

    If you want a custom MCP server built for your business, Devwiz builds them. We scope the tools around your workflows and make sure Claude is actually useful inside your systems, not just impressive in a demo. Want to talk through what that looks like? Book a call and let's get into it.

    About the Author

    James Killick
    James Killick

    The AI Orchestrator

    AI Orchestrator and entrepreneur with 10+ years building digital products. Helping $1M+ business owners scale with AI systems, automation, and implementation through The AI Orchestrators, Devwiz, and Njin.

    Related Posts