Gemini CLI RAG MCP

by pedarias

Not rated
GitHub

About

A RAG-based Q&A server using a vector store built from Gemini CLI documentation.

Details

Author
pedarias
Categories
Developer Tools, Knowledge Base, AI, Other

Setup

Install Gemini CLI RAG MCP in your MCP client (Claude Desktop, Cursor, Windsurf, and others).

Repository: https://github.com/pedarias/gemini-cli-rag-mcp

Follow the installation instructions in the repository README, then restart your MCP client.

A RAG-based Q&A server using a vector store built from Gemini CLI documentation.

This project builds a standalone RAG service, transforming the staticgemini-clidocumentation into a dynamic and queryable tool. This tool exposes knowledge via a protocol (like MCP), making it accessible to any integrated client. Therefore, environments like gemini-cli, VS Code, or Cursor can provide developers with instant, accurate answers in natural language, directly within their workflow. Accelerating learning and letting you intuitively leverage the tool's full potential.

- Project Overview
-
Features
-
System Architecture
-
Getting Started

- Prerequisites
-
Installation

- 1. Run the MCP Service with Docker
-
2. Configure Gemini CLI
-
3. Ask Questions

- Data Extraction and Vectorization
-
MCP Server
-
Gemini CLI Integration

This project integrates a RAG pipeline and it consists of three main components:
- Data Extraction and Processing: Python scripts that extract content from all markdown files in thegemini-cli/docsdirectory and sub-directories, process it, and create a vector store.
- MCP Server: A Python-based MCP server that exposes the vector store as a queryable tool.
- Gemini CLI/VSCode/ClaudeCode/Windsurf/Cursor...etc: The official Gemini CLI, which can connect to the MCP server to answer questions about its documentation.

- RAG-based Q&A: Ask questions about the Gemini CLI in natural language and get answers based on its official documentation.
- Local Vector Store: The entire documentation is stored and indexed locally usingSKLearnVectorStore.
- Extensible: The MCP server can be easily extended with new tools and data sources.

The system is composed of the following parts:
- extract.py: This script walks through thegemini-cli/docsdirectory, finds all.mdfiles, and concatenates their content into a singlegemini_cli_docs.txtfile.
- create_vectorstore.py: This script loads thegemini_cli_docs.txtfile, splits it into chunks, and creates agemini_cli_vectorstore.parquetfile usingHuggingFaceEmbeddingsandSKLearnVectorStore.
- gemini_cli_mcp.py: This script runs aFastMCPserver that loads the vector store and exposes two endpoints:

- gemini_cli_query_tool(query: str): A tool that takes a user query, retrieves relevant documents from the vector store, and returns them.
- docs://gemini-cli/full: A resource that returns the entire content of thegemini_cli_docs.txtfile.

- Python 3.13
-
Node.js 18+
- An existinggemini-cliinstallation. If you don't have it, you can clone the official repository:

git clone https://github.com/google-gemini/gemini-cli.git
git clone https://github.com/your-username/gemini-cli-rag-mcp.git cd gemini-cli-rag-mcp

Prepare the documentation data:Run theextract.pyscript to gather all the markdown documentation into a single file.

Create the vector store:Run thecreate_vectorstore.pyscript to create the vector store from the documentation file.

Before running with docker, try running the mcp in dev mode and test:

OnCommandfield type 'python' and onArgumentstype 'gemini_cli_mcp.py' and press Connect.

The most efficient way to run the MCP server is with Docker Compose. This starts a container in the background and keeps it ready for Gemini CLI to connect to.

The container will keep running, but the Python MCP script itself will only be executed on-demand by Gemini CLI.

To make Gemini CLI aware of your local MCP server, you need to create a configuration file.

-

Inside the.geminidirectory add the following content to thesettings.jsonfile:

{ "mcpServers": { "local_rag_server": { "command": "docker", "args": [ "exec", "-i", "gemini-cli-mcp-container", "python", "gemini_cli_mcp.py" ] } } }

This configuration tells Gemini CLI how to launch your MCP server usingdocker exec.Obs: To use it in VSCode, go toSettingstype 'mcp' and click onsettings.json. Then put on Agent mode and ask copilot to implement the gemini-cli-mcp server (give the json above as context).

After restarting terminal to changes make effect, simply rungeminifrom your terminal. It will automatically discover thelocal_rag_serverand use its tools when needed.

My gemini cli is not showing an interactive prompt when I run it on my build server, it just exits. I have a CI_TOKEN environment variable set. Why is this happening and how can I fix it?

Theextract.pyscript recursively finds all markdown files in thegemini-cli/docsdirectory. It reads their content and combines it into a single text file,gemini_cli_docs.txt.

Thecreate_vectorstore.pyscript then takes this text file and:
- Loads the document.
- Splits it into smaller, overlapping chunks usingRecursiveCharacterTextSplitter.
- UsesHuggingFaceEmbeddings(with theBAAI/bge-large-en-v1.5model) to create embeddings for each chunk.
- Stores these embeddings in aSKLearnVectorStore, which is persisted togemini_cli_vectorstore.parquet.

Thegemini_cli_mcp.pyscript creates aFastMCPserver. This server defines a tool,gemini_cli_query_tool, which can be called by the Gemini CLI or VSCode/Cursor/etc. When this tool is invoked, it:
- Loads the persistedSKLearnVectorStore.
- Uses the vector store as a retriever to find the most relevant document chunks for the given query.
- Returns the content of these chunks to the Gemini CLI.

The Gemini CLI is designed to be extensible through MCP servers. The CLI discovers available tools by connecting to servers defined in themcpServersobject in asettings.jsonfile (either in the project's.geminidirectory or in the user's home~/.geminidirectory).

Gemini CLI supports three transport mechanisms for communication:

- Stdio Transport: Spawns a subprocess and communicates with it overstdinandstdout. This is the method used in this project, with thecommandproperty insettings.json.
- SSE Transport: Connects to a Server-Sent Events (SSE) endpoint, defined with aurlproperty.
- Streamable HTTP Transport: Uses HTTP streaming for communication, configured with anhttpUrlproperty.

By using thedocker execcommand, we are leveraging thestdiotransport to create a direct communication channel with the Python script inside the container.

- extract.py: Extracts documentation from markdown files.
- create_vectorstore.py: Creates the vector store.
- gemini_cli_mcp.py: Runs the MCP server.

The main Python dependencies are listed inrequirements.txt:

- langchain: For text splitting, vector stores, and embeddings.
- tiktoken: For token counting.
- sentence-transformers: For the embedding model.
- scikit-learn: For the vector store.
- mcp: For the MCP server.
- fastapi: For the MCP server.

The project relies on thegemini-clipackage and its dependencies. Seegemini-cli/package.jsonfor more details.

This is a web browser that enables your coding agent, such as Claude Code, to visit websites on your behalf and assist you in identifying bugs or creating UI test cases.

A Retrieval-Augmented Generation (RAG) server for document processing, vector storage, and intelligent Q&A, powered by the Model Context Protocol.

Integrates LLM applications with RAG data sources and tools using the Model Context Protocol.

Free local RAG for Claude Code - Save tokens & time with vector search. Indexes markdown docs and finds relevant info without reading entire files (40x fewer tokens, 15x faster).

A powerful Model Context Protocol (MCP) server using gemini embedding 3 that transforms any local directory into an ultrafast, visually-aware spatial search engine for AI agents.

MCP server that ingests project docs once and lets Claude search by meaning instead of reading everything — saving tokens on large codebases

Local code analysis MCP server with 25+ tools: semantic search, call graph tracing, dependency analysis, and symbol navigation. Built with Tree-sitter and CozoDB. Supports Go, Python, JS, TS.

Easily provide codebase context to Large Language Models (LLMs).

A local-first code indexer that enhances LLMs with deep code understanding. It integrates with AI assistants via the Model Context Protocol (MCP) and supports AI-powered semantic search.

A knowledge management tool for code repositories using vector embeddings, powered by a local Ollama service.

Provides up-to-date, version-specific documentation and code examples for libraries directly into your prompt.

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.