MCP Tools Reference: dataform.googleapis.com

工具:read_repository_file

返回 Dataform 代码库中某个文件的内容。

此工具不适用于标准流水线开发。它旨在实现直接的代码库互动,通常用于管理笔记本或已保存的查询等单文件资产。

请勿在连接到远程 Git 主机的代码库中使用此工具。如需进行验证,请使用 get_repository 工具。如果存在 git_remote_settings 字段,则表示代码库已连接到远程主机,您必须使用 read_file 工具从工作区读取文件。

name 参数值是指代码库,必须采用 projects/{project_id}/locations/{location}/repositories/{repository} 格式。

path 参数值必须相对于代码库根目录。请勿使用目录遍历,例如 ..。使用 query_repository_directory_contents 工具获取有效的文件路径。

以下代码示例展示了如何使用 curl 调用 read_repository_file MCP 工具。

Curl 请求
curl --location 'https://dataform.googleapis.com/mcp' \
--header 'content-type: application/json' \
--header 'accept: application/json, text/event-stream' \
--data '{
  "method": "tools/call",
  "params": {
    "name": "read_repository_file",
    "arguments": {
      // Provide these details according to the MCP tool specification.
    }
  },
  "jsonrpc": "2.0",
  "id": 1
}'

输入架构

ReadRepositoryFile 请求消息。

ReadRepositoryFileRequest

JSON 表示法
{
  "name": string,
  "commitSha": string,
  "path": string
}
字段
name

string

必需。代码库的名称。

commitSha

string

可选。要从中读取的提交的提交 SHA。如果未设置,系统将从 HEAD 读取文件。

path

string

必需。要读取的完整文件路径(包括文件名),从代码库根目录开始。

输出架构

ReadRepositoryFile 响应消息。

ReadRepositoryFileResponse

JSON 表示法
{
  "contents": string
}
字段
contents

string (bytes format)

文件的内容。

使用 base64 编码的字符串。

工具注释

工具注释会发送给 MCP 客户端,用于描述指定工具的基本风险。大多数客户端会将这些提示视为不受信任的,但它们可用于确定何时向用户发送确认提示。

除了标题字符串之外,还定义了以下布尔值提示:

  • readOnlyHint:如果为 true,则工具不会修改其环境。默认值:false。
  • destructiveHint:如果为 true,则工具可以执行破坏性操作。如果为 false,则该工具只能执行添加操作。默认值:true。
  • idempotentHint:如果为 true,则使用相同实参重复调用该工具不会对其环境产生任何额外影响。默认值:false。
  • openWorldHint:如果为 true,则工具可以与外部实体的“开放世界”进行交互。如果为 false,则该工具只能与内部实体互动。例如,网络搜索工具是开放世界工具,而内存工具不是开放世界工具。

破坏性提示:❌ | 等幂性提示:✅ | 只读提示:✅ | 开放世界提示:❌