mcp-tiny-agent / README.md
s2v-general's picture
building the agent toekn 2
1cf2b92
|
Raw History Blame Contribute Delete
3.01 kB

A newer version of the Gradio SDK is available: 6.32.0

Upgrade
metadata
title: Mcp Tiny Agent
emoji: πŸ“‰
colorFrom: pink
colorTo: blue
sdk: gradio
sdk_version: 5.49.1
app_file: app.py
pinned: false

MCP Tiny Agent with Sentiment Analysis

An AI agent built with smolagents that connects to an MCP sentiment analysis server.

πŸš€ HuggingFace Space Deployment

Quick Deploy

  1. Push to HuggingFace Space

    git add .
    git commit -m "Deploy MCP Tiny Agent"
    git push
    
  2. Configure Secrets (Required)

  3. The Space will automatically:

    • Install dependencies from requirements.txt
    • Run app.py
    • Make the agent available at your Space URL

HuggingFace Space Features

  • βœ… Automatic Token Access: If you're the Space owner, HF_TOKEN is automatically available
  • βœ… Secrets Management: Secure API key storage via Space Settings
  • βœ… Public Access: Share your agent with others via Space URL
  • βœ… Auto-Deploy: Updates automatically on git push

πŸ’» Local Setup

1. Install Dependencies

pip install -r requirements.txt

2. Configure API Key

For Nebius provider, you need to set up authentication. Choose one of these methods:

Option 1: Environment Variable (Recommended)

# Windows PowerShell
$env:HF_TOKEN="your_huggingface_token_here"

# Windows CMD
set HF_TOKEN=your_huggingface_token_here

# Linux/Mac
export HF_TOKEN="your_huggingface_token_here"

Option 2: HuggingFace CLI Login

huggingface-cli login

3. Get Your HuggingFace Token

  1. Go to https://huggingface.co/settings/tokens
  2. Create a new token (read access is sufficient)
  3. Copy the token and set it as an environment variable

4. Run the Application

python app.py

✨ Features

  • Sentiment Analysis: Uses MCP sentiment analysis server to analyze text sentiment
  • Qwen 2.5 72B Model: Powered by Qwen/Qwen2.5-72B-Instruct via HuggingFace Inference API
  • Gradio Interface: User-friendly chat interface
  • Fallback Support: Automatically falls back to TextBlob if MCP server is unavailable
  • Dual Deployment: Works both locally and on HuggingFace Spaces

πŸ”§ Model Configuration

The agent is configured to use Qwen/Qwen2.5-72B-Instruct via HuggingFace Inference API. If you hit rate limits, see the comments in app.py for alternative model configurations.

πŸ“ Notes

  • HuggingFace Spaces: The code automatically detects if it's running in a Space and uses the appropriate token
  • Local Development: Set HF_TOKEN environment variable or use huggingface-cli login
  • Secrets: Never commit API keys to git. Use Space Secrets for deployment or environment variables for local development

Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference