MCPServerAdapter to authenticate and retrieve an image project you
already created. This example calls native BaseTool.run methods directly. It
requires no Agent, Crew, language model or model-provider key, and starts no new
generation or media download.
Install and configure
Use Python 3.12. Download recover-image.py and requirements.txt into the same private directory, then install the normal declared dependencies:crewai==1.15.22 and crewai-tools[mcp]==1.15.22, matching the
existing upstream quickstart PR.
These are the full released packages; the example does not remove their dependencies.
Provide a Magic Hour API key through
your normal private process environment or secret manager. Keep it out of source,
notebook cells, prompts and shared logs. Select an image project owned by that account:
MAGIC_HOUR_API_KEY from its own environment. No model-provider
credentials are needed for direct tool invocation.
Retrieve a status snapshot
The adapter connects tohttps://mcp.magichour.ai/ using Streamable HTTP and bearer
authorization. It admits only get_account_info and get_image_project.
The account call verifies field types before printing an authorization marker; account
values are not printed. The project call supplies only the saved id and checks that
the response contains that exact ID and a string status.
The runnable example is:
Connection lifecycle and privacy
The released adapter passes a single MCP text block through as text. The example parses the API-backed tools’ JSON response and validates its shape before reporting success. Any failure produces a static message without a raw response, account values or temporary download URL.MCPServerAdapter connects during construction. Its context manager disconnects after
the calls, including when validation fails; do not call start() again inside it.
The script sets supported OTEL_SDK_DISABLED and CREWAI_DISABLE_TELEMETRY flags
before importing CrewAI. Keep verbose tool/response logging and tracing off when
handling private metadata. Use a dedicated working directory and preserve any existing
CrewAI storage when cleaning up your own disposable run.
Optional: let a local Crew choose the retrieval tool
Download recover-with-crew.py when adding saved-project retrieval to an existing CrewAI agent. The direct-tool example remains the simpler choice for a deterministic lookup. This optional example lets one native Crew select one read-only tool, then returns that tool’s result without asking the model to rewrite it. It uses the samecrewai==1.15.22 and crewai-tools[mcp]==1.15.22 requirements;
no additional dependencies or external model credentials are required. Start your
own private local Ollama service with an already-installed tool-capable model:
qwen2.5:7b-instruct-q4_K_M. Set OLLAMA_BASE_URL to its loopback URL,
including /v1, if it differs from http://127.0.0.1:11434/v1. This example does not start a service or download
a model. Keep the existing Magic Hour key and saved project-ID environment variables.
Run python recover-with-crew.py in a dedicated private process and working
directory. The example disables Crew telemetry and tracing, delegation, planning and retries. Only
get_image_project is exposed; there is no account, creation or media
tool. The native result_as_answer=True option returns the real tool result directly.
The program also requires the public usage counter to equal one and validates the
returned JSON ID/status. A plausible model answer without a tool invocation fails.
A tool attempt alone is not success: its actual returned JSON must pass validation.
CrewAI stores task outputs in its private latest_kickoff_task_outputs.db SQLite
file even when memory=False. Its normal storage location follows CrewAI’s settings;
this example does not change or automatically remove that storage. Use a dedicated
private process and working directory, and keep normal CrewAI state private.
The complete project response can contain private download URLs. The example prints
only ID/status; do not print CrewOutput.raw, enable verbose tracing or add an output
file. Remove disposable state only after your process has stopped, preserving any
existing CrewAI state.
The LLM request has a 120-second timeout and the agent a 180-second execution limit.
These native settings do not replace an external process deadline for operations.
For a CPU-only service, bound its CPU/RAM and configure context length on the Ollama
server. Do not assume arbitrary num_ctx or num_thread fields pass through the
OpenAI-compatible client.
The exact optional example ran with CrewAI 1.15.22, local Ollama 0.40.10 and the
already-installed Qwen2.5 model. One Crew kickoff admitted one native retrieval tool
attempt and returned the actual requested project ID with complete status. The
program’s usage-count and strict JSON checks passed; the process exited successfully.
No account, creation or media tool was exposed. The native tool counter measures
admitted attempts, not an independently instrumented HTTP request count.
Verification scope
The direct example ran with CrewAI and CrewAI Tools 1.15.22, MCP 1.28.1 and MCPAdapt 0.1.20 on Python 3.12 with all normal declared dependencies. Its two filtered native tools verified account field types and retrieved an existing image project with the requested ID andcomplete status. The process exited successfully with no stderr;
neither the key nor private response data appeared in captured output. The context
closed, and the owned process and private runtime state were cleaned up.
The direct example verifies native tool invocation and saved-project metadata
retrieval. The separate optional example above verifies a model-dispatched read-only
local Crew. Neither verifies image/video creation or media preservation. The original
video-generation Crew branch in the existing upstream notebook remains unverified;
an open PR does not imply upstream acceptance.
See Magic Hour MCP,
image-project retrieval, and the
released CrewAI MCP adapter.