export_artifact
Retrieve and export an artifact in your preferred format by providing its artifact ID and selecting from HTML, Markdown, JSON, or prompt.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| artifact_id | Yes | ||
| format | Yes | ||
| content | Yes |
Implementation Reference
- src/web_gui_mcp/mcp_tools.py:124-148 (handler)The export_artifact_handler function that executes the export logic: retrieves stored artifact, formats content as html/json/markdown/prompt, and returns ExportArtifactOutput.
def export_artifact_handler( input_data: ExportArtifactInput, store: MemoryArtifactStore, ) -> ExportArtifactOutput: stored = store.get(input_data.artifact_id) if stored is None: raise ValueError(f"Unknown artifact_id: {input_data.artifact_id}") if input_data.format == "html": content = stored.html elif input_data.format == "json": content = json.dumps( stored.spec.model_dump(mode="json", by_alias=True), ensure_ascii=False, indent=2, sort_keys=True, ) elif input_data.format == "markdown": content = export_markdown(stored.spec) else: content = export_prompt(stored.spec) return ExportArtifactOutput( artifact_id=stored.artifact_id, format=input_data.format, content=content, ) - src/web_gui_mcp/mcp_tools.py:192-195 (registration)The MCP tool registration for export_artifact inside register_tools(). Decorates a function with @mcp.tool() that delegates to export_artifact_handler.
@mcp.tool() def export_artifact(input: ExportArtifactInput) -> ExportArtifactOutput: return export_artifact_handler(input, store) - ExportArtifactInput schema: artifact_id (str) and format (Literal["html", "markdown", "json", "prompt"]).
class ExportArtifactInput(ToolBaseModel): artifact_id: str format: Literal["html", "markdown", "json", "prompt"] - ExportArtifactOutput schema: artifact_id (str), format (str), content (str).
class ExportArtifactOutput(ToolBaseModel): artifact_id: str format: str content: str - src/web_gui_mcp/mcp_tools.py:9-9 (helper)Imports for export_markdown and export_prompt helper functions used in the handler.
from web_gui_mcp.render.markdown_export import export_markdown