get_flet_doc
Fetch complete Markdown documentation for any Flet control or topic using its exact file path. Get detailed reference material directly from the official docs.
Instructions
Fetch the full Markdown documentation for a specific Flet control or topic.
Args: doc_path: The exact path to the doc file, usually obtained from search_flet_docs (e.g., 'website/docs/controls/dropdown/index.md').
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| doc_path | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/flet_mcp/server.py:23-32 (handler)The async handler function for the 'get_flet_doc' MCP tool. Decorated with @mcp.tool(), it fetches full Markdown documentation for a Flet control by delegating to docs_fetcher.get_doc_content().
@mcp.tool() async def get_flet_doc(doc_path: str) -> str: """ Fetch the full Markdown documentation for a specific Flet control or topic. Args: doc_path: The exact path to the doc file, usually obtained from search_flet_docs (e.g., 'website/docs/controls/dropdown/index.md'). """ return await docs_fetcher.get_doc_content(doc_path) - The helper method get_doc_content in FletDocsFetcher that does the actual work: constructs a raw.githubusercontent.com URL and fetches the Markdown content with caching.
async def get_doc_content(self, file_path: str) -> str: """Fetches the raw Markdown content for a specific Flet doc file.""" # Use raw.githubusercontent for fast, quota-free raw file fetching raw_url = f"https://raw.githubusercontent.com/flet-dev/flet/main/{file_path}" content = await self._fetch_text(raw_url) if content: return content return f"Error: Could not fetch documentation for {file_path}. Ensure the path is correct." - src/flet_mcp/server.py:23-24 (registration)The tool is registered via the @mcp.tool() decorator on FastMCP instance 'mcp' in src/flet_mcp/server.py.
@mcp.tool() async def get_flet_doc(doc_path: str) -> str: - The _fetch_text helper method that caches fetched Markdown content with a 24-hour TTL using diskcache.
async def _fetch_text(self, url: str) -> str | None: """Helper to fetch and cache raw Markdown text (24-hour TTL).""" if url in cache: return cache[url] response = await self.client.get(url) if response.status_code == 200: text = response.text cache.set(url, text, expire=86400) return text return None