Skip to main content
Glama

drive_files_list

List Google Drive files with search queries, pagination, field selection, and sorting. Shared drives are included automatically.

Instructions

List files in Google Drive. Supports search queries via the 'q' parameter. Shared drive files are included automatically.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
qNoSearch query (e.g. "name contains 'report'" or "mimeType='application/vnd.google-apps.folder'")
pageSizeNoMax results per page (1-1000, default 100)
fieldsNoFields to include (e.g. "files(id,name,mimeType)")
orderByNoSort order (e.g. "modifiedTime desc")

Implementation Reference

  • src/services.ts:40-52 (registration)
    Tool definition registration for 'drive_files_list' as a ToolDef object — specifies name, description, gws command ['drive','files','list'], params schema (q, pageSize, fields, orderBy), and shared drive defaults.
    const driveTools: ToolDef[] = [
      {
        name: "drive_files_list",
        description: "List files in Google Drive. Supports search queries via the 'q' parameter. Shared drive files are included automatically.",
        command: ["drive", "files", "list"],
        params: [
          { name: "q", description: "Search query (e.g. \"name contains 'report'\" or \"mimeType='application/vnd.google-apps.folder'\")", type: "string", required: false },
          { name: "pageSize", description: "Max results per page (1-1000, default 100)", type: "number", required: false },
          { name: "fields", description: "Fields to include (e.g. \"files(id,name,mimeType)\")", type: "string", required: false },
          { name: "orderBy", description: "Sort order (e.g. \"modifiedTime desc\")", type: "string", required: false },
        ],
        defaultParams: DRIVE_SHARED_DEFAULTS,
      },
  • Generic handler that registers all tools (including drive_files_list) via server.tool(). Uses a dynamic schema from buildZodSchema(tool) and delegates execution to executeGws(), which builds CLI args and spawns the gws process.
    for (const tool of tools) {
      const schema = buildZodSchema(tool);
    
      server.tool(
        tool.name,
        tool.description,
        schema,
        async (args) => {
          const result = await executeGws(tool, args as Record<string, unknown>, gwsBinary);
    
          if (result.success) {
            return {
              content: [{ type: "text" as const, text: result.output || "(empty response)" }],
            };
          } else {
            return {
              content: [{ type: "text" as const, text: `Error: ${result.error}` }],
              isError: true,
            };
          }
        },
      );
  • ToolDef interface definition — the TypeScript interface that defines the shape of tool definitions including name, description, command, params, bodyParams, etc.
    export interface ToolDef {
      /** MCP tool name, e.g. "drive_files_list" */
      name: string;
      /** Human-readable description */
      description: string;
      /** gws CLI args, e.g. ["drive", "files", "list"] */
      command: string[];
      /** Parameters passed via --params (query/path params) */
      params: ParamDef[];
      /** Parameters passed via --json (request body) */
      bodyParams?: ParamDef[];
      /** Whether this tool accepts a file upload via --upload */
      supportsUpload?: boolean;
      /** Default params injected into every call (can be overridden by caller) */
      defaultParams?: Record<string, unknown>;
    }
  • buildZodSchema() helper function — dynamically builds a Zod validation schema from ToolDef params, used to generate the schema for drive_files_list (and all other tools) at registration time.
    export function buildZodSchema(tool: ToolDef): Record<string, z.ZodTypeAny> {
      const shape: Record<string, z.ZodTypeAny> = {};
    
      const allParams = [...tool.params, ...(tool.bodyParams || [])];
    
      for (const p of allParams) {
        let field: z.ZodTypeAny;
        switch (p.type) {
          case "number":
            field = z.number().describe(p.description);
            break;
          case "boolean":
            field = z.boolean().describe(p.description);
            break;
          default:
            field = z.string().describe(p.description);
        }
    
        if (!p.required) {
          field = field.optional();
        }
    
        shape[p.name] = field;
      }
    
      // Add optional uploadPath for tools that support file upload
      if (tool.supportsUpload) {
        shape.uploadPath = z.string().describe("Local file path to upload").optional();
      }
    
      return shape;
    }
  • executeGws() — the main handler delegate that builds CLI args from the tool definition and spawns the gws CLI process to actually run 'drive files list' (or any other tool).
    export async function executeGws(
      tool: ToolDef,
      args: Record<string, unknown>,
      gwsBinary: string,
    ): Promise<ExecResult> {
      const cliArgs = buildArgs(tool, args);
    
      console.error(`[gws-mcp] Executing: ${gwsBinary} ${cliArgs.join(" ")}`);
    
      try {
        const { stdout, stderr } = await spawnGwsRaw(gwsBinary, cliArgs);
    
        if (stderr) {
          console.error(`[gws-mcp] stderr: ${stderr}`);
        }
    
        return { success: true, output: stdout || "(empty response)" };
      } catch (err: unknown) {
        const error = err as { message?: string };
        let message = error.message || "Unknown error";
    
        // Enhance Drive 404 errors with actionable hints
        if (message.includes("404") && message.includes("not found") && tool.command[0] === "drive") {
          message += "\n\nHint: If this file is in a shared drive, ensure supportsAllDrives is set (this should be automatic). Check that the file ID is correct and the authenticated account has access.";
        }
    
        console.error(`[gws-mcp] Error: ${message}`);
        return { success: false, output: "", error: message };
      }
    }
Behavior3/5

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

No annotations are provided, so the description alone must disclose behavioral traits. It adds that shared drive files are included automatically, which is helpful. However, it does not discuss error handling, authentication requirements, or pagination behavior beyond the schema. The description is adequate but not comprehensive.

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?

The description is concise with two sentences, each adding value. The first sentence states the purpose, and the second adds key behavioral traits. No fluff or redundancy.

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

Completeness2/5

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

Given the absence of an output schema and annotations, the description should explain what the response contains (e.g., default fields, pagination structure). It fails to do so, leaving the agent uncertain about the return format. The tool is simple but incomplete.

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

Parameters3/5

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

Schema description coverage is 100%, so the baseline is 3. The description adds that the 'q' parameter supports search queries, but this is already explicit in the schema. No additional meaning or context is provided for other parameters.

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 'List files in Google Drive' with a specific verb and resource. It distinguishes itself from sibling tools like drive_files_get (single file) and drive_files_create (create files) by focusing on listing. The mention of search queries and shared drive files adds specificity.

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

Usage Guidelines3/5

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

The description mentions search query support and automatic inclusion of shared drive files, but does not explicitly state when to use this tool versus alternatives like drive_files_get or drive_files_list with specific filters. There is no guidance on when not to use it.

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/conorbronsdon/gws-mcp-server'

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