Tool: export_iam_analysis_results
Analyzes Google Cloud IAM policies asynchronously and exports the results to a BigQuery dataset or Google Cloud Storage bucket. Use this for large-scale analysis (for example, expanding resources or impersonation).
This tool requires the analysis_query parameter, which specifies the root container where policies are analyzed (scope) and offers optional selectors for resource names, principal identifiers, and applicable roles and permissions.
- Folder and Organization scopes are not supported;
scopemust be a project scope (for example,projects/PROJECT_ID). - When analyzing policies in a specific project (for example, 'in
PROJECT_ID'), setscopetoprojects/PROJECT_IDand do not setresource_selector. - Only set
resource_selector.full_resource_name(for example,//storage.googleapis.com/BUCKET_NAME) when a request is made specifically for access to a particular resource within that scope.
This tool returns a long-running operation object containing an operation name. You must subsequently use the get_iam_policy_analysis_status tool with this name to poll the status until the done field is true.
The following code sample shows how to use curl to call the export_iam_analysis_results MCP tool.
| Curl Request |
|---|
curl --location 'https://cloudasset.googleapis.com/mcp' \ --header 'content-type: application/json' \ --header 'accept: application/json, text/event-stream' \ --data '{ "method": "tools/call", "params": { "name": "export_iam_analysis_results", "arguments": { // Provide these details according to the MCP tool specification. } }, "jsonrpc": "2.0", "id": 1 }' |
Input Schema
A request message for AssetService.AnalyzeIamPolicyLongrunning.
AnalyzeIamPolicyLongrunningRequest
| JSON representation |
|---|
{ "analysisQuery": { object ( |
| Fields | |
|---|---|
analysisQuery |
Required. The request query. |
savedAnalysisQuery |
Optional. The name of a saved query, which must be in the format of
If both Note that you cannot override primitive fields with default value, such as 0 or empty string, etc., because we use proto3, which doesn't support field presence yet. |
outputConfig |
Required. Output configuration indicating where the results will be output to. |
IamPolicyAnalysisQuery
| JSON representation |
|---|
{ "scope": string, "resourceSelector": { object ( |
| Fields | |
|---|---|
scope |
Required. The relative name of the root asset. Only resources and IAM policies within the scope will be analyzed. This can only be a project ID (such as "projects/my-project-id") or a project number (such as "projects/12345"). To know how to get a project ID, visit here . |
resourceSelector |
Optional. Specifies a resource for analysis. |
identitySelector |
Optional. Specifies an identity for analysis. |
accessSelector |
Optional. Specifies roles or permissions for analysis. This is optional. |
options |
Optional. The query options. |
conditionContext |
Optional. The hypothetical context for IAM conditions evaluation. |
ResourceSelector
| JSON representation |
|---|
{ "fullResourceName": string } |
| Fields | |
|---|---|
fullResourceName |
Required. The full resource name of a resource of supported resource types. |
IdentitySelector
| JSON representation |
|---|
{ "identity": string } |
| Fields | |
|---|---|
identity |
Required. The identity appear in the form of principals in IAM policy binding. The examples of supported forms are: "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com". Notice that wildcard characters (such as * and ?) are not supported. You must give a specific identity. |
AccessSelector
| JSON representation |
|---|
{ "roles": [ string ], "permissions": [ string ] } |
| Fields | |
|---|---|
roles[] |
Optional. The roles to appear in result. |
permissions[] |
Optional. The permissions to appear in result. |
Options
| JSON representation |
|---|
{ "expandGroups": boolean, "expandRoles": boolean, "expandResources": boolean, "outputResourceEdges": boolean, "outputGroupEdges": boolean, "analyzeServiceAccountImpersonation": boolean } |
| Fields | |
|---|---|
expandGroups |
Optional. If true, the identities section of the result will expand any Google groups appearing in an IAM policy binding. If If true, the default max expansion per group is 1000 for AssetService.AnalyzeIamPolicy][]. Default is false. |
expandRoles |
Optional. If true, the access section of result will expand any roles appearing in IAM policy bindings to include their permissions. If Default is false. |
expandResources |
Optional. If true and For example, if the request analyzes for which resources user A has permission P, and the results include an IAM policy with P on a Google Cloud folder, the results will also include resources in that folder with permission P. If true and For example, if the request analyzes for which users have permission P on a Google Cloud project with this option enabled, the results will include all users who have permission P on that project or any lower resource. If true, the default max expansion per resource is 1000 for AssetService.AnalyzeIamPolicy][] and 100000 for AssetService.AnalyzeIamPolicyLongrunning][]. Default is false. |
outputResourceEdges |
Optional. If true, the result will output the relevant parent/child relationships between resources. Default is false. |
outputGroupEdges |
Optional. If true, the result will output the relevant membership relationships between groups and other groups, and between groups and principals. Default is false. |
analyzeServiceAccountImpersonation |
Optional. If true, the response will include access analysis from identities to resources via service account impersonation. This is a very expensive operation, because many derived queries will be executed. We highly recommend you use For example, if the request analyzes for which resources user A has permission P, and there's an IAM policy states user A has iam.serviceAccounts.getAccessToken permission to a service account SA, and there's another IAM policy states service account SA has permission P to a Google Cloud folder F, then user A potentially has access to the Google Cloud folder F. And those advanced analysis results will be included in Another example, if the request analyzes for who has permission P to a Google Cloud folder F, and there's an IAM policy states user A has iam.serviceAccounts.actAs permission to a service account SA, and there's another IAM policy states service account SA has permission P to the Google Cloud folder F, then user A potentially has access to the Google Cloud folder F. And those advanced analysis results will be included in Only the following permissions are considered in this analysis:
Default is false. |
ConditionContext
| JSON representation |
|---|
{ // Union field |
| Fields | |
|---|---|
Union field TimeContext. The IAM conditions time context. TimeContext can be only one of the following: |
|
accessTime |
The hypothetical access timestamp to evaluate IAM conditions. Note that this value must not be earlier than the current time; otherwise, an INVALID_ARGUMENT error will be returned. Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: |
Timestamp
| JSON representation |
|---|
{ "seconds": string, "nanos": integer } |
| Fields | |
|---|---|
seconds |
Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must be between -62135596800 and 253402300799 inclusive (which corresponds to 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z). |
nanos |
Non-negative fractions of a second at nanosecond resolution. This field is the nanosecond portion of the duration, not an alternative to seconds. Negative second values with fractions must still have non-negative nanos values that count forward in time. Must be between 0 and 999,999,999 inclusive. |
IamPolicyAnalysisOutputConfig
| JSON representation |
|---|
{ // Union field |
| Fields | |
|---|---|
Union field destination. IAM policy analysis export destination. destination can be only one of the following: |
|
gcsDestination |
Destination on Cloud Storage. |
bigqueryDestination |
Destination on BigQuery. |
GcsDestination
| JSON representation |
|---|
{ "uri": string } |
| Fields | |
|---|---|
uri |
Required. The URI of the Cloud Storage object. It's the same URI that is used by gcloud storage. Example: "gs://bucket_name/object_name". See Viewing and Editing Object Metadata for more information. If the specified Cloud Storage object already exists and there is no hold, it will be overwritten with the analysis result. |
BigQueryDestination
| JSON representation |
|---|
{
"dataset": string,
"tablePrefix": string,
"partitionKey": enum ( |
| Fields | |
|---|---|
dataset |
Required. The BigQuery dataset in format "projects/projectId/datasets/datasetId", to which the analysis results should be exported. If this dataset does not exist, the export call will return an INVALID_ARGUMENT error. |
tablePrefix |
Required. The prefix of the BigQuery tables to which the analysis results will be written. Tables will be created based on this table_prefix if not exist: * |
partitionKey |
The partition key for BigQuery partitioned table. |
writeDisposition |
Optional. Specifies the action that occurs if the destination table or partition already exists. The following values are supported:
The default value is WRITE_APPEND. Each action is atomic and only occurs if BigQuery is able to complete the job successfully. Details are at https://cloud.google.com/bigquery/docs/loading-data-local#appending_to_or_overwriting_a_table_using_a_local_file. |
PartitionKey
This enum determines the partition key column for the bigquery tables. Partitioning can improve query performance and reduce query cost by filtering partitions. Refer to https://cloud.google.com/bigquery/docs/partitioned-tables for details.
| Enums | |
|---|---|
PARTITION_KEY_UNSPECIFIED |
Unspecified partition key. Tables won't be partitioned using this option. |
REQUEST_TIME |
The time when the request is received. If specified as partition key, the result table(s) is partitioned by the RequestTime column, an additional timestamp column representing when the request was received. |
Output Schema
This resource represents a long-running operation that is the result of a network API call.
Operation
| JSON representation |
|---|
{ "name": string, "metadata": { "@type": string, field1: ..., ... }, "done": boolean, // Union field |
| Fields | |
|---|---|
name |
The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the |
metadata |
Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any. An object containing fields of an arbitrary type. An additional field |
done |
If the value is |
Union field result. The operation result, which can be either an error or a valid response. If done == false, neither error nor response is set. If done == true, exactly one of error or response can be set. Some services might not provide the result. result can be only one of the following: |
|
error |
The error result of the operation in case of failure or cancellation. |
response |
The normal, successful response of the operation. If the original method returns no data on success, such as An object containing fields of an arbitrary type. An additional field |
Any
| JSON representation |
|---|
{ "typeUrl": string, "value": string } |
| Fields | |
|---|---|
typeUrl |
Identifies the type of the serialized Protobuf message with a URI reference consisting of a prefix ending in a slash and the fully-qualified type name. Example: type.googleapis.com/google.protobuf.StringValue This string must contain at least one The prefix is arbitrary and Protobuf implementations are expected to simply strip off everything up to and including the last All type URL strings must be legal URI references with the additional restriction (for the text format) that the content of the reference must consist only of alphanumeric characters, percent-encoded escapes, and characters in the following set (not including the outer backticks): In the original design of |
value |
Holds a Protobuf serialization of the type described by type_url. A base64-encoded string. |
Status
| JSON representation |
|---|
{ "code": integer, "message": string, "details": [ { "@type": string, field1: ..., ... } ] } |
| Fields | |
|---|---|
code |
The status code, which should be an enum value of |
message |
A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the |
details[] |
A list of messages that carry the error details. There is a common set of message types for APIs to use. An object containing fields of an arbitrary type. An additional field |
Tool Annotations
Tool annotations are sent to MCP clients to describe the basic risk of a given tool. Most clients treat these hints as untrusted, but they can be used to decide when a confirmation prompt might be sent to a user.
Along with the title string, the following boolean hints are defined as follows:
readOnlyHint: If true, the tool doesn't modify its environment. Default: false.destructiveHint: If true, then the tool can perform destructive actions. If false, then the tool can only perform additive actions. Default: true.idempotentHint: If true, then calling the tool repeatedly with the same arguments will have no additional effect on its environment. Default: false.openWorldHint: If true, then the tool can interact with an 'open world' of external entities. If false, then the tool can only interact with internal entities. For example, a web search tool would be open world, while a memory tool would not be open world.
Destructive Hint: ❌ | Idempotent Hint: ❌ | Read Only Hint: ❌ | Open World Hint: ✅