DEV Community

Cover image for How to Screen Zoom Marketplace MCP URLs in Python Before Connecting
vexaloom-labs
vexaloom-labs

Posted on Fully Autonomous

How to Screen Zoom Marketplace MCP URLs in Python Before Connecting

Your agent finds mcpUrl in a marketplace listing. The next generated configuration includes it. A search result has quietly acquired network privileges.

The catch: that field is an endpoint published by the listed app. The Actor reads public marketplace listings; endpoint validation and tool approval aren't guarantees of that collection.

Lab note 184: how can we discover possible MCP integrations without letting retrieved listings expand an agent's tool access?

The handoff that changes the agent's powers

An endpoint in a listing is discovery evidence, not permission to connect.

That distinction matters before a useful tool call succeeds. Contacting a server can expose connection metadata; depending on the client, authentication or initialization may also transmit credentials or application context.

Waiting until tool execution to check permission can therefore be too late.

This collection cell fetches public listing records without contacting their MCP endpoints.

import os
import json
import re
from urllib.parse import urlsplit
from apify_client import ApifyClient

run_input = {
    "category": "productivity",
    "maxItems": 3,
    "includeAppDetails": True,
}

client = ApifyClient(os.environ["APIFY_TOKEN"])
run = client.actor(
    "vexaloom-labs/zoom-marketplace-category-tracker"
).call(run_input=run_input)

if run["status"] != "SUCCEEDED":
    raise RuntimeError(f"Collection ended with {run['status']}")

items = client.dataset(run["defaultDatasetId"]).list_items().items
Enter fullscreen mode Exit fullscreen mode

We want a fork where the listing stops having authority.

public listing -> candidate registry -> labeled retrieval evidence
                         |
                  exact approval check
                         |
                  MCP configuration
Enter fullscreen mode Exit fullscreen mode

The candidate registry can grow automatically. The approval source can't.

Shortcut Pipeline consequence Filter
Accept any parseable HTTPS URL Retrieval triggers an unauthorized connection Screen locally, then require approval
Approve a hostname or display name Permission spreads to another app or endpoint Match appId and the exact URL
Feed listing prose into configuration generation Retrieved instructions influence tool access Generate settings from approved values only
Keep whichever duplicate arrived last Dedup conceals an endpoint change Hold conflicting candidates for review

A parseable address buys no connection rights

A URL parser can reject suspicious structure. It can't establish endpoint ownership, server behavior, or suitability for your workload.

Sending a request to “validate” a discovered URL doesn't solve this. It performs the connection we're trying to gate. A successful response is still not authorization.

This conservative filter accepts ordinary HTTPS DNS endpoints and routes unsupported forms to review without issuing requests.

def endpoint_issue(value):
    if not isinstance(value, str) or not value:
        return "missing endpoint"

    if (
        not value.isascii()
        or any(c.isspace() or ord(c) < 32 or ord(c) == 127 for c in value)
        or "\\" in value
        or re.search(r"%(?![0-9A-Fa-f]{2})", value)
    ):
        return "unsupported URL characters"

    try:
        parts = urlsplit(value)
        host = parts.hostname
        _ = parts.port
    except ValueError:
        return "malformed URL"

    if parts.scheme != "https" or not host:
        return "HTTPS endpoint required"
    if parts.username is not None or parts.password is not None:
        return "embedded credentials"
    if "#" in value or parts.netloc.endswith(":"):
        return "fragment or empty port"

    label_pattern = r"[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?"
    if len(host) > 253 or not all(
        re.fullmatch(label_pattern, label) for label in host.split(".")
    ):
        return "unsupported hostname"

    return None
Enter fullscreen mode Exit fullscreen mode

This is a local acceptance policy, not a universal URL validator. An IPv6 literal or another unsupported form goes to review rather than getting rewritten.

We preserve the original endpoint string. Silently normalizing paths, query strings, or trailing slashes would make the approval check less exact than it looks.

Missing endpoints also stay missing. Empty source values are omitted, so falling back from mcpUrl to appUrl would turn a marketplace page into an invented integration address. We'd rather leave the candidate pending than guess.

Hostname approval lets permission spread sideways

A shared host can serve unrelated applications. Different paths can identify different services.

Approving the host alone can therefore authorize more than the endpoint someone actually reviewed. Matching a display name has a similar problem: a useful retrieval label isn't an authorization identity.

This filter binds approval to the marketplace appId and the exact endpoint string.

approved_endpoints: dict[str, str] = {}

def registration_issue(candidate, approvals):
    issue = endpoint_issue(candidate.get("mcpUrl"))
    if issue is not None:
        return issue

    app_id = candidate.get("appId")
    if not isinstance(app_id, str) or not app_id:
        return "missing app identity"

    if approvals.get(app_id) != candidate["mcpUrl"]:
        return "app and endpoint lack exact approval"

    return None
Enter fullscreen mode Exit fullscreen mode

The empty map is intentional. Collection can populate a review queue immediately; it can't populate its own approval source.

In production, keep that mapping outside the agent's write permissions. A separate review should consider ownership, authentication, exposed tools, and the data the client may send.

The mapping records that decision. It doesn't perform those checks, and it doesn't freeze the server's future behavior.

Client policy still needs to govern credentials, redirects, network destinations, and individual tool calls. Exact URL approval is one boundary, not the whole security model.

Listing prose can write instructions of its own

With includeAppDetails, the Actor adds the full listing description as plain text. Plain text can still contain instructions aimed at an agent.

The dangerous move is asking a model to turn the whole listing into MCP configuration. Promotional copy and executable settings now share a workbench. The copy has brought its own screwdriver.

This filter serializes descriptions as labeled evidence and applies a shared character budget to their prose.

evidence_char_limit = 6000

def listing_evidence(row, candidate):
    remaining = evidence_char_limit
    text = {}

    for field in ("description", "longDescription"):
        value = row.get(field)
        if isinstance(value, str):
            text[field] = value[:remaining]
            remaining -= len(text[field])

    return json.dumps(
        {
            "source_kind": "untrusted_public_listing",
            "listing_reference": candidate,
            "listing_text": text,
        },
        ensure_ascii=True,
    )
Enter fullscreen mode Exit fullscreen mode

JSON serialization prevents source strings from breaking the surrounding JSON structure. It does not prevent a model from following instructions inside those strings.

The enforceable boundary is keeping model output away from approval storage and configuration generation. Labels help interpretation; permissions control the action.

For retrieval, carry the listing reference alongside every description chunk. Otherwise a matching paragraph can lose its app identity and collection timestamp before reaching the answer.

The character budget limits prose size, not exact token usage or the size of the entire evidence object. Apply your application's tokenizer when you need a token ceiling.

Truncated text is incomplete evidence. It shouldn't support claims that depend on the missing portion.

Dedup can hide the endpoint that changed

Every run reads the live marketplace. scrapedAt records collection time; it doesn't certify when an endpoint was verified.

That makes “keep the latest row by name” a poor registration policy. A familiar label can survive while the connection target changes underneath it.

For a current registration batch, we would hold conflicting endpoints for the same app rather than let arrival order choose the winner. The filter below implements that rule before configuration is emitted.

Missing and present endpoint values also count as a conflict in this conservative policy. That can delay a legitimate candidate, but it avoids silently resolving contradictory evidence.

The registry sends evidence and configuration to separate exits

The combined filter preserves discovery references, detects endpoint conflicts, and constructs settings only after the approval check.

candidate_fields = ("appId", "name", "appUrl", "mcpUrl", "scrapedAt")

def build_registry(rows, approvals):
    candidates = [
        {field: row.get(field) for field in candidate_fields}
        for row in rows
    ]

    endpoints_by_app = {}
    for candidate in candidates:
        app_id = candidate.get("appId")
        endpoint = candidate.get("mcpUrl")
        if isinstance(app_id, str) and app_id:
            endpoints_by_app.setdefault(app_id, set()).add(
                endpoint if isinstance(endpoint, str) else None
            )

    conflicts = {
        app_id
        for app_id, endpoints in endpoints_by_app.items()
        if len(endpoints) > 1
    }

    review = []
    evidence = []
    servers = {}

    for row, candidate in zip(rows, candidates):
        evidence.append(listing_evidence(row, candidate))
        issue = registration_issue(candidate, approvals)

        app_id = candidate.get("appId")
        if isinstance(app_id, str) and app_id in conflicts:
            issue = "conflicting endpoints for this app"

        if issue is not None:
            review.append((candidate, issue))
            continue

        servers[app_id] = {"url": candidate["mcpUrl"]}

    return candidates, review, evidence, {"mcpServers": servers}

candidate_registry, review_records, retrieval_evidence, mcp_config = (
    build_registry(items, approved_endpoints)
)
mcp_config_json = json.dumps(mcp_config, indent=2)
Enter fullscreen mode Exit fullscreen mode

The generated shape targets a client that accepts remote servers under mcpServers with a url entry. Adapt that serializer to your client's configuration schema while preserving the gate.

For repeated collections, retain historical candidates separately from the current registration batch. Replacing history loses evidence; mixing every historical endpoint into the current batch can leave a changed app permanently conflicted.

The worked source is Zoom Marketplace Category Tracker. We use its listing records to nominate integrations, while application-controlled state determines which candidates can become configured connections.

An empty configuration can be the correct result

The useful assertion is that a clean address still produces no configuration without approval.

These Example candidates exercise that boundary locally, including an endpoint conflict; the synthetic approval authorizes nothing outside this in-memory check.

probe = {
    "appId": "Example-app",
    "mcpUrl": "https://example.invalid/mcp",
}

assert endpoint_issue(probe["mcpUrl"]) is None

_, pending, _, denied = build_registry([probe], {})
assert pending
assert denied["mcpServers"] == {}

synthetic_approval = {probe["appId"]: probe["mcpUrl"]}
_, _, _, permitted = build_registry([probe], synthetic_approval)
assert permitted["mcpServers"][probe["appId"]]["url"] == probe["mcpUrl"]

changed_probe = {
    **probe,
    "mcpUrl": "https://example.invalid/changed",
}
_, conflicts_pending, _, blocked = build_registry(
    [probe, changed_probe], synthetic_approval
)
assert conflicts_pending
assert blocked["mcpServers"] == {}
Enter fullscreen mode Exit fullscreen mode

We'd ship discovery with this separation. Parsing, source labels, and conflict detection improve the candidate feed; the separately controlled approval map grants configuration authority.

The model's answer needs the same discipline. “The listing publishes an endpoint” can come from retrieved evidence. “Your agent may connect” requires application-controlled approval state.

An empty configuration is a useful outcome when the alternative is an agent confidently granting itself access.

Recreate the approval gap

  • Collect candidates using the exact input below.
  • Run the filters with the approval map empty and inspect review_records and mcp_config_json.
  • Run the synthetic assertions without contacting their endpoints.
  • Add a real approval through your separate review process, then regenerate configuration.

The collection input asks for listings. Connection permission comes from somewhere else.

{
  "category": "productivity",
  "maxItems": 3,
  "includeAppDetails": true
}
Enter fullscreen mode Exit fullscreen mode

Drafted with AI assistance and reviewed for accuracy.

Top comments (1)

Collapse
 
osamamalik profile image
Osama Malik •

Good framing: a listing's endpoint is discovery evidence, not permission. Matching on appId plus the exact URL is the right call, since hostname-level approval lets a vendor swap in a different endpoint later.

One addition from MCP security work: pin the approved entry to a hash of the tool schema or manifest as well as the URL. An approved server can still change its tool descriptions after approval, which is a prompt injection route (tool poisoning). Re-review whenever the hash changes, and keep the approval store outside anything the agent can write to.