Yesterday I stumbled across Gemini CLI while scrolling through the /r/mcp
subreddit.
I hadn’t tried MCP before because I thought it required a paid Claude subscription 😅. But turns out, Gemini CLI is a game changer — especially since Google offers a free tier using the gemini-2.5-pro
model with a 100 RDP limit.
Installing Gemini CLI
Super easy setup. Just make sure you have Node.js v20+ installed. I use nvm to manage multiple versions.
Install via:
npx https://github.com/google-gemini/gemini-cli
or globally:
npm install -g @google/gemini-cli
Then just run:
gemini
To authenticate, you’ll need an API key from Google AI Studio. You can export it like this in your .bashrc
or .zshrc
:
export GEMINI_API_KEY="YOUR_API_KEY"
Alternatively, use a .env
file in your project directory.
MCP + Context7 for Smarter AI
MCP (Model Context Protocol) allows your LLM (like Gemini) to hook into external tools — things like web search, image generation, or custom documentation sources.
You can browse available MCP servers here:
Why this matters
One big issue I’ve had with Gemini or ChatGPT is outdated responses — especially for fast-moving frameworks like Laravel. For example, it might give answers based on Laravel 11 when I’m using version 12.
Example prompt:
> how to override redirect login for authenticated user in Laravel.
✦ In Laravel, the redirection of authenticated users from "guest" routes (like /login) is handled by the
RedirectIfAuthenticated middleware. You can customize this behavior.
1. Locate the Middleware
The middleware is located at app/Http/Middleware/RedirectIfAuthenticated.php.
2. Understand the Default Behavior
The handle method in that file typically looks like this:
Before Context7, Gemini gave this outdated (v11-style) advice using RedirectIfAuthenticated.php
.
Using Context7 to Update Docs
Context7 helps solve this by feeding the LLM updated documentation.
To integrate it with Gemini CLI, edit your settings file at ~/.gemini/settings.json
(or .gemini/settings.json
if you’re using project-local settings) and add:
{
"mcpServers": {
"context7": {
"httpUrl": "https://mcp.context7.com/mcp"
}
}
}
Restart Gemini CLI, and now when you ask the same Laravel question, Gemini will reference the correct v12 docs:
> how to override redirect login for authenticated user in Laravel
✦ To override the redirect for authenticated users in Laravel, you can use the `redirectUsersTo` method in your `bootstrap/app.php` file...
✅ Now the AI gives accurate, up-to-date answers!
Tips for Better Results
- Context7 docs recommend adding
use context7
to your prompt to force using updated docs — but I found Gemini usually does this automatically. - Want to be more specific? Adding
use library /laravel/docs
to target a particular doc set, so it becomeshow to override redirect login for authenticated user in Laravel. use library /laravel/docs
. - You can browse available libraries here: https://context7.com/