1.3
MCP servers: a standard plug for toolsMCP server:插工具的標準接口MCP server:接工具的标准接口
This chapter assumes you know what a tool is. If not, read Tool calling first.
讀這一章,你需要知道什麼是工具。如果不知道,先讀 Tool calling,和給 agent 設計工具。
读这一章,需要你知道什么是工具。如果不知道,先读Tool calling,以及怎么给 agent 设计工具。
The Knowledge經驗分享经验分享
In one sentence
MCP is not a new power. It is a standard plug for tools, and it brings other people's code, permissions and text into your agent.
一句話
MCP 不是新的能力。它是工具的標準插頭,會把別人的程式碼、權限和文字帶進你的 agent。
一句话
MCP 不是什么新的能力。它是工具的一个标准插头,会把别人的代码、权限和文本带进你的 agent。
For leaders
- The decision: treat every MCP server as a dependency you approve, like a library you did not write, and prefer a plain command when one does the job.
- The risk: a server brings in other people's code, their permissions, and text the model will read and obey. Its tool list can also change after you approved it. I have not tested whether a hook guards MCP tools like built-in ones.
- The cost of doing it right: a short review per server (who wrote it, what it can touch, where the credentials live) and a periodic re-read of the tool list.
- Ask the team: "Which servers are connected, who approved each, and what can each one touch?"
給主管
- 要做的決定:把每個 MCP server 當成一個要你批准的依賴,就像一個不是你寫的函式庫;如果一個普通的指令就能完成工作,優先用指令。
- 風險:server 會帶進別人的程式碼、別人的權限,以及模型會讀、也會照做的文字。它的工具清單,還可能在你批准之後改變。hook 能不能像守內建工具那樣守 MCP 工具,我沒有測過。
- 做對的成本:每個 server 做一次簡短的審查(誰寫的、能碰什麼、憑證放在哪裡),再定期重讀工具清單。
- 可以問團隊:「接了哪些 server?每個是誰批准的?每個能碰什麼?」
写给管理者
- 要拍板的事:把每个 MCP server 都当成一个要你批准的依赖,就像一个不是你写的库;如果一条普通命令就能完成任务,优先用命令。
- 风险:server 会带进来别人的代码、别人的权限,以及模型会读、会听从的文本。它的工具清单,在你批准之后也可能变。hook 能不能像管内置工具那样管 MCP 工具,我没有测过。
- 做对的代价:每个 server 做一次简短的审查(谁写的、能碰什么、凭据放在哪),再定期重读一遍工具清单。
- 可以问团队:“现在连着哪些 server?每个是谁批准的?每个能碰什么?”
The problem
An agent is only as useful as the tools it has. You may want yours to read your issue tracker, query a database, or drive a browser. Someone has to write each of those tools, and each platform (VS Code Copilot, Claude Code, Codex) has its own way to accept a tool.
Without a shared standard the work multiplies. Three platforms and three tools could need nine separate connectors. Each connector is code someone must write and keep up to date, and every new platform or tool adds a row or a column.
The Model Context Protocol (MCP) is the standard that fixes this. A tool is written once as an MCP server. A platform learns the protocol once. After that, any server works with any platform that speaks MCP. Think of a USB socket: the plug is the standard, and it says nothing about what you plug in.
Three words first
- An MCP server is a program that offers capabilities to an agent in the standard way. It can run on your machine or elsewhere.
- An MCP host is the AI application, such as VS Code. It makes one client for each server it connects to. A client holds the connection.
- A protocol is an agreed way of sending messages, so two programs written by different people can work together.
This chapter keeps one idea in view. MCP usually does not give the agent a power that it could not have (a remote service with its own sign-in is the exception: it can offer access you have no other way to). It changes how tools are plugged in. Everything in the next sections follows from that.
問題
agent 的用處,取決於它有的工具。你可能想讓它讀你的問題追蹤系統、查資料庫,或操作瀏覽器。每個工具都得有人寫,而每個平台(VS Code Copilot、Claude Code、Codex)又各有自己接收工具的方式。
沒有共同的標準,工作量就會成倍增加。三個平台加三個工具,可能需要九個各自獨立的連接器。每個連接器都是有人要寫、要持續更新的程式碼,每多一個平台或工具,就多一列或一欄。
Model Context Protocol(MCP)就是解決這個問題的標準。一個工具寫一次,成為一個 MCP server。一個平台學一次這個協定。之後,任何 server 都能配合任何支援 MCP 的平台。想想 USB 插座:插頭是標準,而它對你插上去的是什麼,一個字也沒說。
先講三個詞
- MCP server 是用標準方式向 agent 提供能力的程式。它可以跑在你的機器上,也可以跑在別處。
- MCP host 是 AI 應用程式,例如 VS Code。它對連上的每個 server,各建一個 client。client 負責握住連線。
- 協定是約定好的傳訊息的方式,讓不同人寫的兩個程式能一起工作。
這一章始終抓住一個想法。MCP 通常不會給 agent 一個它本來不可能有的能力(有自己登入機制的遠端服務是例外:它能提供你用別的辦法拿不到的存取)。它改變的是工具怎麼接上去。接下來各節說的,都由此而來。
问题
agent 有多大用处,取决于它有哪些工具。你可能想让自己的 agent 读你的问题跟踪系统、查数据库,或者操作浏览器。这些工具得有人来写,而每个平台(VS Code Copilot、Claude Code、Codex)接收工具的方式都不一样。
没有共同的标准,工作量会成倍增加。三个平台、三个工具,可能需要九个单独的连接器。每个连接器都是有人要写、要持续更新的代码,每多一个平台或工具,就多一行或一列。
Model Context Protocol(MCP)就是解决这个问题的标准。一个工具只写一次,写成一个 MCP server。一个平台只学一次这个协议。此后,任何 server 都能和任何支持 MCP 的平台配合。可以想想 USB 接口:插头是标准,它不管你插的是什么。
先说三个词
- MCP server 是一个以标准方式向 agent 提供能力的程序。它可以运行在你的机器上,也可以在别处。
- MCP host 是 AI 应用,比如 VS Code。它为每个连上的 server 建一个 client。client 负责保持连接。
- 协议是一种约定好的发消息的方式,这样不同人写的两个程序可以配合工作。
这一章始终围绕一个想法。MCP 通常不会给 agent 一个它本来拿不到的能力(带自己登录的远程服务是个例外:它能提供你没有别的办法获得的访问)。它改变的是工具怎么接上去。后面几节的内容,都是由此而来的。
How it works
What a server can offer
The protocol defines three things a server can expose. (Architecture overview)
- Tools: functions the agent can call to do something: file operations, API calls, database queries. This is the one most people mean by MCP, and it is the same kind of tool as in chapter 1.2.
- Resources: data the agent can read for context, such as file contents or database records.
- Prompts: reusable templates that help structure a conversation, such as a system prompt or few-shot examples.
The agent's side first asks the server what it has (for tools, a tools/list request), and gets back each tool's name, description and the parameters it accepts. When the model asks for a call, the host sends a tools/call to the right server and puts the answer back into the conversation as text. From the model's point of view this looks like any other tool.
Local and remote
A server can run in two ways.
- Local (stdio). The host starts the server as a program on your machine and talks to it through its standard input and output (the plain text pipes every command line program has). Typically one host uses it.
- Remote (Streamable HTTP). The server runs somewhere else and the host talks to it over ordinary web requests (HTTP), usually with sign-in. One remote server can serve many users.
The protocol is the same on both. The difference matters for safety: a local server is code that runs on your computer with your rights, while a remote one is someone else's service that you send data to.
What you take in when you plug one in
This is the point of the chapter. A server is not a feature you switch on; it is a dependency, like a library you did not write. Four things come in with it.
- Other people's code. A local server runs on your machine. VS Code's own documentation says: "Local MCP servers can run code on your machine, and tools can access external services using your permissions." (MCP servers in VS Code)
- Other people's permissions. The server acts with whatever access you gave it: your database login, your token for the issue tracker. The agent now has that access, through the server.
- Other people's words, as instructions. A server's tool descriptions are text the model reads and takes seriously. And what a tool returns (an issue body, a web page) is text from whoever wrote it. Text the model reads can contain commands for it. Chapter 4.6 is about this.
- A standing cost. Each tool's name, description and parameters are sent to the model on every call. A server with many tools you rarely use still costs tokens on every turn, and many tools make it harder for the model to choose (chapter 1.2). The protocol's own docs mention that clients with many servers can use progressive tool discovery instead of loading every tool up front. (Architecture overview) Anthropic's post Code execution with MCP names tool definitions overloading the context window as a problem, and describes loading only the tools needed, or having the agent call servers through code. I only point to them here. The size of the cost depends on how many tools you connect, so count yours.
What to check before you add one
Four questions, in the order I would ask them.
- Who wrote it, and who keeps it up to date? VS Code's advice is to review "the publisher, command or endpoint, and requested access" before you install or start a server.
- What can it touch? Prefer a server limited to what the job needs. A server for reading issues should not hold a token that can delete repositories.
- Where do the credentials live? Not in the chat and not committed to your project. VS Code warns against pasting credentials into chat or committing them.
- Can what it returns be trusted? If the text comes from outside (the public web, tickets that anyone can file), treat it as untrusted.
MCP, or just a command?
Not every tool needs a server. Many things your agent needs already exist as command-line programs: git, a test runner, a cloud CLI. An agent that can run a terminal can use them with no server at all.
| Reach for | When |
|---|---|
| A command line program | It already exists, runs locally, and its output is short and clear. Fewer moving parts |
| An MCP server | You want the same tool across several platforms, or it needs structured inputs, a discoverable list of capabilities, or sign-in to a remote service |
I lean towards the command first, because it adds less code and fewer permissions to your setup. Moving to MCP is worth it when the shared plug starts to pay for the extra dependency.
What I have not tested
Until you have tested it, do not count on a hook to protect you from an MCP tool. My own harness builds no MCP server. A company sets them up for its own environment, and some company environments forbid unofficial ones. I have not tested whether MCP tool calls pass through a hook the way built-in tool calls do, nor whether the hook sees their arguments in full. If you rely on a hook to guard MCP tools, test that first, with a harmless server.
Test your own setup
Three questions about every server you have connected:
- Do I know who wrote it and what it can touch?
- Could a command-line program do the same job?
- How many of its tools do I really use?
A zero-install check. List the tools your agent currently has (most editors show them in the chat's tools picker; check your editor's docs for where). Count them. Then ask which ones you used in the last week. The rest are cost and risk without benefit.
原理
server 能提供什麼
協定定義了 server 可以公開的三樣東西。(Architecture overview)
- Tools(工具):agent 可以呼叫來做事的函式:檔案操作、API 呼叫、資料庫查詢。大多數人說 MCP 指的就是這個,它和 Tool calling,和給 agent 設計工具 裡的工具是同一類。
- Resources(資源):agent 可以讀來當上下文的資料,例如檔案內容或資料庫紀錄。
- Prompts(提示):幫忙組織對話的可重複使用範本,例如 system prompt 或 few-shot 範例。
agent 這一邊,先問 server 有什麼(對工具來說,是一個 tools/list 請求),拿回每個工具的名字、描述和它接受的參數。模型要求一次呼叫時,host 會向對的 server 送出一個 tools/call,再把答案當文字放回對話。從模型的角度看,這和其他任何工具沒有兩樣。
本地和遠端
server 有兩種跑法。
- 本地(stdio)。host 在你的機器上把 server 當成程式啟動,透過標準輸入和輸出(每個命令列程式都有的純文字管道)跟它說話。通常是一個 host 用它。
- 遠端(Streamable HTTP)。server 跑在別處,host 透過普通的網路請求(HTTP)跟它說話,通常要登入。一個遠端 server 可以服務很多使用者。
兩種的協定是一樣的。差別在安全上很重要:本地 server 是在你的電腦上、以你的權限執行的程式碼,遠端的則是別人的服務,你要把資料送過去。
你把一個接上去,就把什麼帶進來了
這是這一章的重點。server 不是你打開的一個功能,而是一個依賴,像一個不是你寫的函式庫。它會帶進來四樣東西。
- 別人的程式碼。本地 server 在你的機器上執行。VS Code 自己的文件說:「本地 MCP server 可以在你的機器上執行程式碼,而工具可以用你的權限存取外部服務。」(MCP servers in VS Code)
- 別人的權限。server 以你給它的任何存取權行動:你的資料庫登入、你的問題追蹤系統 token。agent 現在透過 server 擁有了那些存取權。
- 別人的話,當成指令。server 的工具描述,是模型會讀、也會當真的文字。而工具回傳的(問題的內文、網頁),是寫它的人寫的文字。模型讀到的文字,可能含有給它的命令。agent 讀到的文字可能在指揮它 講的就是這個。
- 固定的成本。每個工具的名字、描述和參數,每次呼叫都會送給模型。一個有很多你很少用的工具的 server,每一輪還是要花 token,而且工具一多,模型就更難選(Tool calling,和給 agent 設計工具)。協定自己的文件提到,連了很多 server 的 client,可以用漸進式的工具探索,不必一開始就載入所有工具。(Architecture overview)Anthropic 的文章 Code execution with MCP 把工具定義塞滿上下文視窗,當成一個問題,並描述了只載入需要的工具,或讓 agent 透過程式碼呼叫 server。我在這裡只是指出它們。成本有多大,取決於你接了多少工具,所以數一數你自己的。
加一個之前要檢查什麼
四個問題,是我會問的順序。
- 誰寫的?誰持續更新它?VS Code 的建議是,安裝或啟動 server 之前,先檢視「發布者、指令或端點,以及要求的存取權」。
- 它能碰什麼?偏好只限於工作所需的 server。讀問題的 server,不該握有能刪除倉庫的 token。
- 憑證放在哪裡?不放在對話裡,也不提交進你的專案。VS Code 警告不要把憑證貼進對話,也不要提交。
- 它回傳的能信嗎?如果文字來自外面(公開的網路、任何人都能開的工單),當成不可信的輸入。
用 MCP,還是只用一個指令?
不是每個工具都需要 server。你的 agent 需要的很多東西,早就以命令列程式的形式存在了:git、測試執行器、雲端 CLI。能用終端機的 agent,完全不需要 server 就能用它們。
| 選 | 什麼時候 |
|---|---|
| 命令列程式 | 它已經存在、在本地執行,輸出又短又清楚。活動的部分更少 |
| MCP server | 你想在好幾個平台上用同一個工具,或者它需要結構化的輸入、可探索的能力清單,或登入遠端服務 |
我傾向先用指令,因為它在你的設定裡加的程式碼和權限比較少。等共用的插頭開始值得多出來的依賴時,再換成 MCP。
我沒測過的
在你測試過之前,不要指望 hook 能保護你不受 MCP 工具影響。我自己的 harness 沒有建任何 MCP server。公司會為自己的環境設定它們,有些公司環境禁止非官方的。MCP 工具呼叫會不會像內建工具呼叫那樣經過 hook,hook 看不看得到完整的參數,我沒有測過。如果你靠 hook 來守 MCP 工具,先用一個無害的 server 測一下。
測你自己的設定
對你接上的每個 server,問三個問題:
- 我知道是誰寫的、它能碰什麼嗎?
- 一個命令列程式能做同樣的工作嗎?
- 它的工具,我真正用到幾個?
一個不用安裝任何東西的檢查。列出你的 agent 目前有的工具(大多數編輯器在對話的工具選擇器裡顯示;去哪看請查你編輯器的文件)。數一數。然後問自己,過去一週用過哪些。其餘的,是有成本、有風險,卻沒有好處。
原理
server 能提供什么
协议定义了 server 可以对外提供的三样东西。(Architecture overview)
- 工具(Tools):agent 可以调用来做事的函数:文件操作、API 调用、数据库查询。多数人说 MCP,指的就是这个,它和Tool calling,以及怎么给 agent 设计工具里的工具是同一种。
- 资源(Resources):agent 可以读来当上下文的数据,比如文件内容或数据库记录。
- 提示(Prompts):可复用的模板,帮助组织一次对话,比如系统 prompt 或少样本示例。
agent 这一侧先问 server 有什么(对工具来说,是一个 tools/list 请求),拿回每个工具的名字、描述和它接受的参数。模型要求调用时,host 会向对应的 server 发一个 tools/call,并把答案作为文本放回对话。从模型的角度看,这和别的工具没什么两样。
本地和远程
server 有两种运行方式。
- 本地(stdio)。host 在你的机器上把 server 作为一个程序启动,通过它的标准输入和输出(每个命令行程序都有的纯文本管道)和它通信。通常只有一个 host 在用它。
- 远程(Streamable HTTP)。server 运行在别的地方,host 通过普通的网络请求(HTTP)和它通信,通常要登录。一个远程 server 可以服务很多用户。
两种方式的协议是一样的。区别对安全很要紧:本地 server 是以你的权限在你电脑上运行的代码,而远程 server 是别人的服务,你要把数据发给它。
接上一个,你就把什么带了进来
这是本章的重点。server 不是一个你打开的功能;它是一个依赖,像一个不是你写的库。随它而来的有四样东西。
- 别人的代码。本地 server 运行在你的机器上。VS Code 自己的文档说:“本地 MCP server 可以在你的机器上运行代码,工具可以用你的权限访问外部服务。”(MCP servers in VS Code)
- 别人的权限。server 以你给它的任何访问权限行事:你的数据库登录、你的问题跟踪系统的 token。agent 现在通过这个 server,拥有了这些权限。
- 别人的话,变成了指令。server 的工具描述,是模型会读并当真的文本。而工具返回的内容(一个 issue 的正文、一个网页),是写它的人写的文本。模型读到的文本里,可能含有给它的命令。agent 读到的文字可能在指挥它讲的就是这件事。
- 一笔固定的开销。每个工具的名字、描述和参数,每次调用都要发给模型。一个有很多工具、你却很少用的 server,每一轮照样花 token,工具一多,模型也更难选(Tool calling,以及怎么给 agent 设计工具)。协议自己的文档提到,连了很多 server 的 client,可以用渐进式的工具发现,而不是一开始就把所有工具都加载进来。(Architecture overview)Anthropic 的文章 Code execution with MCP 把工具定义撑爆上下文窗口当作一个问题,并介绍了只加载所需工具,或者让 agent 通过代码来调用 server 的办法。这里我只是指个路。这笔开销有多大,取决于你连了多少工具,所以数一数你自己的。
加之前要检查什么
四个问题,按我会问的顺序。
- 谁写的,谁在持续更新? VS Code 的建议是,在安装或启动 server 之前,先审查“发布者、命令或端点,以及它请求的访问权限”。
- 它能碰什么? 优先选只限于任务所需的 server。一个读 issue 的 server,不该拿着一个能删仓库的 token。
- 凭据放在哪? 不要放在对话里,也不要提交进你的项目。VS Code 警告过,不要把凭据贴进对话,也不要提交。
- 它返回的东西可信吗? 如果文本来自外部(公开的网页、任何人都能提的工单),就当成不可信的。
用 MCP,还是一条命令就够?
不是每个工具都需要 server。agent 需要的很多东西,本来就以命令行程序的形式存在:git、测试运行器、云平台的命令行工具。能用终端的 agent,不需要任何 server 就能用上它们。
| 选 | 什么时候 |
|---|---|
| 命令行程序 | 它已经有了,在本地运行,输出又短又清楚。活动部件更少 |
| MCP server | 你想在多个平台上用同一个工具,或者它需要结构化的输入、可发现的能力清单,或者要登录一个远程服务 |
我倾向于先用命令,因为它给你的配置加进来的代码和权限都更少。等共用的插头开始值回多出来的那个依赖,再换成 MCP。
我没测过的
在你测过之前,别指望 hook 能保护你不受 MCP 工具的影响。我自己的 harness 没有搭任何 MCP server。公司会为自己的环境配置它们,有些公司的环境还禁止非官方的 server。MCP 工具调用是不是像内置工具调用那样经过 hook,hook 能不能看到它们的完整参数,我没有测过。如果你靠 hook 来守 MCP 工具,先用一个无害的 server 测一下。
测一测你自己的配置
对你连上的每个 server,问三个问题:
- 我知道它是谁写的、能碰什么吗?
- 命令行程序能做同样的事吗?
- 它的工具里,我真正用到的有几个?
一个不用安装任何东西的检查。列出你的 agent 现在有的工具(多数编辑器在对话的工具选择器里显示;去哪找请查你编辑器的文档)。数一数。然后问问哪些是你上周用过的。其余的就是有成本、有风险,却没有收益。
Costs and traps
More plugs, more attack surface. Each server is a path for outside text and for outside code to reach your agent. A server you added to try something and forgot is still there.
"Official" does not mean safe for you. A server published by a respected company is still given your credentials and still returns text from other people.
A server's tool list can change. The protocol lets a server tell the client that its tools changed. A tool that was fine when you reviewed it may not be the one you have next month. A server can also change a tool's description after you approved it, and the description is text the model obeys (this kind of attack is often called a rug pull or tool poisoning; chapter 4.6 covers the idea). Re-read the list now and then, and pin the version of a server where you can.
A shared standard is not shared behavior. Platforms differ in which parts of the protocol they support, in how they ask for approval, and in where they store the settings. Check the current documentation for yours.
代價和陷阱
插頭越多,被攻擊的面就越大。每個 server 都是外面的文字和外面的程式碼,通向你的 agent 的一條路。你為了試試而加、後來忘了的 server,還在那裡。
「官方」不代表對你安全。受人敬重的公司發布的 server,一樣會拿到你的憑證,也一樣會回傳別人寫的文字。
server 的工具清單可能變。協定讓 server 可以通知 client,它的工具變了。你審查時沒問題的工具,下個月可能就不是你手上這個了。server 還可以在你批准之後改工具的描述,而描述是模型會照做的文字(這種攻擊常被叫做 rug pull 或 tool poisoning;agent 讀到的文字可能在指揮它 講了這個想法)。不時重讀清單,能固定 server 的版本就固定。
共同的標準,不等於共同的行為。各平台支援協定的哪些部分、怎麼要求批准、設定存在哪裡,都不同。請查你的平台目前的文件。
代价和坑
插头越多,攻击面越大。每个 server 都是外部文本和外部代码通向你的 agent 的一条路。你为了试点东西加上、后来又忘了的 server,仍然在那里。
“官方”不等于对你安全。一个受人尊敬的公司发布的 server,仍然会拿到你的凭据,仍然会返回别人的文本。
server 的工具清单会变。协议允许 server 告诉 client,它的工具变了。你审查时没问题的工具,下个月可能就不是那一个了。server 还可以在你批准之后改某个工具的描述,而描述是模型会听从的文本(这类攻击常被叫作 rug pull 或工具投毒;agent 读到的文字可能在指挥它讲了这个想法)。时不时重读一遍清单,能固定 server 的版本就固定。
共用标准不等于行为一致。各平台支持协议的哪些部分、怎么请求审批、把设置存在哪里,都不一样。请查你所用平台的当前文档。
What the industry says Industry practice
- The protocol's own docs describe MCP as a protocol for context exchange, and say it "does not dictate how AI applications use LLMs or manage the provided context". The host decides what to load and how to ask you. (Architecture overview)
- VS Code treats servers as code to review: look at the publisher and the access requested, and approve only actions you understand. (MCP servers in VS Code)
The two agree on the split of jobs: the protocol makes plugging in easy, and deciding what to plug in is still yours.
業界怎麼說 業界做法
- 協定自己的文件把 MCP 描述成交換上下文的協定,並說它「不規定 AI 應用程式怎麼使用 LLM,或怎麼管理提供的上下文」。載入什麼、怎麼問你,由 host 決定。(Architecture overview)
- VS Code 把 server 當成要審查的程式碼:看發布者和要求的存取權,只批准你看得懂的動作。(MCP servers in VS Code)
兩者在分工上一致:協定讓接上去變容易,而決定接什麼,仍然是你的事。
业界怎么说 业界做法
- 协议自己的文档把 MCP 描述为一个交换上下文的协议,并说它“不规定 AI 应用如何使用 LLM,也不规定如何管理所提供的上下文”。加载什么、怎么问你,由 host 决定。(Architecture overview)
- VS Code 把 server 当成要审查的代码:看发布者和请求的访问权限,只批准你理解的操作。(MCP servers in VS Code)
两者对分工的看法一致:协议让接入变容易,而决定接入什么,仍然是你的事。
When to delete it Industry practice
Remove a server when you stop using its tools, or when a plain command does the job. The caution also loosens if a platform starts to sandbox servers by default, so a bad one cannot do much harm. I would still check publisher and access before adding one.
什麼時候可以刪掉 業界做法
你不再用某個 server 的工具,或者一個普通指令就能做同樣的事,就把它移除。如果平台開始預設把 server 放進沙箱,讓壞的 server 做不了太大的壞事,這份謹慎也會放鬆。我仍然會在加之前,先檢查發布者和存取權。
什么时候可以删掉 业界做法
不再用某个 server 的工具了,或者一条普通命令就能完成任务了,就把它移除。如果平台开始默认给 server 加沙箱,让坏的 server 干不了多大的坏事,这份谨慎也可以放松一点。我还是会在添加之前检查发布者和访问权限。
Try it on your own setup
No harness needed. Open your agent in your own repository and paste:
Find every MCP server configured for this project or editor (look in the editor and project settings and any MCP config files). For each one, tell me: who publishes it, whether it runs locally or remotely, what credentials it uses and where they are stored, how many tools it exposes, and whether a plain command-line program could do the same job. Flag any credential stored in a committed file. Do not print secret values, and do not change any files.在你自己的環境試試
不用裝 harness。在你自己的倉庫裡打開 agent,貼上:
找出為這個專案或編輯器設定的每個 MCP server(看編輯器和專案的設定,以及任何 MCP 設定檔)。每一個都告訴我:誰發布的、在本地還是遠端執行、用什麼憑證、憑證存在哪裡、公開幾個工具,以及一個命令列程式能不能做同樣的工作。標出任何存在已提交檔案裡的憑證。不要印出機密的值,也不要改任何檔案。在你自己的环境里试试
不用装 harness。在你自己的仓库里打开 agent,粘贴:
找出为这个项目或编辑器配置的每一个 MCP server(看编辑器和项目的设置,以及所有 MCP 配置文件)。每一个,告诉我:谁发布的、在本地还是远程运行、用什么凭据以及存在哪里、暴露了多少个工具、一个普通的命令行程序能不能做同样的事。把存在已提交文件里的凭据标出来。不要打印任何密钥的值,也不要修改任何文件。Go deeper
- Model Context Protocol: Architecture overview
- VS Code docs: MCP servers in VS Code
- Anthropic: Code execution with MCP
延伸閱讀
- Model Context Protocol:Architecture overview
- VS Code 文件:MCP servers in VS Code
- Anthropic:Code execution with MCP
延伸阅读
- Model Context Protocol:Architecture overview
- VS Code 文档:MCP servers in VS Code
- Anthropic:Code execution with MCP
You can stop here: that is the whole idea. The next part shows where it runs, so you can look inside.讀到這裡就夠了,這就是整個想法。下一部分告訴你它在哪裡運行,可以進去看看。读到这里就够了,核心思路就是这些。下一部分告诉你它在哪里跑,可以进去看看。
In my practice (Copilot Harness)實作实战
Copilot Harness is my open-source harness for VS Code Copilot.
Repository: https://github.com/Smars-Bin-Hu/copilot-agentic-harness
Get started: clone it, open it in VS Code, and type /harness-rookie-get-me-ready in Copilot Chat. You need Python 3.9 or later and git.
Copilot Harness 是我開源的 VS Code Copilot harness。
倉庫: https://github.com/Smars-Bin-Hu/copilot-agentic-harness
開始:clone 下來,用 VS Code 打開,在 Copilot Chat 裡輸入 /harness-rookie-get-me-ready。需要 Python 3.9 以上和 git。
Copilot Harness 是我开源的 VS Code Copilot harness。
仓库: https://github.com/Smars-Bin-Hu/copilot-agentic-harness
上手:把仓库 clone 下来,用 VS Code 打开,在 Copilot Chat 里输入 /harness-rookie-get-me-ready。需要 Python 3.9 及以上版本和 git。
Explore it in the harness
My harness gives the agent three kinds of tools: the built-in ones, its own command line, and optionally MCP. It builds no MCP server itself. The harness can show you where MCP would plug in and how the other tools are sorted, with the real files. After the setup above, type:
/harness-rookie-wondering I have read the chapter "MCP servers: a standard plug for tools". Teach me the three kinds of tools in this harness and where MCP fits. Open the real files with me, and show me how tool names are sorted into kinds.It teaches one small piece at a time, stops to ask if you are following, and opens the files with you.
在 harness 裡探索
我的 harness 給 agent 三種工具:內建的、它自己的命令列,以及可選的 MCP。它本身沒有建任何 MCP server。harness 可以帶著真實的檔案,讓你看 MCP 會接在哪裡,以及其他工具是怎麼分類的。照上面的說明準備好之後,輸入:
/harness-rookie-wondering 我讀完了「MCP server:插工具的標準接口」這一章。請教我這個 harness 的三種工具,以及 MCP 接在哪裡。帶我打開真實的檔案,讓我看工具名稱是怎麼分成幾類的。它一次教一小塊,停下來確認你跟得上,然後和你一起打開檔案。
在 harness 里探索
我的 harness 给 agent 三类工具:内置的、它自己的命令行工具,以及可选的 MCP。它自己没有搭任何 MCP server。harness 可以带你看 MCP 会接在哪里、其他工具是怎么分类的,配上真实的文件。按上面的说明准备好之后,输入:
/harness-rookie-wondering 我读完了“MCP server:接工具的标准接口”这一章。请教我这个 harness 里的三类工具,以及 MCP 放在哪里。带我打开真实的文件,让我看工具名是怎么分到各类里的。它一次只教一小块,停下来确认你跟上了,再和你一起打开文件。