get_human_state
Retrieve current stress scores and recommended actions to adapt AI response length and complexity based on user emotional state.
Instructions
Get current unified human state for a session. Call this before generating important responses.
Returns:
- state: calm | relaxed | focused | stressed | acute_stress
- stress_score: 0-100 (lower = calmer)
- confidence: 0.0-1.0 (based on signal quality and device type)
- suggested_action: maintain_engagement | simplify_and_focus | de-escalate_and_shorten | pause_and_ground
- action_reason: human-readable explanation of why this action was suggested
- adaptation_effectiveness (on 2nd+ call): shows whether your previous suggested_action actually reduced stress — contains previous_action, stress_delta, and effective boolean. Use this to self-improve.
Use suggested_action to adapt your response: calm/relaxed = full complexity, focused = shorter and structured, stressed = max 2 sentences, acute_stress = one grounding sentence only.
Requires a prior ingest call to have data. Not a medical device.Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| session_id | Yes |
Implementation Reference
- proxy.py:44-71 (handler)The get_human_state tool handler implementation. Takes a session_id, makes HTTP GET request to API_URL/v1/state, and returns the human state data including state (calm/relaxed/focused/stressed/acute_stress), stress_score, confidence, suggested_action, and action_reason.
# ── Tool: get_human_state ─────────────────────────────────────── @mcp.tool() async def get_human_state(session_id: str) -> dict: """Get current unified human state for a session. Call this before generating important responses. Returns: - state: calm | relaxed | focused | stressed | acute_stress - stress_score: 0-100 (lower = calmer) - confidence: 0.0-1.0 (based on signal quality and device type) - suggested_action: maintain_engagement | simplify_and_focus | de-escalate_and_shorten | pause_and_ground - action_reason: human-readable explanation of why this action was suggested - adaptation_effectiveness (on 2nd+ call): shows whether your previous suggested_action actually reduced stress — contains previous_action, stress_delta, and effective boolean. Use this to self-improve. Use suggested_action to adapt your response: calm/relaxed = full complexity, focused = shorter and structured, stressed = max 2 sentences, acute_stress = one grounding sentence only. Requires a prior ingest call to have data. Not a medical device. """ async with httpx.AsyncClient(timeout=10) as client: resp = await client.get( f"{API_URL}/v1/state", params={"session_id": session_id}, headers=_headers(), ) if resp.status_code == 200: return resp.json() if resp.status_code == 404: return {"error": f"No data for session {session_id}. Send signals via ingest first."} return {"error": f"API returned {resp.status_code}. Check your API key and parameters."} - proxy.py:45-45 (registration)Registration of the get_human_state tool with the MCP server using the @mcp.tool() decorator from FastMCP.
@mcp.tool() - proxy.py:46-46 (schema)Input schema defined by function signature: session_id (str) parameter. Output schema is dict (generic).
async def get_human_state(session_id: str) -> dict: