How to Use Gemini CLI in Android Studio for Flutter: MCP Server, Dart Integration, and Workflows

Coding Liquids blog cover featuring Sagnik Bhattacharya for How to Use Gemini CLI in Android Studio for Flutter with MCP Server, showing Android Studio IDE with Gemini CLI terminal integration.
Coding Liquids blog cover featuring Sagnik Bhattacharya for How to Use Gemini CLI in Android Studio for Flutter with MCP Server, showing Android Studio IDE with Gemini CLI terminal integration.

Four of the most searched developer terms in early 2026 — Gemini CLI, Android Studio, Flutter, and MCP servers — intersect in a workflow that almost nobody has written about. Google's Gemini CLI gives you a terminal-based AI coding assistant (free until 18 June 2026; it now needs a paid Gemini API key or Code Assist licence, and free users have moved to Antigravity CLI). Android Studio is the default IDE for Flutter development. The Model Context Protocol (MCP) is a new open standard that lets AI tools communicate with external services. And the official Dart/Flutter MCP server, now built into the Dart SDK as dart mcp-server, exposes Flutter-specific tooling — analysis results, pub.dev search and dependency management, and inspection of your running app — directly to any MCP-compatible AI client.

The Complete Flutter Course thumbnail

The Complete Flutter Course: Build Android, iOS and Web apps

Go from scratch to building industry-standard apps with Riverpod, Firebase, animations, REST APIs, and more.

By Sagnik Bhattacharya and Paulina Knop

Buy now

Put these four together and you get an AI-powered Flutter development workflow that understands your project at a level no generic chatbot can match. I have spent the past two weeks configuring and testing this setup across three Flutter projects, and this guide walks through every step — from installation to practical day-to-day workflows. If you are already using Gemini CLI in VS Code, my Gemini CLI VS Code guide covers that setup. This post focuses specifically on Android Studio and Flutter with MCP integration.

Follow me on Instagram@sagnikteaches

Prerequisites

Before you begin, make sure you have the following installed and working:

Connect on LinkedInSagnik Bhattacharya
  1. Node.js (v20 or later). Gemini CLI is distributed as an npm package. Run node --version to verify your installation. If you need to install or update, download from nodejs.org or use a version manager like nvm.
  2. A paid Gemini API key or a Code Assist licence. Since 18 June 2026, Gemini CLI no longer serves free Google accounts or Google AI Pro and Ultra subscribers. You need a Gemini API key with billing enabled (you pay per token) or a work account covered by Gemini Code Assist Standard or Enterprise.
  3. Android Studio (2024.3 or later). Any recent version with the integrated terminal works. I recommend updating to the latest stable release to ensure compatibility with the Flutter and Dart plugins.
  4. Flutter SDK (3.35 or later). Run flutter --version to check. If you are on an older version, run flutter upgrade. The Dart MCP server relies on features in recent Dart SDK releases, so staying current matters.
  5. Dart SDK (3.9 or later). This is bundled with Flutter, but verify it separately with dart --version. The MCP server ships inside the Dart SDK from 3.9 onwards and uses Dart's analysis server APIs, which have been significantly improved in recent releases.

Verify that Android Studio recognises your Flutter SDK by opening Settings > Languages & Frameworks > Flutter and confirming the SDK path is set correctly. Also ensure the Flutter and Dart plugins are installed and enabled.

Subscribe on YouTube@codingliquids

Installing Gemini CLI

Gemini CLI is Google's open-source, terminal-based AI assistant. It runs directly in any terminal — including the one built into Android Studio — and connects to Gemini models via the Google AI API.

  1. Open a terminal (either your system terminal or Android Studio's integrated terminal) and run:
    npm install -g @anthropic-ai/gemini-cli

    Wait — that is not right. Gemini CLI is a Google product. The correct command is:

    npm install -g @google/gemini-cli
  2. After installation completes, run gemini in the terminal. On first launch, it asks how to authenticate. Export your key as GEMINI_API_KEY first and pick "Use Gemini API key", or — with an organisation's Code Assist licence — pick "Sign in with Google", which opens a browser window where you sign in with your work account and grant the requested permissions.
  3. Once authenticated, you will see the Gemini CLI interactive prompt. Type a test query like "What version of Gemini are you using?" to confirm everything is working.

Gemini CLI stores its configuration in a .gemini directory. For project-level settings, this directory sits in your project root. For global settings, it uses ~/.gemini/settings.json. We will use the project-level configuration when connecting MCP servers later.

If you were on the free tier, use Antigravity CLI instead. Install it with curl -fsSL https://antigravity.google/cli/install.sh | bash (macOS and Linux) or irm https://antigravity.google/cli/install.ps1 | iex (Windows PowerShell), then run agy instead of gemini in Android Studio's terminal and sign in with your Google account. The workflows below carry over, with one change for MCP: Antigravity CLI reads servers from .agents/mcp_config.json in your project (or ~/.gemini/config/mcp_config.json globally) rather than .gemini/settings.json, and on first launch it offers to import your existing Gemini CLI settings.

Using Gemini CLI in Android Studio's Terminal

Android Studio includes a built-in terminal panel (View > Tool Windows > Terminal, or Alt+F12). This terminal runs in your project's root directory by default, which is exactly what Gemini CLI needs — it automatically picks up your project context when launched from within a Flutter project.

Open the terminal in Android Studio and type gemini to start an interactive session. From here, you can ask questions about your Flutter project, and Gemini CLI will reference files in your working directory when you use the @ file reference syntax:

gemini> Explain the state management approach in @lib/main.dart and suggest improvements

gemini> Review @lib/widgets/custom_app_bar.dart for accessibility issues

gemini> Generate a unit test for the UserRepository class in @lib/data/user_repository.dart

This file referencing capability is powerful because Gemini CLI reads the actual file contents and includes them in the prompt context. Unlike Gemini Code Assist (the IDE plugin), Gemini CLI does not automatically index your entire workspace — but it gives you explicit control over which files to include, and the @ syntax makes it straightforward to pull in exactly the context you need.

A practical workflow I use: keep the Gemini CLI terminal open alongside your code editor tabs. When you encounter a problem, switch to the terminal, reference the relevant files, and ask your question. The response appears inline in the terminal, and you can copy code snippets directly into your editor. It is not as seamless as inline completions, but it is private (no code stored on Google servers beyond the session), and surprisingly effective for Flutter-specific tasks.

The Dart/Flutter MCP Server

Before configuring the connection, it is worth understanding what MCP is and what the Dart/Flutter MCP server actually does.

What Is the Model Context Protocol (MCP)?

The Model Context Protocol is an open standard, originally developed by Anthropic, that defines how AI assistants communicate with external tools and data sources. Think of it as a standardised API layer between an AI client (like Gemini CLI, Claude, or Cursor) and a tool server that provides specialised capabilities. Instead of the AI model trying to guess how to run flutter doctor or parse a pubspec.yaml file, the MCP server provides these as structured tools with defined inputs and outputs.

The key advantage is that MCP servers give AI models access to real, live data from your development environment rather than relying solely on the model's training data. When Gemini CLI connects to the Dart MCP server, it does not guess what packages your project uses — it reads them directly from your pubspec.lock file through the MCP server's tools.

What the Dart/Flutter MCP Server Exposes

The official Dart/Flutter MCP server, maintained by the Dart team and now shipped inside the Dart SDK, provides more than 20 tools that AI clients can invoke. These are the ones you will lean on most:

  • widget_inspector, hot_reload, and get_runtime_errors: Connect to your running Flutter app through the Dart Tooling Daemon, inspect its widget tree, hot reload after a change, and read the latest runtime errors. This lets the AI see what your app is actually doing rather than making assumptions.
  • pub: Runs pub commands such as dart pub get or flutter pub add against your project, so the AI works from your real pubspec.yaml and pubspec.lock. When you ask "why is my build failing?", it can check for version conflicts directly.
  • analyze_files: Runs the Dart analyser on your project and returns warnings, errors, and lints as structured data. Instead of you copying error messages into the chat, the AI reads them programmatically and can address multiple issues in sequence.
  • lsp: Talks to the Dart language server for hover information, signature help, and symbol resolution. This is especially useful for widget generation tasks, as the AI can check accurate constructors and property types rather than hallucinating parameters that do not exist.
  • pub_dev_search: Searches pub.dev and returns each package's description, download count, licence, and publisher. When you ask the AI to add a package, it can verify the package exists before adding it.

These tools transform Gemini CLI from a generic AI chatbot into a Flutter-aware development assistant. The difference is significant — instead of answers based on training data that may be months out of date, you get responses grounded in your actual project state.

Connecting Gemini CLI to the Dart MCP Server

Now for the configuration that ties everything together. You need to tell Gemini CLI where to find the Dart MCP server and how to start it.

Step 1: Check the Dart MCP Server

The Dart MCP server now ships with the Dart SDK (3.9 and later), so there is no package to activate any more. Verify it is available by running:

dart mcp-server --help

You should see a help message listing the available options. The server talks to clients over stdio only, and it works out which project to operate on through its roots tool, so there is no project path parameter to pass.

Step 2: Configure Gemini CLI to Use the MCP Server

In your Flutter project root, create a .gemini/settings.json file (create the .gemini directory if it does not exist):

{
  "mcpServers": {
    "dart_flutter": {
      "command": "dart",
      "args": [
        "mcp-server"
      ]
    }
  }
}

This tells Gemini CLI to launch the Dart MCP server when it starts, pointing it at the current project directory. The server communicates over stdio (standard input/output), which is the default MCP transport for local tool servers.

Step 3: Verify the Connection

Open Android Studio's terminal, navigate to your Flutter project root (it should already be there by default), and start Gemini CLI:

gemini

When Gemini CLI starts, it reads the .gemini/settings.json file and launches the configured MCP servers. You should see a message indicating the Dart/Flutter MCP server has connected successfully. To verify the tools are available, ask:

gemini> What MCP tools are available?

Gemini CLI should list the Dart/Flutter tools — analyze_files, pub, pub_dev_search, hot_reload, and others (the /mcp command shows the same list). If you do not see them, check that dart --version reports 3.9 or later and that dart mcp-server --help runs from the same terminal.

Practical Flutter Workflows with MCP

With the connection established, here are the workflows that provide the most value in day-to-day Flutter development.

Widget Generation with Full Context

This is where the MCP integration shines brightest. Without MCP, asking an AI to generate a Flutter widget means it relies on its training data — which may include outdated constructors, deprecated properties, or incorrect parameter types. With the Dart MCP server connected, Gemini CLI can ask the Dart language server for accurate constructor and property information.

gemini> Create a custom card widget that displays a user profile with avatar, name,
        email, and a follow button. Use Material 3 design tokens. Make it responsive
        for both mobile and tablet layouts.

When you issue this prompt, Gemini CLI can use the lsp tool (signature help from the Dart language server) to verify the correct constructors for Card, CircleAvatar, TextButton, and other widgets it uses in the generated code. It can also reference your project's existing theme data and dependencies to ensure consistency. The result is code that is more likely to compile on the first attempt than what you would get from a generic AI chatbot.

For complex widgets, I reference existing files for style consistency:

gemini> Create a settings page widget following the same pattern as @lib/screens/profile_page.dart.
        Include toggles for notifications, dark mode, and data sync. Use the same
        spacing and typography conventions.

Dependency Management

Managing packages in a Flutter project involves checking compatibility, resolving version conflicts, and understanding the dependency tree. The MCP server makes this conversational:

gemini> I want to add offline caching to my app. What packages would you recommend?
        Check my current dependencies and suggest options that won't conflict.

gemini> Add the dio and hive packages to my project. What version constraints should I
        use based on my current Dart SDK version?

gemini> My build is failing with a version solving error. Analyse my dependency tree
        and find the conflict.

For the last prompt, Gemini CLI uses the pub tool to run pub against your real dependency tree, identifies the conflicting constraints, and suggests specific version changes to resolve them. Without MCP, it would ask you to paste the error message and your pubspec.yaml — with MCP, it reads both directly.

Build Error Debugging

When your Flutter project has analysis errors or build failures, the MCP server provides a direct path from error to resolution:

gemini> Run analysis on my project and fix all errors and warnings.

Gemini CLI invokes analyze_files, receives the structured list of issues (file path, line number, error code, message), and generates fixes for each one. For straightforward issues like missing imports, unused variables, or type mismatches, the fixes are accurate and ready to apply. For more complex issues — logic errors, architectural problems — it provides explanations and suggested approaches.

A particularly useful pattern is iterative debugging:

gemini> Run flutter doctor and check if my environment is set up correctly for
        iOS builds. If there are issues, tell me exactly how to fix each one.

The Dart MCP server has no doctor tool, so Gemini CLI runs the actual flutter doctor command through its own shell tool and returns real results, not generic advice. If your Xcode command-line tools are outdated, it tells you the specific version mismatch and the exact command to update them.

Test Scaffolding

Generating tests for Flutter widgets and services is one of the most time-consuming parts of Flutter development. With MCP context, Gemini CLI produces significantly better test code:

gemini> Generate widget tests for @lib/widgets/product_card.dart. Test rendering,
        tap interactions, and overflow behaviour on small screens.

gemini> Create integration tests for the checkout flow starting from
        @lib/screens/cart_screen.dart through to @lib/screens/order_confirmation.dart.

Because the MCP server provides analysis data, Gemini CLI knows the exact types, method signatures, and dependencies in your widget files. The generated tests use correct constructor arguments, proper mock setups, and appropriate finder queries. They are not perfect — you will still need to review and adjust — but they provide a much better starting point than tests generated without project context.

Advanced: Custom MCP Servers for Flutter

The official Dart MCP server covers common scenarios, but you can extend the MCP ecosystem by creating project-specific servers that expose custom tooling. This is an advanced topic, but worth mentioning because it unlocks powerful possibilities.

An MCP server is essentially a programme that speaks the MCP protocol — it receives tool invocation requests over stdio or HTTP and returns structured results. You can write one in Dart using the mcp_server package:

// custom_mcp_server.dart
import 'package:mcp_server/mcp_server.dart';

void main() async {
  final server = McpServer(
    name: 'my_flutter_tools',
    version: '1.0.0',
  );

  server.addTool(
    name: 'check_l10n_coverage',
    description: 'Check which strings are missing translations',
    handler: (params) async {
      // Parse ARB files and find missing keys
      // Return structured result
    },
  );

  server.addTool(
    name: 'generate_api_model',
    description: 'Generate a Dart model class from a JSON API response',
    handler: (params) async {
      // Accept JSON input, generate freezed/json_serializable model
      // Return generated Dart code
    },
  );

  await server.start();
}

Add this custom server to your .gemini/settings.json alongside the official Dart MCP server:

{
  "mcpServers": {
    "dart_flutter": {
      "command": "dart",
      "args": ["mcp-server"]
    },
    "my_flutter_tools": {
      "command": "dart",
      "args": ["run", "tool/custom_mcp_server.dart"]
    }
  }
}

Use cases for custom MCP servers include: checking localisation coverage across ARB files, generating Dart model classes from API responses, running project-specific linting rules, querying your design system tokens, or interfacing with your CI/CD pipeline. The MCP protocol is flexible enough to wrap virtually any development tool.

Gemini CLI + MCP vs Gemini Code Assist vs Copilot for Flutter

If you are choosing between AI tools for Flutter development in Android Studio, here is how the three main options compare:

Feature Gemini CLI + MCP Gemini Code Assist GitHub Copilot
Cost Paid API key or Code Assist licence (free tier ended 18 June 2026) Free for individuals (Gemini in Android Studio); Standard/Enterprise for teams $10/month (Pro); limited Free tier
IDE integration Terminal-based Native plugin Native plugin
Inline completions No Yes Yes
Chat interface Terminal REPL Side panel Side panel
MCP server support Yes — full MCP protocol Yes, in agent mode (remote HTTP servers only) Yes, in agent mode
Flutter-specific tooling via MCP Yes — analysis, deps, running-app inspection Built-in Flutter awareness Via the Dart MCP server in agent mode
Project context File references + MCP tools Workspace indexing Workspace indexing
Offline capability No (requires Google AI API) No No
Customisability High — custom MCP servers, settings Low — plugin settings only Low — plugin settings only
Setup effort Moderate — npm install, MCP config Minimal — install plugin Minimal — install plugin

The key differentiator for Gemini CLI + MCP is customisability and depth of Flutter context. Gemini Code Assist and Copilot are easier to set up and provide inline completions, which Gemini CLI does not offer. Both now support MCP in agent mode, but with a catch for Flutter: Gemini in Android Studio only connects to remote HTTP MCP servers, so it cannot launch the stdio-only Dart MCP server, while Copilot can.

My recommendation: use Gemini CLI + MCP alongside Gemini Code Assist. Let Gemini Code Assist handle inline completions and quick chat queries. Switch to Gemini CLI in the terminal for tasks that benefit from MCP — debugging complex build errors, generating context-aware widgets, managing dependencies, and scaffolding tests. The two tools complement each other well; the in-editor Gemini is still free for individuals, but Gemini CLI now needs a paid API key or Code Assist licence.

Limitations and Caveats

This workflow is promising, but it is important to be honest about where it falls short today:

  • MCP is still early. The Model Context Protocol specification is stable, but the ecosystem is young. Not every AI client supports MCP equally well, and tool behaviour can be inconsistent. Gemini CLI's MCP support works but occasionally fails to invoke tools when it should, particularly for complex multi-step queries.
  • The Dart MCP server has coverage gaps. There is no widget catalogue or doctor tool — widget signatures come from the language server, which only knows the packages in your dependencies. The analysis tool works well for Dart errors but does not always surface platform-specific build issues (Gradle failures, CocoaPods conflicts).
  • Context window limits apply. Even with MCP providing structured data, Gemini CLI operates within a context window. For very large projects with hundreds of files, you still need to be selective about what context you provide. MCP helps by giving the model targeted data rather than dumping entire files, but there are limits.
  • No inline completions. Gemini CLI is a terminal tool. It does not provide tab-autocomplete or inline code suggestions as you type. For that, you need Gemini Code Assist, Copilot, or a similar IDE plugin. This is a fundamental architectural difference, not a bug — Gemini CLI is designed for interactive, conversational development assistance.
  • Authentication requires internet. Unlike local models (Ollama, Gemma), Gemini CLI requires an active internet connection and Google authentication. Your code is sent to Google's servers for processing. If your organisation has strict data policies, verify that Gemini CLI's data handling meets your requirements before using it with proprietary code.
  • MCP server startup adds latency. Launching Gemini CLI with MCP servers configured adds a few seconds to the startup time as each server process initialises. This is a minor inconvenience but worth noting if you are accustomed to instant-on tools.

Frequently Asked Questions

Is Gemini CLI free for Flutter development with MCP?

Not any more for most individuals. Gemini CLI is still open-source, and the Dart/Flutter MCP server is free and ships with the Dart SDK. But since 18 June 2026, Gemini CLI no longer serves free Google accounts or Google AI Pro and Ultra subscribers: you need a Gemini API key with billing enabled (charged per token) or a Gemini Code Assist Standard or Enterprise licence. Google moved free users to Antigravity CLI, which can connect to the same Dart MCP server.

Can I use Gemini CLI with MCP for existing Flutter projects or only new ones?

Existing projects work perfectly. The Dart MCP server reads your project's pubspec.yaml, pubspec.lock, and source files regardless of when the project was created. Simply add the .gemini/settings.json configuration to your project root and start Gemini CLI from that directory. The MCP server will analyse your existing codebase, dependencies, and any analysis issues immediately. There is no migration or conversion step required.

Does Gemini CLI with MCP replace Gemini Code Assist in Android Studio?

No — they serve different purposes and work well together. Gemini Code Assist provides inline code completions and a chat panel integrated directly into the editor. Gemini CLI provides a terminal-based, MCP-powered assistant that can invoke Flutter-specific tools. Use Code Assist for quick completions and simple chat queries. Use Gemini CLI for tasks that benefit from MCP tooling: analysing dependencies, debugging build errors with real diagnostic data, generating context-aware code, and creating test scaffolds. Running both simultaneously gives you the best Flutter AI development experience available today, although since June 2026 the Gemini CLI half needs a paid API key or Code Assist licence.

Sagnik Bhattacharya, founder of Coding Liquids, has written more than 120 free Flutter tutorials for this site, including this one. To go from single topics like this one to a complete app, The Complete Flutter Course at codingliquids.com walks through state management, Firebase, animations and REST APIs inside projects you actually ship.

Related Tutorials

Sources