# Live Remote MCP Server Profiler (`runglab/mcp-server-profiler`) Actor

Profile live remote MCP servers over Streamable HTTP/SSE for BPE token budget & monthly API cost, schema lint anti-patterns, tool-poisoning & hidden Unicode security risks, and RFC 9728 OAuth/A2A compliance.

- **URL**: https://apify.com/runglab/mcp-server-profiler.md
- **Developed by:** [RungLab](https://apify.com/runglab) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $30.00 / 1,000 mcp server 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/running/actors-in-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

## Live Remote MCP Server Profiler — Token Budget, Schema Lint & Tool-Poisoning Security Auditor

**Audit any live remote Model Context Protocol (MCP) server in seconds.** Connect directly over **Streamable HTTP** or **Legacy SSE**, measure exact **pre-turn-1 LLM context-window bloat & monthly API "MCP Token Tax"**, detect **tool-poisoning prompt injections & invisible Unicode smuggling**, lint JSON tool schemas, and verify **RFC 9728 OAuth 2.1 + A2A Agent Card** compliance — with zero headless browsers and zero proxy overhead.

***

### Why Use Live Remote MCP Server Profiler?

In production AI agent systems (Claude Code, Cursor, Windsurf, LangGraph, n8n, OpenAI Agents), attaching remote MCP servers creates two invisible operational risks:

1. **The "MCP Token Tax" (Context Bloat Before Turn 1)**: Every connected MCP server injects its `instructions` and every tool's `name`, `description`, and `inputSchema` into *every single LLM turn*. A handful of verbose MCP servers can quietly consume **15%–60% of a 128k–200k context window** and add hundreds of dollars per month in redundant input token spend.
2. **MCP Supply-Chain & Tool-Poisoning Attacks**: Remote MCP servers are dynamically fetched at runtime. Compromised or malicious tool descriptions can smuggle prompt overrides (`ignore previous instructions`), covert exfiltration instructions (`do not tell the user`, `read ~/.ssh`), cross-tool shadowing, Base64 payloads, or **invisible Unicode Tag Block (`U+E0000–U+E007F`) / BiDi override** characters invisible to human review.

Static GitHub repo scanners cannot see what a **live remote MCP server** actually serves to your agents today. This Actor probes live endpoints directly over JSON-RPC 2.0 and delivers an actionable, scored audit dossier.

***

### Core Capabilities

| Capability | What It Checks |
| :--- | :--- |
| **Live Protocol Probing** | Full MCP JSON-RPC 2.0 handshake (`initialize` → `Mcp-Session-Id` → `notifications/initialized` → paginated `tools/list`, `prompts/list`, `resources/list`). Supports **Streamable HTTP** (`application/json` & `text/event-stream` SSE) with automatic **Legacy HTTP+SSE (`2024-11-05`)** fallback. |
| **Token Budget & API Cost Modeling** | Deterministic BPE token accounting (plus optional `tiktoken`) per tool (`name`, `description`, `inputSchema`, `annotations`) and server `instructions`. Models `%` of `128k` / `200k` / `1M` context windows and monthly uncached + cached USD cost across **Claude Sonnet**, **GPT-4o**, and **Gemini 2.5 Pro**. |
| **Tool-Poisoning & Prompt-Injection Scanner** | Flags instruction overrides, user-deception/secrecy directives, credential/SSH/config exfiltration targeting, cross-tool shadowing, hidden XML/HTML tags (`<IMPORTANT>`, `<SYSTEM>`), Base64-obfuscated instructions, and suspicious external webhook/exfiltration URLs. |
| **Hidden / Invisible Unicode Forensics** | Recursively inspects all server/tool/prompt metadata for **Unicode Tag Block (`U+E0000–U+E007F`)** (automatically decoding smuggled ASCII text!), **BiDi override/isolate spoofing** (`U+202A–U+202E`, `U+2066–U+2069`), and **zero-width characters** (`U+200B–U+200F`, `U+2060`, `U+FEFF`). |
| **Schema Lint & Capability Governance** | Detects duplicate/case-colliding tool names, missing descriptions, missing `additionalProperties: false`, untyped `type: object` blobs, unbounded arrays, verbose context-bloating descriptions, oversized names (`>64` chars), and unannotated high-risk execution/mutation tools (`shell`, `exec`, `write_file`, `sql`). |
| **OAuth 2.1 (RFC 9728) & A2A Compliance** | Gracefully audits `HTTP 401/403` OAuth-gated MCP servers by parsing `WWW-Authenticate` (`resource_metadata`) and probing `/.well-known/oauth-protected-resource`, `/.well-known/oauth-authorization-server`, and `/.well-known/agent-card.json` (A2A). |
| **Official MCP Registry Batch Discovery** | Optional `registryQuery` searches `https://registry.modelcontextprotocol.io/v0/servers` to automatically discover and batch-audit live remote MCP endpoints by keyword. |

***

### Quick Start & Copy-Paste Input Examples

#### 1. Zero-Config Instant Benchmark (Just Click "Start")

Default input profiles three real, public, zero-auth remote MCP servers (DeepWiki, Microsoft Learn, Cloudflare Docs):

```json
{
  "serverUrls": [
    "https://mcp.deepwiki.com/mcp",
    "https://learn.microsoft.com/api/mcp",
    "https://docs.mcp.cloudflare.com/mcp"
  ],
  "modelPricing": "all",
  "callsPerDay": 50,
  "compactMode": false,
  "timeoutSeconds": 15
}
```

#### 2. Batch Audit from the Official MCP Registry

Automatically discover and audit up to 20 live remote MCP servers matching a keyword on `registry.modelcontextprotocol.io`:

```json
{
  "registryQuery": "cloudflare",
  "maxServers": 20,
  "modelPricing": "claude-sonnet",
  "callsPerDay": 100
}
```

#### 3. Audit a Private / OAuth-Gated Remote MCP Server

Pass Bearer tokens or API keys via `authHeaders` (headers are used strictly in-memory for probing and are **never** written to datasets or logs):

```json
{
  "serverUrls": [
    "https://mcp.your-company.internal/mcp"
  ],
  "authHeaders": {
    "Authorization": "Bearer YOUR_MCP_ACCESS_TOKEN"
  },
  "modelPricing": "all",
  "callsPerDay": 500
}
```

#### 4. Compact Mode for AI Agents (Apify MCP / LangGraph / n8n)

Enable `compactMode: true` to receive concise, token-efficient JSON optimized for agent consumption:

```json
{
  "serverUrls": ["https://mcp.deepwiki.com/mcp"],
  "compactMode": true
}
```

***

### Sample Output

Each audited MCP server produces one structured dataset item (plus an aggregated `AUDIT_SUMMARY` JSON record in the Key-Value Store):

```json
{
  "serverUrl": "https://mcp.deepwiki.com/mcp",
  "serverName": "DeepWiki",
  "serverVersion": "4.0.2",
  "status": "ok",
  "httpStatus": 200,
  "transport": "streamable-http-sse",
  "protocolVersion": "2025-03-26",
  "latencyMs": 3730,
  "grade": "A",
  "healthScore": 98,
  "scoreScope": "full-audit",
  "toolCount": 3,
  "totalSchemaTokens": 1304,
  "instructionsTokens": 967,
  "toolsOnlyTokens": 337,
  "bloatTier": "lean",
  "contextWindow128kPct": 1.019,
  "contextWindow200kPct": 0.652,
  "primaryModel": "claude-sonnet",
  "estimatedMonthlyCostUsd": 5.868,
  "estimatedMonthlyCachedCostUsd": 0.5868,
  "potentialTokenSavings": 817,
  "securityCriticalCount": 0,
  "securityHighCount": 0,
  "authRequired": false,
  "oauthProtectedResourceFound": false,
  "agentCardFound": false,
  "tokenBudget": {
    "costEstimates": [
      { "modelId": "claude-sonnet", "monthlyUncachedUsd": 5.868, "monthlyCachedUsd": 0.5868 },
      { "modelId": "gpt-4o", "monthlyUncachedUsd": 4.89, "monthlyCachedUsd": 2.445 },
      { "modelId": "gemini-2.5-pro", "monthlyUncachedUsd": 2.445, "monthlyCachedUsd": 0.6113 }
    ],
    "topTokenHogs": [...],
    "recommendations": [...]
  },
  "security": {
    "scoreBreakdown": { "base": 100.0, "securityPenalty": 0.0, "capabilityAndProtocolPenalty": -2.0, "schemaLintPenalty": 0.0, "tokenBloatPenalty": 0.0, "final": 98.0 },
    "passedChecks": [
      "Endpoint served over HTTPS/TLS",
      "Modern MCP Streamable HTTP transport (streamable-http-sse)",
      "No tool-poisoning or prompt-injection signatures detected",
      "No hidden Unicode tags, BiDi overrides, or zero-width obfuscation detected"
    ],
    "findings": [...]
  }
}
```

***

### Health & Security Score Grading (`0–100`)

| Grade | Score Range | Meaning |
| :---: | :---: | :--- |
| **A** | `90 – 100` | Production-ready: clean security posture, lean schemas, strong protocol compliance |
| **B** | `80 – 89` | Good: no critical/high security issues; minor schema lint or annotation improvements available |
| **C** | `70 – 79` | Moderate risk or noticeable token bloat; review recommendations before broad rollout |
| **D** | `55 – 69` | High-severity governance/lint risks or severe context bloat (any `critical` finding caps score `<= 45`) |
| **F** | `0 – 54` | Unreachable, protocol-broken, or active tool-poisoning / hidden-Unicode attack signatures detected |

***

### Pay-Per-Event (PPE) Pricing

Lightweight pure-HTTP execution (`256MB` RAM, zero proxies, zero browser startup) keeps compute cost negligible:

| Event Name | Description | Recommended Price |
| :--- | :--- | :---: |
| `actor-start` | Charged once per Actor run | `$0.01` |
| `mcp-server-audit` | Charged once per remote MCP server profiled | `$0.03` |

***

### Use Cases

- **AI Platform & DevSecOps CI/CD**: Run weekly automated audits on every internal and third-party remote MCP endpoint before approving them for enterprise Cursor/Claude deployments.
- **MCP Server Authors**: Benchmark your `tools/list` schema token footprint, find bloated parameter descriptions, verify RFC 9728 OAuth metadata, and ship a Grade `A` server.
- **MCP Marketplace & Registry Curators**: Batch-audit dozens of servers from `registry.modelcontextprotocol.io` to rank token efficiency and flag supply-chain security issues.

***

> **Optimizing local IDE MCP configs too?** Once you've audited your remote endpoints here, check out [**MCPDiet**](https://mcp.runglab.dev) for trimming and budget-optimizing local `mcp.json` / `claude_desktop_config.json` setups across Claude Code, Cursor, and VS Code.

# Actor input Schema

## `serverUrls` (type: `array`):

List of live remote MCP server URLs (Streamable HTTP or SSE endpoints) to profile. Leave as default for an instant zero-config benchmark against live public MCP servers.

## `registryQuery` (type: `string`):

Optional keyword query against https://registry.modelcontextprotocol.io/v0/servers to automatically discover and batch-audit live remote MCP endpoints (e.g., 'cloudflare', 'github', 'docs', 'search'). When set alongside empty serverUrls, audits discovered registry servers.

## `maxServers` (type: `integer`):

Maximum total number of unique remote MCP servers to profile in this run (caps combined serverUrls and registryQuery results).

## `authHeaders` (type: `object`):

Optional HTTP headers sent to target MCP endpoints (e.g., {"Authorization": "Bearer <token>"} or {"X-API-Key": "..."}). Never stored in output results.

## `modelPricing` (type: `string`):

Which LLM pricing profile(s) to compute monthly 'MCP Token Tax' estimates for.

## `callsPerDay` (type: `integer`):

Estimated number of LLM turns per day where this MCP server's tool schemas are injected into the prompt context (used to model monthly USD token tax).

## `compactMode` (type: `boolean`):

When enabled, returns a streamlined JSON report omitting verbose per-tool breakdowns and low-severity lint details — ideal for AI agents calling this Actor via MCP.

## `timeoutSeconds` (type: `integer`):

Timeout in seconds for each HTTP request made to remote MCP and discovery endpoints.

## Actor input object example

```json
{
  "serverUrls": [
    "https://mcp.deepwiki.com/mcp",
    "https://learn.microsoft.com/api/mcp",
    "https://docs.mcp.cloudflare.com/mcp"
  ],
  "registryQuery": "",
  "maxServers": 10,
  "authHeaders": {},
  "modelPricing": "all",
  "callsPerDay": 50,
  "compactMode": false,
  "timeoutSeconds": 15
}
```

# Actor output Schema

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

No description

## `summary` (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 = {
    "serverUrls": [
        "https://mcp.deepwiki.com/mcp",
        "https://learn.microsoft.com/api/mcp",
        "https://docs.mcp.cloudflare.com/mcp"
    ],
    "registryQuery": ""
};

// Run the Actor and wait for it to finish
const run = await client.actor("runglab/mcp-server-profiler").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 = {
    "serverUrls": [
        "https://mcp.deepwiki.com/mcp",
        "https://learn.microsoft.com/api/mcp",
        "https://docs.mcp.cloudflare.com/mcp",
    ],
    "registryQuery": "",
}

# Run the Actor and wait for it to finish
run = client.actor("runglab/mcp-server-profiler").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 '{
  "serverUrls": [
    "https://mcp.deepwiki.com/mcp",
    "https://learn.microsoft.com/api/mcp",
    "https://docs.mcp.cloudflare.com/mcp"
  ],
  "registryQuery": ""
}' |
apify call runglab/mcp-server-profiler --silent --output-dataset

```

## MCP server setup

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

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/4ENa7hndDuRlGBo49/builds/9Iyxbij3lxEFxQeo0/openapi.json
