Daily Tech Briefing
AI 科技速览

每天 5 分钟内学习 AI。获取最新的人工智能新闻,理解其重要性,并学习如何将其应用于您的工作。

AI 快讯
Dev.to AI · 2026/7/22 01:12:55

What is the Model Context Protocol (MCP)?

AI 中文解读
MCP来了!这项技术相当于给AI模型装上了万能插头,一次连接就能打通所有数据源,彻底告别了以前每个模型和每个工具都要单独配接头的麻烦。 通俗点说,过去想让AI读取数据库、访问文件或者调用企业系统,开发者得为每个组合写一遍专用代码,就像每换一个手机都要重新配充电器一样痛苦。现在MCP制定了一个统一标准,开发者只需写一个MCP服务器来暴露数据,任何支持MCP的AI应用都能自动识别和使用,就像USB接口让不同设备都能插上电脑一样。这种设计借鉴了语言服务器协议的成功经验,让模型和数据源彻底解耦,你换模型不用改服务器,加应用也只需指向上同一个数据源。 对普通人来说,这意味着未来你用AI助手时,它能更自然地读取你电脑里的文件、公司内部的数据库,甚至直接操作你常用的软件,无需手动上传或繁琐配置,体验会流畅得多。对开发者而言,这简直是生产力的解放,再也不必为每个新模型或新数据源重写适配代码了。
<p>The Model Context Protocol (MCP) is an open standard for connecting language models to tools and data through one consistent interface, so an integration you write once keeps working across different models and host applications.</p> <p>Every time you wire an LLM into a real system, you hit the same wall. The model can reason about your data, but it cannot reach it. Your Postgres rows, your ticketing system, the file on disk that the answer actually depends on. So you write glue. A function here, a JSON schema there, a bespoke adapter for each model vendor. Then a new model ships, or a new data source appears, and you write the glue again.</p> <p>MCP exists to stop that loop.</p> <p>What problem does MCP actually solve?</p> <p>Before MCP, "give the model access to X" meant N times M work. N models, M data sources, and a custom bridge for every pair. Each bridge had its own auth story, its own way of describing what a tool does, its own error handling.</p> <p>MCP collapses that into N plus M. You write one MCP server that exposes your data source. Any MCP-capable client can talk to it. Swap the model, keep the server. Add a second app, point it at the same server. The protocol is the contract in the middle, and both sides only have to speak that contract.</p> <p>If you have used the Language Server Protocol, the shape is familiar. LSP let one language server serve many editors instead of every editor reimplementing support for every language. MCP does the same move for model context.</p> <p>How MCP's client/server model works</p> <p>MCP has three roles worth naming clearly.</p> <p>The host is the application the user interacts with. A desktop assistant, an IDE plugin, a chat UI, your own agent.</p> <p>The client lives inside the host and manages one connection to one server. If the host talks to four servers, it runs four clients.</p> <p>The server is a small program you write that exposes capabilities. A GitHub server, a filesystem server, a company-database server. A server does not track which model is on the other end. It answers protocol messages, and the same server works no matter which LLM the host is driving.</p> <p>Transport is either stdio (the host launches the server as a subprocess and talks over stdin/stdout, good for local tools) or HTTP with server-sent events for remote servers. Messages are JSON-RPC 2.0 in both cases.</p> <p>The important property: the server declares what it can do, and the host discovers those capabilities at connection time. Nothing is hardcoded on the model side.</p> <p>MCP vs raw function calling</p> <p>Function calling is a model feature. The model can emit a structured call against a schema you pass in. MCP is the transport, discovery, and reuse layer built around that feature, so the same capability works across hosts without rewiring.</p> <p>Concern Raw function calling MCP<br> Where tools are defined In your app code, per model vendor In a standalone server, once<br> Reuse across apps Copy the code into each app Point each app at the same server<br> Discovery You hardcode the tool list Host lists tools at connect time<br> Isolation Runs in your app process Server runs as a separate process with its own permissions<br> Transport Vendor SDK specific JSON-RPC over stdio or HTTP/SSE<br> Beyond actions Tools only Tools, resources, and prompts<br> Tools, resources, and prompts</p> <p>An MCP server exposes three kinds of things, and each has a distinct job when you design a server.</p> <p>Tools: actions the model can invoke</p> <p>Tools are actions the model can invoke. create_issue, run_query, send_email. They can have side effects. Each tool ships a name, a description, and a JSON Schema for its inputs. The model reads that schema and decides when and how to call.</p> <p>A tool definition looks roughly like this:</p> <p>json<br> {<br> "name": "search_orders",<br> "description": "Find orders by customer email or order id.",<br> "inputSchema"
分享
阅读原文