Skip to main content
Glama

flutter_clean

Clean Flutter build cache and generated files to resolve project issues and free up disk space by specifying the Flutter project directory.

Instructions

Clean Flutter build cache and generated files

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cwdYesWorking directory (Flutter project root)

Implementation Reference

  • The handler function for the flutter_clean tool. It validates the input arguments using the FlutterCleanSchema, ensures the cwd is a valid Flutter project, executes the 'flutter clean' command with a 2-minute timeout, and returns structured results including success status, project path, exit code, stdout, and duration.
    handler: async (args: any) => {
      const validation = FlutterCleanSchema.safeParse(args);
      if (!validation.success) {
        throw new Error(`Invalid request: ${validation.error.message}`);
      }
    
      const { cwd } = validation.data;
    
      // Validate that it's a Flutter project
      await validateFlutterProject(cwd);
    
      const result = await processExecutor.execute('flutter', ['clean'], {
        cwd,
        timeout: 120000, // 2 minutes timeout for clean
      });
    
      return {
        success: true,
        data: {
          projectPath: cwd,
          exitCode: result.exitCode,
          output: result.stdout,
          duration: result.duration,
        },
      };
    }
  • Zod validation schema defining the input for flutter_clean: requires a 'cwd' string (minimum length 1) for the Flutter project working directory.
    const FlutterCleanSchema = z.object({
      cwd: z.string().min(1),
    });
  • Tool registration within createFlutterTools function: registers 'flutter_clean' in the tools Map with name, description, JSON inputSchema equivalent to Zod schema, and references the handler function.
    // Flutter Clean - Clean build cache
    tools.set('flutter_clean', {
      name: 'flutter_clean',
      description: 'Clean Flutter build cache and generated files',
      inputSchema: {
        type: 'object',
        properties: {
          cwd: { type: 'string', minLength: 1, description: 'Working directory (Flutter project root)' }
        },
        required: ['cwd']
      },
      handler: async (args: any) => {
        const validation = FlutterCleanSchema.safeParse(args);
        if (!validation.success) {
          throw new Error(`Invalid request: ${validation.error.message}`);
        }
    
        const { cwd } = validation.data;
    
        // Validate that it's a Flutter project
        await validateFlutterProject(cwd);
    
        const result = await processExecutor.execute('flutter', ['clean'], {
          cwd,
          timeout: 120000, // 2 minutes timeout for clean
        });
    
        return {
          success: true,
          data: {
            projectPath: cwd,
            exitCode: result.exitCode,
            output: result.stdout,
            duration: result.duration,
          },
        };
      }
    });
  • Supporting helper function validateFlutterProject used by the flutter_clean handler to verify that the provided cwd directory is a valid Flutter project by checking for pubspec.yaml with 'flutter:' section.
    const validateFlutterProject = async (cwd: string): Promise<void> => {
      const pubspecPath = path.join(cwd, 'pubspec.yaml');
      try {
        await fs.access(pubspecPath);
        const pubspecContent = await fs.readFile(pubspecPath, 'utf8');
        if (!pubspecContent.includes('flutter:')) {
          throw new Error(`Directory does not appear to be a Flutter project. No flutter section found in ${pubspecPath}`);
        }
      } catch {
        throw new Error(`pubspec.yaml not found. Flutter project must contain pubspec.yaml at: ${pubspecPath}`);
      }
    };
  • Usage of flutter_clean tool within the flutter_fix_common_issues super-tool handler as the first step in auto-fixing common Flutter issues.
    const cleanResult = await flutterTools.get('flutter_clean').handler({ cwd: args.cwd });
    fixes.push({ step: 'flutter_clean', ...cleanResult });
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action ('clean') but doesn't describe what 'clean' entails (e.g., irreversible deletion, time-consuming operation, potential side effects on project state), nor does it mention permissions, rate limits, or output behavior. This is inadequate for a tool that likely modifies the file system.

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 a single, efficient sentence that front-loads the core action ('clean') and resources. There is no wasted verbiage, repetition, or unnecessary elaboration, making it highly concise and well-structured for quick comprehension.

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 complexity (a tool that likely performs file system operations), lack of annotations, and no output schema, the description is incomplete. It fails to address critical aspects like what 'clean' means in practice, safety considerations, or expected outcomes, leaving significant gaps for the agent to infer behavior.

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

Parameters4/5

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

The description adds no parameter-specific information beyond what the schema provides (schema coverage is 100% with a clear description for 'cwd'). However, with only one parameter, the baseline is high, and the description doesn't contradict or confuse the schema, so it scores well despite not adding extra value.

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

Purpose4/5

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

The description clearly states the verb ('clean') and the resources ('Flutter build cache and generated files'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'flutter_fix_common_issues' or 'flutter_doctor' which might also perform cleanup operations, so it doesn't reach the highest score.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., after build failures, before releases), exclusions, or how it compares to siblings like 'flutter_fix_common_issues' for cache-related issues. This leaves the agent with minimal context for decision-making.

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/cristianoaredes/mcp-mobile-server'

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