Gemini CLI is Google’s open-source terminal-based tool that brings Gemini’s capabilities directly to your command line. Unlike web-based interfaces, Gemini CLI operates entirely in your terminal and has access to your current project folder, offering a lightweight and efficient way to interact with Gemini models from within your project.
When combined with Model Context Protocol (MCP) servers, Gemini CLI becomes even more useful. Using MCP servers, you can give Gemini access to your tools and infrastructure, allowing it to work with your APIs, databases, and other services through built-in MCP support.
This guide shows you how to connect Gemini CLI to a Gram-hosted MCP server using Taskmaster, a full-stack CRUD application for task and project management. Taskmaster includes a web UI for managing projects and tasks, a built-in HTTP API, OAuth 2.0 authentication, and a Neon PostgreSQL database for storing data. Try the demo app to see it in action.
You’ll learn how to set up the connection, test it, and use natural language to manage tasks, projects, and workflows through Gemini CLI.
Use one of the following two options to install Gemini CLI:
Run it directly with npx.
npx https://github.com/google-gemini/gemini-cli
Install it globally.
npm install -g @google/gemini-cli
Verifying the installation
Test that Gemini CLI is working:
gemini --help
If the installation was successful, you’ll see Gemini CLI’s available commands and options.
Authenticating with Gemini CLI
When you first run gemini, you’re prompted to authenticate. Sign in with your personal Google account to get free access to Gemini 2.5 Pro with generous usage limits (60 requests per minute, 1,000 requests per day).
Creating an MCP server
Before connecting Gemini CLI to a Taskmaster MCP server, you first need to create one. Follow our guide to creating a Taskmaster MCP server.
Once your Taskmaster MCP server is ready, there are three ways to connect it to Gemini CLI:
Use the gemini mcp add command from the Gram installation page (recommended).
Use the Gram CLI to automatically configure the connection.
Manually edit the Gemini CLI configuration file.
Connecting Gemini CLI from the Gram installation page
The quickest way to connect Gemini CLI to a Gram-hosted MCP server is to copy the installation command from the Gram dashboard.
Go to your toolset’s installation page at https://app.getgram.ai/mcp/<your-toolset-slug>/install and select Gemini CLI. Copy the installation command and run it in your terminal:
Replace your-toolset-slug with the slug of your toolset.
You can verify the server was added by running /mcp list in Gemini CLI:
Connecting Gemini CLI using the Gram CLI
Alternatively, you can use the Gram CLI to configure the connection. The CLI automatically fetches your toolset configuration and creates the appropriate settings file.
Replace your-toolset-slug with the slug of your toolset. For example, to install the Taskmaster toolset:
gram install gemini-cli --toolset taskmaster
The CLI automatically fetches the toolset configuration from Gram and creates or updates the Gemini CLI settings file.
Setting up environment variables
If your toolset requires authentication, you’ll need to set up environment variables. The gram install command will display the required variable names and provide the export command you need to run.
For the Taskmaster toolset, you’ll need to set the MCP_TASK_MASTER_API_KEY environment variable:
You can control where the MCP server configuration is installed using the --scope flag:
# Install to user-level config (default) - available across all projectsgram install gemini-cli --toolset taskmaster --scope user# Install to project-level config - can be shared with your teamgram install gemini-cli --toolset taskmaster --scope project
Use --scope project when you want to commit the .gemini/settings.json configuration to version control and share it with your team.