Skip to main content

Flet MCP server

flet-mcp is an MCP (Model Context Protocol) server that gives LLM agents and AI coding assistants accurate, version-specific knowledge about Flet. Instead of relying on the model's training data — which drifts out of date and leads to hallucinated controls, properties, and enum members — the agent can look up the real Flet API, search example projects, find icons, and inspect CLI options on demand.

This is useful both inside AI-powered editors (Claude Desktop, Cursor, VS Code, ...) and when building your own agents that generate or refactor Flet code.

Installation

pip install flet-mcp

This registers a flet mcp command (the flet CLI must be installed, which it is in any normal Flet project). The package ships with a pre-built API index, so no extra build step is required to start using it.

Running the server

Start the server over the default stdio transport (used by most desktop AI clients):

flet mcp

Or expose it over HTTP:

flet mcp --transport streamable-http --port 8000

Configuring an AI client

Most MCP-aware clients are configured with a small JSON snippet. For example, in Claude Desktop's claude_desktop_config.json:

{
"mcpServers": {
"flet": {
"command": "flet",
"args": ["mcp"]
}
}
}

Cursor, VS Code, and other clients use the same command / args shape in their respective MCP settings.

Tool groups

Tools are organized into groups that you toggle with FLET_MCP_ENABLE_* environment variables read at server startup. The defaults focus on the hallucination-reduction starter set — API and icons are on, everything else is off:

GroupVariableDefaultTools
APIFLET_MCP_ENABLE_APIonlist_controls, get_api, get_enum, search_enum_members, enum_has_member
IconsFLET_MCP_ENABLE_ICONSonfind_icon
ExamplesFLET_MCP_ENABLE_EXAMPLESoffsearch_examples, get_example
CLIFLET_MCP_ENABLE_CLIoffget_cli_help

Accepted truthy values are 1, true, and yes (case-insensitive). To enable the example search tools, for instance:

FLET_MCP_ENABLE_EXAMPLES=1 flet mcp

The active groups are also surfaced in the server's startup instructions, so clients that forward those instructions to the model keep its guidance in sync with what is actually registered.

Documentation search

A documentation search group (search_docs / get_doc) is planned but not yet enabled — it is being reworked to index the current Docusaurus-based docs site.

What the tools do

ToolDescription
get_apiThe primary verifier. Look up any Flet symbol by name — control, service, dataclass type (ButtonStyle, Padding, ...), event, or enum. A "not found" result is definitive for the installed Flet version. Async methods are flagged "async": true, and every entry carries a "package" field naming the pip package it lives in ("flet" for core, otherwise an extension like "flet-audio").
list_controlsBrowse available controls and services, with optional category/kind filtering.
get_enumGet an enum's members.
search_enum_membersSearch large enums (Icons, CupertinoIcons) by substring.
enum_has_memberVerify a specific enum member exists before using it.
find_iconSearch Material and Cupertino icons by keyword, with synonym matching (e.g. "user" finds account_circle).
search_examplesSearch Flet example projects by keyword, optionally filtered by platform.
get_exampleFetch the full source and metadata for an example returned by search_examples.
get_cli_helpGet structured help for the flet CLI commands and their options.

Using Flet MCP from your own agent

The server is also importable as a FastMCP instance, so a custom agent can consume it directly.

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")

Or in-process via a FastMCP client — no subprocess, no transport. Set the FLET_MCP_ENABLE_* variables 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())