MCP Fundamentals

Apr 10 2026 · Python 3, JavaScript, macOS , Windows, VS Code

Lesson 04: Advanced Features

Sampling with Real AI

Episode complete

Play next episode

Next

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

In this video, you will see the power of Sampling in action. You will run an MCP tool that analyzes a complex database error by using the Client’s connection to Claude.

Step 1: Start the Sampling Server

First, open a terminal window and start your server. This server has the “Brawn” (file writing) but needs the “Brain”.

uv run --with mcp sampling_server.py

Step 2: Configure the Client Environment

Open a second terminal window. Before you run the client, you need to ensure it has the anthropic library installed and the API key configured.

uv add anthropic
$env:ANTHROPIC_API_KEY = "sk-ant-..."
export ANTHROPIC_API_KEY="sk-ant-..."

Step 3: Run the Sampling Client

Now that your environment is ready, run the client script.

uv run --with mcp --with anthropic sampling_client.py
See forum comments
Cinema mode Download course materials from Github
Previous: Understanding Sampling Next: Conclusion