Skip to main content
Glama

list_folders

Retrieve a nested tree of folders of specified type (TESTCASE, TESTCYCLE, or TESTPLAN) for a Jira project. Optionally provide a folder ID to return only that subtree, useful for large projects.

Instructions

List folders of a given type in a project as a nested tree with id, name, parentId, and children. Provide folderId to return only that subtree instead of the full project tree (recommended for large projects).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdYesJira project numeric ID (e.g. 10011)
folderTypeYesFolder type to list
folderIdNoReturn only this folder and its children (subtree). Omit to get the full project tree.

Implementation Reference

  • The handler function for the list_folders tool. It fetches folder data from the QMetry API, optionally filtering to a specific subtree by folderId using a recursive findSubtree helper.
      async ({ projectId, folderType, folderId }) => {
        const folderSegments: Record<string, string> = {
          TESTCASE: "testcase-folders",
          TESTCYCLE: "testcycle-folders",
          TESTPLAN: "testplan-folders",
        };
        const typeSegment = folderSegments[folderType];
        const data = await qtmFetch(`/projects/${projectId}/${typeSegment}`) as any;
        if (folderId === undefined) return ok(data);
        const nodes = data?.data ?? data ?? [];
        // Find and return only the subtree rooted at folderId
        function findSubtree(items: any[]): any | null {
          for (const item of items) {
            if (item.id === folderId) return item;
            const found = findSubtree(item.children ?? []);
            if (found) return found;
          }
          return null;
        }
        const subtree = findSubtree(nodes);
        return ok(subtree ?? { error: `Folder ${folderId} not found` });
      }
    );
  • Input schema for list_folders: requires projectId (string or number), folderType (enum: TESTCASE/TESTCYCLE/TESTPLAN), and optional folderId for subtree filtering.
    {
      projectId: z.union([z.string(), z.number()]).describe("Jira project numeric ID (e.g. 10011)"),
      folderType: z
        .enum(["TESTCASE", "TESTCYCLE", "TESTPLAN"])
        .describe("Folder type to list"),
      folderId: z.number().int().optional().describe("Return only this folder and its children (subtree). Omit to get the full project tree."),
    },
  • src/index.ts:623-655 (registration)
    Registration of the list_folders tool via the local 'tool' wrapper, which calls server.registerTool on the McpServer instance.
    tool(
      "list_folders",
      "List folders of a given type in a project as a nested tree with id, name, parentId, and children. Provide folderId to return only that subtree instead of the full project tree (recommended for large projects).",
      {
        projectId: z.union([z.string(), z.number()]).describe("Jira project numeric ID (e.g. 10011)"),
        folderType: z
          .enum(["TESTCASE", "TESTCYCLE", "TESTPLAN"])
          .describe("Folder type to list"),
        folderId: z.number().int().optional().describe("Return only this folder and its children (subtree). Omit to get the full project tree."),
      },
      async ({ projectId, folderType, folderId }) => {
        const folderSegments: Record<string, string> = {
          TESTCASE: "testcase-folders",
          TESTCYCLE: "testcycle-folders",
          TESTPLAN: "testplan-folders",
        };
        const typeSegment = folderSegments[folderType];
        const data = await qtmFetch(`/projects/${projectId}/${typeSegment}`) as any;
        if (folderId === undefined) return ok(data);
        const nodes = data?.data ?? data ?? [];
        // Find and return only the subtree rooted at folderId
        function findSubtree(items: any[]): any | null {
          for (const item of items) {
            if (item.id === folderId) return item;
            const found = findSubtree(item.children ?? []);
            if (found) return found;
          }
          return null;
        }
        const subtree = findSubtree(nodes);
        return ok(subtree ?? { error: `Folder ${folderId} not found` });
      }
    );
  • The qtmFetch helper used by the list_folders handler to make HTTP requests to the QMetry API.
    async function qtmFetch(
      path: string,
      options: RequestInit = {},
      attempt = 1
    ): Promise<unknown> {
      const url = `${BASE_URL}${path}`;
      const headers: Record<string, string> = {
        apiKey: API_KEY ?? "",
        "Content-Type": "application/json",
        Accept: "application/json",
        ...(options.headers as Record<string, string> | undefined),
      };
    
      const response = await fetch(url, { ...options, headers });
    
      // Exponential back-off for rate limiting (max 3 attempts)
      if (response.status === 429 && attempt < 3) {
        const retryAfter = Number.parseInt(
          response.headers.get("Retry-After") ?? "1",
          10
        );
        const delay = Math.max(retryAfter * 1000, 1000) * attempt;
        await new Promise((r) => setTimeout(r, delay));
        return qtmFetch(path, options, attempt + 1);
      }
    
      const text = await response.text();
      let body: unknown;
      try {
        body = text ? JSON.parse(text) : null;
      } catch {
        body = text;
      }
    
      if (!response.ok) {
        throw new Error(
          `HTTP ${response.status} ${response.statusText}: ${JSON.stringify(body)}`
        );
      }
    
      return body;
    }
  • The 'tool' wrapper function that registers tools on the MCP server, used to register list_folders.
    const tool = <Shape extends z.ZodRawShape>(
      name: string,
      description: string,
      inputSchema: Shape,
      // eslint-disable-next-line @typescript-eslint/no-explicit-any
      callback: (args: z.infer<z.ZodObject<Shape>>) => Promise<any>
    ) =>
      server.registerTool(
        name,
        { description, inputSchema },
        // eslint-disable-next-line @typescript-eslint/no-explicit-any
        callback as any
      );
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description explains that the tool returns a nested tree and supports optional subtree filtering. It is clear that this is a read operation, but does not cover permissions, rate limits, or edge cases.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, front-loaded with the core function, and no unnecessary words. Every sentence adds meaningful information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description covers the return format (nested tree with fields) and the optional subtree filter. Given no output schema, it provides adequate context for a list tool, though could mention empty results.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, but the description adds value by explaining the nested tree structure and the recommendation to use folderId for large projects, clarifying the purpose beyond schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool lists folders of a given type as a nested tree, specifying the fields (id, name, parentId, children). It distinguishes from siblings like create_folder (creation) and search_test_cases (search).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description advises providing folderId for a subtree instead of the full tree, recommended for large projects. It does not explicitly state when not to use or list alternatives, but the guidance is useful.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/salehrifai42/qmetrymcp'

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