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) 是开放标准,用于连接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.stdioimport stdio_client
client = genai.Client(api_key=os.getenv("GEMINI_API_KEY"))
# Create server parameters for stdio connectionserver_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 functionasyncio.run(run())
但是,大如谷歌这样的科技巨头,做出任何决策都没那么容易。
几天前,Steven刚刚使用现在爆火的「吉卜力」风格图片解释了一下什么是MCP。
图片中展示了一个基于MCP协议的分布式系统架构。
简单的说,MCP协议可以使AI根据需求从不同的软件或者网页上获取到数据或者服务。
善于整活的网友还把劈柴哥的这个帖子也整成了「吉卜力」风。
紧跟潮流。
紧跟潮流的还有网友Adam Holt,他用漫画回复了劈柴哥。
漫画中,劈柴哥与Anthropic(MCP协议的推出者)CEO Dario Amodei微笑握手,奥特曼则站在中间,望着劈柴哥。
「为开发者而做。」Adam写道。
网友Jeffrey Emanuel还帮劈柴哥分析起了行业形势。
他表示,考虑到 Anthropic、OpenAI以及DeepSeek全都支持MCP协议,如果谷歌还不采用,将会错失应用开发的热潮。
「并且所有的Gemini模型都将不再那么有用。」他写道。
网友Kris Hansen则进一步表示,现在的MCP就相当于是1993年的HTTP。
「更多产品采用这个标准协议将会有助于所有人。」
综合来看,Kris将MCP比作1993年的HTTP确实比较合理。
两者都是其领域的基础协议,处于早期发展阶段,也都具有改变技术格局的潜力。
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
文章来自于微信公众号 “新智元”,作者 :NJ
【开源免费】ai-comic-factory是一个利用AI生成漫画的创作工具。该项目通过大语言模型和扩散模型的组合使用,可以让没有任何绘画基础的用户完成属于自己的漫画创作。
项目地址:https://github.com/jbilcke-hf/ai-comic-factory?tab=readme-ov-file
在线使用:https://aicomicfactory.app/
【开源免费】LangGPT 是一个通过结构化和模板化的方法,编写高质量的AI提示词的开源项目。它可以让任何非专业的用户轻松创建高水平的提示词,进而高质量的帮助用户通过AI解决问题。
项目地址:https://github.com/langgptai/LangGPT/blob/main/README_zh.md
在线使用:https://kimi.moonshot.cn/kimiplus/conpg00t7lagbbsfqkq0