flet-mcp
MCP (Model Context Protocol) server that gives LLM agents access to Flet examples, documentation, and API reference.
Installation
pip install flet-mcp
Building the data files
The MCP server reads a Griffe-introspected api.json and (optionally) a
SQLite index of examples and docs. Build them from inside the flet SDK
workspace so every Flet extension package (flet-audio, flet-map, …) is
importable — the workspace declares them all as members, but you need the
mcp-build dependency group to pick up the build-time deps (markdownify,
griffe):
cd sdk/python
uv sync --group mcp-build
uv run flet mcp build # api.json only
uv run flet mcp build --examples ./examples # add examples index
The icon search metadata (data/icons.json) is a committed file, not a
build product — it is generated from Google's fonts.google.com icon
metadata (names, synonym tags, popularity; Apache-2.0, the same data that
powers the fonts.google.com icon search) and only changes when Google
ships new icons. Refresh it with:
uv run python -m flet_mcp.build.icons
Docs index is currently deferred. The
--docsflag still expects a mkdocssearch_index.json, which the site no longer produces after the migration to Docusaurus + Algolia. TheDOCStool group stays off by default; rebuilding docs search against Docusaurus is tracked as follow-up work.
Running the build from elsewhere (a downstream project's venv that only
installs core flet) works too, but the resulting api.json will be missing
controls from every extension package not installed in that venv — the
indexer logs a "Failed to load" line per missing package and skips it.
Usage
Start the MCP server
# stdio transport (default, for use with Claude Desktop, Cursor, etc.)
flet mcp
# HTTP transport
flet mcp --transport streamable-http --port 8000
Configure in Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"flet": {
"command": "flet",
"args": ["mcp"]
}
}
}
List available tools
fastmcp list packages/flet-mcp/src/flet_mcp/server.py
Call tools from the command line
# Search examples
fastmcp call packages/flet-mcp/src/flet_mcp/server.py search_examples '{"query": "dropdown"}'
# Get full example code
fastmcp call packages/flet-mcp/src/flet_mcp/server.py get_example '{"example_id": "controls_dropdown_styled"}'
# Get API reference for any symbol (control, service, type, event, enum)
fastmcp call packages/flet-mcp/src/flet_mcp/server.py get_api '{"name": "TextField"}'
# Find an icon
fastmcp call packages/flet-mcp/src/flet_mcp/server.py find_icon '{"query": "settings"}'
# Search large enums
fastmcp call packages/flet-mcp/src/flet_mcp/server.py search_enum_members '{"name": "Icons", "query": "arrow"}'
# Get CLI help
fastmcp call packages/flet-mcp/src/flet_mcp/server.py get_cli_help '{"command": "run"}'
Use with Pydantic AI
from pydantic_ai import Agent
from pydantic_ai.toolsets import MCPToolset
from flet_mcp import mcp
agent = Agent("anthropic:claude-sonnet-4-6", toolsets=[MCPToolset(mcp)])
result = agent.run_sync("Create a Flet app with a login form")
Use in-process via a FastMCP client
The exported mcp is a FastMCP instance, so a custom agent can talk to it
in-process (no subprocess, no transport) by handing it to a fastmcp.Client.
Set the FLET_MCP_ENABLE_* env vars before importing flet_mcp so the desired
tool groups register. The client deserializes structured results onto .data:
import asyncio
from fastmcp import Client
from flet_mcp import mcp
async def main():
async with Client(mcp) as client:
api = (await client.call_tool("get_api", {"name": "TextField"})).data
print(api["kind"], api["package"], len(api["properties"]))
asyncio.run(main())
Tools
Tools are organized into groups that can be toggled at server startup. Defaults focus on the hallucination-reduction starter set: API and icons are on; examples, docs, and CLI are off.
| Group | Default | Tools |
|---|---|---|
API |
on | list_controls, get_api, get_enum, search_enum_members, enum_has_member |
ICONS |
on | find_icon |
EXAMPLES |
off | search_examples, get_example |
DOCS |
off | search_docs, get_doc |
CLI |
off | get_cli_help |
| Tool | Description |
|---|---|
list_controls |
Browse controls and services, with optional filtering |
get_api |
Get the API reference for a class by name — looks across controls, services, dataclass types (ButtonStyle, Padding, ...), and event classes. Async methods are marked "async": true; every entry carries a "package" field naming the pip-installable source package ("flet" = core, anything else needs adding to deps). |
get_enum |
Get enum members |
search_enum_members |
Search large enums (Icons, CupertinoIcons) |
enum_has_member |
Check if an enum value exists |
find_icon |
Search Material and Cupertino icons by keyword |
search_examples |
Search example projects by keyword |
get_example |
Get full source code for an example |
search_docs |
Search documentation by keyword |
get_doc |
Get full content of a doc section |
get_cli_help |
Get structured CLI command options |
Toggling groups
Each group is gated by an environment variable read at server startup:
| Variable | Default | Effect |
|---|---|---|
FLET_MCP_ENABLE_API |
1 |
Register the API tool group |
FLET_MCP_ENABLE_ICONS |
1 |
Register find_icon |
FLET_MCP_ENABLE_EXAMPLES |
0 |
Register example search/get tools |
FLET_MCP_ENABLE_DOCS |
0 |
Register docs search/get tools |
FLET_MCP_ENABLE_CLI |
0 |
Register get_cli_help |
Accepted truthy values: 1, true, yes (case-insensitive). The active
groups are also surfaced in the server's initialize instructions, so MCP
clients that forward those instructions to the model (e.g. Pydantic AI's
MCPToolset(..., include_instructions=True)) keep the model's guidance
in sync with what's actually registered.
Examples:
# Default starter surface (API + icons only)
flet mcp
# Add examples and docs once their indexes have been built
FLET_MCP_ENABLE_EXAMPLES=1 FLET_MCP_ENABLE_DOCS=1 flet mcp
# Narrow further: API tools only, drop icons
FLET_MCP_ENABLE_ICONS=0 flet mcp
Note: enabling EXAMPLES only registers the tools — you also need to populate
the SQLite index by running flet mcp build --examples <path>. Without an index
the tools register cleanly but return empty results. DOCS is deferred (see
"Building the data files" above): the tools register and degrade gracefully to
empty results, but no docs index is built yet.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flet_mcp-0.86.1.tar.gz.
File metadata
- Download URL: flet_mcp-0.86.1.tar.gz
- Upload date:
- Size: 1.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
721d02c54c965a4464b087dc0f2d30ad6a5ae437f7ec1866a373e37be52b76b5
|
|
| MD5 |
bee1eb1c25d7489f5fb17f50251a8b4a
|
|
| BLAKE2b-256 |
2b16b9e344f6b6c836607f06edd8f6bbfb0a2cf7f3cd960dc5c6eb59ff60514f
|
File details
Details for the file flet_mcp-0.86.1-py3-none-any.whl.
File metadata
- Download URL: flet_mcp-0.86.1-py3-none-any.whl
- Upload date:
- Size: 1.5 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c96b9e234639c03c28e604b5a306ca500a0a3ba2c386b8a7c34fbdb5e87a098
|
|
| MD5 |
3c3965ecabd83f9f6723732f073d4eab
|
|
| BLAKE2b-256 |
10c8d550610d5329ad26d61b79a332460f0236bf37bc76f354b843aa62a7b9a4
|