BasalGanglia's picture
πŸ› οΈ Fix HuggingFace Space configuration - Remove quotes from frontmatter
64ced8b verified

A newer version of the Gradio SDK is available: 6.1.0

Upgrade
metadata
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:

{
  "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:

{
  "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

# 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

# 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