MCP Tools Reference: ces.googleapis.com

Tool: create_guardrail

Creates a new guardrail in the given app.

The following sample demonstrate how to use curl to invoke the create_guardrail MCP tool.

Curl Request
                  
curl --location 'https://ces.[REGION].rep.googleapis.com/mcp' \
--header 'content-type: application/json' \
--header 'accept: application/json, text/event-stream' \
--data '{
  "method": "tools/call",
  "params": {
    "name": "create_guardrail",
    "arguments": {
      // provide these details according to the tool's MCP specification
    }
  },
  "jsonrpc": "2.0",
  "id": 1
}'
                

Input Schema

Request message for AgentService.CreateGuardrail.

CreateGuardrailRequest

JSON representation
{
  "parent": string,
  "guardrailId": string,
  "guardrail": {
    object (Guardrail)
  }
}
Fields
parent

string

Required. The resource name of the app to create a guardrail in.

guardrailId

string

Optional. The ID to use for the guardrail, which will become the final component of the guardrail's resource name. If not provided, a unique ID will be automatically assigned for the guardrail.

guardrail

object (Guardrail)

Required. The guardrail to create.

Guardrail

JSON representation
{
  "name": string,
  "displayName": string,
  "description": string,
  "enabled": boolean,
  "action": {
    object (TriggerAction)
  },
  "createTime": string,
  "updateTime": string,
  "etag": string,

  // Union field guardrail_type can be only one of the following:
  "contentFilter": {
    object (ContentFilter)
  },
  "llmPromptSecurity": {
    object (LlmPromptSecurity)
  },
  "llmPolicy": {
    object (LlmPolicy)
  },
  "modelSafety": {
    object (ModelSafety)
  },
  "codeCallback": {
    object (CodeCallback)
  }
  // End of list of possible types for union field guardrail_type.
}
Fields
name

string

Identifier. The unique identifier of the guardrail. Format: projects/{project}/locations/{location}/apps/{app}/guardrails/{guardrail}

displayName

string

Required. Display name of the guardrail.

description

string

Optional. Description of the guardrail.

enabled

boolean

Optional. Whether the guardrail is enabled.

action

object (TriggerAction)

Optional. Action to take when the guardrail is triggered.

createTime

string (Timestamp format)

Output only. Timestamp when the guardrail was created.

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: "2014-10-02T15:01:23Z", "2014-10-02T15:01:23.045123456Z" or "2014-10-02T15:01:23+05:30".

updateTime

string (Timestamp format)

Output only. Timestamp when the guardrail was last updated.

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: "2014-10-02T15:01:23Z", "2014-10-02T15:01:23.045123456Z" or "2014-10-02T15:01:23+05:30".

etag

string

Etag used to ensure the object hasn't changed during a read-modify-write operation. If the etag is empty, the update will overwrite any concurrent changes.

Union field guardrail_type. Guardrail type. guardrail_type can be only one of the following:
contentFilter

object (ContentFilter)

Optional. Guardrail that bans certain content from being used in the conversation.

llmPromptSecurity

object (LlmPromptSecurity)

Optional. Guardrail that blocks the conversation if the prompt is considered unsafe based on the LLM classification.

llmPolicy

object (LlmPolicy)

Optional. Guardrail that blocks the conversation if the LLM response is considered violating the policy based on the LLM classification.

modelSafety

object (ModelSafety)

Optional. Guardrail that blocks the conversation if the LLM response is considered unsafe based on the model safety settings.

codeCallback

object (CodeCallback)

Optional. Guardrail that potentially blocks the conversation based on the result of the callback execution.

ContentFilter

JSON representation
{
  "bannedContents": [
    string
  ],
  "bannedContentsInUserInput": [
    string
  ],
  "bannedContentsInAgentResponse": [
    string
  ],
  "matchType": enum (MatchType),
  "disregardDiacritics": boolean
}
Fields
bannedContents[]

string

Optional. List of banned phrases. Applies to both user inputs and agent responses.

bannedContentsInUserInput[]

string

Optional. List of banned phrases. Applies only to user inputs.

bannedContentsInAgentResponse[]

string

Optional. List of banned phrases. Applies only to agent responses.

matchType

enum (MatchType)

Required. Match type for the content filter.

disregardDiacritics

boolean

Optional. If true, diacritics are ignored during matching.

LlmPromptSecurity

JSON representation
{
  "failOpen": boolean,

  // Union field security_config can be only one of the following:
  "defaultSettings": {
    object (DefaultSecuritySettings)
  },
  "customPolicy": {
    object (LlmPolicy)
  }
  // End of list of possible types for union field security_config.
}
Fields
failOpen

boolean

Optional. Determines the behavior when the guardrail encounters an LLM error. - If true: the guardrail is bypassed. - If false (default): the guardrail triggers/blocks.

Note: If a custom policy is provided, this field is ignored in favor of the policy's 'fail_open' configuration.

Union field security_config. Defines the security configuration mode. The user must choose one of the following configurations. security_config can be only one of the following:
defaultSettings

object (DefaultSecuritySettings)

Optional. Use the system's predefined default security settings. To select this mode, include an empty 'default_settings' message in the request. The 'default_prompt_template' field within will be populated by the server in the response.

customPolicy

object (LlmPolicy)

Optional. Use a user-defined LlmPolicy to configure the security guardrail.

DefaultSecuritySettings

JSON representation
{
  "defaultPromptTemplate": string
}
Fields
defaultPromptTemplate

string

Output only. The default prompt template used by the system. This field is for display purposes to show the user what prompt the system uses by default. It is OUTPUT_ONLY.

LlmPolicy

JSON representation
{
  "maxConversationMessages": integer,
  "modelSettings": {
    object (ModelSettings)
  },
  "prompt": string,
  "policyScope": enum (PolicyScope),
  "failOpen": boolean,
  "allowShortUtterance": boolean
}
Fields
maxConversationMessages

integer

Optional. When checking this policy, consider the last 'n' messages in the conversation. When not set a default value of 10 will be used.

modelSettings

object (ModelSettings)

Optional. Model settings.

prompt

string

Required. Policy prompt.

policyScope

enum (PolicyScope)

Required. Defines when to apply the policy check during the conversation. If set to POLICY_SCOPE_UNSPECIFIED, the policy will be applied to the user input. When applying the policy to the agent response, additional latency will be introduced before the agent can respond.

failOpen

boolean

Optional. If an error occurs during the policy check, fail open and do not trigger the guardrail.

allowShortUtterance

boolean

Optional. By default, the LLM policy check is bypassed for short utterances. Enabling this setting applies the policy check to all utterances, including those that would normally be skipped.

ModelSettings

JSON representation
{
  "model": string,

  // Union field _temperature can be only one of the following:
  "temperature": number
  // End of list of possible types for union field _temperature.
}
Fields
model

string

Optional. The LLM model that the agent should use. If not set, the agent will inherit the model from its parent agent.

Union field _temperature.

_temperature can be only one of the following:

temperature

number

Optional. If set, this temperature will be used for the LLM model. Temperature controls the randomness of the model's responses. Lower temperatures produce responses that are more predictable. Higher temperatures produce responses that are more creative.

ModelSafety

JSON representation
{
  "safetySettings": [
    {
      object (SafetySetting)
    }
  ]
}
Fields
safetySettings[]

object (SafetySetting)

Required. List of safety settings.

SafetySetting

JSON representation
{
  "category": enum (HarmCategory),
  "threshold": enum (HarmBlockThreshold)
}
Fields
category

enum (HarmCategory)

Required. The harm category.

threshold

enum (HarmBlockThreshold)

Required. The harm block threshold.

CodeCallback

JSON representation
{
  "beforeAgentCallback": {
    object (Callback)
  },
  "afterAgentCallback": {
    object (Callback)
  },
  "beforeModelCallback": {
    object (Callback)
  },
  "afterModelCallback": {
    object (Callback)
  }
}
Fields
beforeAgentCallback

object (Callback)

Optional. The callback to execute before the agent is called. Each callback function is expected to return a structure (e.g., a dict or object) containing at least: - 'decision': Either 'OK' or 'TRIGGER'. - 'reason': A string explaining the decision. A 'TRIGGER' decision may halt further processing.

afterAgentCallback

object (Callback)

Optional. The callback to execute after the agent is called. Each callback function is expected to return a structure (e.g., a dict or object) containing at least: - 'decision': Either 'OK' or 'TRIGGER'. - 'reason': A string explaining the decision. A 'TRIGGER' decision may halt further processing.

beforeModelCallback

object (Callback)

Optional. The callback to execute before the model is called. If there are multiple calls to the model, the callback will be executed multiple times. Each callback function is expected to return a structure (e.g., a dict or object) containing at least: - 'decision': Either 'OK' or 'TRIGGER'. - 'reason': A string explaining the decision. A 'TRIGGER' decision may halt further processing.

afterModelCallback

object (Callback)

Optional. The callback to execute after the model is called. If there are multiple calls to the model, the callback will be executed multiple times. Each callback function is expected to return a structure (e.g., a dict or object) containing at least: - 'decision': Either 'OK' or 'TRIGGER'. - 'reason': A string explaining the decision. A 'TRIGGER' decision may halt further processing.

Callback

JSON representation
{
  "description": string,
  "disabled": boolean,
  "proactiveExecutionEnabled": boolean,

  // Union field callback can be only one of the following:
  "pythonCode": string
  // End of list of possible types for union field callback.
}
Fields
description

string

Optional. Human-readable description of the callback.

disabled

boolean

Optional. Whether the callback is disabled. Disabled callbacks are ignored by the agent.

proactiveExecutionEnabled

boolean

Optional. If enabled, the callback will also be executed on intermediate model outputs. This setting only affects after model callback. ENABLE WITH CAUTION. Typically after model callback only needs to be executed after receiving all model responses. Enabling proactive execution may have negative implication on the execution cost and latency, and should only be enabled in rare situations.

Union field callback. The callback to execute. callback can be only one of the following:
pythonCode

string

Required. The python code to execute for the callback.

TriggerAction

JSON representation
{

  // Union field action can be only one of the following:
  "respondImmediately": {
    object (RespondImmediately)
  },
  "transferAgent": {
    object (TransferAgent)
  },
  "generativeAnswer": {
    object (GenerativeAnswer)
  }
  // End of list of possible types for union field action.
}
Fields
Union field action. The action to take. action can be only one of the following:
respondImmediately

object (RespondImmediately)

Optional. Immediately respond with a preconfigured response.

transferAgent

object (TransferAgent)

Optional. Transfer the conversation to a different agent.

generativeAnswer

object (GenerativeAnswer)

Optional. Respond with a generative answer.

RespondImmediately

JSON representation
{
  "responses": [
    {
      object (Response)
    }
  ]
}
Fields
responses[]

object (Response)

Required. The canned responses for the agent to choose from. The response is chosen randomly.

Response

JSON representation
{
  "text": string,
  "disabled": boolean
}
Fields
text

string

Required. Text for the agent to respond with.

disabled

boolean

Optional. Whether the response is disabled. Disabled responses are not used by the agent.

TransferAgent

JSON representation
{
  "agent": string
}
Fields
agent

string

Required. The name of the agent to transfer the conversation to. The agent must be in the same app as the current agent. Format: projects/{project}/locations/{location}/apps/{app}/agents/{agent}

GenerativeAnswer

JSON representation
{
  "prompt": string
}
Fields
prompt

string

Required. The prompt to use for the generative answer.

Timestamp

JSON representation
{
  "seconds": string,
  "nanos": integer
}
Fields
seconds

string (int64 format)

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

integer

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.

Output Schema

Guardrail contains a list of checks and balances to keep the agents safe and secure.

Guardrail

JSON representation
{
  "name": string,
  "displayName": string,
  "description": string,
  "enabled": boolean,
  "action": {
    object (TriggerAction)
  },
  "createTime": string,
  "updateTime": string,
  "etag": string,

  // Union field guardrail_type can be only one of the following:
  "contentFilter": {
    object (ContentFilter)
  },
  "llmPromptSecurity": {
    object (LlmPromptSecurity)
  },
  "llmPolicy": {
    object (LlmPolicy)
  },
  "modelSafety": {
    object (ModelSafety)
  },
  "codeCallback": {
    object (CodeCallback)
  }
  // End of list of possible types for union field guardrail_type.
}
Fields
name

string

Identifier. The unique identifier of the guardrail. Format: projects/{project}/locations/{location}/apps/{app}/guardrails/{guardrail}

displayName

string

Required. Display name of the guardrail.

description

string

Optional. Description of the guardrail.

enabled

boolean

Optional. Whether the guardrail is enabled.

action

object (TriggerAction)

Optional. Action to take when the guardrail is triggered.

createTime

string (Timestamp format)

Output only. Timestamp when the guardrail was created.

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: "2014-10-02T15:01:23Z", "2014-10-02T15:01:23.045123456Z" or "2014-10-02T15:01:23+05:30".

updateTime

string (Timestamp format)

Output only. Timestamp when the guardrail was last updated.

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: "2014-10-02T15:01:23Z", "2014-10-02T15:01:23.045123456Z" or "2014-10-02T15:01:23+05:30".

etag

string

Etag used to ensure the object hasn't changed during a read-modify-write operation. If the etag is empty, the update will overwrite any concurrent changes.

Union field guardrail_type. Guardrail type. guardrail_type can be only one of the following:
contentFilter

object (ContentFilter)

Optional. Guardrail that bans certain content from being used in the conversation.

llmPromptSecurity

object (LlmPromptSecurity)

Optional. Guardrail that blocks the conversation if the prompt is considered unsafe based on the LLM classification.

llmPolicy

object (LlmPolicy)

Optional. Guardrail that blocks the conversation if the LLM response is considered violating the policy based on the LLM classification.

modelSafety

object (ModelSafety)

Optional. Guardrail that blocks the conversation if the LLM response is considered unsafe based on the model safety settings.

codeCallback

object (CodeCallback)

Optional. Guardrail that potentially blocks the conversation based on the result of the callback execution.

ContentFilter

JSON representation
{
  "bannedContents": [
    string
  ],
  "bannedContentsInUserInput": [
    string
  ],
  "bannedContentsInAgentResponse": [
    string
  ],
  "matchType": enum (MatchType),
  "disregardDiacritics": boolean
}
Fields
bannedContents[]

string

Optional. List of banned phrases. Applies to both user inputs and agent responses.

bannedContentsInUserInput[]

string

Optional. List of banned phrases. Applies only to user inputs.

bannedContentsInAgentResponse[]

string

Optional. List of banned phrases. Applies only to agent responses.

matchType

enum (MatchType)

Required. Match type for the content filter.

disregardDiacritics

boolean

Optional. If true, diacritics are ignored during matching.

LlmPromptSecurity

JSON representation
{
  "failOpen": boolean,

  // Union field security_config can be only one of the following:
  "defaultSettings": {
    object (DefaultSecuritySettings)
  },
  "customPolicy": {
    object (LlmPolicy)
  }
  // End of list of possible types for union field security_config.
}
Fields
failOpen

boolean

Optional. Determines the behavior when the guardrail encounters an LLM error. - If true: the guardrail is bypassed. - If false (default): the guardrail triggers/blocks.

Note: If a custom policy is provided, this field is ignored in favor of the policy's 'fail_open' configuration.

Union field security_config. Defines the security configuration mode. The user must choose one of the following configurations. security_config can be only one of the following:
defaultSettings

object (DefaultSecuritySettings)

Optional. Use the system's predefined default security settings. To select this mode, include an empty 'default_settings' message in the request. The 'default_prompt_template' field within will be populated by the server in the response.

customPolicy

object (LlmPolicy)

Optional. Use a user-defined LlmPolicy to configure the security guardrail.

DefaultSecuritySettings

JSON representation
{
  "defaultPromptTemplate": string
}
Fields
defaultPromptTemplate

string

Output only. The default prompt template used by the system. This field is for display purposes to show the user what prompt the system uses by default. It is OUTPUT_ONLY.

LlmPolicy

JSON representation
{
  "maxConversationMessages": integer,
  "modelSettings": {
    object (ModelSettings)
  },
  "prompt": string,
  "policyScope": enum (PolicyScope),
  "failOpen": boolean,
  "allowShortUtterance": boolean
}
Fields
maxConversationMessages

integer

Optional. When checking this policy, consider the last 'n' messages in the conversation. When not set a default value of 10 will be used.

modelSettings

object (ModelSettings)

Optional. Model settings.

prompt

string

Required. Policy prompt.

policyScope

enum (PolicyScope)

Required. Defines when to apply the policy check during the conversation. If set to POLICY_SCOPE_UNSPECIFIED, the policy will be applied to the user input. When applying the policy to the agent response, additional latency will be introduced before the agent can respond.

failOpen

boolean

Optional. If an error occurs during the policy check, fail open and do not trigger the guardrail.

allowShortUtterance

boolean

Optional. By default, the LLM policy check is bypassed for short utterances. Enabling this setting applies the policy check to all utterances, including those that would normally be skipped.

ModelSettings

JSON representation
{
  "model": string,

  // Union field _temperature can be only one of the following:
  "temperature": number
  // End of list of possible types for union field _temperature.
}
Fields
model

string

Optional. The LLM model that the agent should use. If not set, the agent will inherit the model from its parent agent.

Union field _temperature.

_temperature can be only one of the following:

temperature

number

Optional. If set, this temperature will be used for the LLM model. Temperature controls the randomness of the model's responses. Lower temperatures produce responses that are more predictable. Higher temperatures produce responses that are more creative.

ModelSafety

JSON representation
{
  "safetySettings": [
    {
      object (SafetySetting)
    }
  ]
}
Fields
safetySettings[]

object (SafetySetting)

Required. List of safety settings.

SafetySetting

JSON representation
{
  "category": enum (HarmCategory),
  "threshold": enum (HarmBlockThreshold)
}
Fields
category

enum (HarmCategory)

Required. The harm category.

threshold

enum (HarmBlockThreshold)

Required. The harm block threshold.

CodeCallback

JSON representation
{
  "beforeAgentCallback": {
    object (Callback)
  },
  "afterAgentCallback": {
    object (Callback)
  },
  "beforeModelCallback": {
    object (Callback)
  },
  "afterModelCallback": {
    object (Callback)
  }
}
Fields
beforeAgentCallback

object (Callback)

Optional. The callback to execute before the agent is called. Each callback function is expected to return a structure (e.g., a dict or object) containing at least: - 'decision': Either 'OK' or 'TRIGGER'. - 'reason': A string explaining the decision. A 'TRIGGER' decision may halt further processing.

afterAgentCallback

object (Callback)

Optional. The callback to execute after the agent is called. Each callback function is expected to return a structure (e.g., a dict or object) containing at least: - 'decision': Either 'OK' or 'TRIGGER'. - 'reason': A string explaining the decision. A 'TRIGGER' decision may halt further processing.

beforeModelCallback

object (Callback)

Optional. The callback to execute before the model is called. If there are multiple calls to the model, the callback will be executed multiple times. Each callback function is expected to return a structure (e.g., a dict or object) containing at least: - 'decision': Either 'OK' or 'TRIGGER'. - 'reason': A string explaining the decision. A 'TRIGGER' decision may halt further processing.

afterModelCallback

object (Callback)

Optional. The callback to execute after the model is called. If there are multiple calls to the model, the callback will be executed multiple times. Each callback function is expected to return a structure (e.g., a dict or object) containing at least: - 'decision': Either 'OK' or 'TRIGGER'. - 'reason': A string explaining the decision. A 'TRIGGER' decision may halt further processing.

Callback

JSON representation
{
  "description": string,
  "disabled": boolean,
  "proactiveExecutionEnabled": boolean,

  // Union field callback can be only one of the following:
  "pythonCode": string
  // End of list of possible types for union field callback.
}
Fields
description

string

Optional. Human-readable description of the callback.

disabled

boolean

Optional. Whether the callback is disabled. Disabled callbacks are ignored by the agent.

proactiveExecutionEnabled

boolean

Optional. If enabled, the callback will also be executed on intermediate model outputs. This setting only affects after model callback. ENABLE WITH CAUTION. Typically after model callback only needs to be executed after receiving all model responses. Enabling proactive execution may have negative implication on the execution cost and latency, and should only be enabled in rare situations.

Union field callback. The callback to execute. callback can be only one of the following:
pythonCode

string

Required. The python code to execute for the callback.

TriggerAction

JSON representation
{

  // Union field action can be only one of the following:
  "respondImmediately": {
    object (RespondImmediately)
  },
  "transferAgent": {
    object (TransferAgent)
  },
  "generativeAnswer": {
    object (GenerativeAnswer)
  }
  // End of list of possible types for union field action.
}
Fields
Union field action. The action to take. action can be only one of the following:
respondImmediately

object (RespondImmediately)

Optional. Immediately respond with a preconfigured response.

transferAgent

object (TransferAgent)

Optional. Transfer the conversation to a different agent.

generativeAnswer

object (GenerativeAnswer)

Optional. Respond with a generative answer.

RespondImmediately

JSON representation
{
  "responses": [
    {
      object (Response)
    }
  ]
}
Fields
responses[]

object (Response)

Required. The canned responses for the agent to choose from. The response is chosen randomly.

Response

JSON representation
{
  "text": string,
  "disabled": boolean
}
Fields
text

string

Required. Text for the agent to respond with.

disabled

boolean

Optional. Whether the response is disabled. Disabled responses are not used by the agent.

TransferAgent

JSON representation
{
  "agent": string
}
Fields
agent

string

Required. The name of the agent to transfer the conversation to. The agent must be in the same app as the current agent. Format: projects/{project}/locations/{location}/apps/{app}/agents/{agent}

GenerativeAnswer

JSON representation
{
  "prompt": string
}
Fields
prompt

string

Required. The prompt to use for the generative answer.

Timestamp

JSON representation
{
  "seconds": string,
  "nanos": integer
}
Fields
seconds

string (int64 format)

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

integer

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.

Tool Annotations

Destructive Hint: ✅ | Idempotent Hint: ❌ | Read Only Hint: ❌ | Open World Hint: ❌