MCP Agentic AI Crash Course with Python

by anvisimi

Not rated
GitHub

About

A comprehensive crash course on the Model Context Protocol (MCP), covering everything from basic concepts to building production-ready MCP servers and clients in Python.

Details

Author
anvisimi
Categories
Developer Tools

Setup

Install MCP Agentic AI Crash Course with Python in your MCP client (Claude Desktop, Cursor, Windsurf, and others).

Repository: https://github.com/anvisimi/mcpcrashcourse

Follow the installation instructions in the repository README, then restart your MCP client.

A comprehensive crash course on the Model Context Protocol (MCP), covering everything from basic concepts to building production-ready MCP servers and clients in Python.

I'll create a comprehensive README.md file based on the MCP Agentic AI Crash Course content. This will serve as a guide for anyone following along with the tutorial.

# MCP Agentic AI Crash Course with Python A comprehensive crash course on Model Context Protocol (MCP) covering everything from basic concepts to building production-ready MCP servers and clients. ## 📋 Table of Contents - Overview - What is MCP? - Prerequisites - Installation - Project Structure - Building MCP Server from Scratch - Running MCP Server - Integration Methods - Client Implementation - Docker Setup - Course Information ## 🎯 Overview This crash course covers: - MCP Fundamentals: Understanding Model Context Protocol architecture - Server Development: Building MCP servers from scratch - Multiple Integration Methods: MCP Inspector, Claude Desktop, Cursor IDE - Client Implementation: Creating MCP clients with LLM integration - Production Deployment: Docker setup for deployment ## 🔧 What is MCP? Model Context Protocol (MCP) is a standardized way for AI assistants to connect with external services and data sources . ### Key Benefits: - Unified Protocol: Like a USB-C cable for AI services - one protocol for multiple connections - Service Provider Managed: Updates and maintenance handled by service providers - Reduced Code Complexity: No need to write wrapper code for each service ### Architecture:

LLM/AI Assistant ↔ MCP Client ↔ MCP Protocol ↔ MCP Server ↔ External Services

## 📋 Prerequisites - Python 3.11 or higher - Basic understanding of Python and async programming - Familiarity with APIs and HTTP requests - Docker (for deployment) ## 🚀 Installation ### 1. Set up UV (Python Package Manager) 
bash # Install UV if not already installed curl -LsSf https://astral.sh/uv/install.sh | sh

# Initialize project uv init MCP-crash-course cd MCP-crash-course # Create virtual environment uv venv # Activate environment (Windows) .venv\Scripts\activate # Activate environment (macOS/Linux) source .venv/bin/activate

# Core MCP dependencies uv add mcp-cli uv add httpx uv add mcpus # For LLM integration uv add langchain-groq # For development uv add fastapi uvicorn

MCP-crash-course/ ├── server/ │ ├── weather.py # Main MCP server │ ├── server.py # Production server with SSE │ └── client-sse.py # SSE client example ├── client.py # MCP client implementation ├── weather.json # Server configuration ├── requirements.txt # Dependencies ├── Dockerfile # Docker configuration └── README.md # This file

1. Create Weather Service Server (server/weather.py)


from typing import Any import httpx from mcp.server.fastmcp import FastMCP # Initialize MCP server mcp = FastMCP("weather") # Weather API configuration WEATHER_API_BASE = "https://api.weather.gov" USER_AGENT = "MCP-Weather-Server/1.0" async def make_weather_request(url: str) -> dict[str, Any]: """Make request to weather API with proper error handling""" headers = { "User-Agent": USER_AGENT, "Accept": "application/json" } async with httpx.AsyncClient() as client: response = await client.get(url, headers=headers, timeout=30) response.raise_for_status() return response.json() def format_alerts(response: dict[str, Any]) -> str: """Format weather alerts response""" if not response.get("features"): return "No weather alerts found for this state." alerts = [] for feature in response["features"]: properties = feature.get("properties", {}) alerts.append(f"Alert: {properties.get('headline', 'N/A')}") return "\n".join(alerts) @mcp.tool() async def get_alerts(state: str) -> str: """Get weather alerts for a US state (provide 2-character state code)""" url = f"{WEATHER_API_BASE}/alerts?area={state.upper()}" try: response = await make_weather_request(url) return format_alerts(response) except Exception as e: return f"Error fetching weather alerts: {str(e)}" # Resource example @mcp.resource("config://app") async def get_app_config() -> str: """Get application configuration""" return "MCP Weather Server v1.0 - Provides weather alerts for US states" if __name__ == "__main__": mcp.run()


# Start MCP Inspector uv run mcp dev server/weather.py # Access at http://localhost:3000 # Select STDIO transport and connect


# Install server to Claude Desktop uv run mcp install server/weather.py # Configuration automatically added to Claude Desktop settings

- Open Cursor IDE
- Go to File → Preferences → Cursor Settings
- Navigate to MCP section
- Add server configuration:


{ "mcpServers": { "weather": { "command": "uv", "args": ["run", "server/weather.py"], "cwd": "/path/to/your/project" } } }


{ "mcpServers": { "weather": { "command": "uv", "args": ["run", "server/weather.py"], "cwd": "/path/to/your/project" } } }

- STDIO: For local development and same-machine communication
- SSE (Server-Sent Events): For production with separate client/server hosting


import asyncio from langchain_groq import ChatGroq from mcpus import MCPAgent, MCPClient async def main(): # Load configuration client = MCPClient("weather.json") # Initialize LLM llm = ChatGroq( model="llama-3.1-70b-versatile", api_key="your-groq-api-key" ) # Create MCP Agent agent = MCPAgent(llm=llm, client=client) # Interactive loop while True: query = input("Ask about weather: ") if query.lower() in ['quit', 'exit']: break response = await agent.run(query) print(f"Response: {response}") if __name__ == "__main__": asyncio.run(main())


# Set your Groq API key export GROQ_API_KEY="your-api-key-here" # Run client uv run client.py


FROM python:3.11-slim WORKDIR /app # Install UV RUN pip install uv # Copy requirements and install dependencies COPY requirements.txt . RUN uv venv && uv pip install -r requirements.txt # Copy application files COPY server/ ./server/ COPY .py ./ COPY .json ./ # Expose port EXPOSE 8000 # Run server CMD ["uv", "run", "server/server.py"]


# Build Docker image docker build -t mcp-server . # Run container docker run -p 8000:8000 mcp-server

Production Server with SSE (server/server.py)


import asyncio from mcp.server.fastmcp import FastMCP from mcp.server.stdio import stdio_server from mcp.server.sse import sse_server # Your weather server code here... if __name__ == "__main__": import sys if "--sse" in sys.argv: # Run with SSE transport mcp.run_sse(host="0.0.0.0", port=8000) else: # Run with STDIO transport mcp.run()

This tutorial is part of the2.0 Agentic AI and GenAI with MCPcourse :

- Start Date: May 10th, 2025
- Schedule: Every Saturday and Sunday, 3 hours per session
- Focus: Complete coverage of Agentic AI and Generative AI with MCP


GROQ_API_KEY=your-groq-api-key WEATHER_API_KEY=your-weather-api-key # if needed


# Test with MCP Inspector uv run mcp dev server/weather.py # Test specific tool # In MCP Inspector: get_alerts("CA")

- Use MCP Inspector for development and testing
- Check server logs for connection issues
- Verify JSON configuration syntax
- Ensure proper port configuration for SSE transport

- MCP Documentation
-
Python SDK Documentation
-
FastMCP Documentation

Feel free to submit issues and enhancement requests!

This project is licensed under the MIT License.


This README provides a comprehensive guide covering all the major topics from the video, including setup instructions, code examples, and deployment options. It's structured to help users follow along with the tutorial and implement their own MCP servers and clients .# mcpcrashcourse
```

This is a web browser that enables your coding agent, such as Claude Code, to visit websites on your behalf and assist you in identifying bugs or creating UI test cases.

Create crafted UI components inspired by the best 21st.dev design engineers.

Bring agent evaluations, observability, and synthetic test set generation directly into your IDE for free with Galileo's new MCP server

An MCP server to help AI assistants to answer questions and generate AccelByte Extend SDK code more effectively .

MCP server for AI Diagram Maker — generate beautiful software engineering diagrams directly inside Cursor, Claude Desktop, Claude Code, or any MCP-compatible AI agent

ALAPI MCP Tools,Call hundreds of API interfaces via MCP

AI-powered SVG animation generator that transforms static files into animated SVG components using the Allyson platform

MCP server that gives AI assistants on-demand access to 1,500+ amCharts docs, ~300 code examples, and 1000+ class API references.

APIMatic MCP Server is used to validate OpenAPI specifications using APIMatic. The server processes OpenAPI files and returns validation summaries by leveraging APIMatic’s API.

One shared context layer for AI agents and humans — live API specs, DB schemas, and versioned contracts across repos so every agent and teammate works from the same source of truth.

Build and deploy full-stack Next.js apps with 98 tools for React, AWS, and MongoDB

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.