GemSuite-MCP

by PV-Bhat
Verified
  • docs
# Implementation Changes Overview This document outlines the key changes made to implement the GemSuite MCP tools with advanced file handling capabilities. ## Core Architecture Changes 1. **Modular Design** - Separated concerns into utility modules - Created unified handler for all Gemini operations - Implemented shared file handling logic 2. **File Handling Enhancement** - Added file handling to all tools - Implemented MIME type detection - Added support for various file types - Created utility for file-to-API part conversion 3. **Smart Model Selection** - Added model selection based on file type - Added task-based model recommendations - Implemented preference-based overrides 4. **Request Building Standardization** - Created unified request builder - Added operation-specific request builders - Standardized parameter handling ## New Files ### Utility Modules 1. **`file-handler.js`** - Handles file reading and conversion - Detects MIME types and file categories - Prepares files for Gemini API 2. **`model-selector.js`** - Selects appropriate models based on task and file type - Defines model capabilities and use cases - Provides smart fallbacks 3. **`request-builder.js`** - Builds specialized requests for each tool - Handles parameter standardization - Implements thinking mode workarounds ### Handler Modules **`unified-gemini.js`** - Implements all four GemSuite MCP tools: - `gem_search` - `gem_reason` - `gem_process` - `gem_analyze` - Handles API calls and error management - Formats responses consistently ## Tool Definitions ### gem_search ```javascript { name: 'gem_search', description: 'Generates responses based on the latest information using Gemini 2.0 Flash and Google Search.', inputSchema: { type: 'object', properties: { query: { type: 'string' }, file_path: { type: 'string' }, model_id: { type: 'string' }, enable_thinking: { type: 'boolean' } }, required: ['query'] } } ``` ### gem_reason ```javascript { name: 'gem_reason', description: 'Solves complex problems with step-by-step reasoning using Gemini 2.0 Flash Thinking.', inputSchema: { type: 'object', properties: { problem: { type: 'string' }, file_path: { type: 'string' }, show_steps: { type: 'boolean' }, model_id: { type: 'string' } }, required: ['problem'] } } ``` ### gem_process ```javascript { name: 'gem_process', description: 'Performs fast, cost-efficient content processing using Gemini 2.0 Flash-Lite.', inputSchema: { type: 'object', properties: { content: { type: 'string' }, file_path: { type: 'string' }, operation: { type: 'string', enum: ['summarize', 'extract', 'restructure', 'simplify', 'expand', 'critique', 'feedback', 'analyze'] }, model_id: { type: 'string' } } } } ``` ### gem_analyze ```javascript { name: 'gem_analyze', description: 'Analyzes files using the appropriate Gemini model.', inputSchema: { type: 'object', properties: { file_path: { type: 'string' }, instruction: { type: 'string' }, model_id: { type: 'string' } }, required: ['file_path'] } } ``` ## API Request Structure ### Example File Request ```javascript // Request with file { contents: [{ role: 'user', parts: [ { inline_data: { mime_type: 'text/plain', data: 'base64_encoded_file_content' } }, { text: 'Analyze this document' } ] }] } ``` ### Example Search Request ```javascript // Search request with file { contents: [{ role: 'user', parts: [ { inline_data: { mime_type: 'image/jpeg', data: 'base64_encoded_image' } }, { text: 'What objects are visible in this image?' } ] }], tools: [{ google_search: {} }] } ``` ## Model Selection Logic The model selection logic follows this priority: 1. User-specified model (`model_id` parameter) 2. Capability requirements (thinking, search) 3. File type requirements 4. Task type recommendations 5. Default model (Flash for general usage) ## Testing Added comprehensive test cases for: - Basic text processing - File handling - Model selection - Error handling ## Documentation Added detailed documentation on: - File handling best practices - Model selection recommendations - Token efficiency strategies - Example workflows