Skip to content

Commit 1ba0abe

Browse files
flet-mcp: token-efficient get_api, ranked icon search, agent tool fixes (#6654)
* flet-mcp: token-efficient, correct get_api + Google-metadata icon search get_api: - default response is compact signature-style text (~44% smaller than JSON, tokenizes better); format="json" escape hatch - member docstrings trimmed to first sentence; member=<name> drill-down returns full docs; query=<substring> filters members, walking base classes (TextField border props live on FormFieldControl) - event handler types unwrapped (Optional[EventHandler[TapEvent[...]]] -> on_tap(TapEvent)); Optional[X] -> X?; field(...) defaults unwrapped - "fields" member section (dataclass types, event payloads) now included - name collisions resolved by ranked candidates instead of last-wins: Text/Image/Rect no longer shadowed by canvas shapes; dotted names (canvas.Text, flet_map.Camera) select alternates; response notes them - Sphinx :attr:/:class: roles stripped from all rendered docstrings get_example pages large examples per file; get_doc capped with a narrowing hint; search_enum_members ranked (exact/prefix/substring) with Material style variants collapsed. Icon search rebuilt on Google's fonts.google.com icon metadata (tags + popularity, Apache-2.0), committed as data/icons.json and refreshed via `python -m flet_mcp.build.icons`; hand-curated icons.yml and the pyyaml dependency removed. IconStore no longer imports the flet package (find_icon was broken on runtime-only installs) and ranks by tags/popularity with golden-query regression tests. * Inject web-only app.zip assets in flet build instead of Jinja-in-comments pubspec The build template's pubspec.yaml guarded the web-only `assets:` section (app/app.zip, app/app.zip.hash) with Jinja tags hidden in YAML comments. Any tooling that round-trips the file with a YAML parser — like the CI release patch script — strips comments, making the assets unconditional and failing native builds on the missing app/app.zip. Move the conditionality into flet build: the template pubspec is now plain YAML, and build_base.py injects flutter.assets into the rendered pubspec when config_platform is "web", in the same post-cookiecutter patching pass as the local-dev and test-mode overrides. Native platforms get no assets entry, as before — serious_python places the app inside the bundle. Also remove the vestigial flet_geolocator Jinja block: its dependencies were themselves commented out, so it could never take effect. * Drop __init__.py from flet-mcp tests A second top-level `tests` package collides with packages/flet/tests under pytest's prepend import mode — whichever imports first owns `tests` in sys.modules and the other's modules fail collection. Without the __init__.py, pytest names the modules by file (unique basenames), which is what `pytest packages/*/tests` in CI needs.
1 parent 401182b commit 1ba0abe

15 files changed

Lines changed: 85966 additions & 2237 deletions

File tree

sdk/python/.pre-commit-config.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,7 @@ repos:
2929
- id: typos
3030
args: [ --config, sdk/python/_typos.toml ]
3131
# Generated *.pbxproj files contain random hex UUIDs that typos
32-
# misreads as misspelled words.
33-
exclude: (/templates/|\.pbxproj$)
32+
# misreads as misspelled words; flet-mcp's icons.json vendors
33+
# Google's icon search tags, which deliberately include common
34+
# misspellings for typo-tolerant search.
35+
exclude: (/templates/|\.pbxproj$|flet_mcp/data/icons\.json$)

sdk/python/_typos.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
[files]
22
# Generated Xcode project files contain random hex UUIDs that typos
3-
# misreads as misspelled words.
4-
extend-exclude = ["*.pbxproj"]
3+
# misreads as misspelled words. flet-mcp's icons.json vendors Google's
4+
# icon search metadata, whose tags deliberately include common
5+
# misspellings for typo-tolerant search.
6+
extend-exclude = [
7+
"*.pbxproj",
8+
"sdk/python/packages/flet-mcp/src/flet_mcp/data/icons.json",
9+
]
510

611
[default.extend-words]
712
# AAC High Efficiency audio codec enum member name

sdk/python/packages/flet-cli/src/flet_cli/commands/build_base.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,6 +1589,17 @@ def create_flutter_project(self, second_pass=False):
15891589
}
15901590
}
15911591

1592+
# Only the web (Pyodide) build loads the packaged app as a Flutter
1593+
# asset; on native platforms serious_python places it inside the
1594+
# bundle, and a missing app/app.zip asset would fail the build.
1595+
if self.config_platform == "web":
1596+
if pubspec is None:
1597+
pubspec = self.load_yaml(self.pubspec_path)
1598+
assets = pubspec.setdefault("flutter", {}).setdefault("assets", [])
1599+
for asset in ["app/app.zip", "app/app.zip.hash"]:
1600+
if asset not in assets:
1601+
assets.append(asset)
1602+
15921603
if pubspec is not None:
15931604
self.save_yaml(self.pubspec_path, pubspec)
15941605

sdk/python/packages/flet-mcp/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ uv run flet mcp build # api.json only
2424
uv run flet mcp build --examples ./examples # add examples index
2525
```
2626

27+
The icon search metadata (`data/icons.json`) is a *committed* file, not a
28+
build product — it is generated from Google's fonts.google.com icon
29+
metadata (names, synonym tags, popularity; Apache-2.0, the same data that
30+
powers the fonts.google.com icon search) and only changes when Google
31+
ships new icons. Refresh it with:
32+
33+
```bash
34+
uv run python -m flet_mcp.build.icons
35+
```
36+
2737
> **Docs index is currently deferred.** The `--docs` flag still expects a mkdocs
2838
> `search_index.json`, which the site no longer produces after the migration to
2939
> Docusaurus + Algolia. The `DOCS` tool group stays off by default; rebuilding

sdk/python/packages/flet-mcp/pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ readme = "README.md"
88
requires-python = ">=3.10"
99
dependencies = [
1010
"fastmcp >=2.0.0",
11-
"pyyaml >=6.0",
1211
]
1312

1413
[project.optional-dependencies]

0 commit comments

Comments
 (0)