AI Hints
Home›MCP Tutorial›Your First Server
MCP · Lesson 8 of 120

Your First Server

One tool.

⏱ 2 min read▶ Video at 6:22🎓 Free
Watch this lesson in the MCP courseWatch on YouTube ↗Full MCP course

Let's build a server with one tool. Northwind customers want to know if delivery is free. We'll write a normal Python function, and turn it into an MCP tool with one decorator.

Your First Server
From the video: Your First Server
  • One tool
  • A normal function
  • One decorator

A delivery cost tool

MCP server creates a server named Northwind. The tool decorator turns the function into a tool. The docstring becomes its description. And run starts the server, using standard IO by default.

northwind.pypython
from mcp.server.mcpserver import MCPServer

mcp = MCPServer("northwind")

@mcp.tool()
def delivery_cost(order_total: float) -> str:
    """UK delivery cost for an order total in pounds."""
    return "free" if order_total >= 50 else "£4.99"

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

What the decorator does

The tool decorator reads the function's name, type hints, and docstring. From those it builds the tool's name, input schema, and description. You write plain Python, and the SDK handles the protocol.

keyvalue
Namefrom the function
Inputsfrom type hints
Descriptionfrom the docstring
Protocolhandled for you

Summary

A server is an MCP server object, with functions marked as tools. Next, calling our tool from a client.

Key takeaways
  • MCPServer
  • @mcp.tool()
  • mcp.run()
Next up: Your First Client — call it in-process