How to build an MCP server (Python, step by step) — The Vibe Hosting
// guide

How to build an MCP server

Updated 2026-10-12

An MCP (Model Context Protocol) server exposes tools — functions an AI model can call — plus optional resources and prompts. Claude, Claude Code, Cursor and other clients discover the tools and call them when a task needs them. Here's a minimal server in Python, from empty folder to a hosted HTTPS endpoint.

1. Install the SDK

python3 -m venv .venv && . .venv/bin/activate
pip install "mcp[cli]"

2. Write the server

A tool is an ordinary function. Type hints and the docstring become the schema and description the model sees, so make them precise.

from mcp.server.fastmcp import FastMCP

mcp = FastMCP("my-tools")

@mcp.tool()
def word_count(text: str) -> int:
    """Count the words in a piece of text."""
    return len(text.split())

@mcp.tool()
def to_celsius(fahrenheit: float) -> float:
    """Convert a temperature from Fahrenheit to Celsius."""
    return round((fahrenheit - 32) * 5 / 9, 2)

if __name__ == "__main__":
    mcp.run()          # stdio: for local clients

3. Test it locally

With the CLI extra installed, mcp dev server.py opens the MCP Inspector, where you can list the tools and call them by hand. Fix descriptions now — a vague docstring is the most common reason a model ignores a tool.

4. Switch to HTTP for remote use

stdio only works when the client starts the server on the same machine. To use it from anywhere, serve it over streamable HTTP:

mcp = FastMCP("my-tools", host="0.0.0.0", port=80)
...
if __name__ == "__main__":
    mcp.run(transport="streamable-http")   # endpoint: /mcp

Put authentication in front of it before it goes online — a bearer token checked on every request is the minimum. Your coding agent can add it.

5. Deploy it

you → your agent
“Fetch thevibehosting.com/SKILL.md and deploy this MCP server there over streamable HTTP on 0.0.0.0:80, behind a bearer token I can set. Give me the URL.”

The agent creates a server, installs the dependencies, starts the MCP server from /root/run.sh (restarted on crash) and returns a URL such as https://my-tools.thevibehosting.com/mcp. More on running it in production: MCP server hosting.

6. Connect Claude

Add the URL as a remote MCP server in your client's settings and send the token as an Authorization: Bearer … header. The exact menu differs between clients — ask your agent to do it.

Tips for tools models actually use

FAQ

What language should I build an MCP server in?

Whatever you know. Official SDKs exist for Python and TypeScript among others; Python with FastMCP is the shortest path for a first server.

What's the difference between stdio and streamable HTTP?

With stdio the client launches the server as a local process. Streamable HTTP serves it over a URL, so remote clients and several users can share one server.

Where can I host an MCP server?

Anywhere a long-running process can listen on HTTPS. The Vibe Hosting gives each server a real Linux box with HTTPS, free to start — your agent deploys it with one prompt.

Try it: paste this to Claude Code, Cursor or Codex.

you → your agent
“Fetch thevibehosting.com/SKILL.md and deploy it there”

No signup, no credit card. Your agent reads the skill, creates the server and ships your project. Full reference: API docs · SKILL.md.