Skip to main content
Glama

get_list

Retrieve items from an existing list by ID to inspect contents, verify items, or check list existence before processing.

Instructions

Retrieves the items in an existing list by its ID.

WHEN TO USE:

  • To inspect the contents of a list before processing

  • To verify which items are in a list

  • To check if a list exists

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
list_idYesThe list ID returned by create_list.

Implementation Reference

  • src/index.ts:298-336 (registration)
    Registration of the 'get_list' tool, including description, input schema, and the inline handler function that retrieves and formats the list contents or returns an error if not found.
    server.registerTool( "get_list", { description: `Retrieves the items in an existing list by its ID. WHEN TO USE: - To inspect the contents of a list before processing - To verify which items are in a list - To check if a list exists`, inputSchema: { list_id: z.string().describe("The list ID returned by create_list."), }, }, async ({ list_id }) => { const items = lists.get(list_id); if (!items) { return { content: [ { type: "text", text: `Error: No list found with ID "${list_id}". The list may have been deleted or the ID is incorrect.`, }, ], isError: true, }; } const itemList = items.map((item, i) => `${i + 1}. ${item}`).join("\n"); return { content: [ { type: "text", text: `List "${list_id}" contains ${items.length} items:\n\n${itemList}`, }, ], }; }, );
  • The handler function for 'get_list' tool. It fetches the list items using lists.get(list_id), handles missing list with error response, otherwise formats the items into a numbered list and returns as text content.
    async ({ list_id }) => { const items = lists.get(list_id); if (!items) { return { content: [ { type: "text", text: `Error: No list found with ID "${list_id}". The list may have been deleted or the ID is incorrect.`, }, ], isError: true, }; } const itemList = items.map((item, i) => `${i + 1}. ${item}`).join("\n"); return { content: [ { type: "text", text: `List "${list_id}" contains ${items.length} items:\n\n${itemList}`, }, ], }; }, );
  • Zod input schema for 'get_list' tool, defining the required 'list_id' parameter.
    inputSchema: { list_id: z.string().describe("The list ID returned by create_list."), },
  • Global Map<string, string[]> named 'lists' that stores all created lists, used by the get_list handler via lists.get(list_id).
    const lists = new Map<string, string[]>();

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/jrandolf/par5-mcp'

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