Skip to main content
Glama

Sentiment + Sarcasm Analyzer

Sentiment + Sarcasm Analyzer (Gradio + MCP)

This project is a lightweight Gradio application that performs sentiment analysis and sarcasm detection using Hugging Face Transformers. It is designed to run on CPU and was developed as part of the Hugging Face MCP Course. The app is fully compatible with the Hugging Face MCP server architecture.

Live Demo

👉 Launch the app on Hugging Face Spaces

Architecture Overview

  • Models (CPU-only):
    • distilbert-base-uncased-finetuned-sst-2-english: Sentiment analysis
    • helinivan/english-sarcasm-detector: Sarcasm detection
  • Frontend: Gradio UI
  • Backend: Python with Hugging Face Transformers
  • MCP Integration: Hugging Face MCP-compatible (gradio[mcp])

Features

  • Sentiment classification: "positive" or "negative"
  • Sarcasm detection with a probability score
  • CPU-compatible (no GPU required)
  • Simple and clean Gradio interface

Output Format

The app returns a structured JSON response with four fields:

{ "assessment": "positive", "confidence": 1.0, "sarcasm_detected": true, "sarcasm_confidence": 0.97 }

Gradio Interface

The interface provides the following controls:

ElementDescription
TextboxEnter text to be analyzed
SubmitRun the sentiment and sarcasm analysis
ClearReset the input/output

Setup Instructions

1. Clone the repository

git clone https://github.com/YOUR_USERNAME/mcp-sentiment cd mcp-sentiment

2. Create a virtual environment

python -m venv .venv # Then activate: .venv\Scripts\activate # Windows source .venv/bin/activate # macOS/Linux

3. Install dependencies

pip install -r requirements.txt

Make sure gradio[mcp] is included for MCP compatibility.

4. Add Hugging Face token

Create a .env file:

HF_TOKEN=your_token_here

5. Run the app locally

python app.py

Deploy to Hugging Face Spaces

git init git remote add origin https://huggingface.co/spaces/YOUR_USERNAME/mcp-sentiment git add . git commit -m "Deploy MCP app" git push -u origin main

Once pushed, the MCP server endpoint will be live at:

https://YOUR_USERNAME-mcp-sentiment.hf.space/gradio_api/mcp/sse

Credits

-
security - not tested
F
license - not found
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

A lightweight Gradio application that analyzes text for sentiment (positive/negative) and sarcasm detection using Hugging Face Transformers, designed to run on CPU and compatible with the MCP server architecture.

  1. Live Demo
    1. Architecture Overview
      1. Features
        1. Output Format
          1. Gradio Interface
            1. Setup Instructions
              1. Clone the repository
              2. Create a virtual environment
              3. Install dependencies
              4. Add Hugging Face token
              5. Run the app locally
            2. Deploy to Hugging Face Spaces
              1. Credits

                Related MCP Servers

                • -
                  security
                  A
                  license
                  -
                  quality
                  An MCP server that generates 2D and 3D game assets from text prompts using AI models from Hugging Face Spaces, allowing developers to easily create game art through Claude Desktop or other MCP clients.
                  Last updated -
                  34
                  JavaScript
                  MIT License
                  • Apple
                  • Linux
                • -
                  security
                  A
                  license
                  -
                  quality
                  An MCP server that reviews code with the sarcastic and cynical tone of a grumpy senior developer, helping identify issues in PRs and providing feedback on code quality.
                  Last updated -
                  22
                  10
                  JavaScript
                  MIT License
                  • Linux
                  • Apple
                • -
                  security
                  F
                  license
                  -
                  quality
                  A simplified Model Context Protocol server in Python that reads text input and generates humorous responses, with support for Docker and Azure deployment.
                  Last updated -
                • -
                  security
                  F
                  license
                  -
                  quality
                  An MCP server that provides sentiment analysis functionality using TextBlob, allowing users to analyze text for polarity, subjectivity, and sentiment assessment through Cursor AI.
                  Last updated -
                  Python

                View all related MCP servers

                MCP directory API

                We provide all the information about MCP servers via our MCP API.

                curl -X GET 'https://glama.ai/api/mcp/v1/servers/igorpavlov-mgr/mcp-sentiment'

                If you have feedback or need assistance with the MCP directory API, please join our Discord server