Tool: ListConstraints
Lists constraints that can be applied to a specific resource (project, folder, or organization). Use this to discover what constraints are available to enforce.
The following code sample shows how to use curl to call the ListConstraints MCP tool.
| Curl Request |
|---|
curl --location 'https://orgpolicy.googleapis.com/mcp' \ --header 'content-type: application/json' \ --header 'accept: application/json, text/event-stream' \ --data '{ "method": "tools/call", "params": { "name": "ListConstraints", "arguments": { // provide these details according to the tool's MCP specification } }, "jsonrpc": "2.0", "id": 1 }' |
Input Schema
The request sent to the ListConstraints method.
ListConstraintsRequest
| JSON representation |
|---|
{ "parent": string, "pageSize": integer, "pageToken": string } |
| Fields | |
|---|---|
parent |
Required. The Google Cloud resource that parents the constraint. Must be in one of the following forms:
|
pageSize |
Size of the pages to be returned. This is not used, but the server may at any point start using this field to limit page size. |
pageToken |
Page token used to retrieve the next page. This is not used, but the server may at any point start using this field. |
Output Schema
The response returned from the ListConstraints method.
ListConstraintsResponse
| JSON representation |
|---|
{
"constraints": [
{
object ( |
| Fields | |
|---|---|
constraints[] |
The collection of constraints that are available on the targeted resource. |
nextPageToken |
Page token used to retrieve the next page. This is not used. |
Constraint
| JSON representation |
|---|
{ "name": string, "displayName": string, "description": string, "constraintDefault": enum ( |
| Fields | |
|---|---|
name |
Immutable. The resource name of the constraint. Must be in one of the following forms:
For example, "/projects/123/constraints/compute.disableSerialPortAccess". |
displayName |
The human readable name. Mutable. |
description |
Detailed description of what this constraint controls as well as how and where it is enforced. Mutable. |
constraintDefault |
The evaluation behavior of this constraint in the absence of a policy. |
supportsDryRun |
Shows if dry run is supported for this constraint or not. |
equivalentConstraint |
Defines the equivalent constraint name, if it exists. Managed constraints can have an equivalent legacy managed constraint, and legacy managed constraints can have an equivalent managed constraint. For example, "constraints/iam.disableServiceAccountKeyUpload" is equivalent to "constraints/iam.managed.disableServiceAccountKeyUpload". |
supportsSimulation |
Shows if simulation is supported for this constraint or not. |
Union field Immutable after creation. |
|
listConstraint |
Defines this constraint as being a list constraint. |
booleanConstraint |
Defines this constraint as being a boolean constraint. |
ListConstraint
| JSON representation |
|---|
{ "supportsIn": boolean, "supportsUnder": boolean } |
| Fields | |
|---|---|
supportsIn |
Indicates whether values grouped into categories can be used in |
supportsUnder |
Indicates whether subtrees of the Resource Manager resource hierarchy can be used in |
BooleanConstraint
| JSON representation |
|---|
{
"customConstraintDefinition": {
object ( |
| Fields | |
|---|---|
customConstraintDefinition |
Custom constraint definition. Defines this as a managed constraint. |
CustomConstraintDefinition
| JSON representation |
|---|
{ "resourceTypes": [ string ], "methodTypes": [ enum ( |
| Fields | |
|---|---|
resourceTypes[] |
The resource instance type that this policy applies to, in the format
|
methodTypes[] |
All the operations being applied for this constraint. |
condition |
Org policy condition/expression. For example: The max length of the condition is 1000 characters. |
actionType |
Allow or deny type. |
parameters |
Stores the structure of An object containing a list of |
ParametersEntry
| JSON representation |
|---|
{
"key": string,
"value": {
object ( |
| Fields | |
|---|---|
key |
|
value |
|
Parameter
| JSON representation |
|---|
{ "type": enum ( |
| Fields | |
|---|---|
type |
Type of the parameter. |
defaultValue |
Sets the value of the parameter in an assignment if no value is given. |
validValuesExpr |
Provides a CEL expression to specify the acceptable parameter values during assignment. For example, parameterName in ("parameterValue1", "parameterValue2"). |
metadata |
Defines subproperties primarily used by the UI to display user-friendly information. |
item |
Determines the parameter's value structure. For example, |
Value
| JSON representation |
|---|
{ // Union field |
| Fields | |
|---|---|
Union field kind. The kind of value. kind can be only one of the following: |
|
nullValue |
Represents a JSON |
numberValue |
Represents a JSON number. Must not be |
stringValue |
Represents a JSON string. |
boolValue |
Represents a JSON boolean ( |
structValue |
Represents a JSON object. |
listValue |
Represents a JSON array. |
Struct
| JSON representation |
|---|
{ "fields": { string: value, ... } } |
| Fields | |
|---|---|
fields |
Unordered map of dynamically typed values. An object containing a list of |
FieldsEntry
| JSON representation |
|---|
{ "key": string, "value": value } |
| Fields | |
|---|---|
key |
|
value |
|
ListValue
| JSON representation |
|---|
{ "values": [ value ] } |
| Fields | |
|---|---|
values[] |
Repeated field of dynamically typed values. |
Metadata
| JSON representation |
|---|
{ "description": string } |
| Fields | |
|---|---|
description |
Detailed description of what this |
ConstraintDefault
Specifies the default behavior in the absence of any policy for the constraint. This must not be CONSTRAINT_DEFAULT_UNSPECIFIED.
Immutable after creation.
| Enums | |
|---|---|
CONSTRAINT_DEFAULT_UNSPECIFIED |
This is only used for distinguishing unset values, and results in an error if set. |
ALLOW |
Indicate that all values are allowed for list constraints. Indicate that enforcement is off for boolean constraints. |
DENY |
Indicate that all values are denied for list constraints. Indicate that enforcement is on for boolean constraints. |
MethodType
The operation for which this constraint will be applied. To apply this constraint only when creating new resources, set method_types to CREATE only. To apply this constraint when creating or updating resources, set method_types to CREATE and UPDATE.
UPDATE-only custom constraints are not supported. Use CREATE or CREATE, UPDATE.
| Enums | |
|---|---|
METHOD_TYPE_UNSPECIFIED |
This is only used for distinguishing unset values, and results in an error if used. |
CREATE |
Constraint applied when creating the resource. |
UPDATE |
Constraint applied when updating the resource. |
DELETE |
Constraint applied when deleting the resource. Not supported. |
REMOVE_GRANT |
Constraint applied when removing an IAM grant. |
GOVERN_TAGS |
Constraint applied when enforcing forced tagging. |
ActionType
Allow or deny type.
| Enums | |
|---|---|
ACTION_TYPE_UNSPECIFIED |
This is only used for distinguishing unset values, and results in an error if used. |
ALLOW |
Allowed action type. |
DENY |
Deny action type. |
Type
All valid types of parameter.
| Enums | |
|---|---|
TYPE_UNSPECIFIED |
This is only used for distinguishing unset values, and results in an error if used. |
LIST |
List parameter type. |
STRING |
String parameter type. |
BOOLEAN |
Boolean parameter type. |
NullValue
Represents a JSON null.
NullValue is a sentinel, using an enum with only one value to represent the null value for the Value type union.
A field of type NullValue with any value other than 0 is considered invalid. Most ProtoJSON serializers will emit a Value with a null_value set as a JSON null regardless of the integer value, and so will round trip to a 0 value.
| Enums | |
|---|---|
NULL_VALUE |
Null value. |
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: ❌