MCP Tutorial

Welcome to the MCP (Model Context Protocol) tutorial. This course is based on the official MCP documentation and the 2026-07-28 specification. It treats MCP as a standalone protocol course: how Host, Client, and Server collaborate; how Tools, Resources, and Prompts expose context; and how to build a reusable server with the official Python SDK.

The official metaphor: MCP is USB-C for AI applications. One standard plugs local files, HTTP APIs, GitHub, browsers, and other systems into hosts such as Claude Code, Cursor, VS Code, and ChatGPT—without a one-off plugin for every product.

This course teaches the protocol. MCP chapters inside Cursor, Claude Code, Codex, and OpenCode are client-specific wiring. We link them instead of duplicating product menus and troubleshooting.


Table of Contents

Basics

  1. Introduction — Why MCP, the USB-C metaphor, who should learn
  2. Architecture — Host / Client / Server, local vs remote, data and transport layers
  3. Primitives — Tools, Resources, Prompts, and conceptual JSON-RPC examples
  4. Transports — Stdio, Streamable HTTP, and leftover SSE

Development

  1. Installation — Node / Python, pip install mcp, Inspector
  2. Quick Start — A tiny add tool and Inspector
  3. Python Server — Official SDK: tool + resource + prompt
  4. Connect Clients — Cursor, Claude Code, Codex, OpenCode snippets

Operations

  1. Official Servers — filesystem, GitHub, Fetch / Playwright, marketplace
  2. Security — Approval, sandbox, allowlists, supply chain
  3. Practical Examples — Local notes, wrap a public API, one server in two hosts
  4. Resources — Spec, SDKs, this site's agent courses

Learning Path

StageGoalChapters
Day 1Mental modelIntro → Architecture → Primitives → Transports
Day 2First working serverInstall → Quick Start → Python Server
Day 3Real hostsConnect Clients → Official Servers
Week 1Reuse safelySecurity → Examples → Resources

Use Inspector before an IDE or CLI host. Inspector lists tools, resources, and prompts directly, which is faster than guessing whether a chat model “saw” your tool.


Prerequisites

  • Python 3.10+ basics (decorators, type hints, virtual environments)
  • Comfort with JSON and request/response thinking; JSON-RPC itself is optional
  • At least one MCP-capable host (Cursor, Claude Code, Codex, …). Inspector is enough if you have no host yet
  • Node.js for Inspector and most npx reference servers (Inspector currently documents a newer Node floor—see Installation)
  • On Windows use PowerShell; Unix / macOS commands are listed alongside

You do not need an LLM application framework. MCP does not dictate how an app uses the model; it only standardizes how context is exchanged.


GoalCourse
Protocol, primitives, write a serverThis tutorial
Cursor mcp.jsonCursor / MCP
claude mcp add and .mcp.jsonClaude Code / MCP
~/.codex/config.toml mcp_serversCodex / MCP
OpenCode MCP + LSPOpenCode / MCP and LSP

The current specification is 2026-07-28: a stateless protocol core, with capability discovery via server/discover. Sampling is deprecated; this course mentions it once and does not teach it as current practice.

How to read this: picture Host / Client / Server and the three primitives first, run a tiny server in Inspector, then paste the same process into a product config. If a chat “cannot see the tool,” go back to Inspector before blaming the model.


Next

评论