How MCP Servers Are Implemented and Deployed as Lesson Outputs in AI Engineering From Scratch

MCP servers in the AI Engineering From Scratch curriculum are implemented as reusable Python artifacts using the FastMCP framework and deployed through lesson-specific outputs/ directories as production-ready skill files complete with OAuth configurations, OPA policies, and registry manifests.

The AI Engineering From Scratch repository by Rohit G00 treats Model Context Protocol (MCP) servers as first-class curriculum artifacts rather than theoretical concepts. Each lesson covering MCP architecture ships concrete server implementations alongside deployment specifications stored in lesson-specific outputs/ directories, enabling learners to graduate from minimal examples to production-grade deployments.

MCP Server Architecture in the Curriculum

The curriculum defines MCP servers through a layered architecture that progresses from standard library implementations to high-level FastMCP abstractions.

Core Server Implementation

At the foundation, lessons in phases/13-tools-and-protocols/07-building-an-mcp-server/ demonstrate server construction using Python. The source code transitions from manual JSON-RPC dispatching to the FastMCP framework, reducing implementation from approximately 180 lines to fewer than 80 lines while maintaining full protocol compliance.

The implementation uses the official SDK import as referenced in phases/11-llm-engineering/14-model-context-protocol/docs/en.md:

from mcp.server.fastmcp import FastMCP

Tools are registered via decorators, with the server object exposing typed JSON-schema functions:

@app.tool
def list_notes():
    """Return a list of note titles."""
    return ["Shopping", "Meeting", "Ideas"]

@app.tool
def add_note(title: str, body: str):
    """Add a note and return its ID."""
    return {"id": 42, "title": title}

Tool and Resource Primitives

MCP servers in the curriculum implement three core primitives: tools (callable functions), resources (read-only data streams), and prompts (reusable templates). The lesson documentation in phases/13-tools-and-protocols/07-building-an-mcp-server/docs/en.md explains how resources expose embeddings or documents while prompts provide structured templates for client LLMs.

Transport and Manifests

Production implementations utilize StreamableHTTP transport running on port 8000 by default. Upon startup, servers publish a capability manifest at /.well-known/mcp-capabilities containing the tool list, transport URL, and authentication requirements. As documented in phases/19-capstone-projects/13-mcp-server-with-registry/docs/en.md, this manifest enables automatic discovery by MCP-aware clients and registry services.

Deployment as Lesson Outputs

The curriculum treats deployment specifications as reusable artifacts stored in outputs/ directories, following the repository's pattern of shipping prompts, skills, and agents as markdown files.

The Skill Output Structure

For the capstone project in phases/19-capstone-projects/13-mcp-server-with-registry/, the lesson output consists of outputs/skill-mcp-server.md. This file contains:

  • Docker and uvicorn execution commands
  • Helm chart configurations for TLS and rate-limiting
  • OAuth 2.1 middleware specifications
  • OPA policy definitions for gating destructive actions

Production Security Layer

The capstone lesson implements enterprise security through the skill-mcp-server.md output, specifying OAuth 2.1 scope enforcement per tool and Open Policy Agent (OPA) integration. Destructive operations route through a separate human-approval MCP server that triggers Slack notifications before execution, as detailed in phases/19-capstone-projects/13-mcp-server-with-registry/docs/en.md.

Implementation Example: FastMCP Server

The following implementation from phases/13-tools-and-protocols/07-building-an-mcp-server/code/main.py demonstrates the minimal viable server:

from fastmcp import FastMCP

app = FastMCP("notes")

@app.tool
def list_notes():
    """Return a list of note titles."""
    return ["Shopping", "Meeting", "Ideas"]

@app.tool
def add_note(title: str, body: str):
    """Add a note and return its ID."""
    return {"id": 42, "title": title}

if __name__ == "__main__":
    # StreamableHTTP runs on port 8000 by default

    app.run()

Deployment Configuration

The output file phases/19-capstone-projects/13-mcp-server-with-registry/outputs/skill-mcp-server.md specifies production deployment through containerized uvicorn:

python -m venv .venv && source .venv/bin/activate
pip install fastmcp[all]
uvicorn main:app --host 0.0.0.0 --port 8000

The markdown file additionally provides Docker build instructions and Helm chart values for registry integration, enabling immediate deployment to Kubernetes clusters with TLS termination and rate limiting configured.

Key Source Files

Summary

  • MCP servers in the curriculum are implemented using FastMCP to reduce boilerplate while maintaining full protocol compliance
  • Lesson outputs reside in outputs/ directories as markdown skill files containing deployment specifications
  • Production deployments include OAuth 2.1 scopes, OPA policies, and human-approval workflows for destructive tools
  • The StreamableHTTP transport and capability manifests at /.well-known/mcp-capabilities enable automatic client discovery
  • Learners can deploy immediately using the Docker and Helm configurations provided in skill-mcp-server.md

Frequently Asked Questions

What is the difference between the standard library MCP implementation and FastMCP in the curriculum?

The standard library approach requires approximately 180 lines of manual JSON-RPC handling. FastMCP reduces this to under 80 lines using decorators like @app.tool while maintaining full protocol compliance. The lesson in phases/13-tools-and-protocols/07-building-an-mcp-server/ teaches both approaches to demonstrate the "Build → Use → Ship" progression.

Where are MCP server deployment configurations stored in the repository?

Configurations are stored as lesson outputs in the outputs/ directory of each relevant lesson. The capstone project stores its production specification in phases/19-capstone-projects/13-mcp-server-with-registry/outputs/skill-mcp-server.md. This file includes Docker commands, Helm charts, and OAuth middleware specifications.

How does the curriculum handle security for production MCP deployments?

The capstone lesson implements OAuth 2.1 scope enforcement per tool and Open Policy Agent (OPA) policies to gate destructive actions. A separate human-approval MCP server routes sensitive operations through Slack notifications. These security specifications are documented in the skill-mcp-server.md output file.

Can I deploy the MCP servers from this curriculum to production immediately?

Yes. The skill-mcp-server.md file provides immediate deployment instructions using uvicorn for development and Docker/Helm for production clusters. Configurations include TLS termination, rate limiting, and registry integration, enabling direct integration into CI/CD pipelines.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →