In this section, you'll learn how to use MCP servers by building an interactive Python learning companion that helps developers at different skill levels master Python concepts. This hands-on tutorial will teach you how MCP servers work from a consumer perspective before you build your own advanced server.
If you haven't already set up your python environment:
- Download and install VS Code
- Essential for MCP development and integration
- Install Python 3.12 or later from Python.org
- Verify installation:
python --versionorpython3 --version - Ensure pip is installed:
pip --versionorpip3 --version
- Install the Python extension
- Provides comprehensive Python development support
- Includes IntelliSense, debugging, and virtual environment management
To install UV, run the following command in the terminal:
pip install uv # Using venv (recommended)
python -m venv mcp-env
# Activate on macOS/Linux
source mcp-env/bin/activate
# Activate on Windows
mcp-env\Scripts\activateuv sync - Install and configure a Python Learning MCP server in VS Code
- to get the path to uv, run
which uv
Open the .vscode folder and make sure you see a file named mcp.json with the following content:
"learnpython-mcp": {
"command": "{path-to-uv}",
"args": [
"--directory",
".",
"run",
"server_part_2.py"
]
}- To get started we will learn how to use MCP prompts. To do this, edit the server in the mcp.json file to be
prompts_server.pyinstead ofserver_part_2.py. - Next run the play button to start the server.
- Examine the prompts_server.py file and note the
@mcp.promptsdecorator. This is the prompt we will be looking for in copilot. - In Copilot chat type
\and look for the prompt that you saw in the previous step. - Add the
beginnervariable to generate a beginner list of topics and press enter. - Once the prompt shows up in your terminal press enter and note the result!
Key Learning Points:
- Prompts are great for storing information
- Prompts can be dynamic and take variables
- Prompts need to explicilty be called by the user unless sampling is done.
- To learn about MCP tools, edit the server in the mcp.json file to be
tools_server.pyinstead ofprompts_server.py. - Next run the play button to start the server.
- Examine the
tools_server.pyfile and note the@mcp.tool()decorator. These are the tools we will be using in Copilot. - In Copilot chat, you can now use the tools to generate exercises. Try asking: "Use the generate_and_create_exercises tool to create 5 beginner Python exercises about variables"
- Notice how this tool uses sampling - it calls the LLM to generate the content and then processes the result
- You can also use the
list_exercisestool to see all created exercises - Try creating exercises for different levels (beginner, intermediate, advanced) and topics
Key Learning Points:
- Tools extend what LLMs can do by calling functions
- Sampling allows tools to use the LLM's capabilities within the tool execution
- Tools can work together to create more complex workflows
- To learn about MCP resources, edit the server in the mcp.json file to be
resources_server.pyinstead oftools_server.py. - Next run the play button to start the server.
- Examine the
resources_server.pyfile and note the@mcp.resource()decorator. These are file-like data sources that can be read by clients. - Resources in this server provide access to:
user://study-progress/{username}- Get study progress for a specific useruser://exercises/{level}- List exercises available for a specific level
- You can also use the
get_users_progresstool that combines resources with sampling to provide intelligent analysis - Try asking Copilot to "Get the study progress for Marlene" and see how it accesses the resource
- Resources are different from tools - they provide data that can be read, while tools perform actions
Key Learning Points:
- Resources provide structured data access to LLMs
- Resources can be dynamically accessed with parameters (like username or level)
- Resources enable LLMs to read current state and context information
Now let's use the full Study Buddy application with all MCP features integrated:
- Edit the server in the mcp.json file back to
server_part_2.py(this is the complete server with all features) - Run the play button to start the server
- The
server_part_2.pyincludes:- Prompts:
python_topicsfor generating topic lists - Tools:
generate_exercises,create_exercise,track_study_progress,start_study_buddy - Resources: Access to exercises and progress data
- Prompts:
- Open the .Github folder and read the copilot-instructions.md file. This will give copilot instructions on the workflow! This makes the experience more predictable.
To run the complete Study Buddy experience:
- Start Study Session: Tell Copilot in the chat that you want to learn Python and then follow the instructions.
What you'll experience:
- 🐍 Welcome screen with your personalized progress
- 📚 Menu of available exercises at your level
- 💡 Hints and solutions for each exercise
- ✅ Progress tracking as you complete exercises
- 🎯 Achievement system to motivate continued learning
When the final command is run by copilot in the terminal you should observe the following in the terminal:
Sample Study Session Output:
🐍 Python Study Buddy
Welcome, CodeLearner!
Ready to practice Python at the beginner level?
Current Streak: 🔥 0 days
Exercises Completed: ✅ 0
Available Beginner Exercises
┌────┬─────────────────┬────────────┬──────────────┐
│ No.│ Title │ Difficulty │ Status │
├────┼─────────────────┼────────────┼──────────────┤
│ 1 │ Hello World │ ⭐ │ 📝 Not started │
│ 2 │ Variables │ ⭐⭐ │ 📝 Not started │
└────┴─────────────────┴────────────┴──────────────┘
Choose an exercise (number): 1
The Study Buddy app demonstrates the full power of MCP by combining prompts, tools, resources, and sampling to create a personalized, interactive learning experience!
Next Step: Now that you've built a learning application with MCP, let's create an advanced MCP server for AI research discovery!
Continue to: Part 3 - Building Your AI Research Learning Hub →
