Gemini CLI Reference¶
Complete guide to using Gemini CLI with Preloop's Safety Layer.
Overview¶
Gemini CLI is Google's open-source terminal AI agent. It supports MCP out of the box, making it simple to connect to Preloop's Safety Layer.
Installation¶
Or via the official repo:
Verify:
Configuration¶
Connect to Preloop¶
Step 1: Get Your API Key
- Log in to preloop.ai
- Settings → API Keys → + Create API Key
- Name: "Gemini CLI"
- Copy the key
Step 2: Add Preloop MCP Server
Edit ~/.gemini/settings.json:
{
"mcpServers": {
"preloop": {
"url": "https://preloop.ai/mcp/v1",
"headers": {
"Authorization": "Bearer YOUR_API_KEY_HERE"
}
}
}
}
Step 3: Verify Connection
You should see preloop listed with available tools.
Usage¶
Basic Usage¶
The approval flow works the same as other clients:
- Gemini sends tool call to Preloop
- Preloop creates an approval request
- You approve via dashboard, mobile, or email
- Tool executes and result is returned
Differences from Other Clients¶
| Feature | Gemini CLI | Claude Code |
|---|---|---|
| Provider | Anthropic | |
| Transport | HTTP streaming | HTTP streaming |
| Config location | ~/.gemini/settings.json |
~/.claude/mcp-servers.json |
| MCP support | Native | Native |
Automatic Discovery¶
Use the Preloop CLI to automatically detect Gemini CLI:
This scans ~/.gemini/settings.json and inspects the local MCP and model configuration.
Discovery is the entry point for onboarding an existing Gemini CLI setup into Preloop:
- Existing MCP tools can be imported into your Preloop account when they can be represented there
- Existing AI model metadata can be imported or reused when the local configuration is compatible
- Supported managed rewrites can point Gemini CLI to the Preloop Gateway for model traffic and the Preloop Tool Firewall for governed MCP access
If you want discovery to stay non-mutating in scripts or CI, use the read-only flags supported by the Preloop CLI.