Skip to main content
Glama

list_passages

Retrieve paginated memories from an agent's archival store with search, sorting, and filtering capabilities.

Instructions

Retrieve the memories in an agent's archival memory store (paginated query). Use create_passage to add new memories, modify_passage to edit, or delete_passage to remove them.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
agent_idYesID of the agent whose passages to list
afterNoUnique ID of the memory to start the query range at (for pagination).
beforeNoUnique ID of the memory to end the query range at (for pagination).
limitNoHow many results to include in the response.
searchNoSearch passages by text content.
orderNoSort order for passages: "asc" for oldest to newest (default), "desc" for newest to oldest. (SDK v1.0)asc
ascendingNoDEPRECATED: Use "order" instead. Whether to sort passages oldest to newest (True) or newest to oldest (False).
include_embeddingsNoWhether to include the full embedding vectors in the response (default: false).

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
totalNo
has_moreNo
passagesYes

Implementation Reference

  • Core handler function that executes the list_passages tool: validates args, constructs API query for agent's archival memory, fetches passages, optionally removes embeddings, and returns JSON stringified response.
    export async function handleListPassages(server, args) {
        if (!args?.agent_id) {
            server.createErrorResponse('Missing required argument: agent_id');
        }
    
        try {
            const headers = server.getApiHeaders();
            const agentId = encodeURIComponent(args.agent_id);
    
            // Construct query parameters based on optional args
            const params = {};
            if (args.after) params.after = args.after;
            if (args.before) params.before = args.before;
            if (args.limit) params.limit = args.limit;
            if (args.search) params.search = args.search;
            // SDK v1.0: Use 'order' parameter instead of deprecated 'ascending'
            if (args.order) {
                params.order = args.order; // 'asc' or 'desc'
            } else if (args.ascending !== undefined) {
                // Backward compatibility: convert boolean ascending to order string
                params.order = args.ascending ? 'asc' : 'desc';
            }
    
            // Use the specific endpoint from the OpenAPI spec
            const response = await server.api.get(`/agents/${agentId}/archival-memory`, {
                headers,
                params,
            });
            let passages = response.data; // Assuming response.data is an array of Passage objects
    
            // Optionally remove embeddings from the response
            const includeEmbeddings = args?.include_embeddings ?? false;
            if (!includeEmbeddings) {
                passages = passages.map((passage) => {
                    // eslint-disable-next-line no-unused-vars
                    const { embedding, ...rest } = passage; // Destructure to remove embedding
                    return rest;
                });
            }
    
            return {
                content: [
                    {
                        type: 'text',
                        text: JSON.stringify({
                            passages: passages,
                        }),
                    },
                ],
            };
        } catch (error) {
            // Handle potential 404 if agent not found, or other API errors
            if (error.response && error.response.status === 404) {
                server.createErrorResponse(`Agent not found: ${args.agent_id}`);
            }
            server.createErrorResponse(error);
        }
    }
  • Tool definition object including name 'list_passages', description, and detailed inputSchema with properties for agent_id (required), pagination (after/before/limit), search, ordering, and optional embeddings inclusion.
    export const listPassagesDefinition = {
        name: 'list_passages',
        description:
            "Retrieve the memories in an agent's archival memory store (paginated query). Use create_passage to add new memories, modify_passage to edit, or delete_passage to remove them.",
        inputSchema: {
            type: 'object',
            properties: {
                agent_id: {
                    type: 'string',
                    description: 'ID of the agent whose passages to list',
                },
                after: {
                    type: 'string',
                    description:
                        'Unique ID of the memory to start the query range at (for pagination).',
                },
                before: {
                    type: 'string',
                    description: 'Unique ID of the memory to end the query range at (for pagination).',
                },
                limit: {
                    type: 'integer',
                    description: 'How many results to include in the response.',
                },
                search: {
                    type: 'string',
                    description: 'Search passages by text content.',
                },
                order: {
                    type: 'string',
                    enum: ['asc', 'desc'],
                    description:
                        'Sort order for passages: "asc" for oldest to newest (default), "desc" for newest to oldest. (SDK v1.0)',
                    default: 'asc',
                },
                ascending: {
                    type: 'boolean',
                    description:
                        'DEPRECATED: Use "order" instead. Whether to sort passages oldest to newest (True) or newest to oldest (False).',
                    deprecated: true,
                },
                include_embeddings: {
                    type: 'boolean',
                    description:
                        'Whether to include the full embedding vectors in the response (default: false).',
                    default: false,
                },
            },
            required: ['agent_id'],
        },
    };
  • Import statement bringing in the handler function and tool definition for use in central registration.
    import { handleListPassages, listPassagesDefinition } from './passages/list-passages.js';
  • Switch case in the central MCP tool call handler (registerToolHandlers) that dispatches calls to the list_passages handler.
    case 'list_passages':
        return handleListPassages(server, request.params.arguments);
  • Inclusion of listPassagesDefinition in the allTools array used for tool listing and enhanced registration.
    listPassagesDefinition,
Behavior4/5

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

The description adds valuable behavioral context beyond what annotations provide: it specifies this is a 'paginated query' (which isn't in the annotations) and clarifies the scope ('memories in an agent's archival memory store'). While annotations only provide a title ('Search Archival Memory'), the description adds operational details about pagination and memory store context that help the agent understand how to use the tool 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?

The description is perfectly concise with just two sentences that each serve distinct purposes: the first states the core functionality, and the second provides usage guidelines. There's zero wasted language, and the most important information (what the tool does) comes first, making it easy for an agent to quickly understand the tool's purpose.

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?

Given the tool's complexity (8 parameters, pagination, search capabilities) and the presence of both comprehensive schema documentation (100% coverage) and an output schema, the description provides exactly what's needed: clear purpose, usage boundaries, and key behavioral context (paginated query). The description doesn't need to explain return values since an output schema exists, making this complete for the agent's needs.

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?

With 100% schema description coverage, the input schema already comprehensively documents all 8 parameters. The description doesn't add any parameter-specific information beyond what's in the schema, so it meets the baseline expectation. The description's mention of 'paginated query' aligns with the after/before/limit parameters in the schema but doesn't provide additional semantic context.

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?

The description clearly states the specific action ('Retrieve the memories'), identifies the resource ('agent's archival memory store'), and distinguishes it from sibling tools by explicitly naming create_passage, modify_passage, and delete_passage as alternatives for different operations. This provides excellent differentiation from similar tools like search_archival_memory and search_memory.

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?

The description provides explicit guidance on when to use this tool versus alternatives: 'Use create_passage to add new memories, modify_passage to edit, or delete_passage to remove them.' This clearly defines the boundary between this retrieval tool and mutation operations, helping the agent select the right tool for the job.

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/oculairmedia/Letta-MCP-server'

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