Skip to main content
Glama

get_session_history

Retrieve session history with timestamped stress scores and heart rate data to track emotional patterns. Analyze psychological trends using rising, falling, or stable indicators over configurable lookback periods.

Instructions

Get state history for a session over time.

Returns timestamped datapoints with stress_score, state, and heart_rate for each observation.
Includes an overall trend: rising | falling | stable.

Use minutes parameter to control the lookback window (default: 5, max: 60).
Useful for detecting stress patterns during a conversation. Not a medical device.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
session_idYes
minutesNo

Implementation Reference

  • The main handler function for get_session_history tool. It makes an HTTP GET request to the API to retrieve session state history including stress_score, state, and heart_rate datapoints over time. Returns JSON response with trend analysis (rising/falling/stable).
    async def get_session_history(session_id: str, minutes: int = 5) -> dict:
        """Get state history for a session over time.
    
        Returns timestamped datapoints with stress_score, state, and heart_rate for each observation.
        Includes an overall trend: rising | falling | stable.
    
        Use minutes parameter to control the lookback window (default: 5, max: 60).
        Useful for detecting stress patterns during a conversation. Not a medical device.
        """
        async with httpx.AsyncClient(timeout=10) as client:
            resp = await client.get(
                f"{API_URL}/v1/history",
                params={"session_id": session_id, "minutes": minutes},
                headers=_headers(),
            )
            if resp.status_code == 200:
                return resp.json()
            return {"error": f"No history found for session {session_id}."}
  • proxy.py:173-174 (registration)
    Tool registration using FastMCP's @mcp.tool() decorator. This registers the get_session_history function as an MCP tool, making it available to clients. FastMCP automatically derives the JSON schema from the function signature and docstring.
    @mcp.tool()
    async def get_session_history(session_id: str, minutes: int = 5) -> dict:
  • Input/output schema defined via Python type hints in the function signature. Input: session_id (str), minutes (int, default=5). Output: dict. FastMCP automatically generates JSON Schema from these type hints for MCP tool registration.
    async def get_session_history(session_id: str, minutes: int = 5) -> dict:
  • FastMCP server instance initialization. The 'mcp' object is used to register tools via the @mcp.tool() decorator. This is the MCP server that hosts the get_session_history tool.
    mcp = FastMCP(
        "nefesh",
        instructions=(
            "Human State Fusion — send any body signal, "
            "get a unified state for your LLM. "
            "Includes trigger memory for cross-session context. "
            "Not a medical device. MCP + A2A native. Version 4.0.0."
        ),
    )
  • Helper function _headers() used by get_session_history to build HTTP headers with the caller's API key from context variables.
    def _headers() -> dict:
        """Build proxy headers with the caller's API key."""
        key = _nefesh_key.get()
        return {"X-Nefesh-Key": key, "Content-Type": "application/json"}
Behavior4/5

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

Strong disclosure given zero annotations: describes exact return structure (timestamped datapoints with stress_score/state/heart_rate), trend values (rising/falling/stable), constraints (default: 5, max: 60), and critical disclaimer ('Not a medical device'). Carries full burden effectively.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Excellent structure: purpose → return values → parameter usage → use case → disclaimer. Every sentence delivers distinct information without redundancy. Appropriate length for the tool's complexity.

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?

Given no output schema and no annotations, the description adequately compensates by detailing return structure, data fields, and behavioral constraints. Missing only minor details like rate limits or pagination, which are optional for this complexity level.

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

Parameters4/5

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

With 0% schema description coverage, the description compensates well by explaining 'minutes' semantics (lookback window, default 5, max 60). 'session_id' is not explicitly described but is intuitively linked to 'session' in the first sentence and is self-documenting.

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?

Clear verb-resource combination ('Get state history') with temporal scope ('over time'). However, it doesn't explicitly differentiate from sibling 'get_human_state' (likely current state vs. historical), which could cause agent confusion when selecting between them.

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

Usage Guidelines3/5

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

Provides clear use case ('detecting stress patterns during a conversation') and parameter guidance for the lookback window. Lacks explicit when-not-to-use guidance or comparison to siblings like 'get_human_state' or 'get_trigger_memory'.

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/nefesh-ai/nefesh-mcp-server'

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