课程
Model Context Protocol (MCP) 入门
中级技能水平
更新时间 2026年6月
PythonArtificial Intelligence3小时11 视频34 练习2,850 经验值2,142成就证明
创建你的免费账户
继续使用 Google显示更多选项或
继续操作即表示您接受我们的《使用条款》和《隐私政策》,并同意您的数据存储在美国。
深受数千家公司学习者的喜爱
在培训团队?
企业版试用课程描述
为什么学习模型上下文协议?
大型语言模型无法访问实时数据,也无法自主执行操作,而为每个工具或 API 编写自定义代码也无法扩展。 模型上下文协议(MCP)通过一种统一、标准化的方式,让 AI 应用连接外部工具、数据和服务,从而解决这一问题——它常被称为“AI 的 USB-C 接口”。 在这门课程中,你将从零开始使用 Python 构建 MCP 服务器和客户端,并将它们连接到一个 LLM。如何构建并连接我的第一个 MCP 服务器?
你将首先学习 MCP 架构——主机、客户端和服务器——以及每个服务器都会提供的三种基本原语:工具、资源和提示。 然后你将使用 FastMCP 构建一个货币转换器服务器,添加文档字符串和类型提示,以便 LLM 能发现你的工具,并编写一个异步 Python 客户端,通过 stdio 传输列出并调用这些工具。如何为 LLM 提供实时工具和上下文?
仅有工具还不够——模型还需要数据和行为指令。 您将为只读上下文和提示添加资源,以便在输入模糊时引导模型,然后将这三个原语全部接入 OpenAI LLM,使用五步工具调用工作流,使其能够自信地回答,或在需要时请求澄清。如何将 MCP 服务器投入生产环境?
真实世界中的服务器需要的不只是顺利路径代码。 你将把基于文件的资源替换为基于数据库的查询,添加请求超时、结构化错误处理,以及安全的 API 身份验证,将密钥保留在服务器端。 最后,你将连接到一个第三方 MCP 服务器,并看到同一套客户端代码可以与任何支持该协议的服务器一起工作。先决条件
Introduction to APIs in PythonWriting Functions in Python1
The Building Blocks of MCP
Discover how MCP can make integrating AI applications with surrounding systems easier than ever before! Learn about how MCP works, how to define your own MCP tools, and build the bridge between client and server.
2
MCP-Enabled LLM Applications
Add resources and prompts to MCP servers to expose LLMs to read-only context and key instructions to alter its behavior. Get hands-on with LLMs and connect them to your MCP server so it can call tools and retrieve context.
3
Preparing MCP Servers for Production
Find out what it takes to get MCP servers into production by taking a deep-dive into databases and APIs in MCP servers, and the additional considerations that they bring. Finally, integrate third-party MCPs securely and reliably, so you don't have to recreate the wheel for your favorite integrations.
Model Context Protocol (MCP) 入门
课程完成 加入超过19百万学习者,今天就开始Model Context Protocol (MCP) 入门!
创建你的免费账户
继续使用 Google显示更多选项或
继续操作即表示您接受我们的《使用条款》和《隐私政策》,并同意您的数据存储在美国。
通过 DataCamp for Mobile 提升您的数据技能
随时随地通过我们的移动课程和每日 5 分钟编程挑战提升技能。