# MCP Endpoint & OAuth 2.1 Security Auditor (`caliberfoundry/mcp-oauth-security-auditor`) Actor

Audit remote MCP Streamable HTTP servers for OAuth 2.1 (RFC 9728, RFC 8414, PKCE S256), CORS/DNS-rebinding posture, schema token bloat, and tool-poisoning risks. Works in batch mode or as an Apify Standby Server Actor (/mcp).

- **URL**: https://apify.com/caliberfoundry/mcp-oauth-security-auditor.md
- **Developed by:** [Caliber Foundry](https://apify.com/caliberfoundry) (community)
- **Features:** Limited permissions, Multi-tenant, Server interface
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$30.00 / 1,000 remote mcp endpoint security & oauth 2.1 audits

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## MCP Endpoint & OAuth 2.1 Security Auditor

Audit any remote **Model Context Protocol (MCP)** server (`Streamable HTTP`) for **OAuth 2.1 compliance (RFC 9728, RFC 8414, PKCE S256)**, **CORS / DNS-rebinding security**, **schema token bloat**, and **tool-poisoning prompt injection risks** in seconds.

Built by **Caliber Foundry** (`https://caliberfoundry.com/`). Works both as a scheduled **Apify Batch Actor** and as a real-time **Apify Server Actor (`/mcp`)** via `https://mcp.apify.com`.

### What This Actor Checks

1. **OAuth 2.1 & Discovery Compliance:**
   - Unauthenticated `POST /mcp` challenge (`401 Unauthorized` + `WWW-Authenticate: Bearer resource_metadata="..."`).
   - **RFC 9728** Protected Resource Metadata (`/.well-known/oauth-protected-resource`) validation.
   - **RFC 8414 / OIDC** Authorization Server discovery (`authorization_endpoint`, `token_endpoint`, `registration_endpoint`).
   - Mandatory **PKCE `S256`** check (`code_challenge_methods_supported`) and deprecated implicit grant (`response_type="token"`) detection.
2. **Transport & DNS-Rebinding Security:**
   - Enforces HTTPS posture in production and blocks SSRF targets (`127.0.0.0/8`, `10.0.0.0/8`, `169.254.169.254`).
   - Probes CORS with an untrusted `Origin` header to flag wildcard `*` or reflected origin vulnerabilities.
3. **Tool Surface, Token Bloat & Tool-Poisoning Scan:**
   - Connects via Streamable HTTP (`initialize` + `tools/list`) when unauthenticated or when an optional Bearer token is supplied.
   - Estimates total schema token footprint (flagging `> 8,000` / `> 20,000` context bloat).
   - Scans tool names, descriptions, and JSON schemas for invisible Unicode / BiDi steganography, `<IMPORTANT>` / `"ignore previous instructions"` prompt injections, credential path harvesting (`.ssh`, `.aws`, `.env`), and missing `readOnlyHint` / `destructiveHint` annotations.

### Example Input JSON

```json
{
  "targetUrls": [
    "https://mcp.apify.com"
  ],
  "probeTools": true,
  "timeoutMs": 10000
}
```

### Example Output JSON

```json
{
  "targetUrl": "https://mcp.apify.com",
  "auditedAt": "2026-11-28T14:30:00.000Z",
  "score": 96,
  "grade": "A",
  "authMode": "oauth21_compliant",
  "oauth21": {
    "challengeStatus": 401,
    "wwwAuthenticatePresent": true,
    "rfc9728Found": true,
    "rfc8414Found": true,
    "pkceS256Supported": true,
    "dynamicClientRegistrationSupported": true
  },
  "transport": {
    "httpsEndpoint": true,
    "acceptsStreamableHttp": true,
    "allowsUntrustedOrigin": false
  },
  "toolsAudit": {
    "inspected": false,
    "toolCount": 0,
    "estimatedSchemaTokens": 0,
    "poisoningFindingCount": 0
  },
  "findings": [],
  "recommendedFixes": []
}
```

### Connect via Apify MCP (`mcp.apify.com`)

```json
{
  "mcpServers": {
    "mcp-security-auditor": {
      "url": "https://mcp.apify.com/?tools=caliberfoundry/mcp-oauth-security-auditor"
    }
  }
}
```

### Pricing (Pay-Per-Event)

- **`mcp-endpoint-audited`:** `$0.03` per audited MCP endpoint (zero Actor start fee; free preview runs are capped cleanly by your `maxTotalChargeUsd`).

### FAQ

- **Are Bearer tokens stored or logged?** No. Optional `bearerToken` inputs are flagged `isSecret: true` in `.actor/input_schema.json` and used strictly in memory for the single `tools/list` probe.
- **Does this work against private localhost endpoints?** No; production SSRF guards block private/loopback/metadata IP ranges (`127.0.0.1`, `169.254.169.254`, RFC 1918).

# Actor input Schema

## `targetUrls` (type: `array`):

One or more public HTTPS remote MCP server endpoint URLs to audit (for example https://mcp.example.com/mcp).

## `bearerToken` (type: `string`):

Optional Bearer token used only to inspect authenticated tools/list schemas and run tool-poisoning & token-bloat audits on protected endpoints. Never stored or logged.

## `probeTools` (type: `boolean`):

When enabled, attempts a Streamable HTTP JSON-RPC initialize + tools/list handshake (when unauthenticated or bearerToken is supplied) to calculate schema token footprint and scan tool descriptions for prompt-injection / tool-poisoning patterns.

## `auditOrigin` (type: `string`):

Synthetic untrusted Origin sent during transport security checks to detect overly permissive Access-Control-Allow-Origin responses.

## `timeoutMs` (type: `integer`):

Per-request timeout in milliseconds for metadata and MCP transport probes.

## Actor input object example

```json
{
  "targetUrls": [
    "https://mcp.apify.com"
  ],
  "probeTools": true,
  "auditOrigin": "https://untrusted-origin-check.example",
  "timeoutMs": 10000
}
```

# Actor output Schema

## `audits` (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 = {
    "targetUrls": [
        "https://mcp.apify.com"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("caliberfoundry/mcp-oauth-security-auditor").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 = { "targetUrls": ["https://mcp.apify.com"] }

# Run the Actor and wait for it to finish
run = client.actor("caliberfoundry/mcp-oauth-security-auditor").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 '{
  "targetUrls": [
    "https://mcp.apify.com"
  ]
}' |
apify call caliberfoundry/mcp-oauth-security-auditor --silent --output-dataset

```

## MCP server setup

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

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/AzlhjVGnx49ZPjYW2/builds/jxDz7qeIglchtMdDS/openapi.json
