Skip to main content
Glama

list_entities

Retrieve entities currently known in memory, sorted by recent activity, to get an overview at the start of a session before specific recall queries.

Instructions

List the entities currently known to this memory store, sorted by recent activity. Use at the start of a new session ("what do I know about?") before issuing specific recall queries. Cheaper than recall for the "give me an overview" question.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
kindNoFilter by entity kind.
min_memoriesNoOnly include entities with at least N memories. Default 1.
limitNoMax entities to return. Default 30.
offsetNo

Implementation Reference

  • Schema/input definition for the 'list_entities' tool, defining its name, description, and inputSchema properties (kind, min_memories, limit, offset).
    {
      name: 'list_entities',
      description:
        'List the entities currently known to this memory store, sorted by recent activity. Use at the start of a new session ("what do I know about?") before issuing specific recall queries. Cheaper than recall for the "give me an overview" question.',
      inputSchema: {
        type: 'object',
        properties: {
          kind: { type: 'string', enum: ['person', 'company', 'project', 'concept', 'file', 'other'], description: 'Filter by entity kind.' },
          min_memories: { type: 'number', description: 'Only include entities with at least N memories. Default 1.', default: 1 },
          limit: { type: 'number', description: 'Max entities to return. Default 30.', default: 30 },
          offset: { type: 'number', default: 0 },
        },
      },
    },
  • The actual handler function 'handleListEntities' that executes the tool logic: queries the entities table joined with memories, applies filters (kind, min_memories), sorts by momentum/memory_count/recency, and returns the matching entities with layer breakdown and pinned_count.
    function handleListEntities(args: any): string {
      const kind = args?.kind as string | undefined;
      const minMemories = Math.max(1, Number(args?.min_memories ?? 1));
      const limit = Math.max(1, Math.min(200, Number(args?.limit ?? 30)));
      const offset = Math.max(0, Number(args?.offset ?? 0));
    
      let sql = `
        SELECT e.id, e.name, e.kind, e.canonical_key, e.momentum_score,
               e.updated_at, e.created_at,
               COUNT(m.id) as memory_count,
               MAX(m.last_accessed_at) as last_memory_access,
               SUM(CASE WHEN m.layer = 'goal' THEN 1 ELSE 0 END) as goal_count,
               SUM(CASE WHEN m.layer = 'caveat' THEN 1 ELSE 0 END) as caveat_count,
               SUM(CASE WHEN m.layer = 'learning' THEN 1 ELSE 0 END) as learning_count,
               SUM(CASE WHEN m.layer = 'implementation' THEN 1 ELSE 0 END) as impl_count,
               SUM(CASE WHEN m.importance >= 0.9 THEN 1 ELSE 0 END) as pinned_count
        FROM entities e
        LEFT JOIN memories m ON m.entity_id = e.id
        WHERE 1=1
      `;
      const params: any[] = [];
      if (kind) { sql += ' AND e.kind = ?'; params.push(kind); }
      sql += ' GROUP BY e.id';
      if (minMemories > 1) sql += ' HAVING memory_count >= ?';
      if (minMemories > 1) params.push(minMemories);
      // Sort: active (high momentum) first, then most memories, then most recent
      sql += ' ORDER BY (COALESCE(e.momentum_score,0) * 10 + memory_count * 0.5 + (last_memory_access / 86400.0 / 365) * 2) DESC';
      sql += ' LIMIT ? OFFSET ?';
      params.push(limit, offset);
    
      const rows = db.prepare(sql).all(...params) as any[];
    
      const totalRow = db.prepare(
        kind ? 'SELECT COUNT(*) as c FROM entities WHERE kind = ?' : 'SELECT COUNT(*) as c FROM entities'
      ).get(...(kind ? [kind] : [])) as { c: number };
    
      return JSON.stringify({
        ok: true,
        total: totalRow.c,
        returned: rows.length,
        offset,
        has_more: offset + rows.length < totalRow.c,
        entities: rows.map((r) => ({
          id: r.id,
          name: r.name,
          kind: r.kind,
          canonical_key: r.canonical_key,
          momentum: Number((r.momentum_score ?? 0).toFixed(2)),
          memory_count: r.memory_count,
          last_memory_access: r.last_memory_access ? new Date(r.last_memory_access * 1000).toISOString() : null,
          layer_breakdown: {
            goal: r.goal_count,
            caveat: r.caveat_count,
            learning: r.learning_count,
            implementation: r.impl_count,
          },
          pinned_count: r.pinned_count,
        })),
      });
    }
  • The MCP tool dispatch registration in the CallToolRequestSchema handler, routing 'list_entities' to handleListEntities.
    case 'list_entities': text = handleListEntities(args); break;
Behavior4/5

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

No annotations provided, so description carries full burden. It discloses sorting behavior and states it is cheaper than recall, but does not mention any specific permissions or side effects. For a list tool, this is adequate but not fully transparent.

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?

Three sentences, no redundancy. First sentence states purpose, second gives usage context, third adds cost comparison. Every sentence adds value.

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?

No output schema, but description explains return is list of entities sorted by recent activity. Mentions cost comparison and usage context. Could detail return format more but sufficient for low complexity.

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

Parameters3/5

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

Schema descriptions cover 75% of parameters with defaults and enum details. Description adds no additional meaning beyond the schema, so baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states 'List the entities currently known to this memory store, sorted by recent activity' with specific verb and resource. It distinguishes from sibling tools like recall by noting it is for overview before specific queries.

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

Usage Guidelines5/5

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

Explicitly advises use at session start for 'what do I know about?' before specific recall queries. Compares cost to recall tool, providing clear context for when to use this tool.

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/michielinksee/linksee-memory'

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