Instructions
Step 1: Prioritize Assets from the Conversation
If the asset was created or mentioned earlier in the same conversation, then
proceed with that asset instead of searching. Skip steps 2, 3, and 4.
Step 2: Handle Public Datasets or Proceed to Search
Dataplex Lookup Context provides the richest metadata for data assets. You MUST
prioritize using it for all Google Cloud assets, even if you already know their
IDs.
- Public Datasets (Direct Inspection): If the requested asset belongs to
the
bigquery-public-data project, Dataplex Lookup Context will fail. You
MUST skip Steps 3 and 4 and inspect the table directly using the bq CLI or
BigQuery MCP tools instead.
- All Other Assets (Proceed to Step 3): For all other BigQuery, Cloud
Storage, Spanner, BigLake Iceberg or general GCP data assets (whether their
IDs are known or missing), you MUST proceed to Step 3 to search the
Dataplex catalog and obtain their full Entry Name.
Step 3: Execute Discovery Search
You MUST use the Dataplex search command to discover assets and retrieve their
full projects/... entry names. This step is required even if you already know
the asset's short ID (e.g., my_dataset.my_table), because Step 4 strictly
requires the full entry name.
[!IMPORTANT]
The --project parameter MUST ALWAYS be provided. This project_id is used to
attribute the search only and does NOT restrict the search scope. The project
must have the dataplex API enabled and user must have the
dataplex.entries.get permissions.
A. Semantic Search (Natural Language Intent)
Use this when the user describes the meaning or intent of the data
(e.g., "Find Q4 product sales data").
Use the search_entries MCP tool
OR
gcloud dataplex entries search "<NATURAL_LANGUAGE_QUERY>" \
--project="<PROJECT_ID>" \
--semantic-search \
--limit=50
B. Keyword Search (Technical Strings)
Use this for exact keyword matches or technical strings (e.g., name:order_v2).
Search Query Rules (MANDATORY)
- Mode-Specific Syntax:
- Semantic Search: Logical operators (
AND, OR) MUST be
UPPERCASE. Use plural labels. for label filters (e.g.,
labels.env=prod).
- Keyword Search: Operators are case-insensitive. Use singular
label. for label filters (e.g., label.env=prod).
- Abbreviated Logic: Use
| for OR and , for AND within parentheses to
shorten queries (e.g., projectid:(prod|staging) or column:(id,name)).
- Exact vs. Token Match:
- Use
: for token/substring matches (e.g., name:sales).
- Use
= for exact matches. REQUIRED for system, type, and
location.
- Singular Keywords: When performing keyword search, ALWAYS convert
plurals to singular (e.g., "product" NOT "products"). Semantic search
handles singular/plural variations and synonyms automatically.
- Scope Restriction: You SHOULD restrict the search scope using a
parent
filter if the project or dataset is known (e.g.,
parent:projects/<PROJECT_ID>).
Dataplex Search Syntax Reference
name:x: Substring/token match on resource ID.
displayname:x: Substring/token match on display name.
projectid:x: Substring/token match on GCP project ID.
parent:x: Substring match on hierarchical path (e.g.,
projects/my-proj).
location=x: Exact match on location (e.g., us-central1, us).
column:x: Substring/token match on column names in the schema.
system=x: Exact match on source system. Common values: bigquery,
storage, biglake, cloud_sql, cloud_spanner, cloud_bigtable,
pubsub.
type=x: Exact match on entry type (e.g., bigquery-table,
storage-bucket, storage-folder).
labels.key=value: (Semantic Mode ONLY) Exact match on a label.
label.key=value: (Keyword Mode ONLY) Exact match on a label.
createtime[>|<|=]x: Match assets created after/before date
YYYY-MM-DD.
fully_qualified_name=x: Exact match on the FQN (e.g.,
bigquery:project.dataset.table).
[!TIP]
Dataplex search results rely on metadata being ingested into the Universal
Catalog (often via Discovery Scans). If an asset is missing from search,
it may not be indexed. - Fallback 1: Try searching by the
fully_qualified_name qualifier. - Fallback 2: Use native tools (e.g.,
bq show, gcloud storage) or specific skills for that asset type if you
already know the ID.
gcloud dataplex entries search "<KEYWORD_SEARCH_QUERY>" \
--project="<PROJECT_ID>" \
--limit=50
[!IMPORTANT]
Handling Search Results and Avoiding Loops:
- No Results: If the search returns no entries:
- Variation Rule: You may try AT MOST 3 variations of the search
query (e.g., switching AND/OR clauses, adding/removing
parent:,
removing projectid: or location:, trying fully_qualified_name=).
- Stop Rule: If after 3 attempts no results are found, STOP and
inform the user. Ask for clarification, specifically the Dataplex
full entry name if known, or identifiers such as project ID,
dataset ID, or instance ID to help narrow the search. Example:
"I couldn't find any tables matching that description after several
attempts. If you know the Dataplex full entry name (
projects/...),
please provide it. Otherwise, please provide any identifiers you know,
such as project, dataset, or instance name, to help locate the asset."
- Multiple Results:
- If more than 10 results are returned, state that many matches were
found. Show the names of the first 5 entries and ask for
clarification.
- If 2-10 results are returned and you cannot definitively choose, list
them and ask the user.
- Single Result: Proceed to Step 3 with the full entry name.
- Avoid Infinite Loops: MUST NOT re-run identical or near-identical
queries. If Dataplex fails to return the expected asset, prioritize asking
the user for the exact resource ID or using Fallback 2 (Native Tools).
Criteria: Once candidate assets are returned, proceed to Step 4 using the
full entry names from the search results.
Step 4: Lookup Context
You MUST use the Lookup Context command to fetch schema and deep metadata
for the relevant results obtained from Step 3.
[!IMPORTANT]
The --resources parameter MUST be the full name (starting with
projects/) returned by the search result. Passing short table IDs, GCS URIs,
or fully qualified bigquery: prefixes is PROHIBITED and will fail.
Command Execution
Use the lookup_context MCP tool
OR
gcloud dataplex context lookup --resources="<FULL_ENTRY_NAME>"
Completion Criteria: The command returns the detailed schema and business
context.
Troubleshooting
Context Lookup Fails or "Resource not found"
- Cause: Short table names were used improperly.
- Fix: Ensure you use the correct entry name format from the search
results (starting with
projects/).
Search Returns No Results
- Cause: Plural terms in keyword search or lack of scoping.
- Fix: Switch to singular keywords. For semantic search, try more
descriptive natural language.
Context Lookup Fails with "NOT_FOUND" (despite correct format)
- Cause: The table belongs to a project (e.g.,
bigquery-public-data)
that has not fully synchronized its metadata with the Dataplex Universal
Catalog. While the entry appears in search, context lookup is unavailable.
- Fix: Fall back to direct inspection using native tools (e.g.,
bq CLI).
- Stop Rule: If the native tool (e.g.,
bq show) also returns "Not
Found", STOP. Do not restart the Dataplex discovery loop. Specifically ask
the user to verify the project ID and table ID.
Breaking the Research Loop
If you find yourself repeatedly searching for the same asset:
- STOP.
- State what you have tried (e.g., "I tried searching Dataplex with X and Y,
and checked
bq show").
- Ask the user for the exact project, dataset, and table ID.
Search Fails with "--project: Must be specified."
- Cause:
--project <PROJECT_ID> arguments were not provided
- Fix: Provide a project which will be used to authorize and attribute the
search request.
Search Fails with "PERMISSION_DENIED"
- Cause: The project_id provided in the
--project <PROJECT_ID> arguments
does not have the Dataplex API enabled or the user is missing necessary IAM
permissions.
- Fix: Ask the user if they have a project which has the Dataplex API
enabled with the dataplex.entries.get permission
1---2name: discovering-gcp-data-assets3description: |4 Finds and inspects data assets within Google Cloud.5 Relevant when any of the following conditions are true:6 1. The user request involves finding, exploring, or inspecting data assets7 in Google Cloud, such as:8 - BigQuery datasets, tables, or views9 - BigLake catalog or tables10 - Spanner instances, databases or tables11 - etc.12 2. You need to retrieve the schema, metadata, or governance policies for a13 GCP data asset.14 3. You have a keyword or topic (e.g., "sales data") but lack the specific15 table or resource ID.16 4. You are attempting to find data using `bq ls`, as this skill offers a17 superior approach.18 Don't use when:19 - Assets are outside Google Cloud20license: Apache-2.021metadata:22 version: v423 publisher: google24---2526# Instructions2728## Step 1: Prioritize Assets from the Conversation2930If the asset was created or mentioned earlier in the same conversation, then31proceed with that asset instead of searching. Skip steps 2, 3, and 4.3233## Step 2: Handle Public Datasets or Proceed to Search3435Dataplex Lookup Context provides the richest metadata for data assets. You MUST36prioritize using it for all Google Cloud assets, even if you already know their37IDs.3839- **Public Datasets (Direct Inspection)**: If the requested asset belongs to40 the `bigquery-public-data` project, Dataplex Lookup Context will fail. You41 MUST skip Steps 3 and 4 and inspect the table directly using the `bq` CLI or42 BigQuery MCP tools instead.43- **All Other Assets (Proceed to Step 3)**: For all other BigQuery, Cloud44 Storage, Spanner, BigLake Iceberg or general GCP data assets (whether their45 IDs are known or missing), you MUST proceed to **Step 3** to search the46 Dataplex catalog and obtain their full Entry Name.4748## Step 3: Execute Discovery Search4950You MUST use the Dataplex search command to discover assets and retrieve their51full `projects/...` entry names. This step is required even if you already know52the asset's short ID (e.g., `my_dataset.my_table`), because Step 4 strictly53requires the full entry name.5455> [!IMPORTANT]56>57> The `--project` parameter MUST ALWAYS be provided. This project_id is used to58> attribute the search only and does NOT restrict the search scope. The project59> must have the dataplex API enabled and user must have the60> `dataplex.entries.get` permissions.6162### A. Semantic Search (Natural Language Intent)6364Use this when the user describes the **meaning** or **intent** of the data65(e.g., "Find Q4 product sales data").6667Use the `search_entries` MCP tool6869OR7071```bash72gcloud dataplex entries search "<NATURAL_LANGUAGE_QUERY>" \73 --project="<PROJECT_ID>" \74 --semantic-search \75 --limit=5076```7778### B. Keyword Search (Technical Strings)7980Use this for exact keyword matches or technical strings (e.g., `name:order_v2`).8182#### Search Query Rules (MANDATORY)8384- **Mode-Specific Syntax**:85 - **Semantic Search**: Logical operators (`AND`, `OR`) MUST be86 **UPPERCASE**. Use plural `labels.` for label filters (e.g.,87 `labels.env=prod`).88 - **Keyword Search**: Operators are case-insensitive. Use singular89 `label.` for label filters (e.g., `label.env=prod`).90- **Abbreviated Logic**: Use `|` for OR and `,` for AND within parentheses to91 shorten queries (e.g., `projectid:(prod|staging)` or `column:(id,name)`).92- **Exact vs. Token Match**:93 - Use `:` for token/substring matches (e.g., `name:sales`).94 - Use `=` for exact matches. REQUIRED for `system`, `type`, and95 `location`.96- **Singular Keywords**: When performing keyword search, ALWAYS convert97 plurals to singular (e.g., "product" NOT "products"). Semantic search98 handles singular/plural variations and synonyms automatically.99- **Scope Restriction**: You SHOULD restrict the search scope using a `parent`100 filter if the project or dataset is known (e.g.,101 `parent:projects/<PROJECT_ID>`).102103#### Dataplex Search Syntax Reference104105- **`name:x`**: Substring/token match on resource ID.106- **`displayname:x`**: Substring/token match on display name.107- **`projectid:x`**: Substring/token match on GCP project ID.108- **`parent:x`**: Substring match on hierarchical path (e.g.,109 `projects/my-proj`).110- **`location=x`**: Exact match on location (e.g., `us-central1`, `us`).111- **`column:x`**: Substring/token match on column names in the schema.112- **`system=x`**: Exact match on source system. Common values: `bigquery`,113 `storage`, `biglake`, `cloud_sql`, `cloud_spanner`, `cloud_bigtable`,114 `pubsub`.115- **`type=x`**: Exact match on entry type (e.g., `bigquery-table`,116 `storage-bucket`, `storage-folder`).117- **`labels.key=value`**: (Semantic Mode ONLY) Exact match on a label.118- **`label.key=value`**: (Keyword Mode ONLY) Exact match on a label.119- **`createtime[>|<|=]x`**: Match assets created after/before date120 `YYYY-MM-DD`.121- **`fully_qualified_name=x`**: Exact match on the FQN (e.g.,122 `bigquery:project.dataset.table`).123124> [!TIP]125>126> Dataplex search results rely on metadata being ingested into the Universal127> Catalog (often via **Discovery Scans**). If an asset is missing from search,128> it may not be indexed. - **Fallback 1**: Try searching by the129> `fully_qualified_name` qualifier. - **Fallback 2**: Use native tools (e.g.,130> `bq show`, `gcloud storage`) or specific skills for that asset type if you131> already know the ID.132133```bash134gcloud dataplex entries search "<KEYWORD_SEARCH_QUERY>" \135 --project="<PROJECT_ID>" \136 --limit=50137```138139> [!IMPORTANT]140>141> Handling Search Results and Avoiding Loops:142>143> 1. **No Results:** If the search returns no entries:144> * **Variation Rule:** You may try AT MOST 3 variations of the search145> query (e.g., switching AND/OR clauses, adding/removing `parent:`,146> removing `projectid:` or `location:`, trying `fully_qualified_name=`).147> * **Stop Rule:** If after 3 attempts no results are found, STOP and148> inform the user. Ask for clarification, specifically the Dataplex149> **full entry name** if known, or identifiers such as **project ID**,150> **dataset ID**, or **instance ID** to help narrow the search. Example:151> "I couldn't find any tables matching that description after several152> attempts. If you know the Dataplex full entry name (`projects/...`),153> please provide it. Otherwise, please provide any identifiers you know,154> such as project, dataset, or instance name, to help locate the asset."155> 2. **Multiple Results:**156> * If more than 10 results are returned, state that many matches were157> found. Show the names of the first 5 entries and ask for158> clarification.159> * If 2-10 results are returned and you cannot definitively choose, list160> them and ask the user.161> 3. **Single Result:** Proceed to Step 3 with the full entry name.162> 4. **Avoid Infinite Loops:** MUST NOT re-run identical or near-identical163> queries. If Dataplex fails to return the expected asset, prioritize asking164> the user for the exact resource ID or using Fallback 2 (Native Tools).165166*Criteria*: Once candidate assets are returned, proceed to Step 4 using the167**full entry names** from the search results.168169## Step 4: Lookup Context170171You MUST use the **Lookup Context** command to fetch schema and deep metadata172for the relevant results obtained from Step 3.173174> [!IMPORTANT]175>176> The `--resources` parameter MUST be the **full name** (starting with177> `projects/`) returned by the search result. Passing short table IDs, GCS URIs,178> or fully qualified `bigquery:` prefixes is PROHIBITED and will fail.179180### Command Execution181182Use the `lookup_context` MCP tool183184OR185186```bash187gcloud dataplex context lookup --resources="<FULL_ENTRY_NAME>"188```189190*Completion Criteria*: The command returns the detailed schema and business191context.192193--------------------------------------------------------------------------------194195## Troubleshooting196197### Context Lookup Fails or "Resource not found"198199- **Cause**: Short table names were used improperly.200- **Fix**: Ensure you use the correct entry name format from the search201 results (starting with `projects/`).202203### Search Returns No Results204205- **Cause**: Plural terms in keyword search or lack of scoping.206- **Fix**: Switch to singular keywords. For semantic search, try more207 descriptive natural language.208209### Context Lookup Fails with "NOT_FOUND" (despite correct format)210211- **Cause**: The table belongs to a project (e.g., `bigquery-public-data`)212 that has not fully synchronized its metadata with the Dataplex Universal213 Catalog. While the entry appears in search, `context lookup` is unavailable.214- **Fix**: Fall back to direct inspection using native tools (e.g., `bq` CLI).215- **Stop Rule:** If the native tool (e.g., `bq show`) also returns "Not216 Found", STOP. Do not restart the Dataplex discovery loop. Specifically ask217 the user to verify the **project ID** and **table ID**.218219### Breaking the Research Loop220221If you find yourself repeatedly searching for the same asset:2222231. **STOP.**2242. State what you have tried (e.g., "I tried searching Dataplex with X and Y,225 and checked `bq show`").2263. Ask the user for the exact project, dataset, and table ID.227228### Search Fails with "--project: Must be specified."229230- **Cause**: `--project <PROJECT_ID>` arguments were not provided231- **Fix**: Provide a project which will be used to authorize and attribute the232 search request.233234### Search Fails with "PERMISSION_DENIED"235236- **Cause**: The project_id provided in the `--project <PROJECT_ID>` arguments237 does not have the Dataplex API enabled or the user is missing necessary IAM238 permissions.239- **Fix**: Ask the user if they have a project which has the Dataplex API240 enabled with the dataplex.entries.get permission