返回播客Claude
Claude Code 101
Claude Code 中的 MCP
Model contact protocol is an open standard that lets Claude code connect to external tools and data sources.
Model Context Protocol 是一个开放标准,让 Claude Code 能够连接到外部工具和数据源。
[music]
[music]
When you ask a question, Claude will automatically understand when it should use those tools to better understand your query.
当你提问时,Claude 会自动判断何时应该使用这些工具,以便更好地理解你的查询。
Context is one of the most important parts when working with Claude code.
在使用 Claude Code 时,context 是最重要的部分之一。
A lot of your context lives elsewhere like your databases, your productivity apps, or [music] in public repositories.
你的大量 context 存在于其他地方,比如你的数据库、生产力应用,或者 [music] 公共代码仓库中。
This is where MCP comes [music] in.
这正是 MCP 发挥作用 [music] 的地方。
First, it's important to understand the concept of tools when talking about Agentic AI.
首先,谈论 Agentic AI 时,理解工具这一概念非常重要。
Tools give agents like Claude code the ability to perform actions in order for them to better complete their tasks.
工具赋予 Claude Code 等 agent 执行操作的能力,使其能够更好地完成任务。
This is different from other AI where you just get an output back directly in text usually.
这与其他 AI 不同,其他 AI 通常只是直接以文本形式返回输出。
For example, if your team is using Linear as our project management software, you can add a Linear MCP server to bring in the details of your specific issues.
例如,如果你的团队使用 Linear 作为项目管理软件,你可以添加一个 Linear MCP 服务器,以引入特定 issue 的详细信息。
If you want to get up-to-date documentation of a dependency that you're working with, then the Context 7 MCP server will provide Claude code with that.
如果你想获取正在使用的某个依赖的最新文档,Context 7 MCP 服务器会为 Claude Code 提供这些内容。
There are also hundreds of different connectors at claude.com/connectors.
此外,在 claude.com/connectors 还有数百种不同的连接器。
You can add MCP servers with the Claude MCP add command.
你可以使用 Claude MCP add 命令添加 MCP 服务器。
There are two main types.
主要有两种类型。
HTTP servers are for remote services.
HTTP 服务器用于远程服务。
These are hosted by the service provider and connect over the network.
这些服务器由服务提供商托管,通过网络进行连接。
STDIO servers are for local processes that run on your machine.
STDIO 服务器用于在你本机上运行的本地进程。
You can manage your servers with the /mcp inside a Claude code session to see what's connected, the status, and disable servers that you don't want to use.
你可以在 Claude Code 会话中使用 /mcp 管理你的服务器,查看连接状态,并禁用不想使用的服务器。
MCP servers can be scoped in three different ways.
MCP 服务器可以以三种不同的方式设定作用域。
One, local means it's only available in the current project for you.
第一,local 表示仅在当前项目中对你可用。
Two, the user, which means it's available across all your projects.
第二,user 表示在你所有项目中均可用。
And three, project scope uses a .mcp.json file that you check into your version control, so anyone working on the code base gets the exact same servers automatically.
第三,project 作用域使用一个 .mcp.json 文件,你将其提交到版本控制中,这样所有在该代码库工作的人都会自动获得完全相同的服务器。
Now, one thing to be aware of is that MCP servers add tool definitions to your context window, even when you're not using them.
现在,有一点需要注意:MCP 服务器会将工具定义添加到你的 context 窗口中,即使你并未使用它们。
So, if you have a lot of servers configured, this eats into your available context.
因此,如果你配置了大量服务器,这会占用你的可用 context。
Run the {slash} MCP command to see what's connected and disable anything that you're not actively using or don't think that you're going to use.
运行 /mcp 命令查看已连接的服务器,并禁用任何你未在积极使用或认为不会使用的服务器。
If a tool has a CLI equivalent like GH for GitHub or AWS for AWS, the CLI is more context efficient because it doesn't add persistent tool definitions.
如果某个工具有等效的 CLI,例如 GitHub 的 gh 或 AWS 的 aws,CLI 更节省 context,因为它不会添加持久性工具定义。
You also might benefit from using a skill in this scenario.
在这种场景下,你也可能受益于使用 skill。
A skill has a name and a description that is loaded into context.
skill 有一个名称和描述,会被加载到 context 中。
Similar to MCP, when Cloud thinks it needs to use that skill, it then decides to load it into the context window, which is where you could put the command line interface tools.
与 MCP 类似,当 Claude 认为需要使用该 skill 时,会决定将其加载到 context 窗口中,你可以在其中放置命令行界面工具。
If your MCP tools exceed 10% of your context window, Cloud code will automatically switch to tool search mode, which will discover the right tools on demand, but this might not work as well since it's just not in the
如果你的 MCP 工具超过 context 窗口的 10%,Claude Code 会自动切换到工具搜索模式,按需发现合适的工具,但这种方式效果可能不如直接加载好,因为工具并不在 context 中。
[music]
[music]
Now, a quick recap.
现在来快速回顾一下。
MCP connects Cloud code to your external tools and data
MCP 将 Claude Code 连接到你的外部工具和数据
[music]
[music]
Add servers with Cloud MCP add, scope them to your project with .mcp.json so that your team gets them automatically, and keep an eye on the context usage by disabling servers [music] that you're not actively using.
使用 Claude MCP add 添加服务器,通过 .mcp.json 将其限定在你的项目范围内,让团队成员自动获得这些服务器,并通过禁用未积极使用的服务器来关注 context 的使用情况。 [music]