Skip to main content
Connect the Strands Agents Python SDK’s native MCP client to Magic Hour’s hosted server. Discover tools, verify API authorization, then generate an image and retrieve its actual image bytes. This example uses no Strands Agent, AWS account, or model-provider key. Magic Hour performs the image generation and charges API credits.

Install and configure

Requires Python 3.10+. These versions were verified together using Python 3.12:
Strands 1.62.0 requires MCP below 2.2. Use a separate environment if another application requires a newer MCP version. Provide your Magic Hour API key through a server-side secret manager as MAGIC_HOUR_API_KEY. Keep keys, account details, and temporary download URLs private. The SDK sends your key to Magic Hour’s MCP server in a bearer header.

Generate an image and save the result

This example requests one Flux 2 Klein image at 640px and 1:1, currently estimated at 5 credits. It saves the accepted project ID before waiting. Running it again with the same local project file resumes that project instead of creating another image. Use prompts and media you are authorized to send to Magic Hour. Run the creation step once; if a request fails without returning an ID, check your Magic Hour projects before trying again. An empty project file means creation was interrupted. Recover the accepted ID from your Magic Hour projects before editing or removing that file; do not repeat creation.
Tool discovery is public; the separate account call verifies API authorization. Strands returns its own tool-result dictionary with a status, structured metadata when available, and content blocks. The native client converts inline MCP image content into image bytes. The context manager closes the MCP connection. A timeout does not cancel the server job. Retain the local project file and rerun only retrieval, waiting, or download. To start another image intentionally, use a separate saved project file. Never treat tool_use_id as a server idempotency key.

Verified behavior

Native validation discovered and adapted 48 tools, verified account access, and retrieved an existing completed project. One separate native creation returned an accepted ID and charged 5 credits; waiting on that same ID completed and native download returned a 640×640 PNG. The image was opened and visually inspected. The connection closed and the task process exited. No Strands Agent or model-provider inference was run; that flow requires separate provider configuration and remains unverified. See Magic Hour MCP for other media tools, our privacy policy, and the official Strands MCP client API.