Skip to main content
Glama

HuggingFace — Sentiment Analysis

hf_inference.nlp.sentiment
Read-onlyIdempotent

Classify the sentiment of a text using a HuggingFace NLP model via the Inference API. Returns a predicted label (positive, negative, or neutral) with a confidence score, plus scores for all classes. Default model (cardiffnlp/twitter-roberta-base-sentiment-latest) is optimized for social media and short-form text. Supports a custom model parameter. Useful for customer feedback analysis, social media monitoring, and review classification.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesInput text to process. Maximum ~10,000 characters depending on model context window.
modelNoHuggingFace model ID to use for sentiment classification. Default: "cardiffnlp/twitter-roberta-base-sentiment-latest" (3-class: positive/neutral/negative). Alternatives: "distilbert-base-uncased-finetuned-sst-2-english" (2-class: POSITIVE/NEGATIVE), "nlptown/bert-base-multilingual-uncased-sentiment" (1-5 star, multilingual).

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
errorNoPresent only when the call failed. Includes error code, message, request_id, and any provider-specific extras.
resultNoTool response payload. Shape varies per tool — consult the tool description and inputSchema. May be an object, array, string, or number depending on the upstream provider response.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A3.6/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint, idempotentHint, destructiveHint=false and openWorldHint, covering the safety profile. The description adds that results include a predicted label plus per-class confidence scores, though this overlaps with the output schema. It says nothing about rate limits, authentication, or failure modes.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The operation and output are front-loaded in the first two sentences. The trailing use-case list ('customer feedback analysis, social media monitoring, review classification') is filler that an agent gains little from, and the 'Supports a custom model parameter' sentence restates the schema.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With only two parameters, an output schema covering return values, and annotations covering safety and idempotency, the description supplies everything else an agent needs: the task, the default model's domain fit, and the multi-class score output. Nothing material for correct invocation is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so both parameters (text and model) are already fully documented, including the alternative model IDs and their class schemes. The description's note that 'Supports a custom model parameter' and that the default suits short-form text adds only marginal meaning beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('Classify the sentiment of a text ... via the Inference API') and names the concrete output, so the task is unambiguous. It distinguishes itself from summarize/translate/ner siblings only implicitly via the task word; it never addresses the overlap with hf_inference.nlp.zero_shot, which can also perform sentiment classification with arbitrary labels.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Usage is only implied through example applications ('customer feedback analysis, social media monitoring, and review classification') rather than stated as selection criteria. It also notes the default model is tuned for social media/short-form text, which hints at when the default is appropriate, but there is no guidance on when to pick zero_shot or a custom model instead.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.