目录
MCP介绍
2024年11月25日,Anthropic公司发布了《Introducing the Model Context Protocol》
原文如下:https://www.anthropic.com/news/model-context-protocol
Today, we're open-sourcing the Model Context Protocol (MCP), a new standard for connecting AI assistants to the systems where data lives, including content repositories, business tools, and development environments. Its aim is to help frontier models produce better, more relevant responses.
As AI assistants gain mainstream adoption, the industry has invested heavily in model capabilities, achieving rapid advances in reasoning and quality. Yet even the most sophisticated models are constrained by their isolation from data—trapped behind information silos and legacy systems. Every new data source requires its own custom implementation, making truly connected systems difficult to scale.
MCP addresses this challenge. It provides a universal, open standard for connecting AI systems with data sources, replacing fragmented integrations with a single protocol. The result is a simpler, more reliable way to give AI systems access to the data they need.
今天,我们开源了模型上下文协议(MCP),这是一个新的标准,用于将AI助手连接到数据所在系统,包括内容存储库、业务工具和开发环境。其目的是帮助前沿模型生成更好、更相关的响应。
随着AI助手获得主流采用,行业在模型能力方面进行了大量投资,实现了推理和质量的快速进步。然而,即使是最先进的模型也受限于与数据的隔离——被困在信息孤岛和遗留系统中。每个新的数据源都需要单独定制实现,使得真正互联的系统难以扩展。
MCP解决了这一挑战。它提供了一个通用的开放标准,用于将AI系统与数据源连接起来,用单一协议取代碎片化的集成。结果是,为AI系统访问所需数据提供了一种更简单、更可靠的方法。
什么是MCP
Introduction - Model Context Protocol
MCP is an open protocol that standardizes how applications provide context to LLMs. Think of MCP like a USB-C port for AI applications. Just as USB-C provides a standardized way to connect your devices to various peripherals and accessories, MCP provides a standardized way to connect AI models to different data sources and tools.
开源设计
开源仓库
Model Context Protocol · GitHub
架构
Core architecture - Model Context Protocol
MCP Host vs MCP Client
To understand the difference between an MCP host and an MCP client, it's essential to grasp the overall architecture of the Model Context Protocol (MCP). Here's a breakdown:
- MCP Host:
-
- This is the user-facing AI application or agent environment. Think of it as the main application that the user interacts with. Examples include the Claude desktop app, an IDE plugin, or any custom LLM-based application.
- The host's primary role is to connect to and utilize the capabilities of multiple MCP servers.
- Essentially, the host is the application that houses the AI that utilizes external tools and data.
- MCP Client:
-
- The client is an intermediary component that resides within the MCP host.
- Its function is to manage the secure connections between the host and individual MCP servers.
- Critically, there is one MCP client for each MCP server that the host connects to, providing isolation and security.
- Essentially the client is the connection manager for each individual server that the host is connected to.
In simpler terms:
- The host is the overall application.
- The client is the connection point to a specific server, that is contained within the host.
Therefore, the host contains one or more clients, each of which connect to a seperate server.
Key points to remember:
- MCP Host facilitates the integration of LLMs with external data sources and tools.
- The client-server architecture ensures modularity and security.
I hope this explanation is helpful.
当然,以下是对 MCP 主机和 MCP 客户端之间区别的中文翻译:
MCP 主机 (MCP Host):
- 这是面向用户的 AI 应用程序或代理环境。可以将其视为用户与之交互的主要应用程序。示例包括 Claude 桌面应用程序、IDE 插件或任何自定义的基于 LLM 的应用程序。
- 主机的主要作用是连接并利用多个 MCP 服务器的功能。
- 本质上,主机是包含使用外部工具和数据的 AI 的应用程序。
MCP 客户端 (MCP Client):
- 客户端是驻留在 MCP 主机内的中间组件。
- 其功能是管理主机和各个 MCP 服务器之间的安全连接。
- 至关重要的是,主机连接的每个 MCP 服务器都有一个 MCP 客户端,从而提供隔离和安全性。
- 本质上,客户端是主机连接的每个单独服务器的连接管理器。
简单来说:
- 主机是整体应用程序。
- 客户端是到特定服务器的连接点,包含在主机内。
因此,主机包含一个或多个客户端,每个客户端都连接到单独的服务器。
需要记住的要点:
- MCP 主机促进了 LLM 与外部数据源和工具的集成。
- 客户端-服务器架构确保了模块化和安全性。
MCP 主机和 MCP 客户端的总结,包括中文和英文:
中文总结:
- MCP(模型上下文协议) 是一种旨在简化人工智能(AI)模型与外部数据源和工具集成的协议。
- MCP 主机(MCP Host):
-
- 是用户直接交互的 AI 应用程序,例如 Claude 桌面应用或 IDE 插件。
- 负责协调和利用 LLM 以及各种外部工具和数据源。
- 通过 MCP 客户端与 MCP 服务器建立连接,从而实现与外部资源的交互。
- 是整个集成过程的中心。
- MCP 客户端(MCP Client):
-
- 是位于 MCP 主机内部的中间组件。
- 负责管理与特定 MCP 服务器的安全连接。
- 每个连接的 MCP 服务器都有一个对应的 MCP 客户端,以确保隔离和安全。
- 是主机与服务器之间的连接管理器。
- 简单来说:主机是整体应用,客户端是主机内连接具体服务器的连接点。
英文总结:
- MCP (Model Context Protocol) is a protocol designed to simplify the integration of artificial intelligence (AI) models with external data sources and tools.
- MCP Host:
-
- Is the user-facing AI application, such as the Claude desktop app or an IDE plugin.
- Is responsible for coordinating and utilizing LLMs and various external tools and data sources.
- Establishes connections with MCP servers through MCP clients, enabling interaction with external resources.
- Is the central coordinating portion of the overall system.
- MCP Client:
-
- Is an intermediary component residing within the MCP host.
- Is responsible for managing secure connections with specific MCP servers.
- Each connected MCP server has a corresponding MCP client to ensure isolation and security.
- Is the connection manager between the host and individual servers.
- Simply put: the host is the overall application, the client is the connection point to a specific server within the host.
MCP开发
官方参考文档
dev a server
For Server Developers - Model Context Protocol
dev a client
For Client Developers - Model Context Protocol
claud desktop as a host
For Claude Desktop Users - Model Context Protocol
中文站参考文档
一个中文站社区,可以自行查看
构建 MCP 客户端-Python – MCP 中文站(Model Context Protocol 中文)
其它分析文档
https://zhuanlan.zhihu.com/p/29001189476
讲解了概念,重点分析,Claud模型是如何调用function call的应用的。以下摘录自原文:
总结:模型是通过 prompt engineering,即提供所有工具的结构化描述和 few-shot 的 example 来确定该使用哪些工具。另一方面,Anthropic 肯定对 Claude 做了专门的训练(毕竟是自家协议,Claude 更能理解工具的 prompt 以及输出结构化的 tool call json 代码)
Cline集成
cline是比较流行的AI编程工具,相关介绍可以参考
https://zhuanlan.zhihu.com/p/15806278946
https://zhuanlan.zhihu.com/p/20222456593
讲解了概念,重点分析的是,一个本地SQL服务作为MCP Server提供服务的实践。
其它分析视频
MCP是啥?技术原理是什么?一个视频搞懂MCP的一切
MCP是啥?技术原理是什么?一个视频搞懂MCP的一切。Windows系统配置MCP,Cursor Cline使用MCP_哔哩哔哩_bilibili
介绍了概念、Cursor实践、如何添加nodejs、python版本的常见的 MCP Server,还介绍了一些聚合网站smithery.ai等
以下是一些概念介绍
VSCode+Cline实践
Windows实践过程中,安装nodejs遇到的问题:
npx -v npx : File C:\Program Files\nodejs\npx.ps1 cannot be loaded because running scripts is disabled on this system. For mor e information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:1 + npx -v + ~~~ + CategoryInfo : SecurityError: (:) [], PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess
解决办法:以管理员权限运行Powershell,输入命令,Set-ExecutionPolicy RemoteSigned解决以上问题;
Windsurf集成MCP Server
Github - MCP Server | Windsurf Directory
注意:
-
MCP 服务器使用 Token 进行身份验证:
-
当 MCP 服务器启动时,它会读取
GITHUB_PERSONAL_ACCESS_TOKEN
环境变量,并使用这个 token 来调用 GitHub API。 -
GitHub API 会根据这个 token 识别出你的 GitHub 账号,并允许你执行与该 token 权限相关的操作。
-