get-tags
Retrieve all tags from Things 3 database to organize and categorize tasks for better project management and workflow optimization.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| include_items | No | Include items tagged with each tag |
Implementation Reference
- src/index.ts:882-900 (handler)The "get-tags" tool definition and handler, which queries the database for tags and optionally includes tasks associated with each tag.
server.tool( "get-tags", { include_items: z.boolean().optional().describe("Include items tagged with each tag"), }, async ({ include_items }) => { const data = await withDatabase((db) => { const tags = getTags(db); if (!include_items) return tags; const tasks = getAllTasks(db); return tags.map((tag) => ({ ...tag, items: tasks.filter((task) => task.tags.includes(tag.title)), })); }); return buildTextResponse(`Found ${data.length} tags`, { tags: data }); } ); - src/index.ts:540-550 (helper)Helper function `getTags` that executes the SQL query to retrieve all tags from the database.
function getTags(db: DatabaseSync): TagRecord[] { return db .prepare( ` SELECT uuid, title, shortcut FROM TMTag ORDER BY "index" ` ) .all() as Array<TagRecord>; }