MCP情感分析演示

MCP情感分析演示是一个集成远程Hugging Face与本地Ollama AI模型的情感分析服务,适用于文本情感极性判断场景。

  • by Koori-ai
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 Koori-ai/MCP-

使用说明

MCP (Model Context Protocol) Sentiment Analysis Demo

A comprehensive demonstration of MCP implementation with local and remote AI models for sentiment analysis.

🎯 Project Overview

This project demonstrates the implementation and integration of Model Context Protocol (MCP) in two different architectures:

  • Unit 1: Remote MCP server deployment on Hugging Face Spaces
  • Unit 2: Local AI integration using Continue + Ollama with MCP connectivity

🏗️ Architecture

Remote Setup (Unit 1)

  • MCP Server: Deployed on Hugging Face Spaces
  • Technology: Python + Gradio + TextBlob
  • Endpoint: https://reply2susi-mcp-e2e-app.hf.space
  • Features: TextBlob-based sentiment analysis with numerical scoring

Local Setup (Unit 2)

  • AI Models: Ollama (Llama 3.1 8B)
  • IDE Integration: Continue VS Code extension
  • Technology: Python + NLTK (VADER sentiment analysis)
  • Features: Private, offline sentiment analysis

📊 Test Results

Comparative Analysis

Text Input Local NLTK (VADER) Remote MCP (TextBlob) Agreement
"I love working with local AI models!" positive ✅ Positive (0.25) ✅ Yes
"This is amazing!" positive ✅ Positive (0.75) ✅ Yes
"I hate this product" negative ❌ Negative (-0.80) ✅ Yes

Result: 100% agreement between local and remote sentiment analysis systems.

🚀 Getting Started

Prerequisites

  • Python 3.8+
  • VS Code with Continue extension
  • Ollama installed locally
  • Git

Local Setup

# Clone the repository
git clone [your-repo-url]
cd mcp-demo

# Install dependencies
pip install -r requirements.txt

# Install Ollama models
ollama pull llama3.1:8b
ollama pull qwen2.5-coder:1.5b-base
ollama pull nomic-embed-text:latest

# Install VS Code Continue extension
# Copy continue-config/.continuerc.json to ~/.continue/config.json

Running Local Tests

cd local-ai
python test_sentiment.py

Testing Remote MCP Server

Visit: https://reply2susi-mcp-e2e-app.hf.space

📁 Project Structure

mcp-demo/
├── README.md                 # Project documentation
├── requirements.txt          # Python dependencies
├── local-ai/                 # Local AI implementation
│   ├── test_sentiment.py     # NLTK sentiment analysis
│   ├── main.py              # Hello world example
│   └── sentiment_analysis.py # Continue-generated code
├── mcp-server/              # Remote MCP server code
│   ├── app.py               # Gradio app (TextBlob)
│   └── requirements.txt     # Server dependencies
├── continue-config/         # Continue IDE setup
│   └── .continuerc.json    # Continue + MCP configuration
└── results/                 # Test results and comparisons
    └── comparison-results.md

🔧 Technologies Used

  • MCP: Model Context Protocol
  • Local AI: Ollama, Llama 3.1 8B, Continue
  • Remote AI: Hugging Face Spaces, TextBlob, Gradio
  • Languages: Python
  • Libraries: NLTK (VADER), TextBlob, Gradio
  • Tools: VS Code, Git

📈 Results Summary

  • ✅ Successfully deployed MCP server on Hugging Face
  • ✅ Integrated local AI models with Continue
  • ✅ Achieved 100% agreement between local and remote analysis
  • ✅ Demonstrated practical MCP use cases

🔗 Links

  • Live MCP Server: https://reply2susi-mcp-e2e-app.hf.space
  • Continue Extension: https://marketplace.visualstudio.com/items?itemName=Continue.continue
  • Ollama: https://ollama.ai

This project was completed as part of MCP learning curriculum, demonstrating practical implementation of Model Context Protocol in real-world scenarios.