Docs/Sources/Sentiment Analysis for AI Agents

Sentiment Analysis for AI Agents

Analyze text sentiment

OperationalCredits 10 per callp50 573msAI/Computer Vision

Overview

Sentiment Analysis runs two independent scorers over the `text` you POST. The first is lexicon-based: the text is tokenised, each token is looked up in the AFINN list of integer valences from -5 to +5, and the matches are summed into `sentiment`. `comparative` divides that sum by the token count. `sentimentText` maps the sum to a label with fixed cut-offs: 4 and above is very positive, 2 to 3 positive, -1 to 1 neutral, -2 negative, and -3 or below very negative. `isPositive` and `isNegative` are only the sign of the sum, so a score of 1 returns `isPositive: true` while the label still reads neutral.

On paid plans the text is also split into sentences at terminal punctuation and line breaks, and the first 50 sentences go to a transformer classifier trained on social media text. Each sentence gets positive, neutral and negative probabilities. `modelScore` is the mean positive probability minus the mean negative probability, rounded to two decimals, and `modelSentiment` is the label with the highest mean. `isMixed` is true when at least one sentence is labelled positive and another negative, each with confidence of 0.6 or more; `modelSentiment` then reads `mixed`.

`normalizedScore` is the AFINN sum divided by 10 and clamped to -1..1, so any text scoring 10 or more in either direction saturates. `magnitude` is the sum of absolute valences and grows with length: use it to tell strongly worded text from flat text, not to compare documents of different sizes. The free plan skips the model call entirely, so the model fields are null there.

Live Test Sentiment Analysis for AI Agents Source →

The tool

Once your client is connected to the VerveContext server, this appears in its tool list as SentimentAnalysisforAIAgents. It is read-only and open-world — it fetches and never mutates anything on your side — so most clients call it without asking you to confirm.

Tool call
{
  "name": "SentimentAnalysisforAIAgents",
  "arguments": {
    "text": "I absolutely love this product! It exceeded all my expectations."
  }
}

You do not name the tool yourself; the model picks it. Asking about I absolutely love this product! It exceeded all my expectations. in the terms this source covers is enough for it to reach for SentimentAnalysisforAIAgents on its own — naming it explicitly also works, and is the way to force the call.

Connecting

One server URL covers every source in the catalog, including this one. Authorization is OAuth: the client opens a browser once, and there is no key to paste into a config file.

{
  "mcpServers": {
    "vervecontext": {
      "url": "https://api.vervecontext.com/v1/mcp"
    }
  }
}

Per-client setup — Claude, Cursor, VS Code, ChatGPT — is on the MCP setup page.

Arguments

These are the properties on the tool's inputSchema, so a well-behaved client validates them before the call is made. Premium arguments are accepted on every plan but only take effect on plans that include them.

ArgumentTypeDescription
textRequiredstringThe text to analyze the sentiment of
length 0–50000

What the model gets back

The result carries a structuredContent object matching the tool's declared outputSchema, so a client reads fields without parsing prose. status is "ok" and error is null on success; a null field means the value was not available for that input, not that the call failed.

Result
{
  "status": "ok",
  "error": null,
  "data": {
    "comparative": 0.25,
    "sentimentText": "positive",
    "sentiment": 3,
    "isPositive": true,
    "isNegative": false,
    "normalizedScore": 0.3,
    "magnitude": 3,
    "positiveWords": [
      "excited"
    ],
    "negativeWords": [],
    "modelSentiment": "positive",
    "modelScore": 0.98,
    "isMixed": false,
    "sentences": [
      {
        "text": "I'm so excited that tomorrow is going to be sunny!",
        "label": "positive",
        "confidence": 0.992,
        "scores": {
          "positive": 0.992,
          "neutral": 0.006,
          "negative": 0.002
        }
      },
      {
        "text": "Can't wait!",
        "label": "positive",
        "confidence": 0.973,
        "scores": {
          "positive": 0.973,
          "neutral": 0.024,
          "negative": 0.003
        }
      }
    ]
  }
}

Response fields

Paths are relative to data. Premium fields are absent rather than zeroed on plans that do not include them, so check for presence instead of comparing to 0.

FieldTypeExampleDescription
comparativenumber0.25The sentiment score divided by the number of words, so long and short texts compare
sentimentTextstringpositiveThe score read as a label: very positive, positive, neutral, negative or very negative
sentimentnumber3AFINN sentiment score: the summed valence of the matched words, negative for negative sentiment
isPositivebooleantrueWhether the sentiment is positive
isNegativebooleanfalseWhether the sentiment is negative
normalizedScorePremiumnumber0.3Sentiment score normalized to -1 to 1 range
magnitudePremiumnumber3Total emotional strength: the summed absolute valence of every matched word, so strongly mixed text scores high even when sentiment nets to zero
positiveWordsPremiumarray["excited"]The distinct words that pushed the AFINN score up
negativeWordsPremiumarray[]The distinct words that pulled the AFINN score down, including positive words negated by not or never
modelSentimentPremiumstringpositiveOverall label from a transformer sentiment model read sentence by sentence: positive, neutral, negative, or mixed when the text has a confident positive and a confident negative sentence; null if the model is unavailable
modelScorePremiumnumber0.98Model score from -1 (negative) to 1 (positive): the mean positive minus the mean negative probability across sentences
isMixedPremiumbooleanfalseTrue when at least one sentence is confidently positive and another confidently negative (model confidence 0.6 or higher)
sentencesPremiumarray[2]Per-sentence model results for the first 50 sentences
sentences.0.textPremiumstringI'm so excited that tomorrow is going to be sunny!The sentence as split from the input
sentences.0.labelPremiumstringpositivepositive, neutral or negative
sentences.0.confidencePremiumnumber0.992Model probability of the label, 0 to 1
sentences.0.scoresPremiumobject{…}Probability of each label
sentences.0.scores.positivePremiumnumber0.992Probability the sentence is positive
sentences.0.scores.neutralPremiumnumber0.006Probability the sentence is neutral
sentences.0.scores.negativePremiumnumber0.002Probability the sentence is negative

Why ground on it

A model can produce something that looks like this answer from its training data, and be confidently out of date or simply wrong. This source returns the current value in a shape you can check, which is the difference between an answer you can cite and one you have to hedge.

Point an evaluation at comparative: it is the field most worth pinning a claim to, and it is either present and current or absent — never plausibly invented.

Failure modes

Errors come back as tool errors carrying a sentence the model can act on, not a bare status code. Error handling covers the full list.

StatusWhat it means
400 / 422The arguments did not validate. The message names the offending one.
401The OAuth session is invalid or expired — reconnect the server.
403Blocked by a key restriction or an IP allow-list. Never a bad identity.
404This source is not part of VerveContext. Check the catalog.
429Out of credits, or a brief rate limit. The message tells them apart.

A call costs 10 credits each time the tool actually runs; a model that reasons about the tool without calling it costs nothing.

Use cases

Support Ticket Escalation
Route angry customer messages to senior support reps immediately when the sentiment score drops to very negative.
Review Stream Filtering
Product managers categorize incoming app store feedback into positive praise and negative complaints using the five-tier sentiment label.
Social Media Sentiment Analysis
When tracking brand tags on social networks, marketing teams flag sudden spikes in negative valence scores to address PR issues early.
Survey Response Sorting
Sort open-ended employee survey responses automatically by comparative sentiment to isolate recurring workplace grievances without manual reading.

Other ways to use Sentiment Analysis for AI Agents

Set up Sentiment Analysis for AI Agents on VerveContext, or reach the same source a different way. Your VerveContext account and credits work on all of them — one key, one balance.

Call it as a REST APIOne HTTPS endpoint and an x-api-key header, with SDKs for Node, Python and .NET.APIVerve →Reference →
Give it to an AI agentConnect over MCP and your agent calls it as a native tool — Claude, Cursor, ChatGPT.VerveKit →Reference →
Google Sheets or ExcelA =VERVE() formula fills a column — no script, no export, recalculates in place.VerveSheets →Reference →

More in AI/Computer Vision:

Was this page helpful?