search_flet_docs
Locate the correct documentation file path by searching the official Flet index for a topic or control.
Instructions
Search the official Flet documentation index for a specific topic or control. Always use this first to find the correct file path before calling get_flet_doc.
Args: query: The keyword to search for (e.g., 'dropdown', 'navigation', 'layout').
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/flet_mcp/server.py:12-21 (handler)The async function `search_flet_docs` is decorated with @mcp.tool(), defining the tool. It accepts a `query` string and delegates to `docs_fetcher.search_docs(query)`.
@mcp.tool() async def search_flet_docs(query: str) -> list[str]: """ Search the official Flet documentation index for a specific topic or control. Always use this first to find the correct file path before calling get_flet_doc. Args: query: The keyword to search for (e.g., 'dropdown', 'navigation', 'layout'). """ return await docs_fetcher.search_docs(query) - src/flet_mcp/server.py:12-21 (registration)The tool is registered via the `@mcp.tool()` decorator on the `search_flet_docs` function in the FastMCP server.
@mcp.tool() async def search_flet_docs(query: str) -> list[str]: """ Search the official Flet documentation index for a specific topic or control. Always use this first to find the correct file path before calling get_flet_doc. Args: query: The keyword to search for (e.g., 'dropdown', 'navigation', 'layout'). """ return await docs_fetcher.search_docs(query) - src/flet_mcp/server.py:13-20 (schema)Type annotations and docstring define the input schema: a single `query: str` parameter (keyword to search for). Return type is `list[str]`.
async def search_flet_docs(query: str) -> list[str]: """ Search the official Flet documentation index for a specific topic or control. Always use this first to find the correct file path before calling get_flet_doc. Args: query: The keyword to search for (e.g., 'dropdown', 'navigation', 'layout'). """ - The `search_docs` method on `FletDocsFetcher` is the helper that performs the actual keyword search. It fetches the full docs tree via `get_docs_tree()`, then filters paths containing the query (case-insensitive).
async def search_docs(self, query: str) -> list[str]: """A keyword search over the available document paths.""" all_docs = await self.get_docs_tree() query_lower = query.lower() # Filter paths that contain the query string # e.g., querying "dropdown" will match "docs/docs/controls/dropdown.md" matches = [path for path in all_docs if query_lower in path.lower()] return matches - The `get_docs_tree` method fetches the Git tree from the flet-dev/flet GitHub repo using the Trees API, returning a flat list of all Markdown file paths under `website/docs/`.
async def get_docs_tree(self) -> list[str]: """Gets a flat list of all Markdown documentation paths in the Flet repo.""" # The Tree API is the most efficient way to get all files in a repo at once repo_api_url = "https://api.github.com/repos/flet-dev/flet/git/trees/main?recursive=1" data = await self._fetch_json(repo_api_url) if not data or "tree" not in data: return [] # Filter out everything except markdown files in the docs folder doc_paths = [ item["path"] for item in data["tree"] if item["path"].startswith("website/docs/") and item["path"].endswith(".md") ] return doc_paths