Add flet-mcp: MCP server for LLM agents - #6624
Merged
Merged
Conversation
Introduce a new flet-mcp Python package (pyproject, README, package code and data) providing an MCP server for LLM agents, including ApiStore and bundled icons/docs data. Integrate flet-mcp into the CLI by registering an optional "mcp" subcommand only when the package is installed and add an optional dependency entry in flet-cli's pyproject. Update GitHub Actions to build, package, and publish flet-mcp (new build_flet_mcp job and inclusion in the publish step). Also add .gitignore for generated MCP artifacts and include various minor Python package updates.
Introduce a new flet_mcp build subpackage and tooling to generate MCP data. Adds api.py (API reference builder using Griffe, injects icon enums and extracts CLI help), docs.py (mkdocs search_index -> SQLite FTS5 indexer), examples.py (pyproject.toml-based examples indexer), and indexer.py (orchestrator that runs examples/docs/API pipelines and writes mcp.db/api.json). Update .gitignore to un-ignore the build subpackage and tweak icons.yml comment/content.
Defaults: API and ICONS groups on, EXAMPLES/DOCS/CLI off, so the hallucination-reduction starter set is what consumers get out of the box. Server instructions enumerate the active groups so the model sees only relevant guidance.
Adds a 'Toggling groups' section to the package README explaining which tool groups are on by default, the env var per group, and how the active set is surfaced to MCP clients via the server's initialize instructions.
… async methods, classify @value as dataclass - Single get_api(name) tool replaces get_control_api + get_type_api. Looks across controls, services, dataclass types, and events and tags every match with a 'kind' discriminator ('control'/'service'/'type'/'event'). One tool means one lookup instead of multiple guess-the-bucket attempts. - Methods declared async def are now marked '"async": true' in the api.json methods list. The get_api tool docstring and the FastMCP server instructions both call this out, so callers know to await them (e.g. page.window.center() is async — handler must be async def). - Treat Flet's @value decorator as a dataclass in the API builder. Most styling/value classes (ButtonStyle, Padding, ...) use @value, so prior builds were missing 70% of them. Type count: 28 -> 199.
Page extends BasePage, which extends BaseControl, but the classifier only matched direct inheritance from BaseControl/LayoutControl/ AdaptiveControl/Service. Adding BasePage to the known control bases catches Page itself (the most-used class in Flet). Controls: 166 -> 168 (Page + anything else inheriting from BasePage).
get_api responses now carry a 'package' field naming the pip-installable package the class lives in. Derived from the first segment of 'module' with underscores swapped for hyphens — so flet_video -> flet-video, flet_audio -> flet-audio, etc. Core flet classes stay 'flet'. Agents can now route 'use Video' to 'first add flet-video to deps' without having to guess the distribution name from the import path. The tool docstring, FastMCP server instructions, and README all call this out so consumers know to surface it to the user.
…, mark deprecated classes
Three related changes to make get_api the true universal verifier:
1. _is_control_class now walks the inheritance chain through a global
class-name registry built in a pre-pass over all loaded packages.
Catches transitive subclasses of BaseControl/LayoutControl/
AdaptiveControl/Service through intermediate bases (DialogControl,
BasePage, ...) without hardcoding every link. AlertDialog, BottomSheet,
SnackBar, Banner, Page, and ~80 other previously-missed controls now
resolve. Controls indexed: 168 -> 248. BasePage drops out of the
hardcoded base set since it's no longer needed.
2. api_store.get() now falls through to enums after controls/types/events.
Calling get_api('MainAxisAlignment') returns the enum directly instead
of 'not found' (it used to force a separate get_enum round-trip). Large
enums (Icons, CupertinoIcons) come back truncated, same as get_enum.
3. Deprecated classes are kept in the index but marked with a
'deprecated' object carrying reason/version/delete_version parsed from
@deprecated_class. ElevatedButton now answers with
'deprecated: {reason: "Use Button instead."}' — the model sees both
the verdict and the replacement in one shot.
for Gradient, list[ColorValue] instead of list[str]
…n-process use - Add table guards to search_docs/get_doc so they return empty results instead of crashing when no docs index is built - Mark the docs index as deferred (mkdocs search_index.json no longer produced after the Docusaurus + Algolia migration) in README and the --docs CLI help - Document in-process FastMCP usage via fastmcp.Client(mcp); fix stale get_control_api reference (now get_api) and bump the Pydantic AI model
Deploying flet-website-v2 with
|
| Latest commit: |
23ba2b0
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://95448859.flet-website-v2.pages.dev |
| Branch Preview URL: | https://flet-mcp.flet-website-v2.pages.dev |
The CLI docs index auto-lists every registered command (including the new 'mcp' command), so the Docusaurus build failed on a broken link to a missing flet-mcp page. Add the cli/flet-mcp.md stub (importing the generated cli-mcp.mdx partial) and the sidebar entry, matching the other commands.
ndonkoHenri
reviewed
Jun 30, 2026
| isolated: If `True`, marks the control as isolated. An isolated control | ||
| is excluded from page updates when its parent control is updated. | ||
| post_init_args: Number of InitVar arguments to pass to __post_init__. | ||
| categories: MCP metadata — control categories (e.g. ``("input", "form")``). |
Contributor
There was a problem hiding this comment.
single backsticks instead of double
ndonkoHenri
reviewed
Jun 30, 2026
|
|
||
|
|
||
| @control("Tabs") | ||
| @control("Tabs", categories=("navigation", "layout"), tags=("tabbed", "switcher")) |
Contributor
There was a problem hiding this comment.
Hum, so we will have to do this for all controls?
Contributor
Author
There was a problem hiding this comment.
it's experimental. As AI is a non-deterministic, we currently don't know what would really help it to do better decisions. If these categories help - we will annotate all controls; if it happens to be a "noise" - we'll remove.
ndonkoHenri
reviewed
Jun 30, 2026
Contributor
There was a problem hiding this comment.
will be nice to show this in documentation too - just like we do for extensions atm.
from what i see we currently only display the cli help.
Explain how to install and run the flet-mcp server, configure it in AI clients, toggle tool groups, and consume it from a custom agent via Pydantic AI or an in-process FastMCP client.
Drop the unprefixed data-channel-protocol-upgrade.md, default-bundled-python-3-14.md, and removed-pyodide-version-export.md — identical, unreferenced leftovers of the v0-86-0-* rename. Only the v0-86-0-prefixed files are linked from the sidebar.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the flet-mcp package — an MCP server that gives LLM agents Flet API, icons, examples, docs, and CLI lookups — rebased onto
flet-0.86and verified end to end.Tool groups gate on
FLET_MCP_ENABLE_*(API + icons on by default; examples, docs, CLI off).What works (verified)
api.jsonbuilt via Griffe against the 0.86 source: 249 controls, 91 events, 201 types, 149 enums, 13 CLI commands. Spot-checked.find_iconwith synonym matching.get_exampleround-trip, and platform filter all validated against the current[tool.flet.metadata]/[tool.flet].platformslayout.get_cli_helpfrom theflet_cliparser.from flet_mcp import mcp+fastmcp.Client(mcp)exercised across all 11 tools.Docs tools — deferred
The docs indexer parses a mkdocs
search_index.jsonthat the site no longer produces after the Docusaurus + Algolia migration. TheDOCSgroup stays off and now degrades gracefully (table guards return empty results instead of crashing). README and the--docsCLI help note the deferral. Rebuilding docs search against Docusaurus is tracked as follow-up.CI / packaging
build_flet_mcpjob builds the indexes (flet mcp build --examples) thenuv build --package flet-mcp.releasejob andflet_mcpis included in thepy_publishloop.data/api.jsonanddata/mcp.db(viapackage-data = data/*).Notes
api.jsonandmcp.dbare gitignored build artifacts, generated at packaging time.Summary by Sourcery
Introduce a new flet-mcp MCP server package for Flet, integrate its build and publication into the Python SDK and CI, and add metadata hooks for richer API indexing and MCP discovery.
New Features:
flet mcpwith build and serve subcommands and optional in-process usage via FastMCP.Enhancements:
Build:
Documentation: