Skip to main content
Glama

get-areas

Retrieve all areas from Things 3 to organize projects and tasks, with an option to include nested items for comprehensive project management.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
include_itemsNoInclude projects and tasks within areas

Implementation Reference

  • Tool registration for "get-areas" and the handler function logic.
    server.tool(
      "get-areas",
      {
        include_items: z.boolean().optional().describe("Include projects and tasks within areas"),
      },
      async ({ include_items }) => {
        const data = await withDatabase((db) => {
          const tasks = getAllTasks(db);
          return getAreas(db, tasks, include_items ?? false);
        });
        return buildTextResponse(`Found ${data.length} areas`, { areas: data });
      }
    );
  • Helper function `getAreas` which executes the actual database logic to fetch and format areas.
    function getAreas(db: DatabaseSync, tasks: TaskRecord[], includeItems = false): AreaRecord[] {
      const rows = db
        .prepare(
          `
          SELECT AREA.uuid, AREA.title
          FROM TMArea AS AREA
          ORDER BY AREA."index"
          `
        )
        .all() as Array<{ uuid: string; title: string }>;
    
      const areaTags = db
        .prepare(
          `
          SELECT AREA_TAG.areas AS area_id, TAG.title AS tag_title
          FROM TMAreaTag AS AREA_TAG
          LEFT JOIN TMTag AS TAG ON TAG.uuid = AREA_TAG.tags
          ORDER BY TAG."index"
          `
        )
        .all() as Array<{ area_id: string; tag_title: string | null }>;
    
      const tagsByArea = new Map<string, string[]>();
      for (const row of areaTags) {
        if (!row.tag_title) continue;
        const current = tagsByArea.get(row.area_id) ?? [];
        current.push(row.tag_title);
        tagsByArea.set(row.area_id, current);
      }
    
      return rows.map((row) => {
        const area: AreaRecord = {
          id: row.uuid,
          title: row.title,
          tags: tagsByArea.get(row.uuid) ?? [],
        };
    
        if (includeItems) {
          area.projects = tasks.filter(
            (task) =>
              task.type === "project" &&
              task.areaId === row.uuid &&
              !task.trashed
          );
          area.todos = tasks.filter(
            (task) =>
              task.type === "to-do" &&
              task.areaId === row.uuid &&
              !task.trashed &&
              !task.projectId
          );
        }
    
        return area;
      });
    }

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/soycanopa/SupaThings-MCP'

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