MCP Academy · Lesson

Config & Secrets via Environment

Load settings without hardcoding credentials.

Never Hardcode Secrets

An API key typed straight into your code can leak the moment you push to Git. Keep secrets out of source files entirely.

The Environment Holds Config

The standard place for settings is the environment. Your server reads values at startup instead of baking them into the build.

import os
api_key = os.environ["WEATHER_API_KEY"]

All lessons in this course

  1. Layered Server Architecture
  2. Config & Secrets via Environment
  3. Idempotent, Side-Effect-Aware Tools
  4. Versioning Tools & Schemas
← Back to MCP Academy