get_sample
Retrieve random samples from an emotion-labeled Twitter dataset for analysis, returning text and emotion labels in JSON format.
Instructions
Get n random samples from the emotion dataset.
Args: n: Number of samples to retrieve (default: 5, max: 20)
Returns: JSON string with samples including text and emotion label
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| n | No |
Implementation Reference
- server.py:53-76 (handler)The get_sample function is registered as an MCP tool using the @mcp.tool() decorator and retrieves n random samples from the loaded emotion dataset.
@mcp.tool() def get_sample(n: int = 5) -> str: """Get n random samples from the emotion dataset. Args: n: Number of samples to retrieve (default: 5, max: 20) Returns: JSON string with samples including text and emotion label """ n = min(max(n, 1), 20) # Clamp to 1-20 dataset = get_dataset() indices = random.sample(range(len(dataset)), n) samples = [] for idx in indices: sample = dataset[idx] samples.append({ "text": sample["text"], "emotion": EMOTION_LABELS[sample["label"]], "index": idx }) return json.dumps(samples, indent=2)