Skip to content

Actor crashes at startup for runs with meta.origin="MCP" (MetaOrigin enum missing MCP, present in apify-shared-js) #1032

Closed

Description

@consnam

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")

Activity

  1. added
    t-toolingIssues with this label are in the ownership of the tooling team.
    on Jul 8, 2026
  2. self-assigned this
    on Jul 8, 2026
  3. vdusek commented on Jul 8, 2026

    @vdusek
    Contributor

    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

  4. vdusek commented on Jul 8, 2026

    @vdusek
    Contributor

    This should be fixed in apify-shared v2.2.1. You can either regenerate your dependencies or add an explicit constraint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working.t-toolingIssues with this label are in the ownership of the tooling team.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions