Build an MCP Server

You used an MCP client. Now you build the server.

A good server is small: clear tools, safe paths, data next to the process.


ShopTiny support server

Tool What it does
get_order Read one order from data/orders.json
list_orders List order ids
get_refund_policy Return text from data/refund_policy.md

Use case: any agent (or IDE host) can ask “what’s order 4412?” and “what’s our refund rule?” without shipping shop code inside the agent.

Server owns data and tools.
  data/orders.json
  data/refund_policy.md


   shoptiny_server.py  (FastMCP)
           │  stdio

      Any MCP client

Server rules that matter

  1. @mcp.tool() — docstring = description the client (and model) see.
  2. stdio — no casual print() on stdout.
  3. Safe paths — only read files under your data/ folder (block ../ tricks).
  4. Return JSON-friendly values — dicts/strings the client can parse.

Smoke test

The lab includes a tiny client that starts your server, lists tools, and calls get_refund_policy plus get_order.

When that works, any MCP host can use the same server.

See it in Code

Python authors the FastMCP server; TypeScript runs a real MCP smoke client against it.
Java / Go tabs are empty here — no hand-rolled mirror.