Skip to main content
Glama

flutter_pub_get

Install Flutter project dependencies by running pub get in the specified working directory to resolve and fetch required packages.

Instructions

Install Flutter project dependencies (pub get)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cwdYesWorking directory (Flutter project root)

Implementation Reference

  • The handler function executes the 'flutter pub get' command. It validates the input using FlutterPubGetSchema, ensures the directory is a valid Flutter project, runs the command with a 5-minute timeout, and returns structured results including output, errors, exit code, and duration.
    handler: async (args: any) => {
      const validation = FlutterPubGetSchema.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', ['pub', 'get'], {
        cwd,
        timeout: 300000, // 5 minutes timeout for pub get
      });
    
      return {
        success: true,
        data: {
          projectPath: cwd,
          exitCode: result.exitCode,
          output: result.stdout,
          errors: result.stderr,
          duration: result.duration,
          success: result.exitCode === 0,
        },
      };
    }
  • Zod schema for validating the tool's input parameters. Requires a 'cwd' string (working directory of the Flutter project).
    const FlutterPubGetSchema = z.object({
      cwd: z.string().min(1),
    });
  • Registers the 'flutter_pub_get' tool in the tools Map within createFlutterTools function. Includes name, description, JSON inputSchema mirroring the Zod schema, and references the handler function.
    tools.set('flutter_pub_get', {
      name: 'flutter_pub_get',
      description: 'Install Flutter project dependencies (pub get)',
      inputSchema: {
        type: 'object',
        properties: {
          cwd: { type: 'string', minLength: 1, description: 'Working directory (Flutter project root)' }
        },
        required: ['cwd']
      },
      handler: async (args: any) => {
        const validation = FlutterPubGetSchema.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', ['pub', 'get'], {
          cwd,
          timeout: 300000, // 5 minutes timeout for pub get
        });
    
        return {
          success: true,
          data: {
            projectPath: cwd,
            exitCode: result.exitCode,
            output: result.stdout,
            errors: result.stderr,
            duration: result.duration,
            success: result.exitCode === 0,
          },
        };
      }
    });
  • Helper function used by the handler to validate that the provided cwd is a valid Flutter project by checking for pubspec.yaml with a '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}`);
      }
    };
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action ('Install') but doesn't describe what 'pub get' does beyond that (e.g., downloads packages, updates lockfile, may require internet). It lacks details on side effects, error handling, or typical runtime. This is inadequate for a tool with potential network/disk operations.

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 directly states the tool's purpose with zero redundant information. It's front-loaded and appropriately sized for a simple command-line tool, with every word earning its place.

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 tool's complexity (executing a Flutter command with potential side effects), no annotations, and no output schema, the description is insufficient. It doesn't explain what the tool returns (e.g., success/failure, output logs) or behavioral aspects like idempotency. For a dependency installation tool, more context on outcomes and errors is needed.

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%, with the single parameter 'cwd' well-documented in the schema as 'Working directory (Flutter project root)'. The description adds no parameter-specific information beyond what the schema provides, so it meets the baseline for high schema coverage without compensating 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 action ('Install') and resource ('Flutter project dependencies') with the specific command 'pub get'. It distinguishes from siblings like 'flutter_clean' or 'flutter_build' by focusing on dependency installation. However, it doesn't explicitly differentiate from similar tools like 'flutter_setup_environment' which might also handle dependencies.

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., needing a valid Flutter project), when to run it (e.g., after adding dependencies), or what happens if dependencies are already installed. There's no comparison to siblings like 'flutter_fix_common_issues' for dependency resolution.

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