Google发布可机器读取的开发者知识API和MCP Server,支持Firebase、Cloud、Android等官方文档实时检索,AI助手可直接接入权威文档上下文。
如果你在 Google Cloud 上构建 AI Agent 或开发者工具,别再依赖脆弱的网页抓取,也别再和过时的 LLM 训练数据截止日期较劲了。
借助 Google Developer Knowledge API 生态,你可以更快、更智能、更自信地进行开发。这套生态包括 gcloud CLI 界面、官方 Agent Skill、API Explorer 和多语言客户端库。无论你是在命令行终端中操作、向 AI Agent 提问、交互式测试请求,还是在编写生产环境软件,我们的工具都能为你提供 Google 官方文档。
Developer Knowledge API 是 Google 官方提供的程序化开发者文档权威数据源,涵盖 Google Cloud、Firebase、Android 等内容。它专门为现代 AI Agent、IDE 扩展程序和自动化工作流设计,用结构化 API 取代了脆弱的网页抓取,提供新鲜的 Markdown 格式文档。
通过提供语义搜索和关键词搜索、智能文档分块以及基于检索的问答能力,该 API 确保你的 Agent 和开发者工具始终保持准确且 token 高效。
Developer Knowledge API 会频繁建立索引,以确保可预测的检索、新鲜的文档,以及上游更新与 Agent 访问之间的最小延迟。
通过 Developer Knowledge API 接口,开发者和 AI Agent 可以在终端、IDE 和后端代码库中发现、检索并综合基于 Google 官方文档的答案。
Developer Knowledge API 的 gcloud CLI 界面将官方文档搜索、检索和基于检索的问答集成到你的命令行环境中。它预装在 Cloud Shell 中,在 Linux、macOS 和 Windows 的标准 Google Cloud SDK 安装中无需额外插件或配置即可使用。
主要能力和命令:
answer-query:在终端中获取基于检索的答案。documents search-chunks:跨 Google 文档搜索文档片段和分块。documents describe:检索特定文档的元数据和内容。# Get grounded answers
gcloud developer-knowledge answer-query --query="How do I create a BigQuery dataset?"
# Search document chunks
gcloud developer-knowledge documents search-chunks --query="Firestore transactions"
# Retrieve metadata and content for a specific document
gcloud developer-knowledge documents describe "documents/docs.cloud.google.com/storage/docs/creating-buckets"
# Troubleshoot an error trace by piping it directly into the answer-query command
gcloud developer-knowledge answer-query --query="$(cat error.txt)"
要开始使用 gcloud CLI,请参阅 gcloud CLI 快速入门。
Developer Knowledge Agent Skill 在 AI 编码助手和 Google 文档生态之间建立了链接,使自主工具能够访问最新的技术规范。
searchDocumentChunks 检查代码和文档分块,再使用 documents.get 获取完整的 Markdown 页面,或使用 answerQuery 提供基于检索的答案。在终端中运行以下 CLI 辅助命令来配置 Skill:
npx skills add google/skills --skill retrieving-developer-knowledge
此命令在你的项目中安装 Developer Knowledge Agent Skill。该 Skill 指导你的助手如何使用 Developer Knowledge MCP Server(或使用 curl 回退到 REST API)。
要在 IDE 中连接 MCP Server,或配置 Application Default Credentials 或 API Key 身份验证,请参阅连接到 Developer Knowledge MCP Server。
客户端库让你可以将文档检索、搜索和基于检索的答案生成嵌入到生产系统、自动化 CI/CD 流水线和企业知识机器人中。
AnswerQuery、SearchDocumentChunks、GetDocument 和 BatchGetDocuments 的程序化访问。BatchGetDocuments 等方法支持在单次 API 调用中检索最多 20 个文档。按照快速入门设置你的环境、安装库并开始检索开发者文档。
以下示例演示了 AI Agent 如何使用 Python 客户端库获取最新的产品发布说明,确保其回答基于训练截止日期之外的数据:
from google.cloud import developer_knowledge_v1
def FetchMyProductReleaseNotes(my_product_name: str) -> str:
"""Fetches the latest release notes to bridge a model's knowledge cutoff."""
# Initialize the Developer Knowledge API client
my_api_client = developer_knowledge_v1.DeveloperKnowledgeClient()
# Formulate a targeted query for the specific product's release notes
my_search_query = f"{my_product_name} latest release notes"
my_request = developer_knowledge_v1.SearchDocumentChunksRequest(
query=my_search_query,
)
# Retrieve and return the relevant documentation chunks
my_response = my_api_client.search_document_chunks(request=my_request)
# Extract the chunk text
my_release_notes = [my_chunk.text for my_chunk in my_response.chunks]
return "\n".join(my_release_notes)
# Example usage:
# my_latest_notes = FetchMyProductReleaseNotes("Firestore")
Google APIs Explorer for the Developer Knowledge API 提供了集成在 Google 开发者网站上的交互式零代码界面,让你能够试验和验证 API 请求和响应结构。
通过 API Explorer,你可以测试以下核心端点:
准备好将 Google 开发者文档整合到你的工作流和 AI 工具中了吗?以下是几种入门方式: