Setting Up Codex CLI for Flutter Development on Ubuntu 24.04
- Roger Erismann
- Jan 27
- 4 min read
Turning Codex into a real autonomous Flutter dev (not just a code generator)

If you’ve tried using Codex (or any LLM) to help build apps, you’ve probably hit this wall:
It writes code… but you still have to copy/paste files, run builds manually, fix errors yourself and wire everything together. That’s not “AI development.”That’s autocomplete with extra steps. The missing piece is MCP (Model Context Protocol). Once you wire Codex CLI + MCP + Flutter together, Codex stops being a chatbot and starts acting like a junior developer that can actually build, run, and fix your project locally.
🌳 Tree risk assessments don’t happen at desks.
They happen standing in wet grass, on uneven ground, looking up through branches, one hand holding a mallet and the other pointing at decay. There’s usually no table. No keyboard and we try to have our gloves on.
And yet the workflow most arborists follow still looks like it came from 1998:
Observe the tree.Write notes.Take photos.Go back to the truck.Transcribe everything. Fill out the TRAQ form. Write the report. By the time the report is finished, you’ve described the same tree three different times. It’s not just slow — it’s cognitively expensive. Energy that should go into assessment gets spent on paperwork.
We kept asking a simple question:
Why are we typing anything at all?
If an arborist can describe a tree out loud faster than they can write it, why isn’t the report built directly from speech?
That question led us to build Hands-Free TRAQ. We will be using Codex to generate a flutter app for the client and an app for a server that extracts the information from the recorded text to fill out the TRAQ form using structured generation with an llm
This guide walks through the full setup on:
Ubuntu 24.04
Codex CLI
Flutter
Android emulator
MCP integration
By the end, you’ll be able to do things like:
“Read my spec and scaffold the app. Then run flutter build and fix errors.”
…and Codex will actually do it.
Mental Model First (important)
Before commands, understand the architecture.
Without MCP
Codex → prints code
You → manually apply it
With MCP
Codex → filesystem → writes files
Codex → shell → runs flutter
Codex → fixes build errors automatically
Think:
Codex = brain
MCP = hands
Step 1 — Install Flutter (global, not per project)
Flutter is a toolchain. Install it once.
Recommended directory layout
~/projects/
flutter/ ← SDK (global)
my_app/ ← your repo
Install prerequisites
sudo apt update
sudo apt install -y git curl unzip xz-utils zip libglu1-mesa openjdk-17-jdk
Install Flutter (git clone is most reliable)
cd ~/projects
git clone https://github.com/flutter/flutter.git -b stable
Add to PATH
echo 'export PATH="$HOME/projects/flutter/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
Verify
flutter --version
Step 2 — Install Android SDK + Emulator
Flutter needs Android tooling.
Install Android Studio
sudo snap install android-studio --classic
Launch:
android-studio
During setup:
Install Android SDK
Install Emulator
Install at least one system image
Install command-line tools (important)
In Android Studio:
Tools → SDK Manager → SDK Tools → ✓ Android SDK Command-line Tools (latest)
Without this, flutter doctor --android-licenses will fail.
Accept licenses
flutter doctor --android-licenses
Verify everything
flutter doctor -v
You want:
[✓] Flutter
[✓] Android toolchain
Step 3 — Install Linux build tools (optional but recommended)
Only needed if you want Linux desktop builds.
sudo apt install -y clang cmake ninja-build pkg-config
Step 4 — Install Codex CLI
(Assumes you already installed it via OpenAI’s instructions.)
Check:
codex --version
Step 5 — Add MCP Servers (THIS IS THE MAGIC)
This is what makes Codex actually useful.
We add:
filesystem access → edit code
shell access → run flutter
These are global one-time installs.
Add filesystem MCP (restrict to repo only)
codex mcp add fs -- npx -y @modelcontextprotocol/server-filesystem ~/projects/my_app
Add shell MCP
codex mcp add shell -- npx -y @modelcontextprotocol/server-shell
Verify
codex mcp list
Expected:
fs
shell
Important: Where you run Codex matters
Filesystem MCP is scoped to one directory.
So ALWAYS:
cd ~/projects/my_app
codex
NOT:
codex # from ~
Codex uses current directory as workspace.
Step 6 — First run with Codex
Inside your repo:
codex
Now you can give instructions like:
Initialize a Flutter project here.
Run flutter create if needed.
Implement the UI from my spec.
Run flutter build and fix any errors.
Codex will:
create files
edit code
run flutter commands
iterate until it builds
No copy/paste.
Emulator Tips
Create device:
Android Studio → Device Manager → Create Device
Start it.
Check:
flutter devices
Run:
flutter run
Speed up emulator (important on Linux)
Enable KVM:
sudo apt install qemu-kvm libvirt-daemon-system
sudo usermod -aG kvm $USER
Log out/in.
This makes emulator ~10x faster.
Security Best Practices
MCP is powerful. Don’t overexpose.
Good:
filesystem → ~/projects/my_app
Bad:
filesystem → /
Only give Codex what it needs.
Final Workflow
Daily routine:
cd ~/projects/my_app
codex
Then talk naturally:
“Add audio recording”
“Run flutter analyze and fix issues”
“Refactor to use JSON template”
“Build release apk”
Codex becomes a real dev assistant.
What You Now Have
You now have:
✅ Flutter SDK✅ Android SDK + emulator✅ Codex CLI✅ MCP tools✅ Autonomous local builds
At this point Codex is no longer just generating snippets — it can own the build loop.
That’s the difference between “AI help” and “AI developer.”

Comments