谷歌随OpenAI强势入局,劈柴4天闪电部署Gemini+MCP!
【导读】3月31日,谷歌CEO劈柴哥抛出一句「To MCP or not to MCP」,引发热议。4天后,Gemini更新API文档,正式宣布接入MCP。至此,OpenAI、谷歌、Anthropic等AI巨头全部投入「Agent协议」MCP的怀抱。
3月31日,谷歌CEO Sundar Pichai(劈柴哥)发出灵魂一问:
To MCP or not to MCP, that's the question.
(MCP还是不MCP,这是个问题。)
MCP的持续火爆,加上OpenAI在27日官宣对MCP的支持,终究还是让谷歌坐不住了。
劈柴哥让网友们给拿一拿主意。
OpenAI的工程师Steven Heidel很快回复道:「我们已经做了,现在到你们了。」
劈柴在线征求意见还不到4天,谷歌DeepMind的高级AI关系工程师Philipp Schmid,在X上宣布在Gemini API文档中添加了使用MCP的示例。
现在可以直接将MCP服务器与Gemini 模型搭配使用。
谷歌官宣支持MCP
模型上下文协议 (MCP) 是开放标准,用于连接AI应用与外部工具、数据源和系统。
MCP为模型提供了一个通用协议,以便AI模型访问上下文,例如函数(工具)、数据源(资源)或预定义的提示。
可以使用工具调用功能将模型与MCP服务器搭配使用。
如下示例,了解如何将本地MCP服务器与Gemini、Python SDK和 mcp SDK搭配使用。
import asyncioimport os from datetime
import datetime from google
import genai from google.genai
import types from mcp
import ClientSession, StdioServerParameters from mcp.client.stdio
import stdio_client
client = genai.Client(api_key=os.getenv("GEMINI_API_KEY"))
# Create server parameters for stdio connection
server_params = StdioServerParameters(command="npx", # Executable
args=["-y", "@philschmid/weather-mcp"], # Weather MCP Server
env=None, # Optional environment variables
)
async def run():
async with stdio_client(server_params) as (read, write):
async with ClientSession(read, write) as session:
# Prompt to get the weather for the current day in London.
prompt = f"What is the weather in London in {datetime.now().strftime('%Y-%m-%d')}?"
# Initialize the connection between client and server
await session.initialize()
# Get tools from MCP session and convert to Gemini Tool objects
mcp_tools = await session.list_tools()
tools = [
types.Tool(
function_declarations=[
{
"name": tool.name,
"description": tool.description,
"parameters": {
k: v
for k, v in tool.inputSchema.items()
if k not in ["additionalProperties", "$schema"]
},
}
]
)
for tool in mcp_tools.tools
]
# Send request to the model with MCP function declarations
response = client.models.generate_content(
model="gemini-2.0-flash",
contents=prompt,
config=types.GenerateContentConfig(
temperature=0,
tools=tools,
),
)
# Check for a function call
if response.candidates[0].content.parts[0].function_call:
function_call = response.candidates[0].content.parts[0].function_call
print(function_call)
# Call the MCP server with the predicted tool
result = await session.call_tool(
function_call.name, arguments=function_call.args
)
print(result.content[0].text)
# Continue as shown in step 4 of "How Function Calling Works"
# and create a user friendly response
else:
print("No function call found in the response.")
print(response.text)
# Start the asyncio event loop and run the main function
asyncio.run(run())
但是,大如谷歌这样的科技巨头,做出任何决策都没那么容易。
几天前,Steven刚刚使用现在爆火的「吉卜力」风格图片解释了一下什么是MCP。
图片中展示了一个基于MCP协议的分布式系统架构。
善于整活的网友还把劈柴哥的这个帖子也整成了「吉卜力」风。
紧跟潮流。
紧跟潮流的还有网友Adam Holt,他用漫画回复了劈柴哥。
漫画中,劈柴哥与Anthropic(MCP协议的推出者)CEO Dario Amodei微笑握手,奥特曼则站在中间,望着劈柴哥。
「为开发者而做。」Adam写道。
网友Jeffrey Emanuel还帮劈柴哥分析起了行业形势。
他表示,考虑到 Anthropic、OpenAI以及DeepSeek全都支持MCP协议,如果谷歌还不采用,将会错失应用开发的热潮。
「并且所有的Gemini模型都将不再那么有用。」他写道。
网友Kris Hansen则进一步表示,现在的MCP就相当于是1993年的HTTP。
「更多产品采用这个标准协议将会有助于所有人。」
综合来看,Kris将MCP比作1993年的HTTP确实比较合理。
两者都是其领域的基础协议,处于早期发展阶段,也都具有改变技术格局的潜力。
方面
HTTP 0.9 (1993)
MCP (2025)
版本
0.9,早期版本
最新版本,2024年推出
主要功能
传输超文本文档,支持GET方法
为AI模型提供上下文,连接数据源和工具
架构
客户端-服务器,基于TCP/IP
客户端-服务器,标准化接口
复杂性
非常简单,无头部信息
更复杂,支持实时双向通信
采用阶段
早期,刚刚开始推广
早期,工具如Zed和Replit开始集成
潜在影响
成为万维网基础,促成网络革命
可能改变AI数据集成方式,增强AI应用能力
当然,在一片支持的评论中也不乏反对的声音。
网友Han就希望谷歌自己推出一个「更强大、更轻量级的MCP进化版本」。
To MCP or not to MCP
标准化协议对于整个AI生态的构建都是至关重要的。
就像互联网需要HTTP协议奠定基础一样,AI时代同样需要像MCP这样的标准来促进互操作性和创新。
如果谷歌宣布支持MCP,那么Gemini可以作为MCP客户端,轻松连接到各种数据源和工具。
同时,谷歌也可以提供MCP服务器,让其他AI模型访问其服务,如Gmail、Google Calendar和Google Drive 。
但是,大如谷歌这样的科技巨头,做出任何决策都没那么容易。
其中重要的是,依赖外部标准可能带来的风险。
毕竟,MCP协议是由谷歌在AI领域的对手Anthropic推出和主导的。
谷歌很难影响其长期的发展方向。
虽说MCP协议现在是开源的,但以后怎样谷歌也拿不准。
参考资料:
https://x.com/sundarpichai/status/1906484930957193255
https://ai.google.dev/gemini-api/docs/function-calling?example=weather&hl=zh-cn#use_model_content_protocol_mcp
https://x.com/_philschmid/status/1908155219801694278
声明:本文转载自新智元,转载目的在于传递更多信息,并不代表本社区赞同其观点和对其真实性负责,本文只提供参考并不构成任何建议,若有版权等问题,点击这里。

游客
- 鸟过留鸣,人过留评。
- 和谐社区,和谐点评。