apify-mcp-policy-gateway

apify-mcp-policy-gateway

A local-first MCP policy gateway that provides a four-step workflow (plan, approve, execute, read) for a single Apify fixture Actor, enforcing a fixed policy and sanitizing results. It does not call Apify and is designed as a policy control plane.

Category
访问服务器

README

Apify MCP Policy Gateway — M1

A deliberately narrow, local-first MCP policy gateway for one organization-owned Apify fixture Actor.

M1 does not call Apify. It exposes a four-step stdio workflow backed by a fake local Actor transport:

  1. plan_operation
  2. approve_operation
  3. execute_approved_operation
  4. read_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 P4XBS39SYl7aeFJ7g
Canonical owner/name metahubb~apify-mcp-policy-fixture
Build 0.1.1
Maximum runtime 60 seconds
Maximum charge ceiling USD 0.10
Maximum result count 3
Risk low only

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.

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_RISK policy decision.
  • Bounded execution parameters.
  • approval_required status.

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 injected ActorRunTransport.

The default transport is local and fake. There is no HTTP Apify adapter and no environment-variable credential loading.

Execution states:

  • SUBMITTED: the fake 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 locally generated results belonging to an execution in this gateway state namespace. 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.

Local state and audit

By default, npm run start creates .gateway-state/ in the current working directory.

  • gateway.lock is acquired with exclusive creation. A second process cannot use the same state directory.
  • state.json is written to a new file, fsynced, atomically renamed, and followed by a directory fsync.
  • audit.jsonl is 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 start

Standard 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 typecheck

All 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 .env or 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.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选