Skip to content

EuclideanAI/fastmcp-course

Repository files navigation

FastMCP from Zero to Hero: Course Outline

Coverage

Introduction

  • What's MCP (Model Context Protocol)
  • Why do we need it (key features and benefits)
  • Live Demo with Atlassian MCP Server

Quick Start

  • Set up the dev environment
  • Creating your first server
  • Understand the core building blocks - Tools, Resources, Prompts, Context

Project 1 - Confluence MCP

  • Building a Confluence MCP
  • Integrate with VS Code Copilot and Claude Desktop

Project 2 - Unit Test, Network, Authentication and Remote Server

  • Unit test
  • Transport protocols
  • Authentication
  • Remote Server Deployment

Project 3 - Advanced Topics

  • Mounting to FastAPI
  • Sampling
  • Proxy Server

πŸš€ How to Complete the Projects?

We have provided step-by-step video tutorials on YouTube to guide you through each project in this course. Each project corresponds to a specific branch name (e.g., project1, project2, project3). Simply follow the instructions below to clone the appropriate branch and you'll have a codebase that matches the starting point of the video for each project.

πŸ“Ί Video Links

Happy coding! πŸŽ‰

Development Setup

This project uses modern Python development tools to ensure code quality and consistency.

Prerequisites

  • Python 3.10+
  • uv - Fast Python package installer and resolver

Setting Up Development Environment

  1. Clone the project branch:

    • Project 1 (Confluence MCP):
      git clone -b project1 https://github.com/EuclideanAI/fastmcp-course.git
      cd fastmcp-course
    • Project 2 (Network, Authentication and Remote Server):
      git clone -b project2 https://github.com/EuclideanAI/fastmcp-course.git
      cd fastmcp-course
    • Project 3 (Advanced Topics):
      git clone -b project3 https://github.com/EuclideanAI/fastmcp-course.git
      cd fastmcp-course
  2. Install dependencies using uv:

    • If you don't have uv installed, follow the installation guide.
    • If uv is already installed, sync dependencies:
      uv sync
  3. Set up pre-commit hooks (recommended):

    uv run pre-commit install
    uv run pre-commit install --hook-type commit-msg
  4. Lint your code with Ruff:

    uv run ruff check .
  5. Format your code with Ruff:

    uv run ruff format .
  6. Run pre-commit on all files:

    uv run pre-commit run --all-files

Code Quality Standards

This project enforces strict code quality standards through automated tools:

Pre-commit Hooks

We use pre-commit hooks to ensure code quality before commits. The hooks include:

  • Ruff: Fast linting and code formatting
  • MyPy: Static type checking
  • Standard hooks: Trailing whitespace, end-of-file fixes, YAML/TOML validation
  • Conventional Commits: Enforces conventional commit message format

Conventional Commits

This project follows the Conventional Commits specification. All commit messages must follow this format:

<type>[optional scope]: <description>

[optional body]

[optional footer(s)]

Allowed types:

  • feat: A new feature
  • fix: A bug fix
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code
  • refactor: A code change that neither fixes a bug nor adds a feature
  • perf: A code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • chore: Changes to the build process or auxiliary tools

Examples:

feat: add search functionality to confluence tools
fix: resolve type annotation issues in test files
docs: update README with conventional commit guidelines
test: add unit tests for page operations

System Prompts for Copilot Agent

The system prompts saved under .github/prompts outline the code quality standard for copilot coding agent (it will be included as system prompt in every conversation):

  • planning.prompt.md

Requirements

You will need to have the following installed/ready:

  • Python 3.10+ (Can install this through uv)
  • Confluence instance (Cloud)
  • Confluence API credentials

Configuration

Configure the application via environment variables (create .env file):

CONFLUENCE_URL="https://your-domain.atlassian.net"
CONFLUENCE_USERNAME="your-email@example.com"
CONFLUENCE_PAT="your-api-token"

Usage

Run the FastMCP server with Inspector:

fastmcp dev server.py

Run the FastMCP server as a normal mcp server in local:

uv run server.py

Running Tests

This project includes comprehensive tests for the Confluence client and MCP tools. To run the tests:

uv run pytest

For more verbose output:

uv run pytest -v

To run specific test files:

uv run pytest tests/test_client.py
uv run pytest tests/test_tools.py

Test Coverage

The coverage badge at the top of this README is automatically updated via GitHub Actions whenever code is pushed to the main branch.

Local Testing

To run tests with coverage locally:

# Run tests with coverage
uv run pytest

# Manually update the coverage badge (optional - GitHub Actions handles this automatically)
uv run python update_coverage_badge.py

Automated Coverage Updates

The project includes GitHub Actions workflows that:

  1. On Push to Main: Automatically runs tests, calculates coverage, and updates the badge in the README
  2. On Pull Requests: Runs tests and provides coverage information (badge updates only happen on main branch)

The coverage badge shows the current test coverage percentage with color coding:

  • 🟒 Green: 90%+ coverage
  • 🟑 Yellow-Green: 80-89% coverage
  • 🟑 Yellow: 60-79% coverage
  • 🟠 Orange: 50-59% coverage
  • πŸ”΄ Red: <50% coverage

AI Integration

The Confluence MCP server can be integrated with various AI assistants:

VS Code Copilot

To integrate with VS Code Copilot:

  1. Ensure the server is running locally with uv run server.py
  2. Open VS Code with the Copilot extension installed
  3. Connect Copilot to the local MCP server

Claude Desktop

To integrate with Claude Desktop:

  1. Ensure the server is running locally with uv run server.py
  2. Open Claude Desktop
  3. In settings, add the local MCP server URL (typically http://localhost:8000)

Project Structure

fastmcp-course/
β”œβ”€β”€ server.py              # Main FastMCP server entry point
β”œβ”€β”€ confluence/
β”‚   β”œβ”€β”€ __init__.py        # Package initialization
β”‚   β”œβ”€β”€ client.py          # Confluence client implementation
β”‚   β”œβ”€β”€ models.py          # Data models for Confluence objects
β”‚   └── utils.py           # Utility functions
β”œβ”€β”€ tools/
β”‚   β”œβ”€β”€ __init__.py        # Package initialization
β”‚   β”œβ”€β”€ page_tools.py      # Tools for page operations
β”‚   β”œβ”€β”€ search_tools.py    # Tools for search operations
β”‚   └── comment_tools.py   # Tools for comment operations
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ conftest.py        # Test configurations and fixtures
β”‚   β”œβ”€β”€ test_client.py     # Tests for client functionality
β”‚   └── test_tools.py      # Tests for MCP tools
β”œβ”€β”€ config.py              # Configuration management
β”œβ”€β”€ .env.example           # Example environment variables
└── README.md              # Project documentation

License

[MIT]

About

The ultimate fastmcp course from zero to hero

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published