Skip to main content
Glama

memory_hook

Fire lifecycle events like session_started or new_message to trigger memory updates, context compression, and memory pressure handling across user and agent layers.

Instructions

Fire one external lifecycle event (session_started, new_message, ...).

Args: event: one of KNOWN_EVENTS (session_started, session_ended, new_message, auto_save_candidate, context_threshold, memory_pressure, post_context_compression). payload: event body. Recognized keys per event: session_ended: {"summary": str}; new_message/auto_save_candidate: {"text": str}; post_context_compression: {"query": str}; session_started: {"text": str?, "budget": int?}. layer: "user" (default) or "agent". user_id: subject user (bound to API key on HTTP transports). ctx: MCP context (injected).

Returns: Handler results dict; unknown event raises ValueError (MCP error).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
eventYes
layerNouser
payloadNo
user_idNodefault

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. Addedv1.9.0

TDQS

A4/5.0
Behavior4/5

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

With no annotations, the description carries the full transparency burden and does a solid job: it lists all KNOWN_EVENTS, defines recognized payload keys per event, documents layer/user_id defaults, states the return type, and calls out the ValueError for unknown events. It does not fully describe side effects of firing the event, but the event list and error behavior provide substantial disclosure.

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?

The docstring is organized with Args and Returns sections, front-loaded with the core action, and every line contributes useful information. The only minor redundancy is the event list appearing both in the opening and in the event arg, but the details justify it.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 4-parameter tool with no annotations, the description is complete: event vocabulary, payload schema, defaults, auth-bound user_id, context injection, return shape, and error handling are all covered. The stated output schema and return description together make calling this tool unambiguous.

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

Parameters5/5

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

Input schema coverage is 0%, so the description must explain the parameters, and it does. It enumerates all valid event values, documents the payload structure by event type, and clarifies defaults for layer and user_id. This goes well beyond the bare schema fields.

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?

Description opens with a clear verb and resource: 'Fire one external lifecycle event' and enumerates the exact event names. This is specific enough to know what the tool does, but it doesn't explicitly position itself against sibling tools (think, evolve, dream, forget, project), so it doesn't fully achieve sibling differentiation.

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

Usage Guidelines2/5

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

No guidance is given about when to use memory_hook versus think, evolve, dream, forget, or project. The event list implies use cases (session_started, new_message, etc.), but there is no explicit condition or exclusion such as 'use X for internal reasoning'.

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/Cipher208/a-memory'

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