How to Use MCP Servers with Gemini CLI Explained in 5 Minutes
This article explains how to configure and use MCP (Managed Component Provider) servers with Gemini CLI, enabling powerful new data extraction capabilities for your AI workflows.
Initial Setup: Checking for MCP Servers
First, check your current configuration by typing /mcp
in the Gemini CLI. This command lists all currently configured MCP servers. If the list is empty, this guide will walk you through the setup process step-by-step.
Creating the settings.json
File
To begin, you need to create a settings.json
file to hold your configuration.
- Quit Gemini CLI.
- Ensure the configuration directory exists. If not, create it using your terminal:
bash mkdir -p ~/.config/google/gemini-cli
- Create and open the
settings.json
file in your preferred text editor. The following command uses Visual Studio Code as an example:bash code ~/.config/google/gemini-cli/settings.json
Configuring a Bright Data MCP Server
For this guide, we will use the Bright Data MCP server, a powerful platform that allows LLMs, agents, and applications to access and extract web data in real-time. These instructions can be adapted for any MCP server you wish to use with Gemini CLI.
Bright Data is a data scraping service that excels at extracting information from websites that are typically difficult to access, such as LinkedIn, Amazon, Reddit, and YouTube.
Add the MCP Server Configuration
Inside your
settings.json
file, you'll add a new JSON object for the MCP server. If the file already contains settings, add a comma after the last entry before pasting the new configuration.Here is the JSON schema for the MCP server configuration:
"mcp_server": { "api_token": "YOUR_API_TOKEN", "web_unlocker_zone": "YOUR_WEB_UNLOCKER_ZONE", "browser_zone": "YOUR_BROWSER_ZONE", "rate_limits": { "requests_per_second": 5, "concurrent_requests": 10 } }
Get Your Bright Data Credentials
To get the required values, sign up for a Bright Data account. Once logged in, navigate to the Proxies & Scraping section.
- We recommend using the **Web Unlocker** API for the most robust automated scraping, as it handles residential proxies, CAPTCHAs, and JS rendering.
- Click **Create zone**. You can keep the default name (e.g., `web_unlocker_4`).
- Enable the **CAPTCHA solver** and click **Add**.
The platform will provide you with your **Zone** name and **API key**.
Update
settings.json
Now, update your
settings.json
file with the credentials you obtained.
- `api_token`: Your Bright Data API key.
- `web_unlocker_zone`: The zone name you created (e.g., `web_unlocker_4`).
- `browser_zone`: You can leave this with a default value if not using a specific browser zone.
- `rate_limits`: Adjust these values based on your needs and plan.
Your final configuration should look something like this:
```json
{
"gemini": {
"preferred_editor": "vscode",
"auth_method": "api_key"
},
"mcp_server": {
"api_token": "YOUR_API_KEY_HERE",
"web_unlocker_zone": "web_unlocker_4",
"browser_zone": "mcp_server",
"rate_limits": {
"requests_per_second": 10,
"concurrent_requests": 20
}
}
}
```
Activating and Using the MCP Server
After saving your settings.json
file, restart Gemini CLI for the new settings to take effect.
Running the /mcp
command again will now show that one MCP server is configured and active. You now have access to a suite of powerful new tools for web data extraction, including:
- Search engines
- Scraping tools
- Specific data extractors for platforms like LinkedIn, Instagram, Facebook, TikTok, Google services, and YouTube.
Example: Querying YouTube Data
Let's test the integration with a specific query. We can ask for the latest statistics and videos from a YouTube channel.
Prompt:
What are the latest stats of the YouTube channel https://www.youtube.com/@user and what are the last 10 videos on this channel?
Gemini CLI will identify the appropriate tool—in this case, web_data_youtube_profile
from the Bright Data MCP server—and ask for your permission to run it. After you grant permission, it will execute the query.
Example Output: The tool will return up-to-date stats and a list of the 10 most recent videos from the specified channel, demonstrating its ability to extract live data directly from the web.
Advanced Usage and Tips
- Viewing Errors: If a tool call fails, you can inspect the error log by pressing
Ctrl+O
. This is useful for debugging issues, such as hitting rate limits. - Understanding Tool Inputs: To use the MCP server tools effectively, you need to know what inputs they expect. Press
Ctrl+T
to view a detailed overview of each tool, including whether it requires a specific URL or a structured text query. - A Note on Tool Selection: Sometimes, Gemini CLI might default to a general tool like a web search instead of a more specific MCP tool. This is a known area of development, and forcing the use of a particular MCP tool may require more precise prompting.
Alternative: Using MCP Servers with Cloud Desktop
You can also configure the Bright Data MCP server with Cloud Desktop, where it works seamlessly. The setup is very similar:
- In Cloud Desktop, go to Cloud Settings > Developers.
- Click Add Config (or Edit Config) to open the
cloud-desktop-config.json
file. - Paste the same
mcp_server
JSON block you used for Gemini CLI and fill in your credentials.
Running complex queries, such as searching for job listings across multiple sites, often works very well in this environment, as the agent can chain multiple search and scrape actions together to gather and present the requested information.
Setting up MCP servers significantly extends the capabilities of Gemini CLI, opening up powerful new ways to integrate real-time web data into your AI workflows. As the tool is open-source, we can expect its functionality to continue evolving rapidly. I hope you found this guide helpful.
Join the 10xdev Community
Subscribe and get 8+ free PDFs that contain detailed roadmaps with recommended learning periods for each programming language or field, along with links to free resources such as books, YouTube tutorials, and courses with certificates.