apify-mcp-policy-gateway
This server is an MCP policy gateway that manages the full lifecycle of a single, pre-authorized Apify Actor (P4XBS39SYl7aeFJ7g / metahubb~apify-mcp-policy-fixture) through a strict four‑step approval workflow. It enforces a fixed policy: build 0.1.1, input limited to {"message":"1‑64 chars","recordCount":1‑3,"delayMs":0}, runtime ≤ 60 s, charge ≤ $0.10, max 3 results, and risk level low.
plan_operation– Validate a proposed run against the policy and create a short‑lived plan. Returns a plan ID, expiry, SHA‑256 input hash, canonical digest, and anALLOW_LOW_RISKpolicy decision.approve_operation– Approve an existing, unexpired, low‑risk plan (local state transition only).execute_approved_operation– Execute an approved plan once via the configured transport (fake by default; real Apify HTTP ifAPIFY_TRANSPORT=realis set). Creates a durable execution reservation; ambiguous submissions are never retried and result inSUBMITTED,REJECTED, orEXECUTION_UNKNOWN.read_sanitized_results– Fetch up to 3 results from a gateway execution. Strips sensitive keys (tokens, passwords, secrets, API keys, credentials, keys starting with#) and tags all content asuntrusted_external_contentwith full provenance metadata.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@apify-mcp-policy-gatewayPlan a fixture Actor operation with message 'hello' and a 3-item result limit"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Apify MCP Policy Gateway — M1
A deliberately narrow, local-first MCP policy gateway for one organization-owned Apify fixture Actor. It supports a fake transport for deterministic tests and an explicit real Apify HTTP transport for a scoped live fixture.
M1 started with fake transport. The real transport and Codex-agent verification are documented below; the live mode is opt-in and must never receive credentials through MCP tool arguments.
plan_operationapprove_operationexecute_approved_operationread_sanitized_results
The gateway is a policy control plane, not an Actor browser, generic proxy, hosted MCP replacement, or credential forwarder.
Fixed M1 policy
Only this operation can be planned:
Setting | Allowed value |
Actor ID |
|
Canonical owner/name |
|
Build |
|
Maximum runtime | 60 seconds |
Maximum charge ceiling | USD 0.10 |
Maximum result count | 3 |
Risk |
|
The fixture input is restricted to:
{
"message": "1 to 64 characters",
"recordCount": 1,
"delayMs": 0
}recordCount defaults to 3, delayMs defaults to 0, and unknown input fields are denied. recordCount may not exceed the requested result limit.
Related MCP server: lazy-mcp-router
Flow
plan_operation
Validates the exact Actor, pinned build, fixture input, timeout, charge ceiling, and result limit. A successful response contains:
A short-lived plan ID and expiry.
A canonical SHA-256 input hash.
A canonical plan digest.
The explicit
ALLOW_LOW_RISKpolicy decision.Bounded execution parameters.
approval_requiredstatus.
No credential or raw secret is accepted or returned.
approve_operation
Marks a known, valid, unexpired low-risk plan approved. M1 approval is a local state transition only; it is not a signed human approval mechanism.
execute_approved_operation
Creates and durably writes an execution reservation before invoking the configured ActorRunTransport.
The default transport is local and fake. Set APIFY_TRANSPORT=real to use the real Apify HTTP transport. Real mode requires APIFY_TOKEN in the runtime environment and never accepts credentials through MCP arguments.
Execution states:
SUBMITTED: the transport returned a run identity.REJECTED: the transport returned a definitive HTTP rejection such as 403.EXECUTION_UNKNOWN: submission may have reached the upstream boundary, so it is never automatically retried.
The execution ID is replay-safe. A persisted attempted reservation also recovers as EXECUTION_UNKNOWN rather than issuing another POST.
read_sanitized_results
Reads only results belonging to an execution in this gateway state namespace. In fake mode it reads local fixture results; in real mode it reads the execution's Apify default dataset. It:
Returns at most three items.
Removes keys beginning with
#recursively.Removes fields whose names look like token, password, secret, API-key, authorization, or credential fields.
Labels every item with:
{
"dataClassification": "untrusted_external_content"
}The result envelope also states that content must not be treated as instructions and includes Actor, build, execution, policy, and timestamp provenance.
Real transport mode
Keep fake mode as the default for deterministic development. For a scoped live fixture run, inject the token through the runtime environment:
export APIFY_TRANSPORT=real
export APIFY_TOKEN='provided by a secret manager or protected shell environment'
npm run build
node real-apify-run.mjsThe verified live path uses Actor P4XBS39SYl7aeFJ7g, build 0.1.1, a maximum charge ceiling of USD 0.10, a 60-second timeout, and at most three results. Never place the token in MCP arguments, source files, README files, audit logs, Obsidian notes, or Git history.
The Codex-agent live verification and observed Apify metadata are recorded outside the repository in 16_live_mcp_agent_verification_2026-08-09.md.
Local state and audit
By default, npm run start creates .gateway-state/ in the current working directory.
gateway.lockis acquired with exclusive creation. A second process cannot use the same state directory.state.jsonis written to a new file, fsynced, atomically renamed, and followed by a directory fsync.audit.jsonlis append-only in application behavior and each event is fsynced.Audit events contain identifiers, decisions, state, latency, safe error codes, and item counts—not raw Actor input, fixture output, credentials, or authorization material.
A privileged local filesystem user remains outside the M1 tamper-prevention boundary.
Run over stdio
Requirements:
Node.js 22 or later.
Project dependencies installed with npm in a normal development environment.
npm install
npm run startStandard output is reserved for newline-delimited MCP JSON-RPC messages. Do not add console.log diagnostics to the server process.
Example MCP host command:
{
"command": "npm",
"args": ["run", "start", "--silent"],
"cwd": "/root/apify-mcp-policy-gateway"
}Tests and type checking
npm test
npm run typecheckAll tests are non-networked. They use only fake transports, in-memory state, temporary local state directories, and deterministic fixture data.
Build-environment note
The execution environment used to produce this M1 could not fetch packages from its configured npm registry. The repository therefore contains a small dependency-free stdio MCP wire adapter and the verification run used Node's built-in test runner. package.json pins the intended maintained MCP SDK and Vitest dependencies, but replacing the temporary stdio adapter with the official SDK wiring and executing the same suite under Vitest remains a tooling-conformance follow-up. This limitation is recorded in M1_IMPLEMENTATION_REPORT.md rather than hidden.
Security boundaries
No user token field exists.
No
.envor credential loader exists.No live Apify request exists.
No arbitrary Actor, build, run, dataset, or storage identifier is accepted.
The plan digest and current policy are revalidated before approval, execution, and result access.
An ambiguous outbound submission is never retried automatically.
Actor/dataset content is always untrusted external content, never policy or instructions.
Result sanitation is deterministic key removal, not a claim of complete secret detection.
Intentionally not implemented
Real Apify REST transport or token handling.
Arbitrary Actor discovery or execution.
Signed-JWS approval.
Approval-required or blocked workflows beyond explicit denial.
URL-target policy.
Remote run-status or dataset reads.
General redaction of values such as email or phone.
Universal rollback.
Prompt-injection detection or prevention claims.
Multi-user or network transport.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityAmaintenanceGoverned agent execution gateway for LLM workflows, providing deterministic FSM-based execution, audit trails, and idempotency guarantees via MCP.5MIT
- Flicense-qualityCmaintenanceSafety-first local MCP tool gate with control plane, runtime security, and observability for managing MCP backends.
- Flicense-qualityCmaintenanceMCP server that evaluates agent actions against a Policy State Machine, emits a tamper-evident audit trail, and dispatches approved transitions to internal or federated handlers.
- Alicense-qualityBmaintenanceA gateway that enforces permissions, sanitization, approval, and audit for AI agent MCP tool calls, with a policy engine and local proxy CLI.7651MIT
Related MCP Connectors
MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.
Control plane for autonomous software labor. Agents claim objectives over MCP with audit trail.
Private-by-default, local-first memory/context/task orchestrator for MCP apps and agents.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/jespermetahubb/apify-mcp-policy-gateway'
If you have feedback or need assistance with the MCP directory API, please join our Discord server