Skip to main content
Glama
cegme

Emotion Dataset Analysis MCP Server

by cegme

count_by_emotion

Count and calculate percentages of Twitter messages labeled with specific emotions (sadness, joy, love, anger, fear, surprise) in the dair-ai/emotion dataset for statistical analysis.

Instructions

Count samples for a specific emotion.

Args: emotion: One of 'sadness', 'joy', 'love', 'anger', 'fear', 'surprise'

Returns: JSON string with count and percentage

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
emotionYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Implementation of the `count_by_emotion` MCP tool, which counts dataset entries matching a specified emotion and returns the count and percentage as a JSON string.
    @mcp.tool()
    def count_by_emotion(emotion: str) -> str:
        """Count samples for a specific emotion.
    
        Args:
            emotion: One of 'sadness', 'joy', 'love', 'anger', 'fear', 'surprise'
    
        Returns:
            JSON string with count and percentage
        """
        emotion = emotion.lower().strip()
    
        if emotion not in EMOTION_TO_ID:
            return json.dumps({
                "error": f"Invalid emotion. Choose from: {list(EMOTION_TO_ID.keys())}"
            })
    
        emotion_id = EMOTION_TO_ID[emotion]
        dataset = get_dataset()
    
        count = sum(1 for sample in dataset if sample["label"] == emotion_id)
        percentage = (count / len(dataset)) * 100
    
        return json.dumps({
            "emotion": emotion,
            "count": count,
            "total": len(dataset),
            "percentage": round(percentage, 2)
        }, indent=2)
Behavior3/5

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

No annotations provided, so description carries full burden. It discloses return format ('JSON string with count and percentage'), which adds value beyond the schema. However, it omits safety traits (read-only status), rate limits, or side effects that would help an agent understand operational risks.

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?

Uses structured Args/Returns format that efficiently organizes information. Front-loaded with the core purpose. Slightly redundant in documenting return values when an output schema exists, but necessary given the parameter documentation burden.

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 single-parameter counting tool, the description is nearly complete. It documents the parameter domain and return structure. Minor gap: doesn't clarify what 'samples' refers to (text samples inferred from siblings) or whether the count is relative to total dataset (implied by 'percentage').

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

Parameters5/5

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

Critical compensation for 0% schema description coverage: the description provides the complete enum constraint ('One of 'sadness', 'joy', 'love', 'anger', 'fear', 'surprise'') that the schema lacks. Without this, the agent would have no valid values to provide.

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 specific action (Count) and resource (samples) with clear scope (for a specific emotion). Implies distinction from sibling 'analyze_emotion_distribution' by focusing on single-emotion queries, though it doesn't explicitly clarify when to choose one over the other.

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

Usage Guidelines2/5

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

Provides no guidance on when to use this tool versus siblings like 'analyze_emotion_distribution' or 'search_text'. No prerequisites, exclusions, or workflow context is provided.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cegme/cis6930sp26-assignment1.5'

If you have feedback or need assistance with the MCP directory API, please join our Discord server