Blog / Tutorials / Build Your Own MCP Server: A Developer’s Guide

Build Your Own MCP Server: A Developer’s Guide

An MCP (Model Context Protocol) server is a standardized way to expose tools, resources, and prompts to LLM applications like Claude — think of it as a web API, but designed for LLM interactions. This guide covers how to build an MCP server with FastMCP:…

7 min read

An MCP (Model Context Protocol) server is a standardized way to expose tools, resources, and prompts to LLM applications like Claude — think of it as a web API, but designed for LLM interactions. This guide covers how to build an MCP server with FastMCP: defining a tool, adding a resource, testing it locally with the MCP Inspector, and deploying it on a server you control.

What Is MCP (Model Context Protocol)?

MCP is an open protocol, originally released by Anthropic and now adopted broadly across the LLM tooling ecosystem, that standardizes how LLM applications discover and call external tools, read resources, and use prompt templates. Before MCP, every AI application invented its own way to connect an LLM to outside data and actions; an MCP server built once works with any MCP-compatible client — Claude Desktop, Claude Code, Cursor, and others — without custom integration work for each one.

Why Build a Custom MCP Server?

  • Expose an internal API or proprietary dataset to an LLM client without building a one-off integration.
  • Wrap business logic that a generic, pre-built MCP server can’t cover — your own ticketing system, internal search index, or deployment pipeline.
  • Keep sensitive data and credentials server-side, behind a tool call, instead of embedded in agent code or prompts.
  • Standardize a tool interface once and reuse it across every MCP-compatible client your team uses, instead of maintaining separate integrations per tool.

Before You Start: Requirements

  • Python 3.10 or newer.
  • A package manager — pip works fine; uv is faster and is what most current MCP tooling documents first.
  • Something to test against: Claude Desktop or Claude Code work, but the MCP Inspector (covered below) needs no client connected at all — the fastest way to verify a server works.

Step-by-Step: Building an MCP Server with FastMCP

Install FastMCP

pip install fastmcp
# or, with uv:
uv add fastmcp

Define Your First Tool

from fastmcp import FastMCP

mcp = FastMCP("My Server")

@mcp.tool()
def get_status(service: str) -> str:
    """Return the current status for a named internal service."""
    return f"{service} is healthy"

if __name__ == "__main__":
    mcp.run()

The `@mcp.tool()` decorator does the schema work for you: it reads the function’s type hints to build the tool’s parameter schema and uses the docstring as the description the client sees. There’s no separate schema file to maintain — the function signature is the source of truth.

Add a Resource

@mcp.resource("config://app")
def get_config() -> str:
    """Expose read-only app configuration to the client."""
    return open("config.yaml").read()

Resources are for read-only context a client can pull on demand — configuration, recent logs, reference data — as distinct from tools, which the client calls to take an action or run a computation.

Test Locally with the MCP Inspector

fastmcp dev server.py

This launches the MCP Inspector against your server with no client setup at all — you get a browser UI listing every tool and resource the server exposes, and you can call them directly to confirm they work before connecting a real client.

Deploying Your MCP Server on a VPS

The default stdio transport is for local, same-machine clients — it’s what `fastmcp dev` and a local Claude Desktop connection use. To serve remote clients from a VPS, switch to HTTP transport instead: `mcp.run(transport=”http”, port=8000)`. A custom MCP server is worth sizing honestly — it’s a lightweight process handling occasional tool calls, not a compute-heavy workload, so it doesn’t need GPU or dedicated hardware.

WordPress HTML block (copy-paste into WordPress)
Which Contabo VPS Fits Your MCP Server Contabo product specs as of September 2026 (contabo.com/en/pricing/), 24-month billing term.
TierSpecBest for
Cloud VPS 44 vCPU, 8 GB RAM, 100 GB SSD — from €5.24/moOne or two lightweight MCP servers, low concurrent traffic
Cloud VPS 66 vCPU, 12 GB RAM, 200 GB SSD — from €7.14/moA few MCP servers, or one with modest concurrent load
Cloud VPS Plus 44 vCPU, 8 GB RAM, 150 GB NVMe — from €12.85/moI/O-heavy tools (frequent disk reads/writes, local caching)
Cloud VPS Plus 66 vCPU, 12 GB RAM, 300 GB NVMe — from €18.09/moSeveral MCP servers or heavier logging/caching workloads

A custom MCP server is a lightweight process, not a compute-heavy workload — GPU Cloud, Cloud VDS, and Dedicated Server are unnecessary here unless it’s bundled with something else that needs them.

For the reverse proxy, process-management, and systemd patterns that turn this into a real production deployment, Contabo’s existing Python Web Server guide covers that ground in depth — worth reading before you expose the HTTP endpoint publicly. If your goal is closer to consuming a set of already-built MCP servers rather than writing your own, Contabo’s self-hosted LLM gateway guide covers that path instead.

Securing Your MCP Server

Never expose an unauthenticated HTTP MCP endpoint directly to the internet — put a reverse proxy with authentication in front of it, the same pattern worth using for any self-hosted service reachable from outside your network. Treat any tool that executes code, reads the filesystem, or touches a database as a genuine security boundary: validate inputs the same way you would for a public API endpoint, because that’s effectively what it is once an LLM client can call it.

Why Host Your MCP Server on Contabo

Cloud VPS 4 or 6 is the practical entry point for one or a few custom MCP servers — cheap, always-on, and sized honestly for a lightweight process rather than paying for GPU or dedicated hardware a tool server will never use. Move up to Performance VPS if your server does heavier I/O — frequent disk reads and writes, local caching, log-heavy tools. If your team needs both patterns — some custom servers you built yourself, plus a gateway in front of pre-built ones like fetch, GitHub, or Postgres — Contabo’s existing self-hosted LLM gateway guide covers pairing the two on one VPS.

FAQ: Building an MCP Server

What language should I use to build an MCP server?

Python and TypeScript have the most mature official SDKs and the most tooling built around them, but MCP is a protocol, not a language — official and community SDKs exist for other languages too. Python with FastMCP is the fastest path if you’re starting from zero.

Do I need the official MCP SDK, or is FastMCP enough?

FastMCP is enough for the vast majority of custom servers and is the actively recommended path for new development — it builds on the same underlying protocol and adds a much faster development experience. The official SDK’s lower-level API exists for cases needing finer control than FastMCP’s decorators expose.

Can I test an MCP server without connecting it to Claude or another client?

Yes — run `fastmcp dev server.py` to launch the MCP Inspector, a browser-based tool that lists and lets you call every tool and resource your server exposes, with no client configuration needed.

Is MCP only for Claude?

No. MCP is an open protocol, and support has spread well beyond Claude Desktop and Claude Code to other AI coding tools and agent frameworks. A server built against the standard works with any MCP-compatible client, not just one vendor’s.

Disclaimer: Product specifications, features, and prices mentioned in this article are subject to change and may vary by region, billing term, and active promotions. Please check each provider’s or brand’s official website for current figures, pricing, and local currency rates.