search_text
Find emotion-labeled Twitter messages containing specific text queries to analyze sentiment patterns in the dataset.
Instructions
Search for samples containing specific text.
Args: query: Text to search for (case-insensitive) limit: Maximum results to return (default: 10)
Returns: JSON string with matching samples
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| limit | No |
Implementation Reference
- server.py:110-140 (handler)The `search_text` tool implementation, annotated with `@mcp.tool()`, which searches the dataset for a given string.
@mcp.tool() def search_text(query: str, limit: int = 10) -> str: """Search for samples containing specific text. Args: query: Text to search for (case-insensitive) limit: Maximum results to return (default: 10) Returns: JSON string with matching samples """ query = query.lower() limit = min(max(limit, 1), 50) dataset = get_dataset() matches = [] for idx, sample in enumerate(dataset): if query in sample["text"].lower(): matches.append({ "text": sample["text"], "emotion": EMOTION_LABELS[sample["label"]], "index": idx }) if len(matches) >= limit: break return json.dumps({ "query": query, "found": len(matches), "matches": matches }, indent=2)