File size: 5,363 Bytes
64ced8b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
---
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": [
"<file_content_or_path>",
"<processing_type>"
]
}
```
**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** |