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.

Published · 2026-11-238 min readXBSTACK
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.

GPT-generated English concept illustration: discover a tool, load its schema on demand, check policy and only then execute an approved action.

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

ModeDiscoveryInitial model contextAppropriate useKey caveat
Static complete declarationsNo searchNames, descriptions and full schemasSmall fixed registriesRepeated overhead; unfiltered sensitive tool visibility
Server-side tool_searchGemini looks up toolsDeferred names and descriptions; schemas loaded when neededLarge, pre-authorized registriesNames and descriptions remain visible; no business ACL
Client-side tool_searchApplication-owned lookupClient’s search definition; later returns authorized schemasPer-user tools, dynamic integrations, tenant isolationExtra application round trip and your own policy implementation

GPT-generated English comparison of Gemini server-side discovery and client-owned tool search with permission-filtered schemas.

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 structureSizeWhat this proves
64 full static parameter schemas29,408 bytesComplete synthetic definition length
Deferred server names/descriptions plus tool_search9,911 bytesSmaller initial serialized structure in this fixture
That structure plus one full selected schema10,361 bytesThe selected tool’s schema still enters context
Client-side search tool declaration120 bytesSmall initial search declaration, excluding subsequent turns
Authorized matching client search results905 bytesFiltered 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.

GPT-generated English evidence illustration: 64 synthetic functions, 3 authorized tools and four offline deterministic tests, with no live Gemini API cost or latency measurement.

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.

GPT-generated English illustration of the authorization boundary between tool discovery and approved backend execution.

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

  1. Verify Interactions API preview eligibility, the chosen Gemini model and SDK support.
  2. Remove duplicate and obsolete functions, and avoid sending permission-sensitive names or descriptions to an unfiltered server-side registry.
  3. Use current user/tenant/session authorization filters for client retrieval, including when a plugin connects or disconnects mid-conversation.
  4. Validate every actual call again in the trusted backend, including resource, operation, arguments, approval and idempotency.
  5. Audit search steps, returned schemas, tool selection, rejected calls and final outcomes without recording unnecessary private content.
  6. 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

Independent engineering research; not Google certification, a provider benchmark or a claim that OwnRAG has shipped this integration.

Topic path / MCP

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.

Next problem in the same topicGemini 4 Neon Changes the Agent Economics. Who Signs Off on the Work?An independent argument about why Gemini 4 Neon may change recurring coding-agent economics: the difference between token prices and accepted task costs, what harnesses and approvals actually do, and three falsifiable forecasts for 2027. Based on official sources and XBSTACK engineering, not paid Neon benchmarks.Continue with state and memoryWhat Is Context Engineering? Reducing AI Agent Cost with Retrieval, Tool Search and MemoryContext engineering goes beyond prompt engineering. This guide combines Microsoft, Anthropic and Google sources with XBSTACK tests on retrieval, tools, memory and token cost.Continue with state and memoryGemini 4 Hydrogen, Argon, or Carbon? Model Routing for OwnRAG and SleepAnew EngineeringA source-grounded comparison of Gemini 4 Hydrogen, Argon and Carbon for coding and tool-using agents. OwnRAG's existing BYOK and citation controls, SleepAnew's audio recovery and XBSTACK's bilingual deployment gates illustrate model routing, December 2026 pricing changes, idempotency and verified-task costs without inventing model A/B results.
Comments & evidence

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.

Sign-in required Reviewed before public
Loading the discussion…