get_list
Retrieve items from an existing list by ID to inspect contents, verify items, or check list existence for processing preparation.
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
| Name | Required | Description | Default |
|---|---|---|---|
| list_id | Yes | The list ID returned by create_list. |
Implementation Reference
- src/index.ts:324-348 (handler)Executes the core logic of the get_list tool: retrieves list items by ID from the global 'lists' Map, formats them as a numbered list, or returns an error if the list doesn't exist.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}`, }, ], }; },
- src/index.ts:320-322 (schema)Zod schema defining the input parameter 'list_id' as a required string for the get_list tool.inputSchema: { list_id: z.string().describe("The list ID returned by create_list."), },
- src/index.ts:311-349 (registration)Registers the get_list tool with the MCP server, providing name, description, input schema, and inline handler function.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}`, }, ], }; }, );