Skip to main content

Gemini CLI MCP Setup

Connect MCPBundles MCP servers to Gemini CLI to use Google's AI assistant from the command line.

Requirements

  • Gemini CLI installed (npm install -g @google/gemini-cli or similar)
  • An MCP server enabled in your MCPBundles dashboard
  • Credentials connected for the providers on that MCP server

Time to complete: 2-3 minutes


If you have terminal access, the fastest way to connect is via the MCPBundles CLI:

pip install mcpbundles
mcpbundles init

This automatically discovers your MCP servers, writes the Gemini CLI config, and handles authentication. No manual JSON editing needed.

After running mcpbundles init, restart Gemini CLI and your tools will be available.

Want more control? Use mcpbundles tools to browse available tools, or mcpbundles call <tool-name> to test a tool directly from your terminal.


Option B: Manual Setup

Step-by-Step Setup

1. Get your MCP server URL

  1. Log in to MCPBundles Dashboard
  2. Open the MCP server you want to connect
  3. Scroll to the "Quick Setup" section (only visible when the MCP server is operational)
  4. Copy the MCP Server URL

2. Configure Gemini CLI

Gemini CLI may auto-discover MCP servers or require manual configuration.

Check if Gemini CLI has an MCP configuration file (similar to Gemini Code).

If configuration file exists:

Edit it to add your MCP server (see Gemini Code Integration for format).

If auto-discovery:

Gemini CLI might discover MCP servers automatically if they're configured system-wide.


3. List Available MCP Servers

In Gemini CLI, run:

/mcp list

Your MCP server should appear in the list.


4. Authenticate When Prompted

The first time a tool is called that needs credentials:

  1. Gemini CLI will prompt for authentication
  2. Follow the OAuth flow or provide API key
  3. Credentials are stored for future use

5. Verify Tools Are Available

Ask Gemini:

What tools do you have access to?

Expected response: List of tools from your MCP server(s).


Using Tools in Gemini CLI

Once connected, Gemini can use your tools in command-line interactions.

Example Prompts

Data retrieval:

"Check my Smartlead campaigns and show the top 3 by reply rate"

GitHub operations:

"List my GitHub repos and tell me which ones have the most stars"

CRM tasks:

"Add John Doe (john@example.com) to HubSpot as a new contact"

Gemini will call the tools and display results in the terminal.


Troubleshooting

"/mcp command not found"

Cause: Outdated Gemini CLI or command not supported.

Fix:

  • Update Gemini CLI to the latest release
  • Check release notes for MCP support

MCP server doesn't appear in /mcp list

Cause: Configuration not loaded or file location wrong.

Fix:

  • Check if config file exists at ~/.gemini/settings.json (or equivalent)
  • Verify the MCP server is added correctly
  • Restart Gemini CLI

"Authentication required" when calling tools

Fix:

  1. Go to Settings → Credentials
  2. Scroll to the "Credentials" section
  3. Click "Add Credential" (or "Connect [Provider]" if no credentials exist) on needed providers
  4. Complete OAuth or add API key in the credential panel
  5. Select validation tool and click "Validate Now"
  6. Try the tool again in Gemini CLI

See Provider Credentials Guide.


Tools work but return empty data

Cause: Connected to wrong account or no data exists.

Fix:

  1. Settings → Credentials → find [Provider] and expand it
  2. Scroll to the "Credentials" section
  3. Check which account is connected
  4. If wrong, click "Edit" on the credential card
  5. In the credential panel, click "Connect with [Provider]" again and use correct account
  6. Re-validate the credential
  7. Verify data exists in the provider's app

Configuration Details

Gemini CLI likely uses the same config format as Gemini Code.

See: Gemini Code Integration for detailed config examples.


CLI-Specific Features

Scripting

You can pipe commands to Gemini CLI:

echo "List my Smartlead campaigns" | gemini

Useful for:

  • Automation scripts
  • Cron jobs
  • CI/CD pipelines

Output Formats

Gemini CLI may support different output formats:

  • Plain text (default)
  • JSON (--json flag)
  • Markdown (--markdown flag)

Check gemini --help for available options.


Advanced Usage

Multiple MCP servers

Configure multiple MCP servers in ~/.gemini/settings.json:

{
"mcpServers": {
"marketing": {
"command": "npx",
"args": ["mcp-remote", "https://mcp.mcpbundles.com/bundle/abc123"]
},
"dev": {
"command": "npx",
"args": ["mcp-remote", "https://mcp.mcpbundles.com/bundle/def456"]
}
}
}

All tools from all MCP servers will be available in the CLI.


Environment-specific MCP servers

Use different MCPBundles MCP server URLs for different environments:

Production:

{
"mcpServers": {
"prod": {
"command": "npx",
"args": ["mcp-remote", "https://mcp.mcpbundles.com/bundle/prod-id"]
}
}
}

Staging:

Switch the config to use your staging MCP server URL.


Next Steps


Need Help?