Lab Guide — Building Your Own MCP Server
Three exercises building an MCP server from scratch with tools and resources.
Setup: Install the MCP SDK:
pip install "mcp[cli]". Open lab.pdf in Jupyter. The notebook simulates the MCP server locally so you can iterate without restarting processes. See demo/notes_server.py for the complete standalone server.
📥 Demo Files
⬇ notes_server.pyExercise 1 — Minimal Server with Echo Tool
EX 1
Build a minimal MCP server with one tool
Create the simplest possible MCP server: a single echo tool that returns its input.
- Create a FastMCP server instance
- Register an
echotool that takes amessage: strand returns it - Test the tool function directly (without running the server)
# Your echo tool should work like:
result = echo(message="Hello MCP!")
# Returns: "Echo: Hello MCP!"
Checkpoint: The echo tool is registered and works when called directly.
Exercise 2 — Add Notes Tools
EX 2
Add
Add add_note and list_notes tools
Extend the server with note management tools:
add_note(title: str, content: str) -> str— saves a note and returns confirmationlist_notes() -> str— returns all note titles
Test by adding 3 notes and listing them.
add_note(title="Python", content="A versatile programming language")
add_note(title="MCP", content="Model Context Protocol for LLM tools")
print(list_notes())
# - MCP
# - Python
Checkpoint: Notes persist across calls. list_notes shows all added notes.
Exercise 3 — Add Notes Resource
EX 3
Add a
Add a notes:// resource
Add resources that expose notes data:
notes://all— returns all notes as formatted textnotes://{title}— returns a specific note by title
Test both resource functions.
Checkpoint: Both resources return the expected content. Missing titles return a clear error.
Tip: After completing the exercises, try running the complete server from
demo/notes_server.py with mcp dev demo/notes_server.py to see the Inspector UI.