mcp-sentiment / usage /README.md
phil71x
feat: Update dependencies and add new packages for sentiment analysis
48a7f49
|
raw
history blame
3.34 kB

Usage Scripts

This folder contains the working solutions and utilities for MCP sentiment analysis with consistent naming and proper documentation.

πŸš€ Working Solutions

1. sentiment_mcp.py ⭐ RECOMMENDED

  • What it does: Uses smolagents MCPClient for proper MCP protocol connection
  • Performance: ~0.11 seconds per request (fastest!)
  • Status: βœ… Works perfectly
  • Usage: pdm run python usage/sentiment_mcp.py
  • Dependencies: smolagents[mcp] (already installed)
  • Protocol: Native MCP via smolagents

2. sentiment_gradio.py

  • What it does: Uses Gradio client to bypass MCP protocol entirely
  • Performance: ~1.3 seconds per request
  • Status: βœ… Works reliably as backup solution
  • Usage: pdm run python usage/sentiment_gradio.py
  • Dependencies: gradio_client (already installed)
  • Protocol: Direct Gradio API access

πŸ”§ Utilities

3. debug_imports.py

  • What it does: Debugging utility to check MCP package imports
  • Usage: pdm run python usage/debug_imports.py
  • Purpose: Troubleshooting import issues
  • Dependencies: mcp (for testing imports)

4. access_mcp_using_python.ipynb

  • What it does: Jupyter notebook showing HTTP API approach
  • Purpose: Alternative approach using direct HTTP requests
  • Status: Educational/reference material

Quick Start

For immediate sentiment analysis, use the MCP approach:

# Primary solution (fastest)
pdm run python usage/sentiment_mcp.py

Or the backup solution:

# Backup solution (reliable)
pdm run python usage/sentiment_gradio.py

For troubleshooting:

# Debug imports if having issues
pdm run python usage/debug_imports.py

Performance Comparison

Script Speed Protocol Reliability Command
sentiment_mcp.py 0.11s βœ… Native MCP βœ… Excellent pdm run python usage/sentiment_mcp.py
sentiment_gradio.py 1.3s Direct API βœ… Very Good pdm run python usage/sentiment_gradio.py

File Naming Convention

All scripts now follow a consistent naming pattern:

  • sentiment_*.py - Main functionality scripts
  • debug_*.py - Debugging and utility scripts
  • Each script includes a comprehensive docstring with PDM commands

Dependencies

All required packages are already installed:

  • smolagents[mcp] - For MCP protocol support
  • gradio_client - For direct Gradio API access
  • mcp - Base MCP package

What Was Cleaned Up

The folder was cleaned from 17 files down to 5 essential files:

Removed (12 obsolete files):

  • All hanging MCP test scripts
  • Failed timeout and debugging attempts
  • Redundant test files
  • Empty or obsolete utilities

Kept (5 essential files):

  • ⭐ Primary MCP solution
  • βœ… Backup Gradio solution
  • πŸ”§ Import debugging utility
  • πŸ““ Educational notebook
  • πŸ“– This documentation

Troubleshooting

If you encounter issues:

  1. Import errors: Run pdm run python usage/debug_imports.py
  2. MCP connection issues: Try pdm run python usage/sentiment_gradio.py
  3. Missing dependencies: Check the Dependencies section above
  4. General issues: Both solutions are proven to work reliably

The folder is now clean, organized, and ready for production use! πŸŽ‰