微信扫码
添加专属顾问
我要投稿
谷歌CEO劈柴哥闪电行动,MCP协议成AI巨头新宠。 核心内容: 1. 谷歌CEO劈柴哥提出MCP问题,引发行业关注 2. 谷歌迅速响应,4天内完成Gemini与MCP的集成 3. MCP协议优势及在谷歌Gemini中的应用示例
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协议的分布式系统架构。
简单的说,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确实比较合理。
两者都是其领域的基础协议,处于早期发展阶段,也都具有改变技术格局的潜力。
当然,在一片支持的评论中也不乏反对的声音。
网友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协议现在是开源的,但以后怎样谷歌也拿不准。
毕竟谷歌自己刚把开源的安卓变得封闭起来。
53AI,企业落地大模型首选服务商
产品:场景落地咨询+大模型应用平台+行业解决方案
承诺:免费场景POC验证,效果验证后签署服务协议。零风险落地应用大模型,已交付160+中大型企业
2024-08-13
2024-06-13
2024-08-21
2024-09-23
2024-07-31
2024-05-28
2024-08-04
2024-04-26
2024-07-09
2024-09-17