--- title: MCP File Processor Tool emoji: 📁 colorFrom: yellow colorTo: red sdk: gradio sdk_version: 4.44.1 app_file: app.py pinned: false license: mit tags: - mcp-server-track - mcp - file-processing - document-analysis - data-extraction - hackathon - gradio python_version: 3.11.8 --- # 📁 MCP File Processor Tool An AI-powered file processing tool that provides both a user-friendly Gradio interface and an MCP (Model Context Protocol) server endpoint for integration with AI assistants and other applications. ## ✨ Features - **📄 Multi-Format Support**: Process CSV, JSON, TXT, and other document formats - **🔍 Smart Analysis**: Extract content, structure, and metadata from uploaded files - **📊 Data Insights**: Provide statistical analysis and content summaries - **🔌 MCP Server**: Compliant with Model Context Protocol for AI assistant integration - **🎨 Interactive UI**: Modern Gradio interface with drag-and-drop file upload - **⚡ Fast Processing**: Efficient file parsing and analysis capabilities ## 🚀 Quick Start ### Using the Web Interface 1. **Visit this Space** and interact with the web interface directly 2. **Upload your file** using the drag-and-drop interface 3. **View analysis results** including content extraction and insights 4. **Download processed data** in various formats ### Supported File Types - 📊 **CSV Files**: Data analysis, column profiling, statistical summaries - 📋 **JSON Files**: Structure analysis, key exploration, validation - 📄 **Text Files**: Content extraction, word counts, encoding detection - 📑 **Documents**: Basic text extraction and metadata analysis ## 🔌 MCP Server Integration This tool implements the Model Context Protocol (MCP) for integration with AI assistants, allowing programmatic file processing capabilities. ### MCP Endpoint Details - **Endpoint URL**: `https://[this-space-url]/gradio_api/mcp/sse` - **HTTP Method**: `POST` - **Content-Type**: `application/json` ### Request Format Send a POST request with the following JSON payload: ```json { "data": [ "", "" ] } ``` **Parameters:** - `data[0]` (string): File content or file path to process - `data[1]` (string): Processing type ("analyze", "extract", "summarize") ### Response Format Successful responses return: ```json { "data": [ { "status": "success", "file_type": "csv", "analysis": { "rows": 1000, "columns": 5, "summary": "Data analysis results..." }, "content": "Processed content or insights..." } ] } ``` ## 🎯 Use Cases for AI Assistants When integrated with AI assistants via MCP, this tool enables: 1. **Data Analysis**: "Analyze this CSV file and provide insights" 2. **Content Extraction**: "Extract text content from this document" 3. **File Validation**: "Check if this JSON file is properly formatted" 4. **Data Summary**: "Summarize the key information in this file" 5. **Batch Processing**: "Process multiple files and compare results" ## 🛠️ Technical Details ### Processing Capabilities - **CSV Analysis**: Column types, statistics, missing values, correlations - **JSON Validation**: Structure validation, key analysis, nested object exploration - **Text Processing**: Encoding detection, word count, language detection - **Metadata Extraction**: File size, creation date, format details ### API Configuration - **Timeout**: 60 seconds for large file processing - **Size Limits**: 50MB maximum file size - **Rate Limiting**: Standard Gradio Space limits - **Error Handling**: Comprehensive error messages and recovery ## 🏆 Hackathon Submission This tool is submitted for the **MCP Server Track** of the hackathon, demonstrating: - ✅ **MCP Protocol Compliance**: Full implementation of MCP server specification - ✅ **Production Ready**: Robust error handling and file validation - ✅ **User Experience**: Intuitive file upload interface with previews - ✅ **Documentation**: Comprehensive API documentation and examples - ✅ **Integration Ready**: Easy to integrate with AI assistants and workflows ## 🔧 Local Development ### Prerequisites - Python 3.11+ - Required packages for file processing (pandas, json, csv) ### Installation ```bash # Clone this repository git clone [repository-url] cd mcp_file_processor_gradio # Install dependencies pip install -r requirements.txt # Run the application python app.py ``` ### Testing MCP Endpoint Locally ```bash # Test with curl curl -X POST http://localhost:7860/gradio_api/mcp/sse \ -H "Content-Type: application/json" \ -d '{"data": ["sample_data.csv", "analyze"]}' ``` ## 📊 Performance & Limitations ### Strengths - Fast file processing and analysis - Multi-format support - Comprehensive error handling - MCP protocol compliance ### Limitations - 50MB file size limit - Processing time depends on file size - Limited to common file formats - Requires well-formatted input files ## 📝 License MIT License - Feel free to use and modify for your projects. ## 🤝 Contributing This is a hackathon submission, but feedback and suggestions are welcome! ## 🏷️ Tags `#mcp-server-track` `#file-processing` `#data-analysis` `#gradio` `#ai-assistant` `#model-context-protocol` --- **Built with ❤️ for the MCP Hackathon**