Skip to main content

Core Concept 1: What Is MCP & Building Your First Server

Start from first principles: see how an AI Host, Client, and Server talk like a USB-C plug—and build a local STDIO server without the two classic beginner bugs.

Start from first principles before choosing a cloud: understand how the Host, 1:1 Client, and Server work together, what Tools, Resources, and Prompts do, and how to avoid the two classic beginner pitfalls on a tiny local server.

Key Terms in This Lab:ProtocolModel Context Protocol (MCP)In plain English: Before MCP, every AI app needed custom glue code for each database or API. MCP defines one shared language so any AI host can discover and call tools, read reference resources, and use workflow prompts from any compliant server.Analogy: Like USB-C for AI models: one standard plug connects any AI host to any compliant tool server.On Azure Stack: Microsoft Agent Framework calling a FastMCP 4 server hosted on Azure Container Apps.Core ConceptsHost, Client & Server TopologyIn plain English: The Host is the AI application you talk to (such as Claude Desktop, VS Code, or Cursor) that orchestrates the model and user approval gates. Inside the Host, a Client opens a stateful 1:1 link to a single Server, which wraps a real data source or API.Analogy: Host = smartphone OS, Client = dedicated USB-C driver for one port, Server = external accessory you plug in.On Azure Stack: Cloud-agnostic concept: identical whether hosted locally or fronted by Microsoft Agent Framework.ProtocolMCP Primitives (Tool, Resource, Prompt)In plain English: Tools are functions the AI model decides to run (tools/call). Resources are read-only documents addressed by URI that the host app fetches (resources/read). Prompts are reusable workflow templates that a user clicks in the UI (prompts/get).Analogy: Tools = kitchen appliances the chef operates; Resources = pantry reference binder; Prompts = saved recipe cards the customer picks.On Azure Stack: FastMCP 4 exposes @mcp.tool(), @mcp.resource(), and @mcp.prompt() identically on ACA.Core ConceptsSTDIO Local TransportIn plain English: Most starter MCP servers run locally over Standard Input/Output (STDIO). The Host launches your Python or TypeScript script in the background and streams newline-delimited JSON-RPC messages over stdin and stdout.Analogy: Two engineers passing typed index cards back and forth through a private mail slot on the same desk.On Azure Stack: Local developer inner loop before deploying stateless HTTP to Azure Container Apps.Core ConceptsSTDIO stdout Stream PollutionIn plain English: Because STDIO reserves stdout exclusively for structured JSON-RPC protocol frames, any stray print() in Python or console.log() in Node/TypeScript corrupts message parsing and crashes the client connection.Analogy: Writing doodles across a machine-readable barcode—the scanner rejects the entire package.On Azure Stack: Use sys.stderr / console.error locally; emit structured JSON logs in Azure Container Apps.Core ConceptsMCP InspectorIn plain English: Instead of debugging inside a full AI chat loop, MCP Inspector connects directly to your server over STDIO or HTTP so you can verify initialization, list tools, test arguments, and inspect raw JSON-RPC frames.Analogy: Checking a circuit board with a multimeter before bolting it into the car.On Azure Stack: Verify FastMCP 4 tool schemas locally before publishing behind Azure APIM.
Cloud-Agnostic Core Concept · Identical for Azure & GCPPython (FastMCP) or TypeScript (@modelcontextprotocol/sdk + zod)
Master once, then apply to either cloud stack
Concept Escalator

1. Visual Analogy · MCP Is Like a USB-C Port for AI Apps

Intuition First
Start Here · Plain-English Concept Brief
~4 min

How does an AI assistant discover and run external tools without custom glue code for every app?

Welcome to MCP Foundry! Every module moves through 3 progressive steps (1. Intuition -> 2. Architecture -> 3. Hands-On Simulator), with clickable dotted Key Terms and a live dark Dev Inspector at the bottom. Before thinking about cloud gateways or containers, start with how MCP works on your own laptop: an AI app (the Host) creates a 1:1 Client connector that plugs into your Server to expose actions, read-only files, and prompt templates.

How this fits: Core Concept 1 (cloud-agnostic): Master the Host -> Client -> Server basics here first, using Step-by-Step mode, dotted Key Term tooltips, and the dark Dev Inspector below before moving into cloud-specific labs.

  • Three roles work in a loop: Host (AI app) -> Client (1:1 protocol link) -> Server (your data or API wrapper).
  • Tools run actions, Resources expose read-only data, and Prompts provide reusable instruction templates.
  • Test locally with MCP Inspector first, never print debug text to stdout, and watch live frames in the Dev Inspector.
AI AppMCPDBFilesAPI

Before USB-C, every gadget needed its own proprietary charger and cable. Before MCP, connecting an AI assistant to a database, calendar, or API meant writing custom glue code for every pairing. MCP gives AI apps one standard plug so a server you build once works across compatible AI hosts and editors.

Engineering Takeaway: A local starter server speaks JSON over STDIO—keep stdout strictly for protocol frames (log to stderr) and write sharp tool descriptions with validated inputs.
Quick Concept Check (Optional)

Why must a local STDIO MCP server send debug logs to stderr instead of stdout?

Step 1 of 3 ready? Move on to see how the pieces connect visually.

Engineering Scratchpad

Auto-saved per lab in mcp_foundry_v1_scratchpads

0 chars saved