Area 03 · AI Agents · Concept 08 of 20

MCP Servers

Model Context Protocol servers offer tools, resources and prompts in one standard format.

01–10 · The basePhase 3 · Weeks 11–14≈ 2 hours

The idea

Before MCP, every app wired every tool its own way. The Model Context Protocol is an open standard: an MCP server exposes tools (actions), resources (readable data) and prompts (templates) over a common protocol, and any MCP-capable client can use them.

Servers run locally over stdio (a process the client starts) or remotely over HTTP. Official SDKs exist for Python, TypeScript and other languages; FastMCP in Python turns decorated functions into a server in a few lines.

Write one server for a system you know (your database, your ticket tracker, your notes) and it works in desktop chat apps, IDEs and your own agents.

Why it matters

MCP is becoming the standard way to plug tools into AI apps. Building a server is a core AI engineering skill.

Picture it

Words to know

  • Tool / resource / promptThe three things an MCP server can offer.
  • TransportHow client and server talk: stdio or streamable HTTP.

Try it without code

Install an existing server

  1. In a desktop chat app or IDE that supports MCP, add the official filesystem server for one folder.
  2. Ask it to list and summarise files there.

Use it in code

A notes MCP server with one tool and one resource, using FastMCP.

python
# pip install "mcp[cli]"
from mcp.server.fastmcp import FastMCP
from pathlib import Path

mcp = FastMCP("notes")
NOTES = Path("notes"); NOTES.mkdir(exist_ok=True)

@mcp.tool()
def add_note(title: str, body: str) -> str:
    """Save a note under a title."""
    (NOTES / f"{title}.md").write_text(body)
    return f"Saved {title}"

@mcp.resource("notes://{title}")
def read_note(title: str) -> str:
    """Read a note by title."""
    return (NOTES / f"{title}.md").read_text()

if __name__ == "__main__":
    mcp.run()   # stdio by default
$ mcp dev server.py
PRACTICE · TICK IT AFTER THIS

Write an MCP server for something you use daily, test it with the MCP Inspector, then connect it to a desktop client.

Common mistakes

  • Tools with vague names and descriptions.
  • Printing to stdout in a stdio server (it corrupts the protocol).
  • No auth on a remote server.

Go deeper