Logo 使用MCP构建AI代理:完整课程资料

使用MCP构建AI代理:完整课程资料

Cộng đồng
EnkrateiaLucca

MCP Course OReilly

Nhà phát hànhEnkrateiaLucca
Kho mãmcp-course
Ngôn ngữHTML
Bản fork
147
Sao
172
Công cụ có sẵn
0
Phương thức truyền tảistdio
Danh mục
Liên kết
  • Kết nối công cụ với quy trình làm việc AI

    使用MCP构建AI代理:完整课程资料 cung cấp các khả năng MCP mà ứng dụng khách và tác nhân AI tương thích có thể sử dụng.

  • 0 công cụ có sẵn

    Xem các thao tác có thể gọi bên dưới, kèm tên và mô tả nếu máy chủ cung cấp.

  • Cấu hình sẵn để sao chép

    Dùng các đoạn cấu hình cài đặt mẫu để thiết lập máy chủ này trong ứng dụng khách MCP bạn muốn dùng.

  • Chỉ số quan tâm đến mã nguồn mở

    172 sao và 147 bản fork từ kho mã được liên kết.

Building AI Agents with MCP

From Agent Loop to Production Servers

A hands-on O'Reilly Live Training on the Model Context Protocol (MCP) — the open standard (now under the Linux Foundation's Agentic AI Foundation) for connecting AI agents to tools, data, and external systems.

The course used to ask "The HTTP Moment of AI?" — the question has been answered. MCP was donated to the Linux Foundation in Dec 2025 with every major vendor (Anthropic, OpenAI, Google, Microsoft, AWS…) on board. This course teaches you to build with the settled standard: from the agent loop up to deployed, secured, production servers.

🎯 What is MCP?

  • One protocol, many hosts — the server you write in module 01 is consumed unmodified by Claude Desktop, Claude Code, the Claude Agent SDK, Cursor, and (deployed) Claude web.
  • Tools, resources, prompts — first-class primitives, discoverable at runtime. MCP Apps (interactive UIs) shipped as the first official extension in Jan 2026.
  • Local or remote — stdio for development, streamable-http (stateless) for production.

📚 The arc — 7 modules, one use case

One coherent artifact — a personal research assistant — grows a layer at a time. Every module ends on "why this is the current way."

ModuleThe moveDay
00Agents are loops. Hand-rolled loop, tools = plain Python functions1
01Tools move out of the process. Same tools behind an MCP server; thin client; connect Claude Code & Claude Desktop1
02The Agent SDK is an MCP host. Loop collapses to ~15 lines; in-process servers1
03Skills vs MCP. Access vs know-how — then an agent builds an MCP server via the mcp-builder skill1
04Production shape. Remote HTTP, auth seam, intent-grouped tools, hooks, evals, structured outputs2
05Deploy it. Remote server on Vercel, connected from multiple hosts — plus your first MCP App2
06Defend & scale. Tool-poisoning attack/defense lab; multi-server composition, subagents, sessions2

Take-home: demos/exercises/link-checker/. Retired material: demos/archive/.

🚀 Quick start

Every script carries uv inline metadata — no environment juggling:

bash
curl -LsSf https://astral.sh/uv/install.sh | sh
git clone https://github.com/EnkrateiaLucca/mcp-course.git
cd mcp-course

# run anything directly
uv run demos/01-introduction-to-mcp/mcp_server.py

# inspect any MCP server
mcp dev demos/01-introduction-to-mcp/mcp_server.py

Notebook setup (Jupyter kernel)

The scripts need nothing beyond uv. The notebook (demos/00-intro-agents/intro-agents-cld.ipynb) additionally needs a kernel named mcp-course on Python 3.12+ — requirements.txt pins contourpy==1.4.0, which refuses to install below 3.12. Build it once:

bash
uv venv --python 3.12 && source .venv/bin/activate
uv pip install -r requirements/requirements.txt

# register the kernel the notebook declares — skip this and Jupyter
# opens the notebook with "kernel not found"
python -m ipykernel install --user --name mcp-course --display-name "mcp-course"

Plain pip works too — python -m venv venv && pip install -r requirements/requirements.txt — as long as the active Python is 3.12+ and you still run the ipykernel install line.

Environment

env
# .env at the repo root
ANTHROPIC_API_KEY=sk-...       # all agent demos (console: platform.claude.com)
MCP_AUTH_TOKEN=demo-secret     # module 04 (and optionally 05)

Version pins that matter:

  • mcp>=1.12,<2 — the official Python SDK, pinned to v1. v2 (tracking the 2026-07-28 spec) renames FastMCP → MCPServer; the standalone "FastMCP 3" is a separate Prefect-backed project. Concepts identical.
  • claude-agent-sdk 0.2.x — bundles the Claude Code CLI; Python ≥3.10.

📁 Modules

00 — Agents are loops

demos/00-intro-agents/ · Build the research assistant with the bare Claude API: web_search (DuckDuckGo) + sandboxed filesystem tools in a hand-rolled loop. You'll never write this loop again — but you'll know what every framework is doing.

bash
jupyter lab demos/00-intro-agents/intro-agents-cld.ipynb
uv run demos/00-intro-agents/basic_personal_agent.py "Research MCP and save a brief."

01 — Introduction to MCP

demos/01-introduction-to-mcp/ · Same tools behind a FastMCP server. Inspect with MCP Inspector, watch the raw protocol via the thin client, then connect Claude Code and Claude Desktop to it — two hosts, one server, zero changes.

bash
cd demos/01-introduction-to-mcp
mcp dev ./mcp_server.py                 # inspector
uv run mcp_client.py ./mcp_server.py    # the protocol, demystified
claude mcp add research -- uv run $PWD/mcp_server.py

02 — The Agent SDK is an MCP host

demos/02-research-agent-sdk/ · The loop disappears:

python
options = ClaudeAgentOptions(
    system_prompt=SYSTEM_PROMPT,
    mcp_servers={"research": {"command": "uv", "args": ["run", "mcp_server.py"]}},
    allowed_tools=["mcp__research__*"],
)
async for message in query(prompt=user_prompt, options=options): ...

Plus the in-process pattern (create_sdk_mcp_server) — tools as plain async functions, no subprocess, ideal for serverless.

03 — Skills vs MCP

demos/03-skills-and-mcp/ · The 2026 question, answered: MCP = access, skills = know-how, plugins bundle both. Then the wow moment: the mcp-builder skill scaffolds a working MCP server from one prompt — the workflow the official MCP docs now recommend.

04 — Production-shaped research agent

demos/04-production-research-agent/ · Intent-grouped tools (7→3), streamable-http, a real auth seam (bearer → OAuth 2.1/CIMD ladder), PreToolUse/PostToolUse hooks, telemetry vs evals, structured outputs.

bash
export MCP_AUTH_TOKEN=demo-secret
uv run demos/04-production-research-agent/research_server.py   # terminal 1
uv run demos/04-production-research-agent/research_agent.py "Research MCP auth"

05 — Deploy a remote MCP server (+ MCP Apps)

demos/05-deploy-remote-mcp/ · The 2026 deployment story: don't wrap your agent in a web framework — deploy the server (stateless streamable HTTP) and connect every host to it. Ships an MCP App: an interactive research explorer rendered inside the Claude conversation.

bash
cd demos/05-deploy-remote-mcp
uv run server.py                                      # terminal 1
uv run test_client.py                                 # pre-flight
npx cloudflared tunnel --url http://localhost:8000    # → Claude custom connector
vercel deploy --prod                                  # → permanent

06 — Security & composition

demos/06-security-and-composition/ · security-lab/: a runnable tool-poisoning attack and its PreToolUse defense. composition/: third-party servers (Playwright, Git), a fact-checker subagent, and session resume/fork.


🎨 The five architecture patterns

  1. External stdio server (01) — mcp.run(transport="stdio"); subprocess, language-agnostic.
  2. Agent SDK as host (02) — mcp_servers={...}, allowed_tools=["mcp__x__*"].
  3. In-process server (02b) — create_sdk_mcp_server(tools=[...]); no transport.
  4. Remote HTTP + auth (04) — mcp.run(transport="streamable-http") + bearer/OAuth on the wire.
  5. Stateless remote + MCP Apps (05) — stateless_http=True; tool _meta.ui.resourceUri → ui:// HTML.

🛠️ Development tools

bash
mcp dev path/to/server.py        # MCP Inspector — call tools in a web UI
claude mcp add <name> -- uv run /abs/path/server.py   # Claude Code (stdio)
claude mcp add <name> --transport http <url>          # Claude Code (remote)

Claude Desktop config: ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) / %APPDATA%\Claude\claude_desktop_config.json (Windows) — absolute paths, restart after editing.

🐛 Troubleshooting

  • mcp module not found → uv reads each script's inline metadata; for manual envs pip install "mcp[cli]>=1.12,<2".
  • Claude Desktop doesn't see the server → absolute paths, which uv, run the server standalone first, restart the app.
  • Module 04 401s → MCP_AUTH_TOKEN must be set in both terminals.
  • DDGS returns nothing → DuckDuckGo throttles; the tools degrade gracefully — retry, or swap in your favorite search API.
  • Rate limits → iterate on claude-haiku.

📖 Resources

Official: MCP docs · Spec (2026-07-28 — current) · Spec (2025-11-25 — what our pinned SDK speaks) · 2026-07-28 release post · Python SDK · Claude Agent SDK · MCP Apps · Agent Skills standard

The production canon (read in this order): Building effective agents → Writing tools for agents → Equipping agents with Agent Skills → Code execution with MCP → Advanced tool use → Building agents that reach production systems with MCP

Community: Official MCP Registry · Awesome MCP servers · PulseMCP

Course materials: presentation/presentation.html · presentation/code-execution-with-mcp.html · demos/assets-resources/MCP_TECHNICAL_CHEATSHEET.md

Two handouts, different audiences:

🎓 Instructor

Lucas Soares — Blog · LinkedIn · X · YouTube — Automata Learning Lab · lucasenkrateia@gmail.com


Happy building. 🎉

Cài đặt

TypingMind
{
  "mcpServers": {
    "mcp-course": {
      "command": "python",
      "args": [
        "path/to/your/main.py"
      ]
    }
  }
}

Dùng MCP 使用MCP构建AI代理:完整课程资料 với nhiều mô hình AI

TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên sau khi kết nối 使用MCP构建AI代理:完整课程资料, bạn có thể dùng với nhiều mô hình AI khác nhau trong TypingMind thay vì phải thiết lập riêng cho từng mô hình. MCP này chạy cục bộ thông qua trình kết nối MCP của TypingMind trên thiết bị của bạn.

Hướng dẫn thiết lập để dùng trình kết nối cục bộ

Dùng cách này khi máy chủ MCP cần truy cập các tệp, ứng dụng hoặc tài nguyên riêng tư trên máy tính của bạn.

1

Mở cài đặt MCP

Trong TypingMind, vào Cài đặt, Cài đặt nâng cao, rồi đến Giao thức ngữ cảnh mô hình và chọn Cài trình kết nối.

  1. Mở TypingMind trong trình duyệt của bạn.
  2. Nhấp vào biểu tượng Cài đặt.
  3. Vào Cài đặt nâng cao.
  4. Mở mục Giao thức ngữ cảnh mô hình.
  5. Nhấp vào Cài trình kết nối rồi chọn Thiết bị này.
Màn hình thiết lập trình kết nối MCP của TypingMind với tùy chọn Thiết bị này được chọn
2

Chạy lệnh trình kết nối

Chọn Thiết bị này, sao chép lệnh từ TypingMind và chạy trong Terminal. Giữ tiến trình chạy trong khi bạn dùng MCP.

  1. Sao chép lệnh thiết lập hiển thị trong TypingMind.
  2. Mở Terminal trên macOS hoặc Windows Terminal trên Windows.
  3. Dán và chạy lệnh.
  4. Xác nhận cài đặt gói nếu Terminal hỏi bạn có muốn tiếp tục không.
  5. Giữ tiến trình trong cửa sổ Terminal chạy trong khi dùng các công cụ MCP.
3

Thêm 使用MCP构建AI代理:完整课程资料 làm máy chủ

Khi trạng thái trình kết nối là Sẵn sàng, nhấp vào Sửa máy chủ và dán cấu hình máy chủ MCP.

  1. Đợi đến khi trạng thái trình kết nối hiển thị Sẵn sàng.
  2. Nhấp vào Sửa máy chủ.
  3. Dán cấu hình máy chủ MCP của 使用MCP构建AI代理:完整课程资料.
  4. Lưu danh sách máy chủ.
  5. Làm mới nếu bạn muốn xác nhận trình kết nối vẫn sẵn sàng.
Cài đặt MCP của TypingMind hiển thị máy chủ đang hoạt động và nút Sửa máy chủ
{
  "mcpServers": {
    "mcp-course": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Dùng kết nối với nhiều mô hình

Lưu danh sách máy chủ, mở Plugin, bật các công cụ MCP của 使用MCP构建AI代理:完整课程资料, sau đó chọn bất kỳ mô hình AI nào được hỗ trợ trong TypingMind và dùng các công cụ trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.

  1. Mở trang Plugin trong TypingMind.
  2. Bật các công cụ MCP của 使用MCP构建AI代理:完整课程资料.
  3. Bắt đầu cuộc trò chuyện và chọn mô hình AI bạn muốn dùng.
  4. Dùng các công cụ MCP trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.
  5. Chuyển sang mô hình AI khác bất cứ khi nào cần mà không phải kết nối lại MCP.
Cuộc trò chuyện TypingMind dùng các công cụ MCP đã bật với một mô hình AI được chọn
Bạn có thể dùng 使用MCP构建AI代理:完整课程资料 giúp tôi làm việc này không?
使用MCP构建AI代理:完整课程资料
Được. Tôi đã đọc.
Đây là kết quả tôi tìm được bằng 使用MCP构建AI代理:完整课程资料.

Câu hỏi thường gặp

Máy chủ MCP 使用MCP构建AI代理:完整课程资料 dùng để làm gì?

使用MCP构建AI代理:完整课程资料 là máy chủ MCP cho phép các ứng dụng AI tương thích kết nối với công cụ và ngữ cảnh bên ngoài. Trong TypingMind, bạn chỉ cần thêm máy chủ MCP này một lần để các công cụ của nó có sẵn trong không gian làm việc AI của bạn.

Bạn có thể dùng MCP 使用MCP构建AI代理:完整课程资料 với nhiều mô hình AI trong TypingMind không?

Có. TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên bạn có thể dùng 使用MCP构建AI代理:完整课程资料 với nhiều mô hình AI như Claude, ChatGPT, Gemini hoặc các mô hình khác đã cấu hình trong TypingMind mà không cần thiết lập máy chủ MCP riêng cho từng mô hình.

Vì sao nên dùng MCP 使用MCP构建AI代理:完整课程资料 với TypingMind?

TypingMind là một trong những giao diện trò chuyện với LLM tốt nhất vì tập hợp nhiều mô hình AI, prompt, plugin, tác nhân AI, khóa API và công cụ MCP vào một không gian làm việc. Khi kết nối 使用MCP构建AI代理:完整课程资料, bạn có thể dùng các công cụ MCP của dịch vụ này với những mô hình ưa thích, đồng thời giữ quy trình trò chuyện gọn gàng trong TypingMind.

Làm cách nào để kết nối MCP 使用MCP构建AI代理:完整课程资料 với TypingMind?

使用MCP构建AI代理:完整课程资料 hoạt động thông qua trình kết nối MCP cục bộ của TypingMind. Đây là lựa chọn phù hợp nhất khi máy chủ MCP cần truy cập tệp cục bộ, ứng dụng máy tính, công cụ dòng lệnh hoặc tài nguyên riêng trên máy tính của bạn.

MCP 使用MCP构建AI代理:完整课程资料 cung cấp những công cụ nào trong TypingMind?

使用MCP构建AI代理:完整课程资料 cung cấp các chức năng MCP mà bạn có thể bật từ trang Plugin của TypingMind để dùng trong trò chuyện hoặc gán cho tác nhân AI.

Bạn có cần chia sẻ khóa API với TypingMind để dùng MCP 使用MCP构建AI代理:完整课程资料 không?

Không. TypingMind ưu tiên xử lý cục bộ và cho phép bạn kiểm soát nhà cung cấp mô hình, khóa API, prompt và cấu hình MCP. Nếu 使用MCP构建AI代理:完整课程资料 yêu cầu xác thực, hãy thêm các header, cài đặt OAuth hoặc cấu hình cục bộ cần thiết cho máy chủ MCP đó khi tạo kết nối.

Máy chủ MCP liên quan

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇