File size: 2,230 Bytes
87f9bcf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
title: MCP Sentiment Analysis
emoji: 🎭
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 5.0.0
app_file: app.py
pinned: false
---

# 🎭 Text Sentiment Analysis with MCP

A powerful sentiment analysis tool built with Gradio and TextBlob, featuring Model Context Protocol (MCP) server integration for AI assistant interoperability.

## πŸš€ Features

- **Real-time Sentiment Analysis**: Analyze the emotional tone of any text instantly
- **Polarity Score**: Measures sentiment from -1 (negative) to +1 (positive)
- **Subjectivity Score**: Evaluates objectivity (0) vs subjectivity (1)
- **MCP Server Integration**: Expose sentiment analysis as a tool for AI assistants
- **Clean Web Interface**: User-friendly Gradio interface

## πŸ“Š How It Works

The application uses **TextBlob**, a Python library for natural language processing that:
1. Tokenizes and analyzes input text
2. Applies sentiment lexicon algorithms
3. Returns polarity, subjectivity, and overall assessment

### Output Metrics

- **Polarity**: Emotional tone ranging from -1.0 (very negative) to +1.0 (very positive)
- **Subjectivity**: Opinion level from 0.0 (objective/factual) to 1.0 (subjective/opinionated)
- **Assessment**: Simple classification (positive, negative, or neutral)

## πŸ’‘ Example Usage

**Input:**
```
I absolutely love this product! It's amazing!
```

**Output:**
```json
{
  "polarity": 0.75,
  "subjectivity": 0.95,
  "assessment": "positive"
}
```

## πŸ”§ Technologies Used

- **Gradio**: Web UI framework with MCP support
- **TextBlob**: NLP library for sentiment analysis
- **Python 3.13**: Core programming language

## πŸ€– MCP Integration

This Space runs as an MCP server, allowing AI assistants (like Claude) to discover and use the `sentiment_analysis` function as a tool. This enables AI assistants to analyze sentiment in real-time during conversations.

## πŸ› οΈ Local Development

```bash
# Clone the repository
git clone https://huggingface.co/spaces/SpringDai/mcp-sentiment

# Install dependencies
pip install -r requirements.txt

# Run the application
python app.py
```

## πŸ“ License

Open source - feel free to use and modify!

## πŸ‘€ Author

Created by [SpringDai](https://huggingface.co/SpringDai)