Skip to main content

Dart MCP server

The Dart MCP server exposes Dart (and Flutter) development tool actions to compatible AI-assistant clients.

Overview

#

The Dart MCP server can work with any MCP client that supports standard I/O (stdio) as the transport medium. To access all the features of the Dart MCP server, an MCP client must support Tools and Resources. For the best development experience with the Dart MCP server, an MCP client should also support Roots.

If you are using a client that claims it supports roots but doesn't actually set them, pass --force-roots-fallback to enable tools for managing the roots.

The Dart MCP server provides a growing list of tools that grant AI assistants deep insights into your project. Here is an overview of a few things it can do:

  • Analyze and fix errors in your project's code.
  • Introspect and interact with your running application (such as trigger a hot reload, get the selected widget, fetch runtime errors).
  • Search the pub.dev site for the best package for a use case.
  • Manage package dependencies in your pubspec.yaml.
  • Run tests and analyze the results.

Set up your MCP client

#

The server is run with the dart mcp-server command, which will have to be configured in your preferred client.

This section provides instructions for setting up the Dart MCP server with popular tools like Firebase Studio, Gemini CLI, Gemini Code Assist, Cursor, and GitHub Copilot.

Firebase Studio

#

If you wish to use the Dart MCP Server in Firebase Studio, an agentic cloud-based development environment that helps you build and ship production-quality full-stack AI apps, follow these steps:

  1. In your Firebase Studio app project, create a .idx/mcp.json file in your project if it doesn’t exist already and add the following Dart MCP Server configuration to the file:

    .idx/mcp.json
    json
    {
      "mcpServers": {
        "dart": {
          "command": "dart",
          "args": [
            "mcp-server"
          ]
        }
      }
    }
  2. Ensure your environment is running Dart SDK 3.9/Flutter 3.35 beta or later.

  3. Switch channels and use the flutter upgrade command if needed.

  4. Rebuild your workspace to complete the setup.

    • Open the Command Palette (Shift+Ctrl+P).
    • Enter Firebase Studio: Rebuild Environment.

For more information about MCP server configuration in Firebase Studio, see Customize your Firebase Studio workspace.

Gemini CLI

#

To configure the Gemini CLI to use the Dart MCP server, edit the .gemini/settings.json file in your local project (configuration will only apply to this project) or edit the global ~/.gemini/settings.json file in your home directory (configuration will apply for all projects).

.gemini/settings.json
json
{
  "mcpServers": {
    "dart": {
      "command": "dart",
      "args": [
        "mcp-server"
      ]
    }
  }
}

For more information, see the official Gemini CLI documentation for setting up MCP servers.

Gemini Code Assist in VS Code

#

Gemini Code Assist's Agent mode integrates the Gemini CLI to provide a powerful AI agent directly in your IDE. To configure Gemini Code Assist to use the Dart MCP server, follow the instructions to configure the Gemini CLI.

You can verify the MCP server has been configured properly by typing /mcp in the chat window in Agent mode.

For more information see the official Gemini Code Assist documentation for using agent mode.

Cursor

#

The easiest way to configure the Dart MCP server with Cursor is by clicking the Add to Cursor button:

Add to Cursor

Alternatively, you can configure the server manually:

  1. Go to Cursor > Settings > Cursor Settings > Tools & Integrations.

  2. Click Add Custom MCP or New MCP Server depending on whether you already have other MCP servers configured.

  3. Edit the .cursor/mcp.json file in your local project (configuration will only apply to this project) or edit the global ~/.cursor/mcp.json file in your home directory (configuration will apply for all projects) to configure the Dart MCP server:

    .cursor/mcp.json
    json
    {
      "mcpServers": {
        "dart": {
          "command": "dart",
          "args": [
            "mcp-server",
            "--force-roots-fallback"
          ]
        }
      }
    }

For more information, see the official Cursor documentation for installing MCP servers.

GitHub Copilot in VS Code

#

By default, the Dart-Code extension uses the VS Code MCP API to register the Dart MCP server, as well as a tool to provide the URI for the active Dart Tooling Daemon. This automatically enables it for any tool (such as Copilot) which uses these APIs for MCP configuration.

You explicitly enable or disable the Dart MCP server by configuring the dart.mcpServer setting in your VS Code settings.

To change this globally, update your user settings:

  1. In VS Code, click View > Command Palette and then search for Preferences: Open User Settings (JSON).

  2. Add the following setting:

    json
    "dart.mcpServer": true

If you'd like this setting to apply only to a specific workspace, add the entry to your workspace settings:

  1. In VS Code, click View > Command Palette and then search for Preferences: Open User Settings (JSON).

  2. Add the following setting:

    json
    "dart.mcpServer": true

For more information, see the official VS Code documentation for enabling MCP support.

Use your MCP client

#

Once you've set up the Dart MCP server with a client, the Dart MCP server enables the client to not only reason about your project's context but also to take action with tools. The Large Language Model (LLM) decides which tools to use and when, so you can focus on describing your goal in natural language. Let's see this in action with a couple of examples using GitHub Copilot's Agent mode in VS Code.

Fix a runtime layout error in a Flutter app

#

We've all been there: you build a beautiful UI, run the app, and are greeted by the infamous yellow-and-black stripes of a RenderFlex overflow error. Instead of manually debugging the widget tree, you can now ask your AI assistant for help with a prompt similar to the following:

Prompt: "Check for and fix static and runtime analysis issues. Check for and fix any layout issues."

Behind the scenes, the AI agent uses the Dart MCP server's tools to:

  • See the error: It uses a tool to get the current runtime errors from the running application.
  • Inspect the UI: It accesses the Flutter widget tree to understand the layout that is causing the overflow.
  • Apply a fix: Armed with this context, it applies a fix and checks once more for any remaining errors.

You can then keep or undo the code changes.

#

Imagine you need to add a chart to your app. Which package should you use? How do you add it and write the boilerplate? The Dart MCP server can streamline this entire process with a prompt similar to the following:

Prompt: "Find a suitable package to add a line chart that maps the number of button presses over time."

The AI agent now acts as a true assistant:

  • Find the right tool: It uses the pub_dev_search tool to find popular and highly-rated charting libraries.
  • Manage dependencies: After you confirm its choice (for example, syncfusion_flutter_charts), it uses a tool to add the package to your pubspec.yaml file and runs dart pub get.
  • Generate the code: It generates the new widget code, complete with boilerplate for a line chart that it places in the UI. It even self-corrects syntax errors introduced during the process. You can customize further from there.

What used to be a multi-step process of research, reading documentation, editing pubspec.yaml, and writing the appropriate code in your app, is now a single request.