Leveraging Gemini CLI and the underlying Gemini LLM to build Model Context Protocol (MCP) AI applications using Flutter/Dart with a local development environment.
Why not just use Python?
Python has traditionally been the main coding language for ML and AI tools. One of the strengths of the MCP protocol is that the actual implementation details are independent of the development language. The reality is that not every project is coded in Python- and MCP allows you to use the latest AI approaches with other coding languages.
Flutter/Dart? For AI? Does that even work?
The goal of this article is to provide a minimal viable basic working MCP stdio server in Dart that can be run locally without any unneeded extra code or extensions.
The key MCP Dart package is here:
What Is Flutter / Dart?
Flutter is Google’s open-source UI toolkit and framework used for building natively compiled, multi-platform applications (mobile, web, desktop, and embedded systems) from a single codebase. Dart is the programming language , also developed by Google, in which Flutter apps are written.
The full details of the language can be found here:
Installing Dart
Step by Step instructions vary by platform — a good starting point is here:
For a Debian style Linux Distro these steps are similar to:
sudo apt-get update -y && sudo apt-get upgrade -y
sudo apt-get install -y curl git unzip xz-utils zip libglu1-mesa
The download and extract the latest Flutter Bundle and extract to a common directory like ~/develop :
tar -xf <sdk_zip_path> -C <destination_directory_path>
As of writing the current version is:
tar -xf /mnt/chromeos/MyFiles/Downloads/flutter_linux_3.38.5-stable.tar.xz -C ~/develop/
You can validate the working tools with the — version command:
xbill@penguin:~$ dart --version
Dart SDK version: 3.10.4 (stable) (Tue Dec 9 00:01:55 2025 -0800) on "linux_x64"
xbill@penguin:~$ flutter --version
Flutter 3.38.5 • channel stable • https://github.com/flutter/flutter.git
Framework • revision f6ff1529fd (3 weeks ago) • 2025-12-11 11:50:07 -0500
Engine • hash c108a94d7a8273e112339e6c6833daa06e723a54 (revision 1527ae0ec5) (23 days ago) • 2025-12-11 15:04:31.000Z
Tools • Dart 3.10.4 • DevTools 2.51.1
Gemini CLI
If not pre-installed you can download the Gemini CLI to interact with the source files and provide real-time assistance:
npm install -g @google/gemini-cli
Testing the Gemini CLI Environment
Once you have all the tools and the correct Node.js version in place- you can test the startup of Gemini CLI. You will need to authenticate with a Key or your Google Account:
gemini
Dart Gemini CLI Extension
To simplify working with Dart/Flutter with Gemini CLI- a Gemini CLI extension is available:
Flutter extension for Gemini CLI
The installation will look similar to this:
xbill@penguin:~/gemini-cli-codeassist/mcp-stdio-flutter$
gemini extensions install https://github.com/gemini-cli-extensions/flutter.git --auto-update
Installing extension "flutter".
**The extension you are about to install may have been created by a third-party developer and sourced from a public repository. Google does not vet, endorse, or guarantee the functionality or security of extensions. Please carefully inspect any extension and its source code before installing to understand the permissions it requires and the actions it may perform.**
This extension will run the following MCP servers:
* dart (local): dart mcp-server
This extension will append info to your gemini.md context using flutter.md
Do you want to continue? [Y/n]:
Extension "flutter" installed successfully and enabled.
xbill@penguin:~/gemini-cli-codeassist/mcp-stdio-flutter$
Node Version Management
Gemini CLI needs a consistent, up to date version of Node. The nvm command can be used to get a standard Node environment:
Where do I start?
The strategy for starting MCP development is a incremental step by step approach.
First, the basic development environment is setup with the required system variables, and a working Gemini CLI configuration.
Then, a minimal Hello World Style Dart MCP Server is built with HTTPS transport. This server is validated with Gemini CLI in the local environment.
This setup validates the connection from Gemini CLI to the local process via MCP. The MCP client (Gemini CLI) and the Dart MCP server both run in the same local environment.
Next- the basic MCP server is extended with Gemini CLI for deployment to Google Cloud Run. This remote HTTP connection is validated with a local Gemini CLI instance.
Setup the Basic Environment
At this point you should have a working Dart/Flutter environment and a working Gemini CLI installation. The next step is to clone the GitHub samples repository with support scripts:
cd ~
git clone https://github.com/xbill9/gemini-cli-codeassist
Then run init.sh from the cloned directory.
The script will attempt to determine your shell environment and set the correct variables:
cd gemini-cli-codeassist
source init.sh
If your session times out or you need to re-authenticate- you can run the set_env.sh script to reset your environment variables:
cd gemini-cli-codeassist
source set_env.sh
Variables like PROJECT_ID need to be setup for use in the various build scripts- so the set_env script can be used to reset the environment if you time-out.
Hello World with HTTP Transport
One of the key features that the standard MCP libraries provide is abstracting various transport methods.
The high level MCP tool implementation is the same no matter what low level transport channel/method that the MCP Client uses to connect to a MCP Server.
The simplest transport that the SDK supports is the stdio (stdio/stdout) transport — which connects a locally running process. Both the MCP client and MCP Server must be running in the same environment.
The HTTP(S) transport allows the client and server to be on the same host or distributed over the Internet.
The connection over streaming http will look similar to this:
final server = StreamableMcpServer(
serverFactory: (sessionId) => createServer(),
host: host,
port: port,
path: path,
);
Reviewing the Dart Code
First- switch the directory with the Dart MCP sample code:
cd ~/gemini-cli-codeassist/mcp-https-flutter
Current Version of Dart dependencies:
name: mcp_https_flutter
description: A Model Context Protocol (MCP) server implementation in Dart supporting HTTPS and SSE transport.
version: 1.0.0
repository: https://github.com/xbill9/gemini-cli-codeassist/mcp-https-flutter
environment:
sdk: ^3.10.4
# Add regular dependencies here.
dependencies:
path: ^1.9.0
mcp_dart: ^1.2.0
args: ^2.5.0
logging: ^1.2.0
Gemini CLI is used to review the project:
✦ I have completed the review of the project. Overall, the codebase is well-structured and follows many Dart best practices,
especially regarding logging and server configuration.
Key Strengths
* Structured Logging: Excellent implementation using the logging package with JSON output to stderr, which is ideal for cloud
environments and monitoring.
* Robust Output Handling: Using runZoned to redirect print statements to the logger ensures that any stray output is captured
and formatted correctly.
* Clean CLI Interface: Proper use of ArgParser for configuration and StreamableMcpServer for the HTTP/SSE transport.
* Clear Separation: The server logic is separated from the entry point, facilitating testing.
Installing and Running the Dart Code
Run the build make target on the local system:
xbill@penguin:~/gemini-cli-codeassist/mcp-stdio-flutter$ make release
dart analyze
Analyzing mcp-https-flutter... 0.2s
No issues found!
dart test
00:00 +3: All tests passed!
dart compile exe bin/mcp_https_flutter.dart -o bin/mcp_https_flutter
Generated: /home/xbill/gemini-cli-codeassist/mcp-https-flutter/bin/mcp_https_flutter
To test the Dart Code:
xbill@penguin:~/gemini-cli-codeassist/mcp-https-flutter$ make check
dart analyze
Analyzing mcp-https-flutter... 0.2s
No issues found!
dart test
00:00 +3: All tests passed!
Gemini CLI settings.json
The default Gemini CLI settings.json has an entry for the source:
{
"mcpServers": {
"hello-https-flutter": {
"httpUrl": "http://127.0.0.1:8080/mcp"
}
}
}
Starting the Local HTTP Server
The local server is started with the make run target:
xbill@penguin:~/gemini-cli-codeassist/mcp-https-flutter$ make run
dart run bin/mcp_https_flutter.dart --port 8080 --host 0.0.0.0 --path /mcp
The 0.0.0.0 address tells the development server to listen on all network interfaces. Port 8080 is a commonly used port for the connection.
You will see basic JSON logging:
{"timestamp":"2026-01-05T21:07:24.833764Z","level":"INFO","logger":"mcp_server","message":"Starting MCP server on http://0.0.0.0:8080/mcp"}
{"timestamp":"2026-01-05T21:07:24.854915Z","level":"INFO","logger":"StreamableMcpServer","message":"MCP Streamable HTTP Server listening on http://0.0.0.0:8080/mcp"}
Validation with Gemini CLI
Leave the server running and open new terminal window. Gemini CLI is restarted and the MCP connection over stdio to the Dart Code is validated, The full Gemini CLI Session will start:
gemini
> /mcp list
Configured MCP servers:
🟢 hello-https-flutter - Ready (1 tool)
Tools:
- greet
> greet Dash!
✦ I will read the project files to understand how the greet tool is implemented.
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✓ ReadFolder lib │
│ │
│ Listed 1 item(s). │
│ │
│ ✓ ReadFile bin/mcp_https_flutter.dart │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ I will read lib/mcp_https_flutter.dart to find the implementation of greetHandler.
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✓ ReadFile lib/mcp_https_flutter.dart │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ I will call the greet tool with the parameter "Dash!".
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ? greet (hello-https-flutter MCP Server) {"param":"Dash!"} ← │
│ │
│ MCP Server: hello-https-flutter │
│ Tool: greet │
│ │
│ Allow execution of MCP tool "greet" from server "hello-https-flutter"? │
│ │
│ 1. Allow once │
│ 2. Allow tool for this session │
│ ● 3. Allow all server tools for this session │
│ 4. No, suggest changes (esc) │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ I will call the greet tool with the parameter "Dash!".
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✓ greet (hello-https-flutter MCP Server) {"param":"Dash!"} │
│ │
│ Dash! │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ Dash
Using the Dart Gemini CLI Extension
The Gemini CLI Extension provides tools for working with Dart Code:
> run_tests
✦ I will run the tests for the project to ensure everything is working correctly.
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✓ run_tests (dart MCP Server) {"roots":[{"root":"file:///home/xbill/gemini-cli-codeassist/mcp-https-flutter"}]} │
│ │
│ dart|flutter test in /home/xbill/gemini-cli-codeassist/mcp-https-flutter: │
│ \u001b[32m+3\u001b[0m: All tests passed!\u001b[0m │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ All tests passed successfully. What would you like to do next?
Deploying to Cloud Run
After the local HTTP version of the MCP server has been tested locally — it can be deployed remotely to Google Cloud Run.
First- switch to the directory with the HTTP MCP sample code:
cd ~/gemini-cli-codeassist/mcp-https-flutter
Deploy the project to Google Cloud Run with the pre-built cloudbuild.yaml and Dockerfile:
cd ~/gemini-cli-codeassist/mcp-https-flutter
xbill@penguin:~/gemini-cli-codeassist/mcp-https-flutter$ make deploy
The Cloud Build will start:
Submitting build to Google Cloud Build...
Creating temporary archive of 17 file(s) totalling 7.0 MiB before compression.
Some files were not included in the source upload.
Check the gcloud log [/home/xbill/.config/gcloud/logs/2026.01.05/16.14.12.250917.log] to see which files and the contents of the
default gcloudignore file used (see `$ gcloud topic gcloudignore` to learn
more).
It can take 5–10 minutes to complete the build.
When the build is complete- an endpoint will be returned:
Step #2: Already have image (with digest): gcr.io/cloud-builders/gcloud
Step #2: Deploying container to Cloud Run service [mcp-https-flutter] in project [comglitn] region [us-central1]
Step #2: Deploying...
Step #2: Setting IAM Policy.............done
Step #2: Creating Revision.....................................................................................................................................................................done
Step #2: Routing traffic.....done
Step #2: Done.
Step #2: Service [mcp-https-flutter] revision [mcp-https-flutter-00003-l94] has been deployed and is serving 100 percent of traffic.
Step #2: Service URL: https://mcp-https-flutter-1056842563084.us-central1.run.app
Finished Step #2
The service endpoint in this example is :
https://mcp-https-flutter-1056842563084.us-central1.run.app
The actual endpoint will vary based on your project settings.
Review Service in Cloud Run
Navigate to the Google Cloud console and search for Cloud Run -
and then you can detailed information on the Cloud Run Service:
Cloud Logging
The remote server writes logs to stderr in standard JSON format. These logs are available from the deployed Cloud Run Service:
Validate HTTP connection
Once you have the Endpoint — you can attempt a connection- navigate to in your browser:
https://mcp-https-flutter-1056842563084.us-central1.run.app
You will need to adjust the exact URL to match the URL returned from Cloud Build.
You will get an error- this connection is expecting a message in the MCP format:
Not Found
Gemini CLI settings.json.cloudrun
Replace the default Gemini CLI configuration file — settings.json with a pre-configured sample- settings.json.cloudrun to use the Cloud Run version of the connection:
{
"mcpServers": {
"hello-cloudrun-flutter": {
"httpUrl": "https://mcp-https-flutter-$PROJECT_NUMBER.us-central1.run.app/mcp"
}
}
}
Copy the Cloud Run version of the Gemini CLI configuration file:
xbill@penguin:~/gemini-cli-codeassist/mcp-https-php$ cd .gemini
cp settings.json.cloudrun settings.json
xbill@penguin:~/gemini-cli-codeassist/mcp-https-php/.gemini$
Validation with Gemini CLI
The final connection test uses Gemini CLI as a MCP client with the deployed Cloud Run Service in PHP providing the MCP server. Startup Gemini CLI with the updated settings :
gemini
> /mcp list
Configured MCP servers:
🟢 hello-cloudrun-flutter - Ready (1 tool)
Tools:
- greet
> greet Cloud Dash!
✦ I will greet Cloud Dash for you.
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ? greet (hello-cloudrun-flutter MCP Server) {"param":"Cloud Dash!"} ← │
│ │
│ MCP Server: hello-cloudrun-flutter │
│ Tool: greet │
│ │
│ Allow execution of MCP tool "greet" from server "hello-cloudrun-flutter"? │
│ │
│ 1. Allow once │
│ 2. Allow tool for this session │
│ ● 3. Allow all server tools for this session │
│ 4. No, suggest changes (esc) │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✓ greet (hello-cloudrun-flutter MCP Server) {"param":"Cloud Dash!"} │
│ │
│ Cloud Dash! │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ OK. Cloud Dash
Summary
MCP development with Flutter/Dart using Gemini CLI was validated with an incremental step by step approach.
A minimal streaming HTTP transport MCP Server was built from source code and validated with Gemini CLI running as a MCP client in the same local environment.
Then — the MCP server was wrapped in a container and submitted to Google Cloud Build for deployment to Google Cloud Run. The remote MCP server was validated with a standard browser, and Gemini CLI.
Finally- remote MCP operations were performed from the local Gemini CLI installation to the Flutter/Dart MCP server hosted in Google Cloud Run.
This approach can be extended to more complex deployments and Cloud based options.





Top comments (0)