agent-Specialization/users/jojo/data/conversations/conv_20251031_175856_358.json
2025-11-14 16:44:12 +08:00

172 lines
66 KiB
JSON
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"id": "conv_20251031_175856_358",
"title": "mcp协议是什么格式的",
"created_at": "2025-10-31T17:58:56.358605",
"updated_at": "2025-10-31T18:01:09.925111",
"messages": [
{
"role": "user",
"content": "mcp协议是什么格式的",
"timestamp": "2025-10-31T17:59:01.998055"
},
{
"role": "assistant",
"content": "我来帮您搜索一下MCP协议的相关信息了解一下它的格式。",
"timestamp": "2025-10-31T17:59:04.646773"
},
{
"role": "assistant",
"content": "",
"timestamp": "2025-10-31T17:59:04.654477",
"tool_calls": [
{
"id": "web_search:0",
"index": 0,
"type": "function",
"function": {
"name": "web_search",
"arguments": "{\"query\": \"MCP协议格式 Model Context Protocol specification\", \"max_results\": 5}"
}
}
]
},
{
"role": "tool",
"content": "{\"success\": true, \"summary\": \"🔍 搜索查询: MCP协议格式 Model Context Protocol specification\\n📅 搜索时间: 2025-10-31T17:59:13.666733\\n🎯 过滤条件: Topic: general\\n\\n📝 AI摘要:\\nThe Model Context Protocol (MCP) is an open-source standard for connecting AI applications to external systems. It uses JSON-RPC 2.0 for communication and enables integration with data sources, tools, and workflows. MCP facilitates seamless interaction between AI applications and external resources.\\n\\n---\\n\\n📊 搜索结果:\\n\\n1. Specification - Model Context Protocol MCP\\n 🔗 https://modelcontextprotocol.info/specification/\\n 📄 # Specification\\n\\n# Model Context Protocol Specification\\n\\nThe Model Context Protocol (MCP) is an open protocol that enables seamless integration between LLM applications and external data sources and t...\\n\\n2. Model Context Protocol - Wikipedia\\n 🔗 https://en.wikipedia.org/wiki/Model_Context_Protocol\\n 📄 The Model Context Protocol (MCP) is an open standard, open-sourceframework introduced by Anthropic in November 2024 to standardize the way artificial intelligence (AI) systems like large language mode...\\n\\n3. Model Context Protocol 规范2025-03-26 - MCP 中文文档\\n 🔗 https://mcp.fleeto.us/spec/\\n 📄 Model Context Protocol 规范2025-03-26 | MCP 中文文档\\n\\nMCP 中文文档\\n\\n 文档\\n 规范\\n 博客(伪架构师)\\n About\\n\\n Model Context Protocol 规范2025-03-26\\n 架构\\n 基础协议\\n 传输方式\\n 授权\\n 生命...\\n\\n4. Model Context Protocol\\n 🔗 https://modelcontextprotocol.io/\\n 📄 MCP (Model Context Protocol) is an open-source standard for connecting AI applications to external systems.Using MCP, AI applications like Claude or ChatGPT can connect to data sources (e.g. local fil...\\n\\n5. 大模型MCP协议实现原理与协议格式详解 - Ningto's Blog\\n 🔗 https://ningto.com/blog/2025/MCP%E5%AE%9E%E7%8E%B0%E5%8E%9F%E7%90%86\\n 📄 MCPModel Context Protocol模型上下文协议是由Anthropic等公司推动的开放协议旨在为大模型LLM与外部数据源、工具、上下文管理等提供标准化、可扩展的通信机制。MCP协议极大简化了AI应用与多样化外部系统的集成提升了模型的上下文感知、工具调用和多智能体协作能力。\\n\\nMCP协议的设计灵感部分来源于LSPLanguage Server Protocol和现代...\", \"filters\": {\"topic\": \"general\"}, \"query\": \"MCP协议格式 Model Context Protocol specification\", \"results\": [{\"index\": 1, \"title\": \"Specification - Model Context Protocol MCP\", \"url\": \"https://modelcontextprotocol.info/specification/\", \"content\": \"# Specification\\n\\n# Model Context Protocol Specification\\n\\nThe Model Context Protocol (MCP) is an open protocol that enables seamless integration between LLM applications and external data sources and tools. This section contains the detailed technical specifications for implementing the protocol.\\n\\n## Available Versions\\n\\nMCP is under active development. The following specifications are available:\\n\\nSpecification (Latest) Specification (Draft) [...] For implementation guides, examples, and more information, visit modelcontextprotocol.info.\", \"score\": 0.87981987, \"published_date\": \"\"}, {\"index\": 2, \"title\": \"Model Context Protocol - Wikipedia\", \"url\": \"https://en.wikipedia.org/wiki/Model_Context_Protocol\", \"content\": \"The Model Context Protocol (MCP) is an open standard, open-sourceframework introduced by Anthropic in November 2024 to standardize the way artificial intelligence (AI) systems like large language models (LLMs) integrate and share data with external tools, systems, and data sources.( MCP provides a universal interface for reading files, executing functions, and handling contextual prompts.( Following its announcement, the protocol was adopted by major AI providers, including OpenAI and Google [...] MCP defines a standardized framework for integrating AI systems with external data sources and tools.( It includes specifications for data ingestion and transformation \\\"Data transformation (computing)\\\"), contextual metadatatagging \\\"Tag (metadata)\\\"), and AI interoperability across different platforms. The protocol also supports secure, bidirectional connections between data sources and AI-powered tools.( [...] MCP enables developers to expose their data via MCP servers or to develop AI applications—referred to as MCP clients—that connect to these servers.( Key components of the protocol include a formal protocol specification and software development kits (SDKs), local MCP server support in Claude \\\"Claude (language model)\\\") Desktop applications, and an open-source repository \\\"Repository (version control)\\\") of MCP server implementations.(\\n\\nApplications\\n\\n[edit]\", \"score\": 0.8215175, \"published_date\": \"\"}, {\"index\": 3, \"title\": \"Model Context Protocol 规范2025-03-26 - MCP 中文文档\", \"url\": \"https://mcp.fleeto.us/spec/\", \"content\": \"Model Context Protocol 规范2025-03-26 | MCP 中文文档\\n\\nMCP 中文文档\\n\\n 文档\\n 规范\\n 博客(伪架构师)\\n About\\n\\n Model Context Protocol 规范2025-03-26\\n 架构\\n 基础协议\\n 传输方式\\n 授权\\n 生命周期\\n 工具\\n Ping\\n 取消功能\\n 进度\\n\\n 服务器功能\\n 提示 (Prompts)\\n Resources\\n 是一个开放协议, 为 LLM 应用与外部数据源和工具之间的无缝集成提供了可能。无论您是构建一个 AI 驱动的 IDE增强聊天界面还是创建自定义 AI 工作流MCP 提供了一种标准化方式,将 LLM 与所需的上下文连接起来。 [...] 本规范定义了基于 schema.ts 中的 TypeScript 模式的权威协议要求。\\n\\n要获取实现指南和示例请访问 modelcontextprotocol.io。\\n\\n本文档中的关键词 “MUST”、“MUST NOT”、“REQUIRED”、“SHALL”、“SHALL NOT”、“SHOULD”、“SHOULD NOT”、“RECOMMENDED”、“NOT RECOMMENDED”、“MAY” 和 “OPTIONAL” 的解释方式与 BCP 14 [RFC2119] [RFC8174] 中的描述一致,仅当它们全部以大写形式出现时适用。\\n\\n概述\\n--\\n\\nMCP 提供了一种标准化方式,帮助应用程序:\\n\\n 与语言模型共享上下文信息\\n 向 AI 系统公开工具和功能\\n 构建可组合的集成与工作流\\n\\n该协议使用 JSON-RPC 2.0 消息来建立以下对象之间的通信:\\n\\n Hosts: 发起连接的 LLM 应用\\n Clients: 在 host 应用中运行的连接器\\n Servers: 提供上下文和功能的服务 [...] MCP 从 Language Server Protocol 中获得了一些灵感后者通过一个标准化方式为整个开发工具生态系统添加编程语言支持。类似地MCP 标准化了将额外上下文和工具集成到 AI 应用生态中的方式。\\n\\n关键细节\\n\\n### 基础协议\\n\\n JSON-RPC 消息格式\\n 有状态的连接\\n 服务端和客户端的功能协商\\n\\n### 功能\\n\\n服务端可以向客户端提供以下任意功能\\n\\n Resources: 上下文和数据,供用户或 AI 模型使用\\n Prompts: 为用户提供的模板化消息和工作流\\n Tools: AI 模型可执行的功能\\n\\n客户端可以向服务端提供以下功能\\n\\n Sampling: 服务端发起的代理行为和递归的 LLM 交互\\n\\n### 额外工具\\n\\n 配置\\n 进度跟踪\\n 取消操作\\n 错误报告\\n 日志记录\\n\\n安全与信任 & 安全性\\n\\nModel Context Protocol 通过任意数据访问和代码执行路径提供了强大的功能。与这种能力相伴而来的是所有实现者必须认真考虑的重要安全性和信任问题。\\n\\n### 关键原则\", \"score\": 0.8014549, \"published_date\": \"\"}, {\"index\": 4, \"title\": \"Model Context Protocol\", \"url\": \"https://modelcontextprotocol.io/\", \"content\": \"MCP (Model Context Protocol) is an open-source standard for connecting AI applications to external systems.Using MCP, AI applications like Claude or ChatGPT can connect to data sources (e.g. local files, databases), tools (e.g. search engines, calculators) and workflows (e.g. specialized prompts)—enabling them to access key information and perform tasks.Think of MCP like a USB-C port for AI applications. Just as USB-C provides a standardized way to connect electronic devices, MCP provides a [...] What is the Model Context Protocol (MCP)? - Model Context Protocol\\n\\nSkip to main content\\n\\nModel Context Protocol home pageImage 1: light logoImage 2: dark logo\\n\\nSearch...\\n\\nCtrl K\\n\\n Blog\\n GitHub\\n\\nSearch...\\n\\nNavigation\\n\\nGet started\\n\\nWhat is the Model Context Protocol (MCP)?\\n\\nDocumentationSpecificationCommunityAbout MCP\\n\\n##### Get started\\n\\n What is MCP?\\n\\n##### About MCP\\n\\n Architecture\\n Servers\\n Clients\\n Versioning\\n\\n##### Develop with MCP [...] End-users: MCP results in more capable AI applications or agents which can access your data and take actions on your behalf when necessary.\", \"score\": 0.798077, \"published_date\": \"\"}, {\"index\": 5, \"title\": \"大模型MCP协议实现原理与协议格式详解 - Ningto's Blog\", \"url\": \"https://ningto.com/blog/2025/MCP%E5%AE%9E%E7%8E%B0%E5%8E%9F%E7%90%86\", \"content\": \"MCPModel Context Protocol模型上下文协议是由Anthropic等公司推动的开放协议旨在为大模型LLM与外部数据源、工具、上下文管理等提供标准化、可扩展的通信机制。MCP协议极大简化了AI应用与多样化外部系统的集成提升了模型的上下文感知、工具调用和多智能体协作能力。\\n\\nMCP协议的设计灵感部分来源于LSPLanguage Server Protocol和现代分布式系统的中间件思想。\\n\\n## 2. 协议分层与核心架构\\n\\nMCP协议采用典型的客户端-服务器Client-Server架构主要分为以下层次\\n\\n### 2.1 角色与分层\\n\\n Host宿主如Claude Desktop、Cursor等AI应用负责承载AI交互环境集成MCP客户端。\\n Client客户端运行于Host内部负责与MCP Server建立连接桥接宿主与外部资源。\\n Server服务器暴露工具、资源、提示等能力供Client调用。\\n\\n### 2.2 协议分层结构 [...] 1. 传输层Transport Layer\\n 支持Stdio、HTTP+SSE等多种传输方式。\\n 所有传输均基于JSON-RPC 2.0消息格式。\\n2. 协议层Protocol Layer\\n 负责消息封装、请求-响应关联、通知等高层通信模式。\\n 主要消息类型Request、Result、Error、Notification。\\n3. 功能层Feature Layer\\n 服务器端暴露Prompts提示、Resources资源、Tools工具三大能力。\\n 客户端可支持Sampling采样、Roots根目录等扩展能力。\\n4. 安全与生命周期管理层\\n 包括连接初始化、能力协商、权限控制、用户授权、会话管理等。\\n\\n## 3. 协议格式与消息结构\\n\\nMCP协议所有消息均基于JSON-RPC 2.0,核心消息类型如下:\\n\\n### 3.1 消息类型 [...] 1. 初始化Client发送`initialize`请求,协商协议版本与能力。\\n2. 能力协商双方声明支持的功能如prompts、tools、resources等。\\n3. 正常通信支持Request-Response与Notification两种模式。\\n4. 终止:任一方可关闭连接。\\n\\n### 3.3 错误处理\\n\\n 标准错误码如ParseError、InvalidRequest、MethodNotFound等与自定义错误码。\\n 错误通过Error消息返回。\\n\\n## 4. 主要协议能力与扩展\\n\\n### 4.1 服务器端能力\\n\\n Prompts结构化提示模板支持参数化与复用。\\n Resources结构化数据资源如文件、数据库、API等唯一URI标识。\\n Tools可被模型自动发现和调用的外部工具含参数校验、结果处理、错误处理等。\\n\\n### 4.2 客户端能力\\n\\n Sampling服务器可请求客户端进行LLM采样如生成文本、图片等。\\n Roots客户端可暴露文件系统根目录供服务器访问。\\n\\n### 4.3 能力协商机制\", \"score\": 0.76701033, \"published_date\": \"\"}], \"total_results\": 5}",
"timestamp": "2025-10-31T17:59:13.675161",
"tool_call_id": "web_search:0",
"name": "web_search"
},
{
"role": "assistant",
"content": "让我提取更详细的信息来了解MCP协议的具体格式",
"timestamp": "2025-10-31T17:59:15.680178"
},
{
"role": "assistant",
"content": "",
"timestamp": "2025-10-31T17:59:15.684854",
"tool_calls": [
{
"id": "extract_webpage:1",
"index": 0,
"type": "function",
"function": {
"name": "extract_webpage",
"arguments": "{\"url\": \"https://modelcontextprotocol.info/specification/\"}"
}
}
]
},
{
"role": "tool",
"content": "{\"success\": true, \"url\": \"https://modelcontextprotocol.info/specification/\", \"content\": \"🌐 网页内容 (633 字符):\\n📍 URL: https://modelcontextprotocol.info/specification/\\n==================================================\\n# Specification\\n\\n# Model Context Protocol Specification\\n\\nThe [Model Context Protocol](https://modelcontextprotocol.info) (MCP) is an open protocol that enables seamless integration between LLM applications and external data sources and tools. This section contains the detailed technical specifications for implementing the protocol.\\n\\n## Available Versions\\n\\nMCP is under active development. The following specifications are available:\\n\\n[Specification (Latest)](2024-11-05) [Specification (Draft)](draft)\\n\\nFor implementation guides, examples, and more information, visit [modelcontextprotocol.info](https://modelcontextprotocol.info).\\n==================================================\"}",
"timestamp": "2025-10-31T17:59:17.637625",
"tool_call_id": "extract_webpage:1",
"name": "extract_webpage"
},
{
"role": "assistant",
"content": "",
"timestamp": "2025-10-31T17:59:21.411153",
"tool_calls": [
{
"id": "extract_webpage:2",
"index": 0,
"type": "function",
"function": {
"name": "extract_webpage",
"arguments": "{\"url\": \"https://ningto.com/blog/2025/MCP%E5%AE%9E%E7%8E%B0%E5%8E%9F%E7%90%86\"}"
}
}
]
},
{
"role": "tool",
"content": "{\"success\": true, \"url\": \"https://ningto.com/blog/2025/MCP%E5%AE%9E%E7%8E%B0%E5%8E%9F%E7%90%86\", \"content\": \"🌐 网页内容 (7289 字符):\\n📍 URL: https://ningto.com/blog/2025/MCP%E5%AE%9E%E7%8E%B0%E5%8E%9F%E7%90%86\\n==================================================\\n[Ningto's Blog](/)\\n\\n[Blog](/blog)\\n[LLM](/blog/llm-guide)\\n[Tags](/tags)\\n[Projects](/projects)\\n[About](/about)\\n\\n\\n\\n[AI](/tags/ai)\\n[MCP](/tags/mcp)\\n[协议](/tags/协议)\\n[大模型](/tags/大模型)\\n\\n•\\n\\n* [大模型MCP协议实现原理与协议格式详解](#大模型mcp协议实现原理与协议格式详解)\\n* [1. MCP协议简介](#1-mcp协议简介)\\n* [2. 协议分层与核心架构](#2-协议分层与核心架构)\\n* [2.1 角色与分层](#21-角色与分层)\\n* [2.2 协议分层结构](#22-协议分层结构)\\n* [3. 协议格式与消息结构](#3-协议格式与消息结构)\\n* [3.1 消息类型](#31-消息类型)\\n* [示例:](#示例)\\n* [3.2 连接生命周期](#32-连接生命周期)\\n* [3.3 错误处理](#33-错误处理)\\n* [4. 主要协议能力与扩展](#4-主要协议能力与扩展)\\n* [4.1 服务器端能力](#41-服务器端能力)\\n* [4.2 客户端能力](#42-客户端能力)\\n* [4.3 能力协商机制](#43-能力协商机制)\\n* [5. 安全与信任机制](#5-安全与信任机制)\\n* [6. 典型实现与开发建议](#6-典型实现与开发建议)\\n* [7. 典型应用场景](#7-典型应用场景)\\n* [8. MCP客户端-服务端数据包交互时序图](#8-mcp客户端-服务端数据包交互时序图)\\n* [交互流程说明](#交互流程说明)\\n* [典型数据包示例](#典型数据包示例)\\n* [9. 参考文献与权威资料](#9-参考文献与权威资料)\\n\\n# 大模型MCP协议实现原理与协议格式详解\\n\\n> 本文整理自官方规范、权威技术博客、开源实现与社区资料适合AI/大模型开发者深入理解和落地实现MCP协议。引用文献见文末。\\n\\n---\\n\\n## 1. MCP协议简介\\n\\nMCPModel Context Protocol模型上下文协议是由Anthropic等公司推动的开放协议旨在为大模型LLM与外部数据源、工具、上下文管理等提供标准化、可扩展的通信机制。MCP协议极大简化了AI应用与多样化外部系统的集成提升了模型的上下文感知、工具调用和多智能体协作能力。\\n\\nMCP协议的设计灵感部分来源于LSPLanguage Server Protocol和现代分布式系统的中间件思想。\\n\\n---\\n\\n## 2. 协议分层与核心架构\\n\\nMCP协议采用典型的**客户端-服务器Client-Server架构**,主要分为以下层次:\\n\\n### 2.1 角色与分层\\n\\n* **Host宿主**如Claude Desktop、Cursor等AI应用负责承载AI交互环境集成MCP客户端。\\n* **Client客户端**运行于Host内部负责与MCP Server建立连接桥接宿主与外部资源。\\n* **Server服务器**暴露工具、资源、提示等能力供Client调用。\\n\\n### 2.2 协议分层结构\\n\\n1. **传输层Transport Layer**\\n * 支持Stdio、HTTP+SSE等多种传输方式。\\n * 所有传输均基于JSON-RPC 2.0消息格式。\\n2. **协议层Protocol Layer**\\n * 负责消息封装、请求-响应关联、通知等高层通信模式。\\n * 主要消息类型Request、Result、Error、Notification。\\n3. **功能层Feature Layer**\\n * 服务器端暴露Prompts提示、Resources资源、Tools工具三大能力。\\n * 客户端可支持Sampling采样、Roots根目录等扩展能力。\\n4. **安全与生命周期管理层**\\n * 包括连接初始化、能力协商、权限控制、用户授权、会话管理等。\\n\\n---\\n\\n## 3. 协议格式与消息结构\\n\\nMCP协议所有消息均基于JSON-RPC 2.0,核心消息类型如下:\\n\\n### 3.1 消息类型\\n\\n* **Request**带method和params字段请求响应式。\\n* **Result**:请求成功的响应。\\n* **Error**:请求失败的响应,含错误码和消息。\\n* **Notification**:单向通知,无需响应。\\n\\n#### 示例:\\n\\n```\\n\\n \\n {\\n\\n \\\"jsonrpc\\\": \\\"2.0\\\",\\n\\n \\\"id\\\": 1,\\n\\n \\\"method\\\": \\\"listResources\\\",\\n\\n \\\"params\\\": {}\\n\\n }\\n\\n \\n \\n```\\n\\n### 3.2 连接生命周期\\n\\n1. **初始化**Client发送`initialize`请求,协商协议版本与能力。\\n2. **能力协商**双方声明支持的功能如prompts、tools、resources等。\\n3. **正常通信**支持Request-Response与Notification两种模式。\\n4. **终止**:任一方可关闭连接。\\n\\n### 3.3 错误处理\\n\\n* 标准错误码如ParseError、InvalidRequest、MethodNotFound等与自定义错误码。\\n* 错误通过Error消息返回。\\n\\n---\\n\\n## 4. 主要协议能力与扩展\\n\\n### 4.1 服务器端能力\\n\\n* **Prompts**:结构化提示模板,支持参数化与复用。\\n* **Resources**结构化数据资源如文件、数据库、API等唯一URI标识。\\n* **Tools**:可被模型自动发现和调用的外部工具,含参数校验、结果处理、错误处理等。\\n\\n### 4.2 客户端能力\\n\\n* **Sampling**服务器可请求客户端进行LLM采样如生成文本、图片等。\\n* **Roots**:客户端可暴露文件系统根目录,供服务器访问。\\n\\n### 4.3 能力协商机制\\n\\n* 初始化阶段双方通过capabilities字段声明支持的能力。\\n* 仅协商成功的能力可在会话中使用。\\n\\n---\\n\\n## 5. 安全与信任机制\\n\\n* **用户授权与控制**:所有数据访问、工具调用需用户显式授权。\\n* **数据隐私**Host需获得用户同意后方可暴露数据。\\n* **工具安全**:工具调用需用户确认,描述信息需谨慎对待。\\n* **采样控制**LLM采样需用户批准服务器无法直接读取全部上下文。\\n* **OAuth2等认证机制**:支持远程服务器安全接入。\\n\\n---\\n\\n## 6. 典型实现与开发建议\\n\\n* 官方提供Python、TypeScript、Java等多语言SDK。\\n* 推荐本地进程用Stdio传输远程用HTTP+SSE均需TLS加密。\\n* 消息处理需类型安全、错误友好、超时可控。\\n* 日志、监控、健康检查、性能分析等为最佳实践。\\n* 服务器与客户端均可渐进式扩展能力,支持未来协议升级。\\n\\n---\\n\\n## 7. 典型应用场景\\n\\n* 多智能体协作与分布式Agent系统\\n* RAG检索增强生成与知识库集成\\n* 企业级AI工具链与数据治理\\n* 代码编辑器/IDE智能助手\\n* 复杂工作流自动化与多模态AI\\n\\n---\\n\\n\\n\\n---\\n\\n## 8. MCP客户端-服务端数据包交互时序图\\n\\n```\\n\\n \\n sequenceDiagram\\n\\n participant Client as MCP客户端\\n\\n participant Server as MCP服务端\\n\\n \\n\\n %% 1. 初始化\\n\\n Client->>Server: initialize Request<br/>{ protocolVersion, capabilities, ... }\\n\\n Server-->>Client: initialize Result<br/>{ protocolVersion, capabilities, ... }\\n\\n Client->>Server: initialized Notification\\n\\n \\n\\n %% 2. 正常通信\\n\\n Client->>Server: Request<br/>{ method, params, id }\\n\\n Server-->>Client: Result<br/>{ result, id }\\n\\n Server-->>Client: Notification<br/>{ method, params } %% 服务器主动推送\\n\\n \\n\\n %% 3. 错误处理\\n\\n Client->>Server: Request<br/>{ method, params, id }\\n\\n Server-->>Client: Error<br/>{ code, message, id }\\n\\n \\n\\n %% 4. 终止连接\\n\\n Client->>Server: close/断开连接\\n\\n Server-->>Client: 关闭/断开连接\\n\\n \\n \\n```\\n\\n---\\n\\n### 交互流程说明\\n\\n1. **初始化阶段**\\n\\n * 客户端发送 `initialize` 请求,声明协议版本和能力。\\n * 服务端返回 `initialize` 结果,确认协议版本和能力。\\n * 客户端发送 `initialized` 通知,表示准备好进入正常通信。\\n2. **正常通信阶段**\\n\\n * 客户端可发送各种业务 `Request`(如调用工具、获取资源等)。\\n * 服务端返回对应的 `Result`。\\n * 服务端可随时通过 `Notification` 主动推送事件(如资源变更、异步任务完成等)。\\n3. **错误处理**\\n\\n * 若请求出错,服务端返回 `Error` 消息,包含错误码和说明。\\n4. **终止连接**\\n\\n * 任一方可主动关闭连接,或因异常断开。\\n\\n---\\n\\n### 典型数据包示例\\n\\n* **Request**\\n\\n ```\\n\\n \\n { \\\"jsonrpc\\\": \\\"2.0\\\", \\\"id\\\": 1, \\\"method\\\": \\\"listResources\\\", \\\"params\\\": {} }\\n\\n \\n \\n ```\\n* **Result**\\n\\n ```\\n\\n \\n { \\\"jsonrpc\\\": \\\"2.0\\\", \\\"id\\\": 1, \\\"result\\\": { ... } }\\n\\n \\n \\n ```\\n* **Error**\\n\\n ```\\n\\n \\n { \\\"jsonrpc\\\": \\\"2.0\\\", \\\"id\\\": 1, \\\"error\\\": { \\\"code\\\": -32601, \\\"message\\\": \\\"Method not found\\\" } }\\n\\n \\n \\n ```\\n* **Notification**\\n\\n ```\\n\\n \\n { \\\"jsonrpc\\\": \\\"2.0\\\", \\\"method\\\": \\\"resourceChanged\\\", \\\"params\\\": { ... } }\\n\\n \\n \\n ```\\n\\n---\\n\\n## 9. 参考文献与权威资料\\n\\n1. [MCP官方规范](https://spec.modelcontextprotocol.io/specification/2025-03-26)\\n2. [MCP核心架构](https://modelcontextprotocol.io/docs/concepts/architecture)\\n3. [Anthropic官方博客-模型上下文协议](https://www.anthropic.com/news/model-context-protocol)\\n4. [腾讯云-一文读懂MCP](https://cloud.tencent.com/developer/article/2505540)\\n5. [Medium-MCP技术深度解析](https://medium.com/@singhrajni2210/model-context-protocol-mcp-a-technical-deep-dive-810273a34304)\\n6. [Medium-MCP综合解读](https://medium.com/@sahin.samia/understanding-the-model-context-protocol-mcp-a-comprehensive-explainer-aa0e1809a046)\\n7. [MCP官方GitHub文档](https://github.com/modelcontextprotocol/docs)\\n8. [MCP Python SDK](https://github.com/modelcontextprotocol/python-sdk)\\n9. [MCP TypeScript SDK](https://github.com/modelcontextprotocol/typescript-sdk)\\n10. [AI Engineer Summit-MCP Workshop](https://www.youtube.com/watch?v=kQmXtrmQ5Zg)\\n11. [MCP协议设计原则](https://spec.modelcontextprotocol.io/specification/2024-11-05/architecture/)\\n12. [MCP协议消息格式详解](https://spec.modelcontextprotocol.io/specification/2024-11-05/basic/)\\n13. [MCP安全与信任机制](https://spec.modelcontextprotocol.io/specification/2024-11-05/security/)\\n\\n## 上一篇文章\\n\\n[OpenAI GPT-4.1发布深度解读](/blog/2025/GPT-4.1-发布深度解读)\\n\\n## 下一篇文章\\n\\n[DeepSeek Agent MCP实践](/blog/2025/DeepSeek Agent MCP实践)\\n\\n[← 返回博客列表](/blog)\\n==================================================\"}",
"timestamp": "2025-10-31T17:59:23.338552",
"tool_call_id": "extract_webpage:2",
"name": "extract_webpage"
},
{
"role": "assistant",
"content": "根据我搜索到的信息我来为您详细解释MCP协议的格式\n\n## MCP协议格式详解\n\n**MCPModel Context Protocol模型上下文协议** 是由Anthropic等公司推动的开放协议采用 **JSON-RPC 2.0** 作为基础消息格式。\n\n### 📋 基本消息格式\n\n所有MCP消息都遵循JSON-RPC 2.0标准格式:\n\n#### 1. 请求消息Request\n```json\n{\n \"jsonrpc\": \"2.0\",\n \"id\": 1,\n \"method\": \"listResources\",\n \"params\": {}\n}\n```\n\n#### 2. 成功响应Result\n```json\n{\n \"jsonrpc\": \"2.0\",\n \"id\": 1,\n \"result\": {\n \"resources\": [...]\n }\n}\n```\n\n#### 3. 错误响应Error\n```json\n{\n \"jsonrpc\": \"2.0\",\n \"id\": 1,\n \"error\": {\n \"code\": -32601,\n \"message\": \"Method not found\"\n }\n}\n```\n\n#### 4. 通知消息Notification\n```json\n{\n \"jsonrpc\": \"2.0\",\n \"method\": \"resourceChanged\",\n \"params\": {\n \"uri\": \"file:///path/to/file\"\n }\n}\n```\n\n### 🏗️ 协议架构\n\nMCP采用分层架构\n\n1. **传输层**支持Stdio、HTTP+SSE等方式\n2. **协议层**基于JSON-RPC 2.0的消息封装\n3. **功能层**:提供三大核心能力\n - **Prompts**:结构化提示模板\n - **Resources**:数据资源(文件、数据库等)\n - **Tools**:可调用工具函数\n\n### 🔧 核心功能\n\nMCP协议支持以下主要功能\n\n- **上下文共享**在LLM应用和外部数据源之间共享信息\n- **工具调用**AI模型可以调用外部工具\n- **资源访问**:安全地访问文件、数据库等资源\n- **能力协商**:客户端和服务器协商支持的功能\n\n### 🔒 安全机制\n\n- 所有数据访问需要用户授权\n- 工具调用需要用户确认\n- 支持OAuth2等认证机制\n- 提供完整的错误处理和日志记录\n\nMCP协议就像是\"AI应用的USB-C接口\"为不同的AI系统和外部工具提供了标准化的连接方式极大简化了AI应用与多样化外部系统的集成。",
"timestamp": "2025-10-31T17:59:34.636667"
},
{
"role": "user",
"content": "这看起来和标准的openapi的toolcall没有区别",
"timestamp": "2025-10-31T18:00:23.091852"
},
{
"role": "assistant",
"content": "您说得很有道理确实从表面上看MCP的tool调用和OpenAPI的toolcall很相似都是让AI模型调用外部函数。但让我深入了解一下它们的核心区别",
"timestamp": "2025-10-31T18:00:26.355560"
},
{
"role": "assistant",
"content": "",
"timestamp": "2025-10-31T18:00:26.363373",
"tool_calls": [
{
"id": "web_search:3",
"index": 0,
"type": "function",
"function": {
"name": "web_search",
"arguments": "{\"query\": \"MCP vs OpenAPI toolcall difference comparison Model Context Protocol\", \"max_results\": 5}"
}
}
]
},
{
"role": "tool",
"content": "{\"success\": true, \"summary\": \"🔍 搜索查询: MCP vs OpenAPI toolcall difference comparison Model Context Protocol\\n📅 搜索时间: 2025-10-31T18:00:47.311046\\n🎯 过滤条件: Topic: general\\n\\n📝 AI摘要:\\nThe Model Context Protocol (MCP) is an open standard for AI systems to interact with external tools, while OpenAPI tools use established web API practices. MCP supports ongoing context and two-way interactions, unlike simple API calls.\\n\\n---\\n\\n📊 搜索结果:\\n\\n1. Model Context Protocol (MCP) vs Function Calling vs OpenAPI Tools?\\n 🔗 https://medium.com/life-with-tech/model-context-protocol-mcp-vs-function-calling-vs-openapi-tools-b95f393787ff\\n 📄 Function calling security centers on schema validation and application-level access controls. Since functions execute within the applications runtime, traditional application security practices apply...\\n\\n2. MCP vs OpenAI's OpenAPI Tools: A High-Level Comparison\\n 🔗 https://www.busybrain.pub/mcp-vs-openais-openapi-tools-a-high-level-comparison/\\n 📄 records) and keep it as part of its working context. The user can then ask follow-up questions about that data without the AI having to call the API again, unless needed. Essentially, MCP encourages a...\\n\\n3. Model Context Protocol (MCP): A comprehensive introduction for ...\\n 🔗 https://stytch.com/blog/model-context-protocol-introduction/\\n 📄 agent built with LangChain can call MCP tools easily, leveraging the growing ecosystem of MCP servers. The difference is that MCP formalizes the interface over a protocol (JSON-RPC, with metadata, etc...\\n\\n4. MCP vs APIs: When to Use Which for AI Agent Development - Tinybird\\n 🔗 https://www.tinybird.co/blog/mcp-vs-apis-when-to-use-which-for-ai-agent-development\\n 📄 The emergence of MCP also highlights the importance of designing APIs with AI consumption in mind: MCP enforces consistency that HTTP APIs lack (even with things like OpenAPI describing the interfaces...\\n\\n5. Unified Tool Integration for LLMs: A Protocol-Agnostic Approach to ...\\n 🔗 https://arxiv.org/html/2508.02979v1\\n 📄 Key Results: CPU-bound operations (native tools) achieve peak performance with thread-based concurrency (up to 8,844 calls/sec), while I/O-bound operations (OpenAPI, MCP) benefit from process-based ex...\", \"filters\": {\"topic\": \"general\"}, \"query\": \"MCP vs OpenAPI toolcall difference comparison Model Context Protocol\", \"results\": [{\"index\": 1, \"title\": \"Model Context Protocol (MCP) vs Function Calling vs OpenAPI Tools?\", \"url\": \"https://medium.com/life-with-tech/model-context-protocol-mcp-vs-function-calling-vs-openapi-tools-b95f393787ff\", \"content\": \"Function calling security centers on schema validation and application-level access controls. Since functions execute within the applications runtime, traditional application security practices apply directly.\\n\\nOpenAPI tools benefit from the mature security ecosystem surrounding web APIs, including OAuth2, API gateways, and established patterns for authentication and authorization. [...] Host applications (like Claude Desktop or AI-enhanced IDEs) that interact with users.\\n MCP clients integrated within host applications to handle server connections.\\n MCP servers that expose specific functions and data sources.\\n Transport layers supporting both local (stdio) and remote (HTTP+SSE) connections. [...] The Model Context Protocol, introduced by Anthropic in November 2024, represents a paradigm shift toward standardization. At its core, MCP is an open standard that creates a universal interface between AI applications and external data sources.\\n\\n### How MCP Works\\n\\nMCP operates on a client-server architecture inspired by the Language Server Protocol (LSP) used in development tools. The protocol defines four key components:\", \"score\": 0.8380581, \"published_date\": \"\"}, {\"index\": 2, \"title\": \"MCP vs OpenAI's OpenAPI Tools: A High-Level Comparison\", \"url\": \"https://www.busybrain.pub/mcp-vs-openais-openapi-tools-a-high-level-comparison/\", \"content\": \"records) and keep it as part of its working context. The user can then ask follow-up questions about that data without the AI having to call the API again, unless needed. Essentially, MCP encourages a paradigm where the AI accumulates and maintains useful context from tools in a session. By contrast, OpenAIs function calling doesnt natively manage long-lived resources its up to the developer to feed the model any context it should retain (often by adding it to the conversation history as [...] In summary, MCP vs. OpenAPI-based tools is not an either-or dichotomy but a trade-off between a long-term universal framework and a proven immediate toolkit. MCP shines for those building the next generation of AI assistants that need to work across many contexts and want a sustainable architecture. OpenAIs functions/plugins excel for those who want results today within the OpenAI platforms scope, leveraging the power of GPT models with minimal fuss. A technical reader should view MCP as an [...] Model Context Protocol (MCP): MCP is an open standard introduced by Anthropic in late 2024 for connecting AI models with external tools and data sources . It aims to replace the many fragmented, one-off integrations in AI applications with a single unified protocol . In Anthropics words, MCP provides a “universal, open standard” to bridge AI systems to content repositories, business tools, development environments, etc. . OpenAIs documentation even analogizes MCP to a “USB-C port for AI” a\", \"score\": 0.83742094, \"published_date\": \"\"}, {\"index\": 3, \"title\": \"Model Context Protocol (MCP): A comprehensive introduction for ...\", \"url\": \"https://stytch.com/blog/model-context-protocol-introduction/\", \"content\": \"agent built with LangChain can call MCP tools easily, leveraging the growing ecosystem of MCP servers. The difference is that MCP formalizes the interface over a protocol (JSON-RPC, with metadata, etc.), making it easier to plug into different environments, not just Python frameworks. Similarly, OpenAIs native function calling feature can be seen as handling the formatting of a function call (the model outputs a JSON function call), whereas MCP handles the execution of that call in a [...] Plugins also were mostly one-shot calls the model would call an API and get info, without a persistent connection or ongoing exchange. MCP differs in that its open and universal (not tied to one provider or interface) and it supports rich two-way interactions and continuous context. Think of ChatGPT plugins as specialized tools in a closed toolbox, whereas MCP is an open-standard toolkit that any developer or AI platform can utilize. MCPs standardized auth (especially OAuth) also means it [...] Two-Way Context: Unlike simple API calls, MCP supports maintaining context and ongoing dialogue between the model and the tool. An MCP server can provide Prompts (predefined prompt templates for certain tasks) and Resources (data context like documents) in addition to tools. This means the AI can not only “call an API” but also ingest reference data or follow complex workflows guided by the server. The protocol was designed to support rich interactions, not just one-off queries. This is\", \"score\": 0.8095324, \"published_date\": \"\"}, {\"index\": 4, \"title\": \"MCP vs APIs: When to Use Which for AI Agent Development - Tinybird\", \"url\": \"https://www.tinybird.co/blog/mcp-vs-apis-when-to-use-which-for-ai-agent-development\", \"content\": \"The emergence of MCP also highlights the importance of designing APIs with AI consumption in mind: MCP enforces consistency that HTTP APIs lack (even with things like OpenAPI describing the interfaces they expose). While OpenAPI documents existing patterns, MCP prescribes specific ones: single input schemas, deterministic execution, runtime discovery. [...] In this post I break down the technical trade-offs and share a few learnings on when to use which.\\n\\n## What We're Actually Comparing\\n\\nModel Context Protocol (MCP) is a standardized wire protocol that lets AI systems communicate with external services using natural language. Think of it as a universal adapter for tools. MCP servers wrap your existing APIs, resources and data, exposing them in a way that LLMs can discover and use autonomously during conversations and depending on the situation. [...] Rather than managing numerous API SDKs and formats, you connect to multiple MCP servers all speaking the same protocol. The model can use any tool mid-conversation, treating them like plug-and-play modules.\\n\\n### Agent Autonomy\\n\\n> MCP enables true agent autonomy: the ability to iteratively call tools, get results, and decide next steps in a loop.\", \"score\": 0.78493005, \"published_date\": \"\"}, {\"index\": 5, \"title\": \"Unified Tool Integration for LLMs: A Protocol-Agnostic Approach to ...\", \"url\": \"https://arxiv.org/html/2508.02979v1\", \"content\": \"Key Results: CPU-bound operations (native tools) achieve peak performance with thread-based concurrency (up to 8,844 calls/sec), while I/O-bound operations (OpenAPI, MCP) benefit from process-based execution with up to 3.1x improvement. All scenarios maintained 100% success rates under controlled conditions. Code reduction consistently ranges 79-86% across integration types, demonstrating significant developer productivity gains. [...] Performance Analysis: The performance differential reflects workload characteristics. Native class tools achieve highest throughput due to minimal serialization overhead, while OpenAPI and MCP tools benefit from process-based execution due to better I/O isolation and fault tolerance. Load testing reveals linear scaling for native tools up to hardware limits, with network-bound tools plateauing beyond 100 concurrent connections. Automatic fallback mechanisms handled 100% of serialization\", \"score\": 0.758958, \"published_date\": \"\"}], \"total_results\": 5}",
"timestamp": "2025-10-31T18:00:47.318711",
"tool_call_id": "web_search:3",
"name": "web_search"
},
{
"role": "assistant",
"content": "",
"timestamp": "2025-10-31T18:00:50.298998",
"tool_calls": [
{
"id": "extract_webpage:4",
"index": 0,
"type": "function",
"function": {
"name": "extract_webpage",
"arguments": "{\"url\": \"https://medium.com/life-with-tech/model-context-protocol-mcp-vs-function-calling-vs-openapi-tools-b95f393787ff\"}"
}
}
]
},
{
"role": "tool",
"content": "{\"success\": true, \"url\": \"https://medium.com/life-with-tech/model-context-protocol-mcp-vs-function-calling-vs-openapi-tools-b95f393787ff\", \"content\": \"🌐 网页内容 (21225 字符):\\n📍 URL: https://medium.com/life-with-tech/model-context-protocol-mcp-vs-function-calling-vs-openapi-tools-b95f393787ff\\n==================================================\\n[Sitemap](/sitemap/sitemap.xml)\\n\\n[Open in app](https://rsci.app.link/?%24canonical_url=https%3A%2F%2Fmedium.com%2Fp%2Fb95f393787ff&%7Efeature=LoOpenInAppButton&%7Echannel=ShowPostUnderCollection&%7Estage=mobileNavBar&source=post_page---top_nav_layout_nav-----------------------------------------)\\n\\n[Sign in](/m/signin?operation=login&redirect=https%3A%2F%2Fmedium.com%2Flife-with-tech%2Fmodel-context-protocol-mcp-vs-function-calling-vs-openapi-tools-b95f393787ff&source=post_page---top_nav_layout_nav-----------------------global_nav------------------)\\n\\n[Sign in](/m/signin?operation=login&redirect=https%3A%2F%2Fmedium.com%2Flife-with-tech%2Fmodel-context-protocol-mcp-vs-function-calling-vs-openapi-tools-b95f393787ff&source=post_page---top_nav_layout_nav-----------------------global_nav------------------)\\n\\n[## Life with Tech](https://medium.com/life-with-tech?source=post_page---publication_nav-7b1cb301bf43-b95f393787ff---------------------------------------)\\n\\n·\\n\\nLife with Tech explores how technology shapes our everyday livesfrom productivity and innovation to digital habits and future trends. Practical insights, stories, and ideas for living smarter in a connected world.”\\n\\n# Model Context Protocol (MCP) vs Function Calling vs OpenAPI Tools?\\n\\n## The Critical Differences between the three, that Every Developer must Understand : A Technical Guide\\n\\n6 min readOct 11, 2025\\n\\nBefore diving into the comparison, its crucial to understand the problem these approaches solve. Modern AI applications rarely operate in isolation. They need to fetch real-time data, interact with databases, call external APIs, and coordinate with various services. This creates what developers call the “**N×M problem**” — every AI model needs custom connectors for every external system.\\n\\nTraditional approaches required building bespoke integrations for each combination of AI model and external service. This fragmented landscape led to duplicated effort, vendor lock-in, and systems that became increasingly difficult to maintain as they scaled.\\n\\n## I. Model Context Protocol\\n\\nThe **Model Context Protocol**, introduced by **Anthropic** in November 2024, represents a paradigm shift toward standardization. At its core, MCP is an open standard that creates a universal interface between AI applications and external data sources.\\n\\n### How MCP Works\\n\\nMCP operates on a client-server architecture inspired by the **Language Server Protocol (LSP)** used in development tools. The protocol defines four key components:\\n\\n* Host applications (like Claude Desktop or AI-enhanced IDEs) that interact with users.\\n* MCP clients integrated within host applications to handle server connections.\\n* MCP servers that expose specific functions and data sources.\\n* Transport layers supporting both local (stdio) and remote (HTTP+SSE) connections.\\n\\nWhen a user asks an AI assistant a question requiring external data, the system performs a sophisticated handshake. The MCP client discovers available capabilities from connected servers, registers these tools, and maintains stateful sessions that carry context across multiple interactions.\\n\\n### The Enterprise Advantage\\n\\nWhat makes MCP particularly compelling for enterprise adoption is its approach to standardization and governance. Organizations can expose their internal systems through MCP servers, creating a unified interface that works across different AI models and applications. This eliminates the need for point-to-point integrations and provides centralized control over data access and security policies.\\n\\nEarly enterprise adopters like **Block** have embraced MCP precisely because it aligns with their commitment to open technologies that drive meaningful change. The protocols ability to maintain context across tool interactions makes it especially valuable for complex business workflows that require multiple steps and coordination between different systems.\\n\\n## II. Function Calling\\n\\n**Function calling** represents the most straightforward approach to AI tool integration. Pioneered by OpenAI and now supported across major LLM providers, function calling allows models to invoke predefined functions based on natural language inputs.\\n\\n### The Mechanics of Function Calling\\n\\nThe process is elegantly simple: developers define functions with JSON schemas specifying parameters and descriptions. When processing user queries, the model analyzes the request, determines if a function call is needed, and returns structured JSON containing the function name and arguments. The application then executes the function and feeds results back to the model.\\n\\nThis approach excels in scenarios requiring immediate responses and minimal overhead. A weather application, for instance, can register a `get_weather` function and let the model automatically determine when to call it based on user queries.\\n\\n### Strengths and Limitations\\n\\nFunction callings primary strength lies in its simplicity and low latency. Theres no protocol overhead, no server setup, and the integration happens directly within the applications runtime. This makes it ideal for single-purpose applications or scenarios where tight control over function execution is required.\\n\\nHowever, this simplicity comes with trade-offs. Function calling creates vendor-specific implementations that dont easily port between different AI providers. Each function must be redefined for different models, and theres no built-in mechanism for discovery or dynamic tool loading.\\n\\n## III. OpenAPI Tools\\n\\nOpenAPI tools take a service-oriented approach to AI integration, leveraging the mature OpenAPI Specification (OAS) 3.1 to automatically generate callable tools from existing API documentation.\\n\\n### Architecture and Implementation\\n\\nThe OpenAPI approach builds on decades of web service architecture patterns. Organizations describe their APIs using OpenAPI specifications, and agent frameworks like LangChain automatically generate tool interfaces from these specifications. This creates a bridge between the structured world of web APIs and the natural language interface of AI models.\\n\\n## Get VanshAgrawals stories in your inbox\\n\\nJoin Medium for free to get updates from this writer.\\n\\nGoogles Agent Development Kit exemplifies this approach, allowing developers to instantiate entire toolsets from OpenAPI specifications. The system automatically handles authentication, parameter validation, and HTTP request generation, abstracting away the complexity of direct API integration.\\n\\n### Enterprise Integration Benefits\\n\\nFor organizations with extensive API ecosystems, OpenAPI tools offer compelling advantages. They leverage existing API documentation, support mature security schemes like OAuth2, and integrate naturally with service mesh architectures. Microsofts Semantic Kernel demonstrates how OpenAPI integration can enable microservice architectures for AI agents, facilitating easy scalability and resource management.\\n\\n## When to Choose Each Approach\\n\\nThe decision between MCP, Function Calling, and OpenAPI Tools depends on several critical factors:\\n\\nChoose **Function Calling** When:\\n\\n* Building single-application integrations with tight latency requirements\\n* Working with a small, well-defined set of functions\\n* Requiring direct control over function execution\\n* Developing proof-of-concept or simple automation workflows\\n\\nChoose **MCP** When:\\n\\n* Building applications that need to work across multiple AI models\\n* Requiring persistent, stateful interactions with external systems\\n* Developing agent-based workflows that coordinate multiple tools\\n* Planning for cross-platform compatibility and future-proofing\\n\\nChoose **OpenAPI Tools** When:\\n\\n* Working within large enterprise environments with extensive API catalogs\\n* Requiring mature security and governance frameworks\\n* Building on existing service-oriented architectures\\n* Needing to leverage established API contracts and documentation\\n\\n## The Security and Governance Perspective\\n\\nEach approach handles security and governance differently, which can be decisive for enterprise adoption. MCP relies on host-level policies, user consent mechanisms, and sandboxing to control access to external systems. This places significant responsibility on the host application to implement proper security controls.\\n\\nFunction calling security centers on schema validation and application-level access controls. Since functions execute within the applications runtime, traditional application security practices apply directly.\\n\\nOpenAPI tools benefit from the mature security ecosystem surrounding web APIs, including OAuth2, API gateways, and established patterns for authentication and authorization.\\n\\nAs we stand at this crossroads of AI integration approaches, the path forward becomes clear: theres no single right answer, but there are definitely wrong choices for specific contexts. Understanding these nuances is what separates successful AI implementations from costly technical debt. The future belongs to those who choose wisely, implement thoughtfully, and remain adaptable to the rapid pace of change in this transformative field.\\n\\n## Disclaimer\\n\\nReference : [www.marktechpost.com](https://www.marktechpost.com/2025/10/08/model-context-protocol-mcp-vs-function-calling-vs-openapi-tools-when-to-use-each/)\\n\\nThis blog is provided for informational and educational purposes only, reflects the authors opinions at the time of writing, and does not constitute legal, financial, technical, or other professional advice. Information is offered in good faith but may include errors, omissions, or become outdated as technologies, services, and policies evolve, and all content is provided “as is” without warranties of accuracy, completeness, or fitness for a particular purpose.\\n\\nThanks for reading! 😊 We share more stories like this on **Life with Tech** — hit that *Follow* button to join our community.\\n\\n[**https://medium.com/life-with-tech**](https://medium.com/life-with-tech)\\n\\n[Mcp Server](/tag/mcp-server?source=post_page-----b95f393787ff---------------------------------------)\\n\\n[API](/tag/api?source=post_page-----b95f393787ff---------------------------------------)\\n\\n[OpenAI](/tag/openai?source=post_page-----b95f393787ff---------------------------------------)\\n\\n[Claude](/tag/claude?source=post_page-----b95f393787ff---------------------------------------)\\n\\n[Developer](/tag/developer?source=post_page-----b95f393787ff---------------------------------------)\\n\\n[## Published in Life with Tech](https://medium.com/life-with-tech?source=post_page---post_publication_info--b95f393787ff---------------------------------------)\\n\\n[29 followers](/life-with-tech/followers?source=post_page---post_publication_info--b95f393787ff---------------------------------------)\\n\\n·[Last published 17 hours ago](/life-with-tech/i-asked-chatgpt-to-rewrite-my-portfolio-the-result-mind-blowing-f4d7e7404cc1?source=post_page---post_publication_info--b95f393787ff---------------------------------------)\\n\\nLife with Tech explores how technology shapes our everyday livesfrom productivity and innovation to digital habits and future trends. Practical insights, stories, and ideas for living smarter in a connected world.”\\n\\n[## Written by VanshAgrawal](/@vanshagrawal561?source=post_page---post_author_info--b95f393787ff---------------------------------------)\\n\\n[20 followers](/@vanshagrawal561/followers?source=post_page---post_author_info--b95f393787ff---------------------------------------)\\n\\n·[56 following](/@vanshagrawal561/following?source=post_page---post_author_info--b95f393787ff---------------------------------------)\\n\\nAI Architect & Developer | Data & Research Analyst | Writing blogs about geopolitics, finance, and technology trends.\\n\\n## No responses yet\\n\\nWrite a response\\n\\n[What are your thoughts?](/m/signin?operation=register&redirect=https%3A%2F%2Fmedium.com%2Flife-with-tech%2Fmodel-context-protocol-mcp-vs-function-calling-vs-openapi-tools-b95f393787ff&source=---post_responses--b95f393787ff---------------------respond_sidebar------------------)\\n\\n## More from VanshAgrawal and Life with Tech\\n\\n[VanshAgrawal](/@vanshagrawal561?source=post_page---author_recirc--b95f393787ff----0---------------------e49f19a5_a890_40b8_b5d1_0723c66b994b--------------)\\n\\n[## Why Sam Altman Believes GPT-5 Will Create the First $1 Billion One-Person Business (Part III)](/@vanshagrawal561/why-sam-altman-believes-gpt-5-will-create-the-first-1-billion-one-person-business-part-iii-f00f38bec9d7?source=post_page---author_recirc--b95f393787ff----0---------------------e49f19a5_a890_40b8_b5d1_0723c66b994b--------------)\\n\\nSep 7\\n\\n[33](/@vanshagrawal561/why-sam-altman-believes-gpt-5-will-create-the-first-1-billion-one-person-business-part-iii-f00f38bec9d7?source=post_page---author_recirc--b95f393787ff----0---------------------e49f19a5_a890_40b8_b5d1_0723c66b994b--------------)\\n\\nIn\\n\\n[Life with Tech](https://medium.com/life-with-tech?source=post_page---author_recirc--b95f393787ff----1---------------------e49f19a5_a890_40b8_b5d1_0723c66b994b--------------)\\n\\nby\\n\\n[Arjun. S. Gaikwad](/@arjunsgaikwad?source=post_page---author_recirc--b95f393787ff----1---------------------e49f19a5_a890_40b8_b5d1_0723c66b994b--------------)\\n\\n[## The Roman Empire Fell Because of Lead Poisoning... But Not the One You Think\\n\\n### The fall of the Roman Empire is one of historys most enduring enigmas. For centuries, scholars, historians, and armchair enthusiasts have…](/life-with-tech/the-roman-empire-fell-because-of-lead-poisoning-but-not-the-one-you-think-c343e065b381?source=post_page---author_recirc--b95f393787ff----1---------------------e49f19a5_a890_40b8_b5d1_0723c66b994b--------------)\\n\\nSep 26\\n\\n[323\\n\\n4](/life-with-tech/the-roman-empire-fell-because-of-lead-poisoning-but-not-the-one-you-think-c343e065b381?source=post_page---author_recirc--b95f393787ff----1---------------------e49f19a5_a890_40b8_b5d1_0723c66b994b--------------)\\n\\nIn\\n\\n[Life with Tech](https://medium.com/life-with-tech?source=post_page---author_recirc--b95f393787ff----2---------------------e49f19a5_a890_40b8_b5d1_0723c66b994b--------------)\\n\\nby\\n\\n[TechSam](/@techsam19?source=post_page---author_recirc--b95f393787ff----2---------------------e49f19a5_a890_40b8_b5d1_0723c66b994b--------------)\\n\\n[## 💻 My Flipkart SDE-2 Interview Experience (Anonymous)\\n\\n### Category: Career · Interview · Software Engineering](/life-with-tech/my-flipkart-sde-2-interview-experience-anonymous-8dc6f77ff861?source=post_page---author_recirc--b95f393787ff----2---------------------e49f19a5_a890_40b8_b5d1_0723c66b994b--------------)\\n\\nOct 11\\n\\n[13\\n\\n1](/life-with-tech/my-flipkart-sde-2-interview-experience-anonymous-8dc6f77ff861?source=post_page---author_recirc--b95f393787ff----2---------------------e49f19a5_a890_40b8_b5d1_0723c66b994b--------------)\\n\\n[VanshAgrawal](/@vanshagrawal561?source=post_page---author_recirc--b95f393787ff----3---------------------e49f19a5_a890_40b8_b5d1_0723c66b994b--------------)\\n\\n[## The Market Calendar, They Dont Want You To See\\n\\n### Dates to buy, dates to dumpdecoded from a 19thcentury blueprint](/@vanshagrawal561/the-market-calendar-they-dont-want-you-to-see-ee2f25b9ef97?source=post_page---author_recirc--b95f393787ff----3---------------------e49f19a5_a890_40b8_b5d1_0723c66b994b--------------)\\n\\nAug 16\\n\\n[17\\n\\n1](/@vanshagrawal561/the-market-calendar-they-dont-want-you-to-see-ee2f25b9ef97?source=post_page---author_recirc--b95f393787ff----3---------------------e49f19a5_a890_40b8_b5d1_0723c66b994b--------------)\\n\\n[See all from VanshAgrawal](/@vanshagrawal561?source=post_page---author_recirc--b95f393787ff---------------------------------------)\\n\\n[See all from Life with Tech](https://medium.com/life-with-tech?source=post_page---author_recirc--b95f393787ff---------------------------------------)\\n\\n## Recommended from Medium\\n\\n[Chamuditha Kekulawala](/@ckekula?source=post_page---read_next_recirc--b95f393787ff----0---------------------3bd6e92a_0da7_4cc9_8a8f_5130af8a2791--------------)\\n\\n[## Model Context Protocol (MCP) and its limitations\\n\\n### In part 1 we got a high level understanding of what MCP is. Now lets go into more technical details: MCP provides a standardized way for…](/@ckekula/model-context-protocol-mcp-and-its-limitations-4d3c2561b206?source=post_page---read_next_recirc--b95f393787ff----0---------------------3bd6e92a_0da7_4cc9_8a8f_5130af8a2791--------------)\\n\\nMay 28\\n\\n[5](/@ckekula/model-context-protocol-mcp-and-its-limitations-4d3c2561b206?source=post_page---read_next_recirc--b95f393787ff----0---------------------3bd6e92a_0da7_4cc9_8a8f_5130af8a2791--------------)\\n\\n[Haydar Urdoğan](/@hydrurdgn?source=post_page---read_next_recirc--b95f393787ff----1---------------------3bd6e92a_0da7_4cc9_8a8f_5130af8a2791--------------)\\n\\n[## Mastering CQRS and Event Sourcing in Modern Microservices\\n\\n### How separating reads and writesand recording every change as an eventcan make your architecture more resilient and insightful.](/@hydrurdgn/mastering-cqrs-and-event-sourcing-in-modern-microservices-89100ce07a38?source=post_page---read_next_recirc--b95f393787ff----1---------------------3bd6e92a_0da7_4cc9_8a8f_5130af8a2791--------------)\\n\\nOct 12\\n\\nIn\\n\\n[ITNEXT](https://medium.com/itnext?source=post_page---read_next_recirc--b95f393787ff----0---------------------3bd6e92a_0da7_4cc9_8a8f_5130af8a2791--------------)\\n\\nby\\n\\n[Mario Bittencourt](/@mbneto?source=post_page---read_next_recirc--b95f393787ff----0---------------------3bd6e92a_0da7_4cc9_8a8f_5130af8a2791--------------)\\n\\n[## Up your AI Development Game with Spec-Driven Development\\n\\n### Spec Driven Development is new promising way to adopt AI and keep the developer in the loop. I will cover all aspects of SpecKit here.](/itnext/up-your-ai-development-game-with-spec-driven-development-f5175cf59c7c?source=post_page---read_next_recirc--b95f393787ff----0---------------------3bd6e92a_0da7_4cc9_8a8f_5130af8a2791--------------)\\n\\n6d ago\\n\\n[319\\n\\n2](/itnext/up-your-ai-development-game-with-spec-driven-development-f5175cf59c7c?source=post_page---read_next_recirc--b95f393787ff----0---------------------3bd6e92a_0da7_4cc9_8a8f_5130af8a2791--------------)\\n\\nIn\\n\\n[Level Up Coding](https://medium.com/gitconnected?source=post_page---read_next_recirc--b95f393787ff----1---------------------3bd6e92a_0da7_4cc9_8a8f_5130af8a2791--------------)\\n\\nby\\n\\n[Fareed Khan](/@fareedkhandev?source=post_page---read_next_recirc--b95f393787ff----1---------------------3bd6e92a_0da7_4cc9_8a8f_5130af8a2791--------------)\\n\\n[## Building an Agentic Deep-Thinking RAG Pipeline to Solve Complex Queries\\n\\n### Planning, Retrieval, Reflection, Critique, Synthesis and more](/gitconnected/building-an-agentic-deep-thinking-rag-pipeline-to-solve-complex-queries-af69c5e044db?source=post_page---read_next_recirc--b95f393787ff----1---------------------3bd6e92a_0da7_4cc9_8a8f_5130af8a2791--------------)\\n\\nOct 19\\n\\n[1.1K\\n\\n14](/gitconnected/building-an-agentic-deep-thinking-rag-pipeline-to-solve-complex-queries-af69c5e044db?source=post_page---read_next_recirc--b95f393787ff----1---------------------3bd6e92a_0da7_4cc9_8a8f_5130af8a2791--------------)\\n\\nIn\\n\\n[AI Mind](https://medium.com/ai-mind-labs?source=post_page---read_next_recirc--b95f393787ff----2---------------------3bd6e92a_0da7_4cc9_8a8f_5130af8a2791--------------)\\n\\nby\\n\\n[Adham Khaled](/@adhamhidawy?source=post_page---read_next_recirc--b95f393787ff----2---------------------3bd6e92a_0da7_4cc9_8a8f_5130af8a2791--------------)\\n\\n[## I Spent $200 on Claude Last Month. Then I Found GLM-4.6\\n\\n### How Z.ais new 355B parameter model delivers enterprise-grade coding at 1/7th the costand why embedded engineers like me are switching](/ai-mind-labs/i-spent-200-on-claude-last-month-then-i-found-glm-4-6-24eb7c492aa7?source=post_page---read_next_recirc--b95f393787ff----2---------------------3bd6e92a_0da7_4cc9_8a8f_5130af8a2791--------------)\\n\\nOct 14\\n\\n[462\\n\\n12](/ai-mind-labs/i-spent-200-on-claude-last-month-then-i-found-glm-4-6-24eb7c492aa7?source=post_page---read_next_recirc--b95f393787ff----2---------------------3bd6e92a_0da7_4cc9_8a8f_5130af8a2791--------------)\\n\\nIn\\n\\n[ModernReads Press](https://medium.com/inspire-otivate?source=post_page---read_next_recirc--b95f393787ff----3---------------------3bd6e92a_0da7_4cc9_8a8f_5130af8a2791--------------)\\n\\nby\\n\\n[Kajal Sharma](/@kajalsharma962591?source=post_page---read_next_recirc--b95f393787ff----3---------------------3bd6e92a_0da7_4cc9_8a8f_5130af8a2791--------------)\\n\\n[## A Gentle Introduction to MCP Servers and Clients\\n\\n### Get a gentle introduction to the standard that defines how artificial intelligence systems connect with the outside world.](/inspire-otivate/a-gentle-introduction-to-mcp-servers-and-clients-6e70ec2aef85?source=post_page---read_next_recirc--b95f393787ff----3---------------------3bd6e92a_0da7_4cc9_8a8f_5130af8a2791--------------)\\n\\nOct 3\\n\\n[30](/inspire-otivate/a-gentle-introduction-to-mcp-servers-and-clients-6e70ec2aef85?source=post_page---read_next_recirc--b95f393787ff----3---------------------3bd6e92a_0da7_4cc9_8a8f_5130af8a2791--------------)\\n\\n[See more recommendations](/?source=post_page---read_next_recirc--b95f393787ff---------------------------------------)\\n\\n[Text to speech](https://speechify.com/medium?source=post_page-----b95f393787ff---------------------------------------)\\n==================================================\"}",
"timestamp": "2025-10-31T18:00:53.158936",
"tool_call_id": "extract_webpage:4",
"name": "extract_webpage"
},
{
"role": "assistant",
"content": "您的观察非常敏锐确实从表面上看MCP的tool调用和OpenAPI的toolcall很相似但实际上它们有**本质的区别**。让我详细解释一下:\n\n## 🔍 MCP vs OpenAPI ToolCall核心差异\n\n### 1. **协议层级不同**\n- **OpenAPI ToolCall**基于HTTP的**单次请求-响应**模式\n- **MCP**基于JSON-RPC 2.0的**有状态连接**,支持**双向通信**\n\n### 2. **上下文管理能力**\n- **OpenAPI**:每次调用都是独立的,**无状态**\n- **MCP****维护会话状态**,可以累积和复用上下文信息\n\n```\nOpenAPI流程用户提问 → API调用 → 返回结果 → 结束\nMCP流程建立连接 → 能力协商 → 多轮交互 → 上下文累积 → 结束\n```\n\n### 3. **能力发现和协商**\n- **OpenAPI**需要预先知道API规范**静态配置**\n- **MCP****动态发现**服务器能力,运行时协商\n\n### 4. **交互模式**\n- **OpenAPI****单向**(客户端→服务器)\n- **MCP****双向**(客户端↔服务器),服务器可以主动推送\n\n### 5. **资源管理**\n- **OpenAPI**:只能调用函数,**不能管理资源**\n- **MCP**除了Tools还提供**Resources**和**Prompts**\n\n## 🎯 类比理解\n\n可以把它们想象成\n- **OpenAPI ToolCall** = 传统的**REST API调用**(单次请求)\n- **MCP** = **WebSocket + REST API + 资源管理**(持续连接)\n\n## 💡 实际应用场景差异\n\n| 场景 | OpenAPI | MCP |\n|-----|---------|-----|\n| 简单天气查询 | ✅ 完美适合 | ✅ 也可以 |\n| 多步骤数据分析 | ❌ 需要多次调用 | ✅ 一次连接搞定 |\n| 实时数据推送 | ❌ 不支持 | ✅ 服务器主动推送 |\n| 跨平台工具集成 | ❌ 需要适配 | ✅ 统一协议 |\n\n## 🚀 总结\n\n您说得对**如果只是简单的tool调用**两者确实很相似。但MCP的设计目标是解决**\"N×M问题\"**N个AI模型 × M个外部系统提供一个**统一的、有状态的、双向的**标准化协议而不仅仅是简单的API调用。\n\n简单说**OpenAPI是点-to-点的工具调用MCP是生态级的标准化集成方案。**",
"timestamp": "2025-10-31T18:01:09.922953"
}
],
"todo_list": null,
"metadata": {
"project_path": "/Users/jojo/Desktop/agents/正在修复中/agents/users/jojo/project",
"project_relative_path": "users/jojo/project",
"thinking_mode": true,
"total_messages": 17,
"total_tools": 10,
"status": "active"
},
"token_statistics": {
"total_input_tokens": 112218,
"total_output_tokens": 1912,
"updated_at": "2025-10-31T18:01:09.925306"
}
}