Gemini Tool Retrieval Guide: Dynamic MCP Tools and Permissions
How does Gemini Tool Retrieval work? Learn how tool_search and defer_loading load MCP tool schemas on demand, compare static, server and client discovery, and review XBSTACK’s 64-tool offline permission test and cost limitations.
Evidence 3 cited sources
On this page
When an agent connects to dozens of MCP functions, why should every request send parameter schemas for tools the current task will never use? Google’s November 19, 2026 introduction of Gemini Tool Retrieval (Preview) addresses part of that problem: tool_search and defer_loading: true let an Interactions API request discover and load the full parameters of selected functions on demand.
But the essential boundary is often lost in the excitement: retrieving a tool is not the same as authorizing a tool. If your registry contains functions that can delete documents, export private data or issue refunds, turning on lazy loading does not make those operations safe. Google’s original announcement
This guide separates Google’s documented contract from what XBSTACK actually tested: 64 synthetic function definitions, three registry shapes, client permission filtering and four deterministic tests. It does not invent a remote Gemini benchmark, token saving percentage or model response-time result.

Figure 1|How Gemini Tool Retrieval Works. Discovery, schema loading and execution authorization are separate stages; not a live Gemini API screenshot.
First, the three practical answers
How do I enable Tool Retrieval? In the preview Gemini Interactions API, declare tool_search and add defer_loading: true to functions whose complete parameter schemas should be loaded later. For your own registry search, configure tool_search with execution: "client" and return only the full schemas that the current user may discover.
Does it always save tokens? No. Google says Tool Retrieval carries no separate feature charge, but standard model input and output usage remains billable. Schema lookup has an initial cost, retrieved schemas also consume context, and client search may require an additional round trip. A small registry, or one where most tools are called in every turn, may not benefit.
Does it enforce user permissions? No. In server mode, deferred names and descriptions remain visible to the model. The real executor must independently authorize the user, resources, action, parameters and any high-impact side effect.
Three ways of providing tool definitions
| Mode | Discovery | Initial model context | Appropriate use | Key caveat |
|---|---|---|---|---|
| Static complete declarations | No search | Names, descriptions and full schemas | Small fixed registries | Repeated overhead; unfiltered sensitive tool visibility |
Server-side tool_search | Gemini looks up tools | Deferred names and descriptions; schemas loaded when needed | Large, pre-authorized registries | Names and descriptions remain visible; no business ACL |
Client-side tool_search | Application-owned lookup | Client’s search definition; later returns authorized schemas | Per-user tools, dynamic integrations, tenant isolation | Extra application round trip and your own policy implementation |

Figure 2|Server-side vs Client-side Retrieval. Both ultimately require independent execution-time authorization.
The server-side steps can appear as tool_search_call, tool_search_result and function_call inside interaction.steps. Client search instead uses execution: "client" and an application-generated result in a subsequent interaction. Google’s documentation names Gemini 3.6 and later, including Gemini 4, within the preview Interactions API. That is not a promise that the flag works in every older generateContent SDK pathway. Check the model, SDK, account and endpoint before deploying. Gemini API changelog
What the documented server mode looks like
This illustrates Google’s published request structure, not an XBSTACK live request:
from google import genai
client = genai.Client() # Use your own authorized Gemini API key
interaction = client.interactions.create(
model="gemini-4-hydrogen",
input="Find the report for project A-1042.",
tools=[
{"type": "tool_search"},
{"type": "function", "name": "find_report",
"description": "Find an authorized report by project ID.",
"defer_loading": True,
"parameters": {
"type": "object",
"properties": {"project_id": {"type": "string"}},
"required": ["project_id"],
}},
],
)
for step in interaction.steps:
print(step.type) # Inspect tool steps; do not auto-execute writes
Google states that the names and descriptions of deferred functions are still shown to the model; the full parameters are held back. If the existence of a tool is confidential for a given user, do not include that unfiltered tool in a server-retrieval request.
What our 64-tool offline experiment measured
XBSTACK generated 64 synthetic Function schemas. Only read_docs, search_docs and export_document were allowed for the test user; delete_document and issue_refund were deliberately denied. No Gemini API key, remote MCP server, paid inference or private data was involved.
The numbers below measure compact JSON UTF-8 byte lengths, not Gemini tokens or invoices:
| Offline structure | Size | What this proves |
|---|---|---|
| 64 full static parameter schemas | 29,408 bytes | Complete synthetic definition length |
Deferred server names/descriptions plus tool_search | 9,911 bytes | Smaller initial serialized structure in this fixture |
| That structure plus one full selected schema | 10,361 bytes | The selected tool’s schema still enters context |
| Client-side search tool declaration | 120 bytes | Small initial search declaration, excluding subsequent turns |
| Authorized matching client search results | 905 bytes | Filtered synthetic schema result |
The four test cases passed 4/4. In particular, a locally filtered client search for delete or refund returned no denied schema; a server-deferred declaration still exposed the name of issue_refund. That tests our own policy filter, not Gemini’s enforcement of a real user’s permissions.
JSON byte length cannot be converted directly to model tokens. This experiment did not measure prompt caching, tool-selection accuracy, latency, retry counts, invoice costs or accepted tasks. Its source is in experiments/gemini-tool-retrieval-20261123/compare.py and test_compare.py, runnable with python3 -S, without network access.

Figure 3|What XBSTACK Actually Tested. The results describe local structural and permission checks, not measured Gemini tokens, cost or latency.
MCP metadata and authorization are different security boundaries
A remote MCP server may supply tool descriptions from a less trusted source. Even when the model will load full parameter schemas only when it needs them, the initial tool names and descriptions may reveal capabilities, internal resources or misleading directions.
For public search tools, that may be harmless. For delete_document, issue_refund or private customer-record tools, visibility itself may be permission-sensitive. Filter the registry by user, workspace, tenant and session before discovery. Validate schema IDs and tool source provenance, and treat tool descriptions and responses as untrusted data.
A model choosing a function is not an execution authorization. The application must verify identity, resource ownership, operation scope, arguments, approval status, prior attempts and a stable idempotency key before any external write. Discovery cannot approve a refund, send an email or delete a file.
For OwnRAG, authorization to search a local collection is also separate from permission to send selected evidence to a remote model provider. This article does not claim OwnRAG has integrated or tested Tool Retrieval. XBSTACK’s existing Agent Tool Authorization Policy Gate covers what happens after the model proposes an action; MCP Tool Poisoning addresses malicious metadata and third-party trust. This article focuses on the earlier discovery and schema exposure stage.
A workable authorization-first design
User request
↓
Authenticate user, determine tenant/resource scope
↓
Filter tool registry before discovery
↓
Client tool_search returns only permitted full schemas
↓
Model selects a function (not a grant of access)
↓
Backend checks identity, tool ID, arguments, policy and scope
↓
Require approval for consequential writes; stable operation key
↓
Execute or reject → audit outcome → return minimal data
The following is a simplified policy sketch, not production-ready identity or tenant authorization:
ALLOWED = {"read_docs", "search_docs", "export_document"}
def find_available_tools(registry, user_allowed, term):
allowed = ALLOWED.intersection(user_allowed)
return [tool for tool in registry
if tool["name"] in allowed
and term.lower() in tool["name"].lower()]
def authorize_execution(user_allowed, tool_name, resource_scope):
if tool_name not in ALLOWED.intersection(user_allowed):
raise PermissionError("Unauthorized tool")
if not resource_scope:
raise PermissionError("Missing resource scope")
Real deployments need per-resource authorization, tenant isolation, user consent and revocation, audit logs and external side-effect reconciliation. If an integration is disconnected during a conversation, both future discovery and an already-pending tool invocation must be rejected as appropriate. Do not treat a cached search result as a permanent permission token.

Figure 4|Authorization Boundary. A discovered capability is not user consent or permission to execute.
When is deferred loading worth the complexity?
Google says Tool Retrieval has no independent feature charge. The model’s input and output tokens remain billable, tool search adds some input, and loaded schemas count as context once loaded. Client search adds an application round trip. Deferred schemas may help prefix caching because a repeated prompt prefix stays more stable, but the actual gain is workload-dependent. Google’s pricing explanation
To compare these strategies honestly, fix the model, task set and registry. Capture actual input/output and cached tokens, schemas loaded, tool_search calls, extra turns, incorrect selections, blocked operations, retries, accepted tasks, total price and latency.
The right metric for an Agent is the cost per successfully accepted task, not the initial JSON length. A five-tool assistant that typically calls nearly every function may gain little by adding a search step. See the related Gemini 4 Neon task acceptance economics analysis, without mistaking that argument for a live Tool Retrieval API benchmark.
XBSTACK has not run the three modes against live Gemini Interactions yet. We therefore do not claim a measured token-saving percentage, average latency improvement or proof that Google’s retrieval mechanism is more secure than a filtered static registry.
Checklist before adoption
- Verify Interactions API preview eligibility, the chosen Gemini model and SDK support.
- Remove duplicate and obsolete functions, and avoid sending permission-sensitive names or descriptions to an unfiltered server-side registry.
- Use current user/tenant/session authorization filters for client retrieval, including when a plugin connects or disconnects mid-conversation.
- Validate every actual call again in the trusted backend, including resource, operation, arguments, approval and idempotency.
- Audit search steps, returned schemas, tool selection, rejected calls and final outcomes without recording unnecessary private content.
- Publish cost or speed claims only after collecting real Gemini usage and task-level results.
Conclusion
Tool Retrieval represents an important shift: an Agent does not need every tool’s full parameter Schema before it starts. But the product benefit depends on more than saving context. The registry should reveal only appropriate tools; the executor should perform only approved actions; and the system should be able to prove what happened.
The next fair comparison is a real Gemini Interactions run with a safe public-tool fixture in static, server-retrieval and client-retrieval modes. Until then, the validated finding is a local policy-boundary experiment plus an official API contract, not a remote-model benchmark.
References
- Google: Introducing Tool Retrieval in the Gemini API (Nov. 19, 2026) — feature behavior, two modes, supported models and cost conditions.
- Gemini API changelog — preview release.
- Gemini Interactions API — request and response lifecycle.
- XBSTACK offline experiment:
experiments/gemini-tool-retrieval-20261123/compare.pyandtest_compare.py; 64 synthetic tools, 4/4 tests; not a paid Gemini API test.
Independent engineering research; not Google certification, a provider benchmark or a claim that OwnRAG has shipped this integration.
Continue from protocol details to production MCP governance
The MCP hub connects protocol fundamentals, transports, authentication, security, JSON-RPC debugging and production deployment without splitting the search intent across isolated guides.
Next step: move MCP toward production
Full decision path →Continue from protocol behavior into transport, authorization, security, and operational boundaries.
DISCUSSION
Questions, verification and corrections
Sign in to comment. Every new comment is reviewed before publication; while pending, it is visible only to you and the administrator.