Hello everyone! Today we will learn about how to run Gemini CLI as MCP client with Docker MCP Server. Gemini CLI is a command-line version of Google’s Gemini that lets developers build AI agents, automate workflows, and run headless or backend tasks. Unlike Claude desktop or chatgpt , it’s fast, scriptable, and open, giving developers full control to combine AI reasoning with real-world actions.
The game-changing feature is that you can use MCP Server in Gemini CLI by turning it into MCP Client. Before diving into it more, lets clear some basics.
What are MCP Server and MCP Client?
MCP stands for Model Context Protocol. It’s a new open standard that lets AI models (like Gemini, Claude, or ChatGPT) communicate with external tools or apps in a consistent, secure way.
With the help of MCP server, you can give your AI agent or model access to multiple tools and make your agentic work smarter.
And the AI models or AI agents that will use the MCP server to use tools are called MCP clients.
Now let's dive into our today's main focus. I will show you step-by-step how you can use Docker MCP in your Gemini CLI.
Step 1: Install Docker
Go to this link and download the installer file for Docker.Docker Desktop
Click your installer file and start the installation.
Make sure to enable this button otherwise docker won't run successfully.
- Click next and complete the installation process.
- After that, click your Docker Desktop and start your Docker engine.
Step 2: Install Node.js.
To run the Gemini CLI, Node.js is a requirement. Go to this link and download Node.js. Node.js
Step 3: Install Gemini CLI Globally
For Windows, Mac, or Linux, run this code in your command prompt and install Gemini CLI.
npm install -g @google/gemini-cli
After installing, verify the Gemini version
gemini --version
Then, you must log in with your Google account.
gemini login
After completing the installation, just write "gemini" in your command prompt, and the Gemini CLI interface will start running. You can use this as you use Gemini by generating texts and doing web searches (you will need the Gemini API for that), but the best part is that now this CLI has access to all the files of your local machine! How cool is that!
Step 4: Docker MCP
Docker Desktop already has a built-in MCP toolkit, which allows you to select any MCP server you want out of 223 servers from their catalogs. You can also choose Claude desktop, Gemini CLI, or Cursor as your MCP client. In this tutorial, we will focus on using Gemini CLI as an MCP client for MCP Docker.
- First, go to MCP toolkit in Docker Desktop.
- Next, go to the catalog to search for our desired MCP server.
- In this tutorial we will show how to add the Wikipedia MCP server to your Docker. For that reason, search for Wikipedia and select the Wikipedia server.
- Next, you can see the Wikipedia server in the "My Servers" tab.
Congrats! Now you have added the Wikipedia MCP server to your Docker Desktop! That's how easy the whole process is. Next, we will add Gemini CLI as an MCP client.
Step 5: Gemini CLI as MCP client
- This step is also very easy. First, go to the "Clients" tab in the MCP toolkit and connect Gemini CLI. That's it; your Gemini CLI is now connected to Docker MCP.
- Next, go to your command prompt and write Gemini. This will initiate Gemini in your command line. It will look something like this:
- You can see that your Gemini CLI is already connected to Docker MCP. You can check that by writing
/mcp
in the command line.
Debugging: In case your Docker MCP is not showing in Gemini CLI,
just run docker mcp gateway run
and this will connect your Docker MCP to Gemini CLI.
Step 6: We're ready!
Now let's test our MCP server. Our Docker MCP now has access to Wikipedia. And with the Gemini CLI as an MCP client, we can directly access all the tools of Wikipedia. Let's test it!
- First, go to your command prompt and write "gemini." This will initialize the Gemini CLI.
- Then write this: "search in wikipedia for Milkyway Galaxy"
- Then you will see something like this. Click "Allow once" and go to the next step.
- Gemini will use the "search_wikipedia" tool with the query of "Milkyway galaxy" and will show a result like this.
- Your Gemini may ask if you want a summary like this in the photo. If you say yes, it will show a summary of the article.
Congrats! You have done it!
Great news! You have successfully tested your Docker MCP server in Gemini CLI. Now you have countless possibilities. From using the Gmail MCP server to send mail to using MongoDB for your database, you can do whatever you want. The sky is the limit!
In the next tutorial, we will show how to automate and send mail to multiple email addresses with just one command with the help of Gemini CLI and MCP Docker.
Top comments (0)