Gemini CLI + MCP Server: A Step-by-Step Tutorial

Muhammad Moin · Intermediate ·👁️ Computer Vision ·1y ago

Key Takeaways

Connecting Gemini CLI to an MCP server step-by-step

Full Transcript

Hello everyone, welcome to this new video tutorial. In this video tutorial, we will explore how to install and use Gemini CLI plus MCP. Gemini CLI is a Google free opensource AI agent. To use Gemini CLI free of charge, you need to simply log in with your personal Google account. To get a free Gemini code assistance lessons, the free lessons offers you access to Gemini 2.5 Pro and its massive 1 million token context window. With Gemini CLI, you can make 60 model requests per minute and 1,000 requests per day at no charge. Also, Gemini CLA comes with a built-in support for model context protocol. So, let's get started with this. So, over here you can see that this is Gemini CLI GitHub repo. Okay. And Gemini CLA is an open-source AI agent that brings the power of Gemini directly into your terminal. And over here if you just scroll down with Gemini CLA you can query and edit large code bases in and beyond Gemini 1 million token context window. You can generate new apps from PDFs or sketches using Gemini multimodel capabilities. You can automate operational task like quiring pull request or handling complex bases. Uh with Gemini CLA you can use tools and MCP servers to connect new capabilities including media generation with image and vio or area you can ground your queries with the Google search tool which comes in built in GM2 Gemini. So first of all you can simply open the command prompt from here and we will run the CLI. You can just go below down. So if you want to use Gemini CLI in your local machine, you need to make sure that you have Node version 18, NodeJS version 18 installed. So you can simply install the NodeJS version 18 or higher by just clicking opening this link. Okay. And if you just go down, you can simply install NodeJS. You can just click over here and you can select the operating system like if you have Windows, Mac OS or Linux operating system and you can install this MSI file. After you install the MSI file, you can run it as administrator. So I have already installed the NodeJS. So I will not install this again. After I have you have installed the NodeJS, now you can run Gemini CLA in your local machine. So to run Gemini CLA you can simply copy this over here and you can just paste this command in your terminal. So here you can see I've opened the command prompt. Now I will just paste this in this terminal over in the command prompt over here. So this will take some time. So now you can see that we have Gemini CLA up and running. So let's look at the different tools that Gemini CLA offers. So, Gemini CLI uh comes with these built-in tools which include Google search tool, save memory, shell, uh write file, edit, find files, read file, read folder, search desk tool. So, you can see the most important tool is Google search tool. Okay. And if I just write about so here we are using Gemini CLI 0.1.9 version and we are using Gemini 2.5.0 model and we have operating system 32. Okay. And um now you can see that uh these are the different options that you can explore. Okay. So like you can see over here help MCP. So now you can see currently uh we don't have MCP server configured and here you can see the uh Gemini CLI configuration details. Okay. So now MCP server is configured. You can open the documentation like you can see the documentation just opened. Okay. Now I can pass my input query over here like I can can ask what is the weather in Lahore today. Ask what is the weather in Lahore today and I will just click on enter. So now it's assessing the needed info. Now you can see that it's using Google search tool and it's searching the web for weather in Lahore and the weather in Lahore is currently mostly sunny with a temperature of 89° Fahrenheit and 32° C which feels like 101 fah and 39° C. The humidity is around 70% and there is a zero chance of rain right now. So like you can pass any input query over here and uh gemline C cla will respond using different tools that comes with built in in it. Okay. So next I will just open Visual Studio Code from here and you can see that I have just created a new project over here Gemini CLA MCP. I will first open the terminal over here and I will just run the npx command over here. So before we go ahead uh let me just uh go over here. So if I just open this smaller agents smaller agents GitHub repo over here. So these are a barebones this is a barebones library for agents that think in code. Okay. So you can see we have the complete GitHub repository over here. So uh in the step number one we'll analyze this GitHub repo. So the task number one is to analyze this complete GitHub repo. Like you can see that we have this complete GitHub repo. Okay. So now I will just go back to the Visual Studio Code over here. I will open new terminal over here. So now I will just clone this GitHub repository. Okay. So I will just go above over here and copy this. So now you can see that we have cloned the complete GitHub repo and we can see all the files over here as well. So now I will just go to the previous kernel from here and I will just redirect towards the GitHub repo that I have blown. So I will just write that small agents. Okay. And over here I will uh I will just analyze this complete GitHub repo that I have cloned. So I will just write analyze the overall architecture of this project including. So now I will just pass some uh input queries over here including main modules and their responsibilities. Okay. And I will also further I will write data flow. So the these points will be included in the analysis as we analyze this GitHub repo data flow and dependencies and also I will ask use of design patterns and we also want to analyze potential R key textural issues. Okay. So I will just press enter now. So now I just want to analyze the overall architecture of this project including okay. So let's see. So currently we are simply analyzing the GitHub repo that we have cloned. In the next step, we will configure MCP with our Gemini CLI. Okay. So, this will take some time. So, let's wait for this to finish. So now you can see that it's uh been able to uh list the directory. So now it's considering the absolute path now. So this will take few seconds before it completes. So now you can see that uh now it has listed one item. It's able to read the folder. So this will take few seconds. Let's wait for this to finish up. So guys, you can see that here we are getting our response. Uh so you can see I have analyzed the agents.py and models.py files. Here is the summary of the architecture main modules and responsibilities. This is the core of the project uh defining the agent logic and uh like you can see we have multi-step agent, code agent, tool calling agent. Then we have the models.py PI file and you can see that we have data flow and dependencies and you have the use of design patterns like the strategy pattern, template method pattern, abstract factory pattern. Then we have potent we have also listed the potential architectural issues like the type coupling between code agent and python executor. We have some security issues as noted in the security.md file. Running the LM generated code is inherently risky. While the project provides option for sandbox execution, security remains a critical concern that needs to be carefully managed. Okay. And it also has a limited error handling. So these are the potential architecture issues. Uh and overall the smaller agents project has a well- definfined and modular architecture that is easy to understand and extend. The use of design patterns like strategy and template method promotes flexibility and code reuse. However, there are some areas where the architecture could be improved particularly in terms of error handling and security. So now you can see that now we have analyzed the complete GitHub repo. Okay. So now we will go ahead and see how we can use MCP tools inside our Gemini CLI. Okay. So let's go ahead with this. Uh so I will just open the browser now. So now you can see that we have over here context 7 MCP server. Uh so it provides us up to date code documentation for LMS and AI code editors. So we will using this uh context 7 MCP server. So now if you just go below down. So now you can see with code context 7 MCP server uh you can pull up to date version specific documentation and code examples right from the source and place them directly into your prompt. Okay. So now we can see that uh you just need to add uh use context 7 in your prompt. So you need uh so for example I can ask create a basic next.js project with app routter. I just need to ask use context 7. Okay. So with the help of context 7 in this tutorial we will be pulling some code examples straight from the source. Okay. So now here you can see that it has also pulled a code example like create a basic next.js project with app routter. create a step to delete the rows where the city is like you can see. Okay. Okay. So that's good. So now first of all I will just uh open my command prompt and add on 7 MCP server. Okay. So uh what I can do is I can simply Okay. That looks good. So if I just go down. Okay. So now you can see inside our Gemini we have this settings JSON file. So I just need to open this over here. So what I will do is so I will just go to this directory gemini and I will just write notepad settings dot JSON. Okay. So now you can see we have opened this settings.json file over here and you can see over here. And now I will go to the context 7 MCP server. So now you can see that context 7 MC MCP server provides us up-to-date code documentation for large language models and AI code editors. So you can see we have we are in the context 7 GitHub repository over here. So with context 7 we can pull uptoate version specific documentation and code examples straight from the source and place them directly into our prompt. So you we just need to add use context 7 in our prompt. Okay. And to configure our to configure context 7 MPC server into our gem into Gemini CLI, we just need to go to local, we can just need to search for local server connection. Like you can see over here we here we have the details local server connection. You just need to copy this code from here. And you just need to add this piece of code over here and just save this. Okay. So now I will just go back to the Visual Studio code over here. And now what I will do is I will just run this npx again. So meanwhile it runs. Uh let's look at the context 7 NPC server. So with context 7 MPC server we can pull up to date version specific documentation and code examples. So let's use context 7 MPC server to pull some code examples. Okay. Now you can see that Gemini CLI is up and running. So let's first see if MCB server is configured. So now you can see that we are using contact 7 MCP. Okay. Okay. So now I will just pass the input query. Use context 7 MCP and pull a simple chat application example from blank chain. Okay. Solo. Let's run this. So now I'm using context 7 MCP to pull a simple chat application example from lang chain. So now it want to use MPCP server context 7 and it wants to use the resolve library ID tool that is available in contact 7 MCB and I won't allow this. So now you can see that it's using contact 7 MCP to generate a response. So now it al wants to use context 7 MCP other tool like get library docs tool. So I will allow once. So this will take few seconds. It's executing. So now it's spinparting the code examples designing the chat application code over here refining the code implementation and it's uh finalizing the code instruction. Okay. So now uh let's getting the error. So now I could solve this error. Okay. Yes, allow once. So now you can see that I apologize I made a mistake and provided a little bit path instead of absolute path. So now I will just allow once. So now you can see that it has created api file and it currently using context 7 mcp. Okay. So it has created a simple chat application using lang chain. Okay. So now if if you want to run this example you will just write python simple chat.py and you can see you just need to have you just need to provide open a key to run this uh child example. Okay. Okay. So that looks quite promising. So now we can add uh other tools as well like you can see what problems we are getting only. Yeah. Like you can see that um it needs to install the lang chain package and this problem will be sorted out. Okay. So I can just write uh install the lang chain library. So now you can see that we are just installing the line chain library. So this will take some time. Uh you can add other MCP servers as well. Like currently we have only one MCP server which is contact 7 MCP. So let wait for this package to get installed and then I will show you how you can add another MCP server as well. So now it's initiating the package installation now. So this will take some time. Now you can see that langchain and lanking- openai libraries are installed and there are no errors like no library issues that we are getting. So now currently you can see that we have configured only one MCP server uh but we can add more MCP servers as well like you can see currently we have only one MCP server that is running so let's add another MCP server like we can add MCP server calculator a model context protocol server for calculating okay so I will just go below down and we can just copy this code from here and I will just open this up from the here and I will just add this. Okay, I think. Okay, so I just made a mistake. I will not save this. I will just open this again by just writing notepad settings.json. Okay. And I'll just add the M60 server over here. Okay. So that looks quite promising. So now you can see that previously we have added context 7 MCB. Now we have added another MCP server tool which is calculator. Okay. So now you can simply close this from here and I will just open the terminal again. Okay. So now I'm just running Gemini CLI and let's see if we have configured second MCP server or not. So now you can see that we have two MCP servers up and running. So now we have uh context 7 MCP server that offer tool tools resolve library ID and get library docs and we have a calc MCB server ready ID as well that offer one tool which is calc. Okay. So I can just write use calculator MCP and I will just write over here 10 + 90 - 50 divided by 22. Okay. So now you can see that it wants to use the calculator tool. So now in the calculator MCP server I will just allow once. So now you can see that it has generated a response. Okay. And uh that looks quite promising like you can see this is our response 199.489 is the response. So in this tutorial we have seen that how we can install and use Gemini CLI plus MCP and we have seen that how we can inte uh how we can use MCP server tools inside our Gemini CLI. Uh okay so that's all from this tutorial. I hope you have learned something from this tutorial. Thank you for watching.

Original Description

In this video, I will show you how to connect Gemini CLI to any MCP server step by step. *🧑🏻‍💻 My AI and Computer Vision Courses⭐* *📗Build AI Agents with LangChain v1: Deep Agents & Tools 2026 (13$)* https://www.udemy.com/course/build-ai-agents-with-langchain-v1-deep-agents-tools-2026/?couponCode=PROMOTION13DOLLARS *📗YOLO26 Bootcamp: Real-Time Detection, Segmentation & Pose (13$)* https://www.udemy.com/course/yolo26-bootcamp-real-time-detection-segmentation-pose/?couponCode=PROMOTION13DOLLARS *📘Hands-On RAG Bootcamp: Build Apps with LangGraph & LangChain (13$)* https://www.udemy.com/course/hands-on-rag-bootcamp-build-apps-with-langgraph-langchain/?couponCode=PROMOTION13DOLLARS *📙Complete Computer Vision Bootcamp: YOLO to Multimodal AI (13$)* https://www.udemy.com/course/complete-computer-vision-bootcamp-yolo-to-multimodal-ai/?couponCode=PROMOTIONJUNE *📚 Generative AI, LLM Apps & AI Agents Masterclass 2026 (13$)* https://www.udemy.com/course/ai-agents-with-n8n-automate-anything-with-no-code/?couponCode=PROMOTIONJUNE *📘 YOLOv12 & YOLO26: Custom Object Detection & Web Apps 2026 (13$)* https://www.udemy.com/course/yolov12-custom-object-detection-tracking-webapps/?couponCode=PROMOTIONJUNE *📙 Modern Computer Vision with OpenCV 2026 (13$)* https://www.udemy.com/course/modern-computer-vision-with-opencv/?couponCode=PROMOTIONJUNE *📚 YOLO11 & YOLOv12: Object Detection & Web Apps in Python 2026 (13$)* https://www.udemy.com/course/yolo11-custom-object-detection-web-apps-in-python-2024/?couponCode=PROMOTIONJUNE *📘 AI 4 Everyone: Build Generative AI & Computer Vision Apps (13$)* https://www.udemy.com/course/ai-4-everyone-dive-into-modern-ai-with-llama-31-and-gemini/?couponCode=PROMOTIONJUNE *📙 YOLOv9, YOLOv10 & YOLO11: Learn Object Detection & Web Apps (13$)* https://www.udemy.com/course/yolov9-learn-object-detection-tracking-with-webapps/?couponCode=PROMOTIONJUNE *📕 LangChain: Build 26 LLM Apps with OpenAI, Llama & DeepSeek (14$)* https://www.udemy.com
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Related Reads

📰
Automatically redact PII in images with Amazon Nova
Automatically redact PII in images using Amazon Nova and complementary tools like SAM 3 and Amazon Textract
AWS Machine Learning
📰
PANet Paper Walkthrough: When Feature Pyramids Go Bottom-Up
Learn how PANet's bottom-up feature pyramid approach improves feature extraction by shortening the path between low-level and high-level features
Towards Data Science
📰
CCTV Action Recognition: Comprehensive Fine-Tuning & Real-Time Deployment Guide
Learn to fine-tune and deploy a hybrid Deep Learning model for CCTV action recognition using MobileNetV2 and Python
Medium · Python
📰
I built a background remover that keeps the fine hair edges
Learn how to build a background remover that preserves fine hair edges, a challenging task in image processing
Dev.to · KunStudio
Up next
Marketing management for ugc net| Important topics of marketing management ugc net commerce dec 2023
Bhoomi Learning Centre~Dr. Muskan
Watch →