# TrustGate MCP — AI Content Firewall (`zixby/trustgate-mcp`) Actor

Authenticated MCP service that screens untrusted text, HTML, and public URLs before an AI agent uses them.

- **URL**: https://apify.com/zixby/trustgate-mcp.md
- **Developed by:** [Zac Blank](https://apify.com/zixby) (community)
- **Categories:** AI, Developer tools
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.001 / trustgate scan

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## TrustGate MCP — AI Content Firewall

TrustGate MCP screens untrusted text, HTML, and public webpages before an AI tutor, research assistant, browser agent, or other automated system places that content in its working context. It detects high-confidence prompt-injection patterns, attempts to expose credentials, tool-manipulation instructions, suspicious encodings, invisible Unicode controls, and instructions hidden in HTML.

The service is deliberately small for v0.1. It exposes one focused MCP tool, `screen_untrusted_content`, with strict JSON input and output schemas. The response includes `verdict`, `risk_score`, `threats`, `safe_text`, `recommended_action`, `confidence`, `analysis_method`, and transparent execution and billing metadata.

### Why use TrustGate

Webpages, uploaded study notes, emails, and documents can contain instructions aimed at the AI system rather than the human reader. TrustGate gives an agent a consistent checkpoint before it uses that material. It is useful for AI tutoring, student research, retrieval-augmented generation, browser automation, support assistants, and any workflow that reads content the developer does not fully control.

TrustGate is a defense-in-depth signal. An `allow` verdict reduces obvious risk but is not a guarantee of safety. Callers should still use least-privilege tools, require confirmation for consequential actions, and keep credentials out of model context.

### How it works

1. The caller provides exactly one of `text`, `html`, or `url` and can optionally describe `agent_intent`.
2. Fast deterministic rules run first. HTML is reduced to visible text while suspicious hidden elements are recorded. Public URL fetching blocks private and local destinations, checks redirects, limits response sizes, and accepts text-like content only.
3. Ambiguous content can use an optional semantic classifier when `OPENAI_API_KEY` is configured. Clear benign and clear malicious inputs avoid that cost.
4. The tool returns a strict structured result. Provider failures degrade to deterministic analysis without returning secret or provider details.

### MCP connection

This Actor runs in Apify Standby mode. Authenticated MCP clients connect to the Actor's `/mcp` endpoint using Streamable HTTP. The root route is a free readiness check and does not invoke the tool or create a billable event. Apify's Standby edge requires the caller's own Apify bearer token; no creator-owned token is embedded in the service. A public OAuth plugin should place a user-controlled gateway in front of this endpoint so OAuth discovery and domain verification remain readable before authentication.

The tool is marked as non-read-only because each successful call records a pay-per-event billing event. It is also marked open-world because URL scans fetch a public external resource. A successful scan charges exactly one `trustgate-result` event. Invalid input, a blocked billing limit, and the default health check do not create a successful scan event.

### Inputs

- `text`: plain untrusted content, up to 200,000 characters.
- `html`: HTML content, up to 500,000 characters.
- `url`: one public HTTP or HTTPS URL returning text, HTML, or JSON.
- `agent_intent`: optional description of the agent's legitimate task.
- `semantic_fallback`: use semantic classification only for ambiguous content when configured.
- `include_safe_text`: include a sanitized content copy in the response.

Never submit passwords, API keys, access tokens, private student records, or other secrets.

### Privacy and security

TrustGate does not intentionally log submitted content, authorization headers, or secrets. MCP results are returned directly to the caller rather than written to the default dataset. Operational metadata is logged without source text. When semantic fallback is enabled and used, the analyzed content and supplied intent are sent to the configured OpenAI API model. Apify and any configured AI provider process data under their own platform terms.

### Ordinary Actor run

Running the Actor outside Standby with empty input produces one zero-cost health result in the default dataset and exits. This makes the default console run safe and predictable.

### Local verification

Install `requirements.txt`, add the project and dependencies to Python's import path, and run:

```text
python -m unittest discover -s tests -v
```

No API key is required for deterministic tests.

# Actor input Schema

## Actor input object example

```json
{}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("zixby/trustgate-mcp").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("zixby/trustgate-mcp").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call zixby/trustgate-mcp --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,zixby/trustgate-mcp"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/wO4ghVnLtqWA0VdAO/builds/mIMX6KCCinJHfVriJ/openapi.json
