Skip to main content
Glama

list_agents

Retrieve available agents in the Letta system to manage, interact with, or create new agents for your workflow.

Instructions

List all available agents in the Letta system. Use with create_agent to add new ones, get_agent_summary for details, or prompt_agent to interact with them.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filterNoOptional filter to search for specific agents

Implementation Reference

  • The core handler function that fetches agents from the Letta API, applies optional filtering, summarizes the list, and returns a structured JSON response.
    export async function handleListAgents(server, args) { try { // Headers for API requests const headers = server.getApiHeaders(); // Get the list of agents const response = await server.api.get('/agents/', { headers }); const agents = response.data; // Apply filter if provided let filteredAgents = agents; if (args?.filter) { const filter = args.filter.toLowerCase(); filteredAgents = agents.filter( (agent) => agent.name.toLowerCase().includes(filter) || (agent.description && agent.description.toLowerCase().includes(filter)), ); } // Extract only essential details for the response const summarizedAgents = filteredAgents.map((agent) => ({ id: agent.id, name: agent.name, description: agent.description, })); return { content: [ { type: 'text', text: JSON.stringify({ count: summarizedAgents.length, agents: summarizedAgents, // Use summarized list }), }, ], }; } catch (error) { logger.error('Error in list_agents:', error.message); logger.error('API Base URL:', server.apiBase); logger.error('Full error:', error.response?.data || error); server.createErrorResponse(error); } }
  • The tool definition object including name, description, and input schema for the list_agents tool.
    export const listAgentsToolDefinition = { name: 'list_agents', description: 'List all available agents in the Letta system. Use with create_agent to add new ones, get_agent_summary for details, or prompt_agent to interact with them.', inputSchema: { type: 'object', properties: { filter: { type: 'string', description: 'Optional filter to search for specific agents', }, }, required: [], }, };
  • Registration in the central tool call dispatcher switch statement, routing 'list_agents' calls to the handler.
    case 'list_agents': return handleListAgents(server, request.params.arguments);
  • Inclusion of the tool definition in the allTools array for ListToolsRequestSchema registration.
    listAgentsToolDefinition,
  • Output schema definition for structured responses from the list_agents tool.
    list_agents: { type: 'object', properties: { agents: { type: 'array', items: { type: 'object', properties: { id: { type: 'string' }, name: { type: 'string' }, description: { type: 'string' }, created_at: { type: 'string' }, model: { type: 'string' }, embedding_model: { type: 'string' }, }, required: ['id', 'name'], }, }, }, required: ['agents'], },

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