Search⌘ K
AI Features

Connecting Gemini to External Tools with MCP

The Model Context Protocol (MCP) provides a standard interface for connecting Gemini-based applications to external tools. Each tool should expose only the operations required by the application. For an order-status assistant, expose a specific operation such as `get_order_status(order_id)` instead of granting the agent unrestricted database access. MCP standardizes communication between applications and tool servers, but authentication, authorization, and request scoping must be implemented and enforced by the participating systems. The application must verify the user's identity and permissions separately from the credentials used to execute tool operations. Tool servers must enforce the appropriate access restrictions before retrieving protected data.

Why expose database administration operations to an order-status assistant that only needs get_order_status(order_id)?

The proposed integration exposes the full Cloud SQL MCP tool catalog, although the application only needs order-status lookups. User u17 belongs to tenant north and requests the status of order O-314.

The integration must restrict available operations and verify that each requested order is accessible to the authenticated user. Successful database connectivity does not establish that the tool has appropriate permissions or that the user is authorized to access the requested order.

Bound the order operation

The order system contains two records:

  • O-314: Tenant north, status awaiting_dispatch.

  • O-908: Tenant south, status delivered.

The assistant needs neither arbitrary SQL nor instance management. Its intended model-visible operation is get_order_status(order_id: str), returning only order_id and status when access succeeds.

A Model Context Protocol server exposes external data or executable capabilities to an AI application through a standardized integration boundary. The application hosts an MCP client; Gemini proposes operations while application and server code execute them.

The integration decision is therefore concrete: Reuse a managed server when its operations and enforceable access boundaries fit the task. Otherwise, expose the missing business operation through a narrow custom server. Smaller tool catalogs reduce irrelevant choices, but authorization still has to answer whether this caller may read this particular order.

Follow O-314 end-to-end

Separate five components before tracing the request:

  • Host: The assistant application that coordinates Gemini and tool execution.

  • Client: The host’s MCP implementation, which communicates with the remote server.

  • Endpoint: The network address and communication interface used to reach that server.

  • Server: The service that exposes tools, validates calls, and enforces its access contract.

  • Backend: The order store that the server reads using independently controlled database permissions.

For u17 asking about O-314, the complete path is:

  1. The host supplies the approved get_order_status contract to Gemini.

  2. Gemini proposes get_order_status with {“order_id”:“O-314”}.

  3. The host’s MCP client sends the call, attaching credentials outside the model content.

  4. The server validates authentication and delegation, checks arguments and policy, and performs a tenant-scoped backend lookup.

  5. The result returns through the client as a tool observation; Gemini can then explain awaiting_dispatch to the user.

Conceptual, not a captured execution: Trusted caller context gates the tenant-scoped O-314 lookup
Conceptual, not a captured execution: Trusted caller context gates the tenant-scoped O-314 lookup

The important crossing is between model-controlled arguments and trusted caller context. order_id expresses what the model requests. Validated authentication and delegation establish who is requesting it and which tenant they may access. Neither a tool description nor an argument saying “tenant”:“north” supplies identity evidence.

An endpoint provides a place to send a request. Google Cloud MCP servers also require enablement and authentication before use. ...