

Welcome to Part 5 of the Gemini CLI Tutorial series.
Gemini CLI Tutorial Series:
Part 1 : Installation and Getting Started
Part 2 : Gemini CLI Command line options
Part 3 : Configuration settings via settings.json and .env files
Part 4 : Built-in Tools
Part 5: Using Github MCP Server (this post)
Model Context Protocol (MCP) has well established itself over the last year as the standard way for AI Clients to connect to external tools. This is not going to be a tutorial on MCP since there is enough material on the web to understand that. I am assuming that you know the value that MCP brings to the table and it was good to see that Gemini CLI supports MCP since its initial release. This means we can look at integrating MCP Servers to augment the functionality that Gemini CLI already has via its model and built-in tools.
This tutorial will take you through how we configure MCP Servers in Gemini CLI, a few commands then within Gemini CLI to work with them and along the way, we shall we setting up the Github official MCP Server and then doing a little exercise of seeing how Gemini CLI helped me fix a problem in my Github repo by detecting the problem, doing the fix and then pushing the changes back to the remote repository.
Before we get to the exact place you will configure MCP Servers, let’s get familiar first with the Gemini CLI and what happens on a system, where you have just installed Gemini CLI and no MCP servers have been setup yet.
I would also like to describe that I am currently in a folder named gemini-cli-projects
in my home folder. I have setup Gemini to authenticate via Vertex AI and my GOOGLE_CLOUD_PROJECT
and GOOGLE_CLOUD_LOCATION
values have been setup in the .gemini/.env
folder in the current folder i.e. gemini-cli-projects
.
When I launch Gemini CLI, I can check up on the MCP servers configured via the /mcp
command as shown below:
It also opens up the documentation for the configuration, that is available over here: https://github.com/google-gemini/gemini-cli/blob/main/docs/cli/configuration.md . You will need to go to the mcpServers
section for that.
If you look at my current settings.json
file, it has the following content:
{
"selectedAuthType": "vertex-ai",
"theme": "Default",
"preferredEditor": "vscode"
}
To add an MCP Server, we need to have the mcpServers
property above and inside of that configure our MCP Servers.
It should look something like the following:
{
"selectedAuthType": "vertex-ai",
"theme": "Default",
"preferredEditor": "vscode",
"mcpServers": {
"server_name_1": {},
"server_name_2": {},
"server_name_n": {}
}
}
Each of the server objects has a name as you can see and then a list of parameters. The documentation provides a clear description of them:
command
(string, required): The command to execute to start the MCP server.args
(array of strings, optional): Arguments to pass to the command.env
(object, optional): Environment variables to set for the server process.cwd
(string, optional): The working directory in which to start the server.timeout
(number, optional): Timeout in milliseconds for requests to this MCP server.trust
(boolean, optional): Trust this server and bypass all tool call confirmations.
Let’s look at configuring a few MCP Servers now to understand how it all comes together.
There is one point to note before we configure a few of these servers. Gemini CLI is able to integrate with your host system, as a result of which, if you already have these utilities configured on your system, chances are good that Gemini CLI will be able to find them and execute them for you. So you will have to make a choice if you need to have the MCP Server or not. For e.g. if you already have git installed and setup on the host system, Gemini CLI should be able to invoke the commands.
The Github official MCP Server provides sufficient documentation on the tools that it exposes along with how to configure the same. You can pick your choice in terms of running it locally or remotely, since Gemini CLI supports remote MCP Servers too.
In this tutorial, I have chosen to the Remote MCP Server option in Github. For this, you will need to have a Personal Access Token (PAT) from Github.
The MCP Server object that we will need to put in the settings.json
file is shown below:
"github": {
"httpUrl": "https://api.githubcopilot.com/mcp/",
"headers": {
"Authorization": ""
},
"timeout": 5000
}
My settings.json
file in .gemini
folder in the home
directory looks like this now:
{
"selectedAuthType": "vertex-ai",
"theme": "Default",
"preferredEditor": "vscode",
"mcpServers": {
"github": {
"httpUrl": "https://api.githubcopilot.com/mcp/",
"headers": {
"Authorization": ""
},
"timeout": 5000
}
}
}
Let me start Gemini CLI with this and I see the following on the home screen at startup (Notice that it says Using 1 MCP Server):
At this point, if you give the /mcp
command, you will see the following:
I try out a little exercise to find out if it can use the tool to know who I am. It picks up the right tool get_me
from the Github MCP Server and displays the required information, as shown below:
Gemini CLI — Discover an issue automatically
I want to get around to doing something interesting with Gemini CLI and one of my repositories. So while it is not exactly just a MCP server configuration, its a nice little exercise to see the kind of stuff that Gemini can identify and fix for us too.
One of my repository is https://github.com/rominirani/adk-projects and it contains a bunch of Agent Development Kit (ADK) projects that I have created when I was learning the framework. I have a README.md
file that has a list of all the folders, each of which contains a sample agent that has been developed using ADK.
The README.md
file has a problem in that one of the descriptions / folder is incorrect. The current README.md
file is shown here:
The 3rd entry is incorrect. There is no folder like that or description. I want to see if Gemini CLI can figure this out and then make the changes. Then we shall use the MCP Github server configured tool to push back the changes.
So, lets ask what’s there in the adk-projects
repository that I own:
There is a lot of text and then it gives me the following summary:
The adk-projects repository contains a .gitignore file, a README.md file,
and 10 directories, each appearing to be a separate project.
The project directories are numbered 1 through 10 and have descriptive names
like 1-helpful-assistant, 2-travel-planner-agent, and so on.
I get down to the real task now and tell Gemini CLI:
I’d like to fix a problem in the README.md file. How can I do that?
It picks up the right tool from the MCP Server again to get the file contents and reads the content:
But then, when I ask it will you be able to find that out by getting all the files and the folders inside of it?
, it mentions the following:
Yes, by listing the files and folders, I can see the structure of your
repository. This helps me understand the context of your projects.
However, to know what to fix in the README.md file, I need you to
tell me what the problem is.
I can't determine that just by looking at the file names.
This is understandable, so the next thing that I ask
Please get clone the repository from github here on my local system
This makes it execute the git clone
command successfully and it gets the copy locally.
Fantastic ! Then I pass in the following command, asking it to go through the README.md
file, all the folders
and figure out the mistake.
Go through the @adk-projects/README.md and the @adk-projects/ and
determine the issue with the README.md file
It does an excellent job in detecting the problem as shown here and to which I ask it to fix it:
Lovely, its identified the fix and corrected it too.
My next step would be to help me out with committing those changes locally, adding a commit message and then pushing the changes back to remote.
But when it tried to push, it also knows that there is a git
utility on my system and it chose to use that instead of the MCP Server that we have setup. Since I did not setup my Personal Access Token on my system, it gave the following error:
So as you can see in the last statement, I asked it to use the MCP Github Server instead, since the Personal Access Token (PAT) has been configured there.
It does it’s work and then reaches the final step to push and completes it successfully.
Here’s the commit from the Github repository.
This concludes Part 5 of the series. I decided to keep this part separate to demonstrate both configuring MCP Servers in Gemini CLI and also to do an exercise of how Gemini CLI worked on its own to determine the problem in one of my repositories, suggested a fix and then helped me commit the changes to the Github repository via some of the tools from the Github MCP Server that we configured in Gemini CLI.
In the next part, we will move a bit faster with MCP Server configurations and look at other MCP Servers : Firebase MCP Server, Google Generative AI MCP Servers (Imagen, Veo, Lyria, Chirp, etc) and possibly look at writing our own MCP Server and configuring it inside Gemini CLI. Stay tuned.
Source Credit: https://medium.com/google-cloud/gemini-cli-tutorial-series-part-5-github-mcp-server-b557ae449e6e?source=rss—-e52cf94d98af—4