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**