MCP Tools Reference: dataform.googleapis.com

工具:search_files

在 Dataform 工作区中查找与搜索过滤条件匹配的文件和目录。

当您需要在大型代码库中按名称或扩展名查找文件时,请使用此工具,而不是使用 query_directory_contents 工具以递归方式列出目录。

workspace 参数值必须采用 projects/{project_id}/locations/{location}/repositories/{repository}/workspaces/{workspace} 格式。

filter 参数值会限制结果。仅支持对 path 字段(例如 path="*.sqlx"path="definitions/model.sqlx")进行过滤。

以下代码示例展示了如何使用 curl 调用 search_files 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": "search_files",
    "arguments": {
      // Provide these details according to the MCP tool specification.
    }
  },
  "jsonrpc": "2.0",
  "id": 1
}'

输入架构

包含文件搜索请求参数的配置。

SearchFilesRequest

JSON 表示法
{
  "workspace": string,
  "pageSize": integer,
  "pageToken": string,
  "filter": string
}
字段
workspace

string

必需。工作区的名称。

pageSize

integer

可选。要返回的搜索结果数量上限。服务器返回的项目数量可能少于请求的数量。如果未指定,服务器将选择合适的默认值。

pageToken

string

可选。从之前的 SearchFilesRequest 调用接收的页面令牌。利用其进行后续页面检索。

进行分页时,提供给 SearchFilesRequest 的所有其他参数(page_size 除外)必须与提供页面令牌的调用匹配。

filter

string

可选。过滤返回列表的可选过滤条件,采用过滤格式。目前仅支持对 path 字段进行过滤。如需了解详情,请参阅 https://google.aip.dev/160

输出架构

面向客户的文件搜索响应表示形式。

SearchFilesResponse

JSON 表示法
{
  "searchResults": [
    {
      object (SearchResult)
    }
  ],
  "nextPageToken": string
}
字段
searchResults[]

object (SearchResult)

匹配结果列表。

nextPageToken

string

可选。可作为 page_token 发送并用于检索下一页的令牌。如果省略此字段,则不存在后续页面。

SearchResult

JSON 表示法
{

  // Union field entry can be only one of the following:
  "file": {
    object (FileSearchResult)
  },
  "directory": {
    object (DirectorySearchResult)
  }
  // End of list of possible types for union field entry.
}
字段
联合字段 entry。相应条目的内容。entry 只能是下列其中一项:
file

object (FileSearchResult)

搜索结果为文件时的详细信息。

directory

object (DirectorySearchResult)

搜索结果为目录时的详细信息。

FileSearchResult

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

string

相对于工作区根目录的文件系统路径。

DirectorySearchResult

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

string

相对于工作区根目录的文件系统路径。

工具注释

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

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

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

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