S9.2

    What Is an MCP Server and How Do You Build One?

    ·
    What Is an MCP Server and How Do You Build One?

    The short answer

    An MCP server is a small program that exposes tools and data to an AI model using a standard protocol. The model calls the server when it needs to do something outside its training, like read a file, query a database, or call an API. Think of it as a plugin system for AI.

    TL;DR

    • →MCP stands for Model Context Protocol. It's a standard way for AI models to connect to external tools.
    • →An MCP server exposes tools, resources, and prompts that an AI model can call.
    • →Anthropic created MCP. Claude supports it natively.
    • →You can build a basic MCP server in under 50 lines of Python or TypeScript.
    • →MCP replaces ad-hoc tool integrations with a consistent, reusable standard.

    What is an MCP server?

    An MCP server is a small program that exposes tools and data to an AI model using a standard protocol. The model calls the server when it needs to do something outside its training, like read a file, query a database, or call an API. Think of it as a plugin system for AI.

    MCP stands for Model Context Protocol. Anthropic created it to solve a real problem: every developer was building their own custom tool-calling setup, and none of them worked the same way. MCP gives you a single standard that any compatible model can use.

    How does an MCP server actually work?

    Here's the flow.

    1. You build an MCP server that exposes one or more tools. A tool is just a function with a name, a description, and a schema for its inputs.
    2. The AI model gets a list of available tools at the start of a conversation.
    3. When the model decides it needs to use a tool, it sends a structured request to your MCP server.
    4. Your server runs the function and returns the result.
    5. The model uses that result to continue its response.

    The model decides when to call tools. You don't hardcode the logic. That's what makes MCP powerful for building agentic workflows.

    MCP servers can expose three things:

    • Tools: Functions the model can call. Search a database, send an email, run a calculation.
    • Resources: Data the model can read. Files, database records, API responses.
    • Prompts: Reusable prompt templates the model can load.

    How do you build a basic MCP server?

    You need the MCP SDK. Anthropic has official SDKs for Python and TypeScript.

    Here's the structure of a minimal MCP server in TypeScript.

    import { Server } from "@modelcontextprotocol/sdk/server/index.js";
    import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
     
    const server = new Server(
      { name: "my-mcp-server", version: "1.0.0" },
      { capabilities: { tools: {} } }
    );
     
    server.setRequestHandler("tools/list", async () => ({
      tools: [
        {
          name: "get_weather",
          description: "Get the current weather for a city",
          inputSchema: {
            type: "object",
            properties: {
              city: { type: "string", description: "City name" }
            },
            required: ["city"]
          }
        }
      ]
    }));
     
    server.setRequestHandler("tools/call", async (request) => {
      if (request.params.name === "get_weather") {
        const city = request.params.arguments.city;
        // Call your weather API here
        return { content: [{ type: "text", text: `Weather in ${city}: 22°C, sunny` }] };
      }
    });
     
    const transport = new StdioServerTransport();
    await server.connect(transport);

    That's under 40 lines. You define the tool, describe it clearly so the model knows when to use it, handle the call, and return a result.

    The description matters a lot. The model reads it to decide whether to call your tool. Write it like you're explaining the tool to a person, not a machine.

    When should you build an MCP server?

    Build one when you want an AI model to interact with your systems in a repeatable way. Good use cases:

    • Query your database in natural language
    • Read and write files during an agentic workflow
    • Trigger actions in external services (CRM, calendar, Slack)
    • Give Claude access to real-time data it doesn't have in training

    If you're just making a single API call as part of a fixed flow, you don't need MCP. It adds value when the model needs to decide which tools to use and when.

    For a broader look at how agents and tools fit together, see how to build an AI agent. And for getting started with the Claude API before you add MCP, start with our Claude API tutorial.

    If you want a production MCP integration built properly, Devwiz can scope and build it for you.


    Want to connect your systems to Claude with an MCP server? Get in touch and we'll map it out.

    Frequently Asked Questions

    Who created MCP?
    Anthropic created and open-sourced the Model Context Protocol in late 2024. It's designed to work with Claude but the protocol is open and other models can support it too.
    Do I need an MCP server to use Claude?
    No. MCP is optional. You can call the Claude API directly without any MCP setup. MCP becomes useful when you want Claude to interact with external tools or data sources in a structured, repeatable way.
    What's the difference between an MCP server and a regular API?
    A regular API is called by your code. An MCP server is called by the AI model itself, based on what it decides it needs. The model sees a list of available tools and chooses when to use them. That's the key difference.