Image
TheImage component automatically handles image sources, supporting both data URLs and public file paths. It automatically prefixes relative paths with the MCP public URL, making it easy to use images from your public/ folder.
Import
Props
TheImage component accepts all standard img HTML attributes, plus:
| Prop | Type | Default | Description |
|---|---|---|---|
src | string | required | Image source URL or path |
Source Resolution
The component handles different source formats:- Absolute URLs (
http://,https://): Used as-is - Data URLs (
data:): Used as-is - Relative paths (
/fruits/apple.png): Prefixed with MCP public URL
Basic Usage
Public Folder Images
When using images from yourpublic/ folder, use paths relative to the public root:
window.__mcpPublicUrl.
Development vs Production
- Development: Images are served from the dev server’s
/mcp-use/public/route - Production: Images are served from the built
dist/public/folder
Fallback Behavior
Ifwindow.__mcpPublicUrl is not available (e.g., in standalone mode), the component falls back to using the source path as-is. This ensures the component works in all environments.
Example: Product Widget
Related Utilities
The component uses these window globals (injected by the MCP server or at build time):window.__mcpPublicAssetsUrl: Base URL for public assets in static deployments (e.g., Supabase storage bucket)window.__mcpPublicUrl: Base URL for public assets (e.g.,http://localhost:3000/mcp-use/public) - used as fallbackwindow.__getFile: Helper function to get file URLs
The Image component prefers
__mcpPublicAssetsUrl when available (static deployments), falling back to __mcpPublicUrl for dynamic serving.Related Components
McpUseProvider- Unified provider for widgetsuseWidget- Widget hook for accessing props