Tool: ask_contexts
Answers a natural-language question directly using contexts retrieved from a RAG Engine Corpus, in a single agentic call. Use this when the user wants a final answer grounded in their corpus and does not need to inspect intermediate retrieved contexts. For raw retrieval use retrieve_contexts; for augmenting a prompt before sending to a separate LLM step use augment_prompt.
Note: This tool is backed by a v1beta1 RPC. Format: 'projects/{project_id}/locations/{region}'. CRITICAL: For {region}, use the region specified in the current context window. If no region is specified, prompt the user to provide one. Do not use 'global'.
Parameters * parent: The parent resource, of the form projects/{project}/locations/{location}. * query: The natural-language query to answer. * query.text: The query text. * query.rag_retrieval_config: Retrieval config (top_k, filter, ranking) used to gather supporting contexts. * tools: Optional list of tools the agentic retriever may use during answering.
The following sample demonstrate how to use curl to invoke the ask_contexts MCP tool.
| Curl Request |
|---|
curl --location 'https://aiplatform.googleapis.com/mcp/generate' \ --header 'content-type: application/json' \ --header 'accept: application/json, text/event-stream' \ --data '{ "method": "tools/call", "params": { "name": "ask_contexts", "arguments": { // provide these details according to the tool's MCP specification } }, "jsonrpc": "2.0", "id": 1 }' |
Input Schema
Agentic Retrieval Ask API for RAG. Request message for VertexRagService.AskContexts.
AskContextsRequest
| JSON representation |
|---|
{ "parent": string, "query": { object ( |
| Fields | |
|---|---|
parent |
Required. The resource name of the Location from which to retrieve RagContexts. The users must have permission to make a call in the project. Format: |
query |
Required. Single RAG retrieve query. |
tools[] |
Optional. The tools to use for AskContexts. |
RagQuery
| JSON representation |
|---|
{ "similarityTopK": integer, "ranking": { object ( |
| Fields | |
|---|---|
similarityTopK |
Optional. The number of contexts to retrieve. |
ranking |
Optional. Configurations for hybrid search results ranking. |
ragRetrievalConfig |
Optional. The retrieval config for the query. |
Union field query. The query to retrieve contexts. Currently only text query is supported. query can be only one of the following: |
|
text |
Optional. The query in text format to get relevant contexts. |
Ranking
| JSON representation |
|---|
{ // Union field |
| Fields | |
|---|---|
Union field
|
|
alpha |
Optional. Alpha value controls the weight between dense and sparse vector search results. The range is [0, 1], while 0 means sparse vector search only and 1 means dense vector search only. The default value is 0.5 which balances sparse and dense vector search equally. |
RagRetrievalConfig
| JSON representation |
|---|
{ "topK": integer, "hybridSearch": { object ( |
| Fields | |
|---|---|
topK |
Optional. The number of contexts to retrieve. |
hybridSearch |
Optional. Config for Hybrid Search. |
filter |
Optional. Config for filters. |
ranking |
Optional. Config for ranking and reranking. |
HybridSearch
| JSON representation |
|---|
{ // Union field |
| Fields | |
|---|---|
Union field
|
|
alpha |
Optional. Alpha value controls the weight between dense and sparse vector search results. The range is [0, 1], while 0 means sparse vector search only and 1 means dense vector search only. The default value is 0.5 which balances sparse and dense vector search equally. |
Filter
| JSON representation |
|---|
{ "metadataFilter": string, // Union field |
| Fields | |
|---|---|
metadataFilter |
Optional. String for metadata filtering. |
Union field vector_db_threshold. Filter contexts retrieved from the vector DB based on either vector distance or vector similarity. vector_db_threshold can be only one of the following: |
|
vectorDistanceThreshold |
Optional. Only returns contexts with vector distance smaller than the threshold. |
vectorSimilarityThreshold |
Optional. Only returns contexts with vector similarity larger than the threshold. |
Ranking
| JSON representation |
|---|
{ // Union field |
| Fields | |
|---|---|
Union field ranking_config. Config options for ranking. Currently only Rank Service is supported. ranking_config can be only one of the following: |
|
rankService |
Optional. Config for Rank Service. |
llmRanker |
Optional. Config for LlmRanker. |
RankService
| JSON representation |
|---|
{ // Union field |
| Fields | |
|---|---|
Union field
|
|
modelName |
Optional. The model name of the rank service. Format: |
LlmRanker
| JSON representation |
|---|
{ // Union field |
| Fields | |
|---|---|
Union field
|
|
modelName |
Optional. The model name used for ranking. See Supported models. |
Tool
| JSON representation |
|---|
{ "functionDeclarations": [ { object ( |
| Fields | |
|---|---|
functionDeclarations[] |
Optional. Function tool type. One or more function declarations to be passed to the model along with the current user query. Model may decide to call a subset of these functions by populating |
retrieval |
Optional. Retrieval tool type. System will always execute the provided retrieval tool(s) to get external knowledge to answer the prompt. Retrieval results are presented to the model for generation. |
googleSearch |
Optional. GoogleSearch tool type. Tool to support Google Search in Model. Powered by Google. |
googleSearchRetrieval |
Optional. Specialized retrieval tool that is powered by Google Search. |
googleMaps |
Optional. GoogleMaps tool type. Tool to support Google Maps in Model. |
enterpriseWebSearch |
Optional. Tool to support searching public web data, powered by Agent Platform Search and Sec4 compliance. |
parallelAiSearch |
Optional. If specified, Agent Platform will use Parallel.ai to search for information to answer user queries. The search results will be grounded on Parallel.ai and presented to the model for response generation |
codeExecution |
Optional. CodeExecution tool type. Enables the model to execute code as part of generation. |
urlContext |
Optional. Tool to support URL context retrieval. |
computerUse |
Optional. Tool to support the model interacting directly with the computer. If enabled, it automatically populates computer-use specific Function Declarations. |
FunctionDeclaration
| JSON representation |
|---|
{ "name": string, "description": string, "parameters": { object ( |
| Fields | |
|---|---|
name |
Required. The name of the function to call. Must start with a letter or an underscore. Must be a-z, A-Z, 0-9, or contain underscores, dots, colons and dashes, with a maximum length of 128. |
description |
Optional. Description and purpose of the function. Model uses it to decide how and whether to call the function. |
parameters |
Optional. Describes the parameters to this function in JSON Schema Object format. Reflects the Open API 3.03 Parameter Object. string Key: the name of the parameter. Parameter names are case sensitive. Schema Value: the Schema defining the type used for the parameter. For function with no parameters, this can be left unset. Parameter names must start with a letter or an underscore and must only contain chars a-z, A-Z, 0-9, or underscores with a maximum length of 64. Example with 1 required and 1 optional parameter: type: OBJECT properties: param1: type: STRING param2: type: INTEGER required: - param1 |
parametersJsonSchema |
Optional. Describes the parameters to the function in JSON Schema format. The schema must describe an object where the properties are the parameters to the function. For example: This field is mutually exclusive with |
response |
Optional. Describes the output from this function in JSON Schema format. Reflects the Open API 3.03 Response Object. The Schema defines the type used for the response value of the function. |
responseJsonSchema |
Optional. Describes the output from this function in JSON Schema format. The value specified by the schema is the response value of the function. This field is mutually exclusive with |
Schema
| JSON representation |
|---|
{ "type": enum ( |
| Fields | |
|---|---|
type |
Optional. Data type of the schema field. |
format |
Optional. The format of the data. For |
title |
Optional. Title for the schema. |
description |
Optional. Describes the data. The model uses this field to understand the purpose of the schema and how to use it. It is a best practice to provide a clear and descriptive explanation for the schema and its properties here, rather than in the prompt. |
nullable |
Optional. Indicates if the value of this field can be null. |
default |
Optional. Default value to use if the field is not specified. |
items |
Optional. If type is |
minItems |
Optional. If type is |
maxItems |
Optional. If type is |
enum[] |
Optional. Possible values of the field. This field can be used to restrict a value to a fixed set of values. To mark a field as an enum, set |
properties |
Optional. If type is An object containing a list of |
propertyOrdering[] |
Optional. Order of properties displayed or used where order matters. This is not a standard field in OpenAPI specification, but can be used to control the order of properties. |
required[] |
Optional. If type is |
minProperties |
Optional. If type is |
maxProperties |
Optional. If type is |
minimum |
Optional. If type is |
maximum |
Optional. If type is |
minLength |
Optional. If type is |
maxLength |
Optional. If type is |
pattern |
Optional. If type is |
example |
Optional. Example of an instance of this schema. |
anyOf[] |
Optional. The instance must be valid against any (one or more) of the subschemas listed in |
additionalProperties |
Optional. If |
ref |
Optional. Allows referencing another schema definition to use in place of this schema. The value must be a valid reference to a schema in For example, the following schema defines a reference to a schema node named "Pet": type: object properties: pet: ref: #/defs/Pet defs: Pet: type: object properties: name: type: string The value of the "pet" property is a reference to the schema node named "Pet". See details in https://json-schema.org/understanding-json-schema/structuring |
defs |
Optional. An object containing a list of |
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. |
PropertiesEntry
| JSON representation |
|---|
{
"key": string,
"value": {
object ( |
| Fields | |
|---|---|
key |
|
value |
|
DefsEntry
| JSON representation |
|---|
{
"key": string,
"value": {
object ( |
| Fields | |
|---|---|
key |
|
value |
|
Retrieval
| JSON representation |
|---|
{ "disableAttribution": boolean, // Union field |
| Fields | |
|---|---|
disableAttribution |
Optional. Deprecated. This option is no longer supported. |
Union field source. The source of the retrieval. source can be only one of the following: |
|
vertexAiSearch |
Set to use data source powered by Agent Platform Search. |
vertexRagStore |
Set to use data source powered by Vertex RAG store. User data is uploaded via the VertexRagDataService. |
VertexAISearch
| JSON representation |
|---|
{
"datastore": string,
"engine": string,
"maxResults": integer,
"filter": string,
"dataStoreSpecs": [
{
object ( |
| Fields | |
|---|---|
datastore |
Optional. Fully-qualified Agent Platform Search data store resource ID. Format: |
engine |
Optional. Fully-qualified Agent Platform Search engine resource ID. Format: |
maxResults |
Optional. Number of search results to return per query. The default value is 10. The maximumm allowed value is 10. |
filter |
Optional. Filter strings to be passed to the search API. |
dataStoreSpecs[] |
Specifications that define the specific DataStores to be searched, along with configurations for those data stores. This is only considered for Engines with multiple data stores. It should only be set if engine is used. |
DataStoreSpec
| JSON representation |
|---|
{ "dataStore": string, "filter": string } |
| Fields | |
|---|---|
dataStore |
Full resource name of DataStore, such as Format: |
filter |
Optional. Filter specification to filter documents in the data store specified by data_store field. For more information on filtering, see Filtering |
VertexRagStore
| JSON representation |
|---|
{ "ragCorpora": [ string ], "ragResources": [ { object ( |
| Fields | |
|---|---|
ragCorpora[] |
Optional. Deprecated. Please use rag_resources instead. |
ragResources[] |
Optional. The representation of the rag source. It can be used to specify corpus only or ragfiles. Currently only support one corpus or multiple files from one corpus. In the future we may open up multiple corpora support. |
ragRetrievalConfig |
Optional. The retrieval config for the Rag query. |
storeContext |
Optional. Currently only supported for Gemini Multimodal Live API. In Gemini Multimodal Live API, if |
Union field
|
|
similarityTopK |
Optional. Number of top k results to return from the selected corpora. |
Union field
|
|
vectorDistanceThreshold |
Optional. Only return results with vector distance smaller than the threshold. |
RagResource
| JSON representation |
|---|
{ "ragCorpus": string, "ragFileIds": [ string ] } |
| Fields | |
|---|---|
ragCorpus |
Optional. RagCorpora resource name. Format: |
ragFileIds[] |
Optional. rag_file_id. The files should be in the same rag_corpus set in rag_corpus field. |
GoogleSearch
| JSON representation |
|---|
{ "excludeDomains": [ string ], // Union field |
| Fields | |
|---|---|
excludeDomains[] |
Optional. List of domains to be excluded from the search results. The default limit is 2000 domains. Example: ["amazon.com", "facebook.com"]. |
Union field
|
|
blockingConfidence |
Optional. Sites with confidence level chosen & above this value will be blocked from the search results. |
GoogleSearchRetrieval
| JSON representation |
|---|
{
"dynamicRetrievalConfig": {
object ( |
| Fields | |
|---|---|
dynamicRetrievalConfig |
Specifies the dynamic retrieval configuration for the given source. |
DynamicRetrievalConfig
| JSON representation |
|---|
{ "mode": enum ( |
| Fields | |
|---|---|
mode |
The mode of the predictor to be used in dynamic retrieval. |
Union field
|
|
dynamicThreshold |
Optional. The threshold to be used in dynamic retrieval. If not set, a system default value is used. |
GoogleMaps
| JSON representation |
|---|
{
"enableWidget": boolean,
"groundingTypes": {
object ( |
| Fields | |
|---|---|
enableWidget |
Optional. Deprecated: The Google Maps contextual widget behavior in Grounding with Google Maps is being deprecated; this field is planned for removal and no longer has any effect once removed. If true, include the widget context token in the response. |
groundingTypes |
Optional. Specifies the types of Google Maps grounding to enable. Defaults to |
GroundingTypes
| JSON representation |
|---|
{ "places": { object ( |
| Fields | |
|---|---|
places |
Optional. Enables grounding with Google Maps Places. This is the default grounding type when no |
routing |
Optional. Enables grounding with Google Maps Routing APIs (ComputeRoutes and SearchAlongRoute). |
EnterpriseWebSearch
| JSON representation |
|---|
{ "excludeDomains": [ string ], // Union field |
| Fields | |
|---|---|
excludeDomains[] |
Optional. List of domains to be excluded from the search results. The default limit is 2000 domains. |
Union field
|
|
blockingConfidence |
Optional. Sites with confidence level chosen & above this value will be blocked from the search results. |
ParallelAiSearch
| JSON representation |
|---|
{ "apiKey": string, "customConfigs": { object } } |
| Fields | |
|---|---|
apiKey |
Optional. The API key for ParallelAiSearch. If an API key is not provided, the system will attempt to verify access by checking for an active Parallel.ai subscription through the Google Cloud Marketplace. See https://docs.parallel.ai/search/search-quickstart for more details. |
customConfigs |
Optional. Custom configs for ParallelAiSearch. This field can be used to pass any parameter from the Parallel.ai Search API. See the Parallel.ai documentation for the full list of available parameters and their usage: https://docs.parallel.ai/api-reference/search-beta/search Currently only |
ComputerUse
| JSON representation |
|---|
{
"environment": enum ( |
| Fields | |
|---|---|
environment |
Required. The environment being operated. |
excludedPredefinedFunctions[] |
Optional. By default, predefined functions are included in the final model call. Some of them can be explicitly excluded from being automatically included. This can serve two purposes: 1. Using a more restricted / different action space. 2. Improving the definitions / instructions of predefined functions. |
Type
Type contains the list of OpenAPI data types as defined by https://swagger.io/docs/specification/data-models/data-types/
| Enums | |
|---|---|
TYPE_UNSPECIFIED |
Not specified, should not be used. |
STRING |
OpenAPI string type |
NUMBER |
OpenAPI number type |
INTEGER |
OpenAPI integer type |
BOOLEAN |
OpenAPI boolean type |
ARRAY |
OpenAPI array type |
OBJECT |
OpenAPI object type |
NULL |
Null 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. |
PhishBlockThreshold
These are available confidence level user can set to block malicious urls with chosen confidence and above. For understanding different confidence of webrisk, please refer to https://cloud.google.com/web-risk/docs/reference/rpc/google.cloud.webrisk.v1eap1#confidencelevel
| Enums | |
|---|---|
PHISH_BLOCK_THRESHOLD_UNSPECIFIED |
Defaults to unspecified. |
BLOCK_LOW_AND_ABOVE |
Blocks Low and above confidence URL that is risky. |
BLOCK_MEDIUM_AND_ABOVE |
Blocks Medium and above confidence URL that is risky. |
BLOCK_HIGH_AND_ABOVE |
Blocks High and above confidence URL that is risky. |
BLOCK_HIGHER_AND_ABOVE |
Blocks Higher and above confidence URL that is risky. |
BLOCK_VERY_HIGH_AND_ABOVE |
Blocks Very high and above confidence URL that is risky. |
BLOCK_ONLY_EXTREMELY_HIGH |
Blocks Extremely high confidence URL that is risky. |
Mode
The mode of the predictor to be used in dynamic retrieval.
| Enums | |
|---|---|
MODE_UNSPECIFIED |
Always trigger retrieval. |
MODE_DYNAMIC |
Run retrieval only when system decides it is necessary. |
Environment
Represents the environment being operated, such as a web browser.
| Enums | |
|---|---|
ENVIRONMENT_UNSPECIFIED |
Defaults to browser. |
ENVIRONMENT_BROWSER |
Operates in a web browser. |
Output Schema
Response message for VertexRagService.AskContexts.
AskContextsResponse
| JSON representation |
|---|
{
"response": string,
"contexts": {
object ( |
| Fields | |
|---|---|
response |
The Retrieval Response. |
contexts |
The contexts of the query. |
RagContexts
| JSON representation |
|---|
{
"contexts": [
{
object ( |
| Fields | |
|---|---|
contexts[] |
All its contexts. |
Context
| JSON representation |
|---|
{ "sourceUri": string, "sourceDisplayName": string, "text": string, "distance": number, "sparseDistance": number, "chunk": { object ( |
| Fields | |
|---|---|
sourceUri |
If the file is imported from Cloud Storage or Google Drive, source_uri will be original file URI in Cloud Storage or Google Drive; if file is uploaded, source_uri will be file display name. |
sourceDisplayName |
The file display name. |
text |
The text chunk. |
distance |
The distance between the query dense embedding vector and the context text vector. |
sparseDistance |
The distance between the query sparse embedding vector and the context text vector. |
chunk |
Context of the retrieved chunk. |
Union field
|
|
score |
According to the underlying Vector DB and the selected metric type, the score can be either the distance or the similarity between the query and the context and its range depends on the metric type. For example, if the metric type is COSINE_DISTANCE, it represents the distance between the query and the context. The larger the distance, the less relevant the context is to the query. The range is [0, 2], while 0 means the most relevant and 2 means the least relevant. |
RagChunk
| JSON representation |
|---|
{ "text": string, "fileId": string, "chunkId": string, // Union field |
| Fields | |
|---|---|
text |
The content of the chunk. |
fileId |
The ID of the file that the chunk belongs to. |
chunkId |
The ID of the chunk. |
Union field
|
|
pageSpan |
If populated, represents where the chunk starts and ends in the document. |
PageSpan
| JSON representation |
|---|
{ "firstPage": integer, "lastPage": integer } |
| Fields | |
|---|---|
firstPage |
Page where chunk starts in the document. Inclusive. 1-indexed. |
lastPage |
Page where chunk ends in the document. Inclusive. 1-indexed. |
Tool Annotations
Destructive Hint: ❌ | Idempotent Hint: ✅ | Read Only Hint: ✅ | Open World Hint: ❌