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 custom model override. 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

A4.5/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true, idempotentHint=true, and destructiveHint=false. The description adds genuinely useful behavioral context: specifies the default model, confirms it returns both a predicted label and scores for all classes, and notes model override support. It does not expose rate limits or latency, but given the annotations, the added value is solid.

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 description is 4 sentences, information-dense, with the core operation first and model details and use cases following. Every sentence earns its place, though the use-case list is slightly redundant with the rest of the description. Structured and scannable.

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

Completeness4/5

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

For a simple 2-parameter, read-only, idempotent tool, the description covers the main decision points: what the tool returns, the default model, and the use case. Sibling tools are few and clearly distinct. No output schema explanation needed. A minor gap is not stating what happens when custom model returns different labels, but the schema's alternative models already hint at that.

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

Parameters4/5

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

Schema description coverage is 100%, so baseline is 3. The description adds context on top: it explains the default model's class set (3-class vs 2-class vs 1-5 star alternatives) and domain optimization, which helps the agent decide whether to override the model. It doesn't expand on the text parameter beyond the schema, but the schema already documents max length and format.

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

Purpose5/5

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

Description states a specific verb ('Classify'), resource ('text using a HuggingFace NLP model via the Inference API'), and clearly distinguishes from siblings like hf_inference.nlp.ner, summarize, translate, zero_shot. It also names the default model and use cases, making the tool's scope unambiguous.

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

Usage Guidelines5/5

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

Description explicitly says the default model is optimized for social media and short-form text, and lists use cases (customer feedback, social media monitoring, review classification). It does not explicitly name sibling alternatives, but the model alternatives in the schema and the tool name itself separate it from other hf_inference.nlp.* tools. Context sufficient for selection.

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.