Skip to content

Commit 788a6eb

Browse files
committed
add unit 0-2
1 parent e70de04 commit 788a6eb

36 files changed

+5005
-2
lines changed

README.md

Lines changed: 81 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,81 @@
1-
# mcp-course-cn
2-
huggingface mcp-course 中文版
1+
# Model Context Protocol (MCP) 课程 | MCP Course
2+
3+
![MCP 课程横幅](https://github.com/user-attachments/assets/d26dcc5e-46cb-449e-aecb-49ece10d342a)
4+
5+
6+
## 中文版
7+
8+
这是 [HuggingFace Model Context Protocol (MCP) 课程](https://github.com/huggingface/mcp-course) 的中文翻译项目。
9+
10+
如果您喜欢本课程,**请不要犹豫,为这个仓库⭐点亮星标**。这有助于我们**让课程获得更多关注🤗**
11+
12+
<img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/communication/please_star.gif" alt="为仓库点亮星标" />
13+
14+
### 项目概述
15+
16+
模型上下文协议(Model Context Protocol,简称MCP)是一种标准化协议,它使AI模型能够无缝地与外部工具和数据源交互。本课程提供了对MCP的全面介绍,从基础知识到实际应用。
17+
18+
### 课程内容
19+
20+
本课程分为4个单元。这些单元将带您**从模型上下文协议的基础知识,到最终在AI应用中实现MCP的项目**
21+
22+
| 单元 | 主题 | 描述 |
23+
| ------- | ----------------------- | --------------------------------------------------------- |
24+
| 0 | 欢迎来到课程 | 欢迎,指南,必要工具和课程概述 |
25+
| 1 | 模型上下文协议介绍 | MCP的定义,关键概念,以及其在连接AI模型与外部数据和工具中的作用 |
26+
| 2 | 使用MCP构建:实践开发 | 学习使用可用的SDK和框架实现MCP客户端和服务器 |
27+
| 3 | 高级用例 | 即将推出 |
28+
| 4 | 社区集成 | 即将推出 |
29+
30+
### 先决条件
31+
32+
* 对AI和LLM概念的基本理解
33+
* 熟悉软件开发原则和API概念
34+
* 至少熟悉一种编程语言(将着重介绍Python或TypeScript示例)
35+
36+
### 项目结构
37+
38+
当前项目结构如下:
39+
40+
```
41+
mcp-course-cn/
42+
├── units/
43+
│ ├── zh/ # 中文版课程内容
44+
│ │ ├── unit0/ # 单元0:课程介绍
45+
│ │ ├── unit1/ # 单元1:MCP基础
46+
│ │ ├── unit2/ # 单元2:端到端MCP应用
47+
│ │ ├── unit3/ # 单元3:高级用例
48+
│ │ ├── unit4/ # 单元4:社区集成
49+
│ │ └── _toctree.yml # 目录结构
50+
│ └── en/ # 英文原版课程内容
51+
├── LICENSE # 许可证
52+
├── README.md # 说明文件
53+
└── requirements.txt # 依赖项
54+
```
55+
56+
### 学习使用
57+
58+
#### 在线学习
59+
60+
正式发布后,可通过以下链接访问在线课程:
61+
- [在线课程链接] - 即将推出
62+
63+
#### 本地学习
64+
65+
您可以通过克隆本仓库来本地学习课程内容:
66+
67+
```bash
68+
git clone https://github.com/yourusername/mcp-course-cn.git
69+
cd mcp-course-cn
70+
```
71+
72+
### 贡献指南
73+
74+
如果您发现任何翻译错误或有改进建议,欢迎提交问题或拉取请求。对于特定的贡献,以下是一些指南:
75+
76+
77+
### 致谢
78+
79+
感谢原课程作者提供的优质内容,以及所有参与翻译和审阅的贡献者。
80+
81+

requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
hf-doc-builder>=0.5.0
2+
mdx_truly_sane_lists
3+
pyyaml

units/en/_toctree.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
- title: "0. Welcome to the MCP Course"
2+
sections:
3+
- local: unit0/introduction
4+
title: Welcome to the MCP Course
5+
6+
- title: "1. Introduction to Model Context Protocol"
7+
sections:
8+
- local: unit1/introduction
9+
title: Introduction to Model Context Protocol (MCP)
10+
- local: unit1/key-concepts
11+
title: Key Concepts and Terminology
12+
- local: unit1/architectural-components
13+
title: Architectural Components
14+
- local: unit1/communication-protocol
15+
title: The Communication Protocol
16+
- local: unit1/capabilities
17+
title: Understanding MCP Capabilities
18+
- local: unit1/sdk
19+
title: MCP SDK
20+
- local: unit1/mcp-clients
21+
title: MCP Clients
22+
- local: unit1/gradio-mcp
23+
title: Gradio MCP Integration
24+
25+
- title: "2. Use Case: End-to-End MCP Application"
26+
sections:
27+
- local: unit2/introduction
28+
title: Introduction to Building an MCP Application
29+
- local: unit2/gradio-server
30+
title: Building the Gradio MCP Server
31+
- local: unit2/clients
32+
title: Using MCP Clients with your application
33+
- local: unit2/gradio-client
34+
title: Building an MCP Client with Gradio
35+
- local: unit2/tiny-agents
36+
title: Building a Tiny Agent with TypeScript
37+
38+
- title: "3. Use Case: Advanced MCP Development"
39+
sections:
40+
- local: unit3/introduction
41+
title: Coming Soon
42+
43+
- title: "Bonus Units"
44+
sections:
45+
- local: unit4/introduction
46+
title: Coming Soon

units/en/unit0/introduction.mdx

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# Welcome to the 🤗 Model Context Protocol (MCP) Course
2+
3+
![MCP Course thumbnail](https://huggingface.co/datasets/mcp-course/images/resolve/main/unit0/1.png)
4+
5+
Welcome to the most exciting topic in AI today: **Model Context Protocol (MCP)**!
6+
7+
This free course will take you on a journey, **from beginner to informed**, in understanding, using, and building applications with MCP.
8+
9+
This first unit will help you onboard:
10+
11+
* Discover the **course's syllabus**.
12+
* **Get more information about the certification process and the schedule**.
13+
* Get to know the team behind the course.
14+
* Create your **account**.
15+
* **Sign-up to our Discord server**, and meet your classmates and us.
16+
17+
Let's get started!
18+
19+
## What to expect from this course?
20+
21+
In this course, you will:
22+
23+
* 📖 Study Model Context Protocol in **theory, design, and practice.**
24+
* 🧑‍💻 Learn to **use established MCP SDKs and frameworks**.
25+
* 💾 **Share your projects** and explore applications created by the community.
26+
* 🏆 Participate in challenges where you will **evaluate your MCP implementations against other students'.**
27+
* 🎓 **Earn a certificate of completion** by completing assignments.
28+
29+
And more!
30+
31+
At the end of this course, you'll understand **how MCP works and how to build your own AI applications that leverage external data and tools using the latest MCP standards**.
32+
33+
Don't forget to [**sign up to the course!**](https://huggingface.co/mcp-course)
34+
35+
## What does the course look like?
36+
37+
The course is composed of:
38+
39+
* _Foundational Units_: where you learn MCP **concepts in theory**.
40+
* _Hands-on_: where you'll learn **to use established MCP SDKs** to build your applications. These hands-on sections will have pre-configured environments.
41+
* _Use case assignments_: where you'll apply the concepts you've learned to solve a real-world problem that you'll choose.
42+
* _Collaborations_: We're collaborating with Hugging Face's partners to give you the latest MCP implementations and tools.
43+
44+
This **course is a living project, evolving with your feedback and contributions!** Feel free to open issues and PRs in GitHub, and engage in discussions in our Discord server.
45+
46+
After you have gone through the course, you can also send your feedback 👉 using this form [LINK TO FEEDBACK FORM]
47+
48+
## What's the syllabus?
49+
50+
Here is the **general syllabus for the course**. A more detailed list of topics will be released with each unit.
51+
52+
| Chapter | Topic | Description |
53+
| ------- | ------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
54+
| 0 | Onboarding | Set you up with the tools and platforms that you will use. |
55+
| 1 | MCP Fundamentals, Architecture and Core Concepts | Explain core concepts, architecture, and components of Model Context Protocol. Show a simple use case using MCP. |
56+
| 2 | End-to-end Use case: MCP in Action | Build a simple end-to-end MCP application that you can share with the community. |
57+
| 3 | Deployed Use case: MCP in Action | Build a deployed MCP application using a the Hugging Face ecosystem and partners' services. |
58+
| 4 | Bonus Units | Bonus units to help you get more out of the course, working with partners' libraries and services. |
59+
60+
## What are the prerequisites?
61+
62+
To be able to follow this course, you should have:
63+
64+
* Basic understanding of AI and LLM concepts
65+
* Familiarity with software development principles and API concepts
66+
* Experience with at least one programming language (Python or TypeScript examples will be shown)
67+
68+
If you don't have any of these, don't worry! Here are some resources that can help you:
69+
70+
* [LLM Course](https://huggingface.co/learn/llm-course/) will guide you through the basics of using and building with LLMs.
71+
* [Agents Course](https://huggingface.co/learn/agents-course/) will guide you through building AI agents with LLMs.
72+
73+
<Tip>
74+
75+
The above courses are not prerequisites in themselves, so if you understand the concepts of LLMs and agents, you can start the course now!
76+
77+
</Tip>
78+
79+
## What tools do I need?
80+
81+
You only need 2 things:
82+
83+
* _A computer_ with an internet connection.
84+
* An _Account_: to access the course resources and create projects. If you don't have an account yet, you can create one [here](https://huggingface.co/join) (it's free).
85+
86+
## The Certification Process
87+
88+
You can choose to follow this course _in audit mode_, or do the activities and _get one of the two certificates we'll issue_. If you audit the course, you can participate in all the challenges and do assignments if you want, and **you don't need to notify us**.
89+
90+
The certification process is **completely free**:
91+
92+
* _To get a certification for fundamentals_: you need to complete Unit 1 of the course. This is intended for students that want to get up to date with the latest trends in MCP, without the need to build a full application.
93+
* _To get a certificate of completion_: you need to complete the use case units (2 and 3). This is intended for students that want to build a full application and share it with the community.
94+
95+
## What is the recommended pace?
96+
97+
Each chapter in this course is designed **to be completed in 1 week, with approximately 3-4 hours of work per week**.
98+
99+
Since there's a deadline, we provide you a recommended pace:
100+
101+
![Recommended Pace](https://huggingface.co/datasets/mcp-course/images/resolve/main/unit0/2.png)
102+
103+
## How to get the most out of the course?
104+
105+
To get the most out of the course, we have some advice:
106+
107+
1. Join study groups in Discord: studying in groups is always easier. To do that, you need to join our discord server and verify your account.
108+
2. **Do the quizzes and assignments**: the best way to learn is through hands-on practice and self-assessment.
109+
3. **Define a schedule to stay in sync**: you can use our recommended pace schedule below or create yours.
110+
111+
![Course advice](https://huggingface.co/datasets/mcp-course/images/resolve/main/unit0/3.png)
112+
113+
## Who are we
114+
115+
About the authors:
116+
117+
### Ben Burtenshaw
118+
119+
Ben is a Machine Learning Engineer at Hugging Face who focuses building LLM applications, with post training and agentic approaches.
120+
121+
<!-- ## Acknowledgments -->
122+
123+
<!-- We would like to extend our gratitude to the following individuals and partners for their invaluable contributions and support: -->
124+
125+
<!-- TODO: @burtenshaw add contributors and partners -->
126+
127+
## I found a bug, or I want to improve the course
128+
129+
Contributions are **welcome** 🤗
130+
131+
* If you _found a bug 🐛 in a notebook_, please open an issue and **describe the problem**.
132+
* If you _want to improve the course_, you can open a Pull Request.
133+
* If you _want to add a full section or a new unit_, the best is to open an issue and **describe what content you want to add before starting to write it so that we can guide you**.
134+
135+
## I still have questions
136+
137+
Please ask your question in our discord server #mcp-course-questions.
138+
139+
Now that you have all the information, let's get on board
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Architectural Components of MCP
2+
3+
In the previous section, we discussed the key concepts and terminology of MCP. Now, let's dive deeper into the architectural components that make up the MCP ecosystem.
4+
5+
## Host, Client, and Server
6+
7+
The Model Context Protocol (MCP) is built on a client-server architecture that enables structured communication between AI models and external systems.
8+
9+
![MCP Architecture](https://huggingface.co/datasets/mcp-course/images/resolve/main/unit1/4.png)
10+
11+
The MCP architecture consists of three primary components, each with well-defined roles and responsibilities: Host, Client, and Server. We touched on these in the previous section, but let's dive deeper into each component and their responsibilities.
12+
13+
### Host
14+
15+
The **Host** is the user-facing AI application that end-users interact with directly.
16+
17+
Examples include:
18+
- AI Chat apps like OpenAI ChatGPT or Anthropic's Claude Desktop
19+
- AI-enhanced IDEs like Cursor, or integrations to tools like Continue.dev
20+
- Custom AI agents and applications built in libraries like LangChain or smolagents
21+
22+
The Host's responsibilities include:
23+
- Managing user interactions and permissions
24+
- Initiating connections to MCP Servers via MCP Clients
25+
- Orchestrating the overall flow between user requests, LLM processing, and external tools
26+
- Rendering results back to users in a coherent format
27+
28+
In most cases, users will select their host application based on their needs and preferences. For example, a developer may choose Cursor for its powerful code editing capabilities, while domain experts may use custom applications built in smolagents.
29+
30+
### Client
31+
32+
The **Client** is a component within the Host application that manages communication with a specific MCP Server. Key characteristics include:
33+
34+
- Each Client maintains a 1:1 connection with a single Server
35+
- Handles the protocol-level details of MCP communication
36+
- Acts as the intermediary between the Host's logic and the external Server
37+
38+
### Server
39+
40+
The **Server** is an external program or service that exposes capabilities to AI models via the MCP protocol. Servers:
41+
42+
- Provide access to specific external tools, data sources, or services
43+
- Act as lightweight wrappers around existing functionality
44+
- Can run locally (on the same machine as the Host) or remotely (over a network)
45+
- Expose their capabilities in a standardized format that Clients can discover and use
46+
47+
## Communication Flow
48+
49+
Let's examine how these components interact in a typical MCP workflow:
50+
51+
<Tip>
52+
53+
In the next section, we'll dive deeper into the communication protocol that enables these components with practical examples.
54+
55+
</Tip>
56+
57+
1. **User Interaction**: The user interacts with the **Host** application, expressing an intent or query.
58+
59+
2. **Host Processing**: The **Host** processes the user's input, potentially using an LLM to understand the request and determine which external capabilities might be needed.
60+
61+
3. **Client Connection**: The **Host** directs its **Client** component to connect to the appropriate Server(s).
62+
63+
4. **Capability Discovery**: The **Client** queries the **Server** to discover what capabilities (Tools, Resources, Prompts) it offers.
64+
65+
5. **Capability Invocation**: Based on the user's needs or the LLM's determination, the Host instructs the **Client** to invoke specific capabilities from the **Server**.
66+
67+
6. **Server Execution**: The **Server** executes the requested functionality and returns results to the **Client**.
68+
69+
7. **Result Integration**: The **Client** relays these results back to the **Host**, which incorporates them into the context for the LLM or presents them directly to the user.
70+
71+
A key advantage of this architecture is its modularity. A single **Host** can connect to multiple **Servers** simultaneously via different **Clients**. New **Servers** can be added to the ecosystem without requiring changes to existing **Hosts**. Capabilities can be easily composed across different **Servers**.
72+
73+
<Tip>
74+
75+
As we discussed in the previous section, this modularity transforms the traditional M×N integration problem (M AI applications connecting to N tools/services) into a more manageable M+N problem, where each Host and Server needs to implement the MCP standard only once.
76+
77+
</Tip>
78+
79+
The architecture might appear simple, but its power lies in the standardization of the communication protocol and the clear separation of responsibilities between components. This design allows for a cohesive ecosystem where AI models can seamlessly connect with an ever-growing array of external tools and data sources.
80+
81+
## Conclusion
82+
83+
These interaction patterns are guided by several key principles that shape the design and evolution of MCP. The protocol emphasizes **standardization** by providing a universal protocol for AI connectivity, while maintaining **simplicity** by keeping the core protocol straightforward yet enabling advanced features. **Safety** is prioritized by requiring explicit user approval for sensitive operations, and discoverability enables dynamic discovery of capabilities. The protocol is built with **extensibility** in mind, supporting evolution through versioning and capability negotiation, and ensures **interoperability** across different implementations and environments.
84+
85+
In the next section, we'll explore the communication protocol that enables these components to work together effectively.

0 commit comments

Comments
 (0)