pulse
Detect spikes in emotional tones (angry, sad, fearful) by polling. Returns spike ratio and alerts when spike ratio exceeds 1.5 with meaningful volume.
Instructions
Pollable spike detector. Returns spike_ratio and a boolean
spiking for each watched tone (default angry/sad/fearful), plus
an alerts array populated when spike_ratio >= 1.5 with meaningful
volume. Intended for repeated polling (every 5-15 min). Only
surface to the user when alerts is non-empty.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| tones | No | ||
| recent_hours | No | ||
| baseline_hours | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/overtone_news_mcp/server.py:120-139 (handler)Pulse tool handler: a pollable spike detector that calls the 'pulse' API endpoint. Accepts query, optional tones filter, recent_hours (1-168), and baseline_hours (1-720). Returns spike_ratio, spiking flags per tone, and alerts when spike_ratio >= 1.5.
@mcp.tool() def pulse( query: Query, tones: Annotated[list[ToneName], Field(max_length=7)] | None = None, recent_hours: Annotated[int, Field(ge=1, le=168)] = 6, baseline_hours: Annotated[int, Field(ge=1, le=720)] = 72, ) -> dict[str, Any]: """Pollable spike detector. Returns spike_ratio and a boolean `spiking` for each watched tone (default angry/sad/fearful), plus an `alerts` array populated when spike_ratio >= 1.5 with meaningful volume. Intended for repeated polling (every 5-15 min). Only surface to the user when `alerts` is non-empty.""" body: dict[str, Any] = { "query": query, "recent_hours": recent_hours, "baseline_hours": baseline_hours, } if tones: body["tones"] = tones return _post("pulse", body) - Schema types used by pulse: Query (str, 1-500 chars), ToneName (literal list of 7 emotions), and Bin type.
Query = Annotated[str, Field(min_length=1, max_length=500)] ToneFilter = Literal["positive", "negative", "informational"] ToneName = Literal[ "happy", "funny", "hopeful", "informational", "angry", "sad", "fearful" ] Bin = Literal["hour", "6h", "day"] - src/overtone_news_mcp/server.py:120-120 (registration)Registration of 'pulse' as an MCP tool via the @mcp.tool() decorator on the FastMCP instance.
@mcp.tool() - Helper function _post that sends HTTP POST requests to the Overtone API with the API key. Used by pulse to call the 'pulse' endpoint.
def _post(path: str, body: dict[str, Any]) -> dict[str, Any]: with httpx.Client(timeout=HTTP_TIMEOUT) as client: resp = client.post( f"{API_URL}/{path}", headers={"X-API-Key": _load_api_key()}, json=body, ) resp.raise_for_status() return resp.json()