MCP Server#
flet_pkg.mcp.server
#
MCP server for flet-pkg.
Exposes scaffolding and code generation capabilities to AI agents via the Model Context Protocol (tools, resources, prompts).
app_lifespan
async
#
Provide a shared PubDevDownloader instance for the server lifetime.
tool_derive_names
#
Derive project/package/control names from a Flutter package name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
flutter_package
|
str
|
A pub.dev package name (e.g. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Dict with |
dict
|
and |
Source code in src/flet_pkg/mcp/server.py
tool_map_dart_type
#
Convert a Dart type string to its Python/Flet equivalent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dart_type
|
str
|
Dart type string (e.g. |
required |
flet_aware
|
bool
|
Use native Flet types ( |
False
|
Returns:
| Type | Description |
|---|---|
dict
|
Dict with |
Source code in src/flet_pkg/mcp/server.py
tool_fetch_metadata
#
Get pub.dev package metadata (version, description, homepage).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
flutter_package
|
str
|
A pub.dev package name. |
required |
ctx
|
ToolContext
|
MCP tool context for dependency injection. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Dict with package metadata fields. |
Source code in src/flet_pkg/mcp/server.py
tool_detect_extension_type
#
Auto-detect whether a Flutter package should be a service or ui_control extension.
Downloads the package (cached) and scans for widget classes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
flutter_package
|
str
|
A pub.dev package name. |
required |
ctx
|
ToolContext
|
MCP tool context for dependency injection. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Dict with |
Source code in src/flet_pkg/mcp/server.py
tool_scaffold
#
tool_scaffold(template_name: str, flutter_package: str, project_name: str, package_name: str, control_name: str, description: str = '', author: str = '', output_dir: str = '.', include_console: bool = True) -> dict
Create a project skeleton from a template (service or ui_control).
Does NOT generate code — only scaffolds the directory structure with template stubs. Use run_pipeline after this to fill in the generated code.
Source code in src/flet_pkg/mcp/server.py
tool_run_pipeline
#
tool_run_pipeline(flutter_package: str, control_name: str, extension_type: str, project_dir: str, package_name: str, description: str = '', control_name_snake: str = '', include_console: bool = True, local_package_path: str | None = None) -> dict
Run the full generation pipeline: download → parse → analyze → generate → write.
Overwrites template stubs in project_dir with auto-generated code. Set local_package_path to use a local Flutter package instead of downloading.
Source code in src/flet_pkg/mcp/server.py
tool_analyze_gaps
#
Analyze coverage gaps between a Flutter package and its generated code.
Downloads the package, parses, analyzes, and runs deterministic gap analysis. No LLM is used — purely structural comparison.
Source code in src/flet_pkg/mcp/server.py
resource_type_map
#
Full Dart-to-Python type mapping table.
Includes standard mappings, Flet-aware mappings, and skipped types.
Source code in src/flet_pkg/mcp/server.py
resource_templates
#
Available template names and their paths.
scaffold_service
#
Step-by-step guide to scaffold a Flet service extension.
Source code in src/flet_pkg/mcp/server.py
scaffold_ui_control
#
Step-by-step guide to scaffold a Flet UI control extension.
Source code in src/flet_pkg/mcp/server.py
analyze_package
#
Guide to analyze a Flutter package's coverage without scaffolding.