Repository navigation
Description
Summary
Any Python Actor invoked through the Apify MCP server crashes during startup, before any user code runs. The run's meta.origin is "MCP", but the MetaOrigin enum in apify-shared (Python) has no MCP member, so the SDK's charging manager fails to validate the run with a pydantic.ValidationError inside Actor.__aenter__.
Notably, apify-shared-js already includes MCP (and CI), so this looks like the Python apify-shared simply lagging behind the platform / JS SDK.
Environment
apify3.4.1apify-client2.5.1apify-shared2.2.0- Python 3.12
- Run started via the Apify MCP server (
meta.origin == "MCP")
Minimal reproduction
from apify_shared.consts import MetaOrigin
MetaOrigin("MCP") # ValueError: 'MCP' is not a valid MetaOriginReal-world path: an MCP-triggered run reaches apify/_charging.py:
run = run_validator.validate_python(await self._client.run(self._actor_run_id).get())The fetched run has meta.origin == "MCP", which fails validation against ActorRun.meta.origin: MetaOrigin, raising during async with Actor:. The Actor exits with code 1 within a few seconds regardless of input.
Current values
apify-shared (Python) MetaOrigin:
DEVELOPMENT, WEB, API, SCHEDULER, TEST, WEBHOOK, ACTOR, STANDBY, CLI — no MCP.
apify-shared-js META_ORIGINS (master):
... CLI, STANDBY, CI, MCP — includes MCP (commented "Job started through apify client triggered from apify-mcp-server") and CI.
- JS (has it): https://github.com/apify/apify-shared-js/blob/master/packages/consts/src/consts.ts
- Python (missing): https://github.com/apify/apify-shared-python/blob/master/src/apify_shared/consts.py
- Crash site: https://github.com/apify/apify-sdk-python/blob/master/src/apify/_models.py (
MetaOriginused formeta.origin)
Proposed fix
Add the missing origins to MetaOrigin in apify-shared-python to match apify-shared-js:
class MetaOrigin(str, Enum):
...
CI = 'CI'
MCP = 'MCP'Optional hardening: make run-origin parsing forward-compatible so a newly added platform origin does not hard-crash older SDKs.
Impact
Every Python Actor invoked via the Apify MCP server is affected — the crash happens before user code, so Actors appear broken over MCP with no useful error surfaced to the caller.
Workaround (for affected Actor authors)
Register the value at runtime before importing apify:
from apify_shared.consts import MetaOrigin
if "MCP" not in MetaOrigin.__members__:
m = str.__new__(MetaOrigin, "MCP")
m._name_ = m._value_ = "MCP"
MetaOrigin._member_map_["MCP"] = m
MetaOrigin._value2member_map_["MCP"] = m
MetaOrigin._member_names_.append("MCP")
Activity
vdusek commentedon Jul 8, 2026
Hi, thanks for reporting it. The fix is on the way.
apify/apify-docs#2752
apify/apify-client-python#929
apify/apify-shared-python#73
fix(openapi): add MCP to RunOrigin enum (#2752)
fix: add CI and MCP to MetaOrigin enum (#73)
vdusek commentedon Jul 8, 2026
This should be fixed in
apify-sharedv2.2.1. You can either regenerate your dependencies or add an explicit constraint.