Skip to content

Instantly share code, notes, and snippets.

@JayDoubleu
Created July 18, 2025 08:51
Show Gist options
  • Save JayDoubleu/e2f7acfb2563081a6b195ed94a5e46fb to your computer and use it in GitHub Desktop.
Save JayDoubleu/e2f7acfb2563081a6b195ed94a5e46fb to your computer and use it in GitHub Desktop.

Let's Learn MCP Python - Slide Deck

Slide 1: Welcome to Let's Learn MCP Python

Presenters

  • Marlene - Senior Developer Advocate, Python on Azure team at Microsoft
    • Active in Python community (ACM volunteer, Python Software Foundation board)
  • Gwen - Developer Advocate, Same team as Marlene
    • 4 years at Microsoft, YouTube content creator

Today's Focus

  • Model Context Protocol (MCP) with Python
  • Hands-on demos and practical examples
  • Building MCP servers from scratch

Slide 2: Session Agenda

What We'll Cover

  1. MCP Fundamentals - What is MCP and how does it work?
  2. In-depth MCP Features - Tools, Resources, and Prompts
  3. Live Demos - Building MCP servers step by step
  4. Complete Example - Study Buddy application
  5. Advanced Example - AI Research Hub with multiple MCP servers

Interactive Elements

  • Live coding demonstrations
  • GitHub repository with tutorials
  • Real-time Q&A

Slide 3: Agentic Coding Landscape

Popular Agent Tools

  • GitHub Copilot (with Agent Mode)
  • Claude Code
  • Cursor
  • Cline
  • Many others emerging rapidly

The Challenge

  • How to provide more context to LLMs?
  • How to connect to databases and external resources?
  • How to perform specific actions beyond just code generation?

The Solution: MCP


Slide 4: What is MCP?

Model Context Protocol (MCP)

  • Created by: Anthropic (makers of Claude)
  • Purpose: Open protocol that standardizes how applications provide context to LLMs
  • Analogy: "Like USB-C but for AI"
  • Similar to: REST for web APIs

Key Benefits

  • Standardized way to connect AI tools with external resources
  • Extensible and community-driven
  • Reduces context confusion and improves AI responses

Slide 5: MCP Architecture - The Three Components

1. Hosts

  • Environments where MCP interactions happen
  • Examples: VS Code, Claude Desktop, other AI tools

2. Clients

  • Tools that interact with MCP servers
  • Examples: GitHub Copilot, Claude, other AI assistants

3. Servers

  • Expose functionality, tools, and resources
  • Built by developers to provide specific capabilities

The Flow

HostClientServer


Slide 6: Core MCP Concepts

1. Tools

  • Controlled by: The model/LLM
  • Purpose: Functions that can be invoked
  • Examples: Retrieving data, sending messages, updating database records

2. Resources

  • Controlled by: The application
  • Purpose: Expose information or data to the model
  • Examples: Files, documents, database records, API responses

3. Prompts

  • Controlled by: The user
  • Purpose: Predefined templates for specific tasks
  • Examples: Document Q&A, output formatting, transcript summaries

Slide 7: Setting Up MCP in Python

Installation

pip install mcp
# or with uv
uv sync

Basic Server Structure

from mcp.server.fastmcp import FastMCP

# Create server instance
mcp = FastMCP("your-server-name")

# Your tools, resources, and prompts go here

if __name__ == "__main__":
    mcp.run()

VS Code Configuration

  • Create .vscode/mcp.json file
  • Configure server settings and paths

Slide 8: VS Code MCP Configuration

Configuration File: .vscode/mcp.json

{
  "mcpServers": {
    "learn-python-mcp": {
      "command": "uv",
      "args": ["--directory", ".", "run", "server.py"]
    }
  }
}

Key Components

  • Server name: Identifier for your MCP server
  • Command: How to run your server (uv, python, etc.)
  • Args: Arguments passed to the command
  • Directory: Working directory for the server

Slide 9: MCP Prompts - Deep Dive

What are Prompts?

  • Predefined templates for specific tasks
  • Can be static or dynamic
  • Accessible via / command in VS Code

Example: Dynamic Topic Generator

@mcp.prompt()
async def generate_topics(level: str) -> str:
    return f"Generate five Python topics for someone with {level} experience"

Use Cases

  • Consistent welcome messages
  • Complex prompt templates
  • Reusable instruction sets

Slide 10: MCP Tools - Function Calling

What are Tools?

  • Python functions that LLMs can invoke
  • Enable specific actions and operations
  • Decorated with @mcp.tool()

Example: Exercise Generator

@mcp.tool()
async def generate_exercises(topic: str, level: str, context) -> str:
    # Get prompt template
    prompt_text = await get_prompt("generate_exercise_prompt")
    
    # Use context to call LLM automatically
    response = await context.session.create_message(
        role="user", 
        content=prompt_text
    )
    
    return response

Slide 11: MCP Resources - Data Access

What are Resources?

  • File-like data sources (read-only)
  • Identified by URIs: protocol://host/path
  • Reduce token usage and provide context

Example: Study Progress Tracker

@mcp.resource("file://user/study_progress.json")
async def get_study_progress(username: str) -> str:
    with open("study_progress.json", "r") as f:
        data = json.load(f)
        return json.dumps(data.get(username, {}))

Use Cases

  • Configuration files
  • Database records
  • Document collections
  • Image assets

Slide 12: Bonus Feature - Sampling

What is Sampling?

  • Allows client to automatically call LLMs
  • Enables autonomous workflows
  • Reduces manual intervention

Implementation

# Use context to automatically invoke LLM
response = await context.session.create_message(
    role="user",
    content=prompt_text
)

Benefits

  • Seamless user experience
  • Better for agentic coding workflows
  • Reduces need for manual prompt triggering

Slide 13: Demo 1 - Study Buddy Application

Application Goals

  • Generate Python exercises based on skill level
  • Track learning progress
  • Provide personalized study materials

Components

  1. Prompt: Generate topic suggestions
  2. Tool: Create and store exercises
  3. Resource: Access progress data

Key Features

  • Dynamic difficulty adjustment
  • Progress tracking
  • Exercise database management

Slide 14: Demo 2 - AI Research Hub

Application Purpose

  • Automate research workflows
  • Integrate multiple MCP servers
  • Streamline paper and code discovery

Workflow

  1. Research topic initialization
  2. Search Hugging Face papers
  3. Find GitHub repositories
  4. Compile research dashboard
  5. Generate summary reports

Multi-Server Integration

  • Custom Research Hub MCP
  • Hugging Face MCP
  • GitHub MCP

Slide 15: Advanced MCP Configuration

Multiple Server Setup

{
  "mcpServers": {
    "ai-research-hub": {
      "command": "uv",
      "args": ["run", "server.py"]
    },
    "github": {
      "type": "github",
      "url": "https://github.com/modelcontextprotocol/servers"
    },
    "huggingface": {
      "type": "huggingface",
      "url": "https://github.com/huggingface/mcp-server"
    }
  }
}

Best Practices

  • Only include tools you need
  • Deselect unused functionality
  • Organize by project requirements

Slide 16: Tool Selection and Management

VS Code Tool Management

  • Access via GitHub Copilot → Tools → MCP Servers
  • Select/deselect specific tools
  • Organize by relevance to current project

Performance Tips

  • Fewer tools = better performance
  • Reduce context confusion
  • Select tools relevant to current task

Tool Categories

  • Custom server tools
  • Third-party MCP servers
  • Built-in integrations

Slide 17: Real-World MCP Applications

Popular Use Cases

  • Documentation: MS Docs MCP for better technical answers
  • Development: Database connectivity and API integration
  • Research: Paper discovery and code implementation finding
  • Productivity: Task automation and workflow orchestration

Community Servers

  • Growing ecosystem of community-built servers
  • GitHub repositories with pre-built functionality
  • Easy to extend and customize

Slide 18: Best Practices and Tips

Writing Effective Prompts

  • Use pseudo-code style natural language
  • Be specific about expected outputs
  • Include clear instructions and context

Copilot Instructions

  • Create .github/copilot-instructions.md
  • Explicitly mention MCP server usage
  • Provide context about your project

Agent Mode vs Ask Mode

  • MCP works best in Agent Mode
  • Agent Mode enables autonomous tool calling
  • Ask Mode requires manual tool selection

Slide 19: Common Challenges and Solutions

Challenge: Tools Not Appearing

  • Solution: Ensure proper MCP configuration
  • Solution: Restart VS Code after config changes
  • Solution: Check file paths and permissions

Challenge: Poor Performance

  • Solution: Limit selected tools
  • Solution: Use specific, clear prompts
  • Solution: Optimize resource usage

Challenge: Context Issues

  • Solution: Use Copilot instructions
  • Solution: Be explicit about MCP server usage
  • Solution: Structure prompts effectively

Slide 20: Getting Started - Next Steps

Immediate Actions

  1. Visit Tutorial Repository: Follow aka.ms/learnmcppython
  2. Set Up Development Environment: Install uv, Python, VS Code
  3. Try Basic Examples: Start with prompts, then tools, then resources

Learning Path

  1. Implement the Study Buddy application
  2. Build your own simple MCP server
  3. Integrate multiple MCP servers
  4. Contribute to the community

Resources

  • GitHub repository with complete examples
  • Documentation and best practices
  • Community Discord and forums

Slide 21: Community and Ecosystem

MCP Community

  • Created by: Anthropic, adopted by AI community
  • Evolution: Rapidly evolving with community input
  • Contribution: Open source and community-driven

Key Contributors

  • David Sariah (Twitter: active MCP updates)
  • Microsoft Python team
  • Growing developer community

Future Outlook

  • Standardization across AI tools
  • Expanded server ecosystem
  • Enhanced integration capabilities

Slide 22: Q&A and Wrap-Up

Key Takeaways

  • MCP standardizes AI tool integration
  • Three core concepts: Tools, Resources, Prompts
  • Python implementation is straightforward and powerful
  • Agent Mode provides the best experience

Questions to Consider

  • What workflows could you automate with MCP?
  • Which external resources would benefit your AI interactions?
  • How could MCP improve your development productivity?

Thank You!

  • Follow us for more Python and AI content
  • Check out the GitHub repository
  • Join the MCP community discussions

Slide 23: Additional Resources

Links and References

  • Tutorial Repository: aka.ms/learnmcppython
  • MCP Documentation: Official Anthropic docs
  • Python Community: ACM, Python Software Foundation
  • Microsoft Python Team: Azure Python resources

Tools Mentioned

  • UV: Modern Python package manager
  • Rich: Terminal UI library
  • FastMCP: Python MCP server framework
  • VS Code: Primary development environment

Community

  • Python Discord servers
  • MCP developer forums
  • GitHub discussions and issues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment