MCP-Gemini-FileSearch
# MCP-Gemini-FileSearch
Google Gemini File Search API를 MCP(Model Context Protocol) 서버로 래핑한 도구입니다. ChatGPT, Claude Desktop 등 MCP 호환 클라이언트에서 문서 기반 RAG 검색을 사용할 수 있습니다.
## Feature
- **Gemini File Search API MCP 래퍼** - MCP 호환 LLM 클라이언트에서 사용 가능
- **파일 업로드** - 로컬 파일 & URL 자동 다운로드 지원
- **자연어 검색** - 문서 내용 기반 RAG 검색
- **인용 검증** - 특정 페이지 본문 조회 (get_passages)
- **메타데이터 관리** - 제목, 저자, 연도, DOI, 태그, 출처 URL
- **필터링 검색** - 연도 범위, 저자, 태그별 검색
## Usage Example
<div style="overflow-x: auto; white-space: nowrap;">
<img src="./asset/1.png" alt="1. 문서 업로드" width="400" style="display: inline-block; margin-right: 10px;"/>
<img src="./asset/2.png" alt="2. 등록된 문서 확인" width="400" style="display: inline-block; margin-right: 10px;"/>
<img src="./asset/3.png" alt="3. 문서 검색 및 조회" width="400" style="display: inline-block; margin-right: 10px;"/>
<img src="./asset/4.png" alt="4. 상세 정보 확인" width="400" style="display: inline-block;"/>
</div>
## Quick Start
### 1. API 키 발급
**무료 API 키 받기**: [Google AI Studio](https://aistudio.google.com/apikey)에서 무료로 Gemini API 키를 발급받을 수 있습니다.
### 2. MCP 설정
Claude Desktop이나 다른 MCP 호환 클라이언트의 설정 파일에 다음을 추가하세요:
```json
{
"mcpServers": {
"gemini-filesearch": {
"command": "npx",
"args": ["-y", "mcp-gemini-filesearch"],
"env": {
"GEMINI_API_KEY": "AIzaSyXXXXXXXXXXXXXXXX",
"GEMINI_FILESTORE_NAME": "select-your-store-name"
}
}
}
}
```
**중요**:
- `GEMINI_API_KEY`: [Google AI Studio](https://aistudio.google.com/apikey)에서 발급받은 무료 API 키를 입력하세요
- `GEMINI_FILESTORE_NAME`: 원하는 스토어 이름을 지정하세요 (예: "my-research", "논문모음", "technical-docs")
- **같은 이름을 사용하면 이전에 업로드한 문서들을 계속 사용할 수 있습니다**
- 다른 이름을 사용하면 새로운 독립된 문서 저장소가 만들어집니다
## Internal Tool Usage Example
### create_file_store
```json
{
"display_name": "My Research Store"
}
```
### add_document
Local file:
```json
{
"source": "/path/to/document.pdf",
"metadata": {
"title": "Attention Is All You Need",
"authors": ["Vaswani", "Shazeer", "Parmar"],
"year": 2017,
"tags": ["transformer", "attention"]
}
}
```
URL:
```json
{
"source": "https://arxiv.org/pdf/1706.03762.pdf",
"metadata": {
"title": "Attention Is All You Need",
"year": 2017
}
}
```
### search
```json
{
"query": "What are the limitations of self-attention?",
"top_k": 5
}
```
```json
{
"query": "neural network architectures",
"top_k": 10,
"filters": {
"year_min": 2015,
"year_max": 2023,
"tags": ["transformer"]
}
}
```
### get_passages
retrival specific page
```json
{
"doc_id": "gemfile_abc123xyz",
"page_spans": [
{ "start": 3, "end": 4 },
{ "start": 7, "end": 7 }
]
}
```
### list_documents
```json
{
"page": 1,
"page_size": 20,
"filters": {
"year_min": 2015,
"tags": ["transformer"]
}
}
```
### delete_document
```json
{
"doc_id": "gemfile_abc123xyz"
}
```
## Exception
- `FILE_TOO_LARGE`: 파일 크기 초과
- `INVALID_FILE_TYPE`: 지원하지 않는 형식
- `RATE_LIMITED`: API 요청 제한 (자동 재시도)
## Develop
```bash
npm install
npm run build
npm test
npm run lint
```
### Project Structure
```
mcp-gemini-filesearch/
├── bin/cli.js # CLI 진입점
├── src/
│ ├── server.ts # MCP 서버
│ ├── tools/ # MCP 도구
│ └── lib/ # 핵심 라이브러리
├── tests/unit/ # 단위 테스트
├── manifest.json # MCP 메타데이터
└── package.json
```
## Requirement
- Node.js ≥ 20
- TypeScript 5.7
- Model Context Protocol (MCP) 1.0
- Google Gemini File Search API
- Zod 3.23 (Validation)
- Jest 29 (Unit Test)
## 라이선스
MIT License
## 참고
- [Model Context Protocol](https://modelcontextprotocol.io)
- [Google Gemini API](https://ai.google.dev/docs)
TDQS
Scored across 6 tools
Each tool maps to a distinct resource+action: store lifecycle (create_file_store), document lifecycle (add/list/delete), retrieval (search for snippets, get_passages for full-text citation verification). The search vs get_passages boundary is explicitly clarified in the descriptions (snippets with relevance scores vs full text for page ranges), so an agent can select correctly.
All names are snake_case verb_noun, which is consistent and readable. Minor deviations: 'search' is a bare verb with no object, and 'add_document' vs 'create_file_store' use slightly different verbs for the same create semantics.
Six tools is well-scoped for a document indexing/search server: one store-create, three document lifecycle tools, and two retrieval tools. Nothing appears redundant or pad.
Document lifecycle (add, list, delete, retrieve passages, search) is well covered, but store coverage is asymmetric: create_file_store has no list_file_stores or delete_file_store counterpart, and there is no update/re-index operation. These are minor gaps agents can work around by reusing the store ID.