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
apify 3.4.1
apify-client 2.5.1
apify-shared 2.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 MetaOrigin
Real-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.
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")
Summary
Any Python Actor invoked through the Apify MCP server crashes during startup, before any user code runs. The run's
meta.originis"MCP", but theMetaOriginenum inapify-shared(Python) has noMCPmember, so the SDK's charging manager fails to validate the run with apydantic.ValidationErrorinsideActor.__aenter__.Notably,
apify-shared-jsalready includesMCP(andCI), so this looks like the Pythonapify-sharedsimply lagging behind the platform / JS SDK.Environment
apify3.4.1apify-client2.5.1apify-shared2.2.0meta.origin == "MCP")Minimal reproduction
Real-world path: an MCP-triggered run reaches
apify/_charging.py:The fetched run has
meta.origin == "MCP", which fails validation againstActorRun.meta.origin: MetaOrigin, raising duringasync 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— noMCP.apify-shared-jsMETA_ORIGINS(master):... CLI, STANDBY, CI, MCP— includesMCP(commented "Job started through apify client triggered from apify-mcp-server") andCI.MetaOriginused formeta.origin)Proposed fix
Add the missing origins to
MetaOrigininapify-shared-pythonto matchapify-shared-js: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: