One header
says who made the agent.

Login already says which person approved the app. It does not say which company made the agent. This header does. Your MCP server can require it without a new login system.

Companies publish keys on Account. Gateways pin from Keys or GET /api/keys. Copy-paste wiring: Prompts — desk / MCP host. Test a cooperating gateway: Integrate — Test your gateway.

01 Login does not name the company

OAuth is the person’s permission. It says which person approved the app. It does not say which company made the agent that is about to call a tool.

This is not RSA Agent ID or Microsoft Entra Agent ID. Those control agents inside one company’s account. This header is what another company’s MCP server can check without joining that account.

The check runs before the tool. The MCP server does not have to store the agent.

  1. The agent sends the signed document.
  2. The MCP client puts that JSON in X-Agent-Credential on the HTTP request.
  3. The server checks the prefix, the key name, the signature, and the expiry. If a cancellation list is published, check it; if none, signature and expiry are enough.
  4. A pass adds X-Agent-ID. A fail is 403 and the tool does not run.

03 Flask middleware

Read the header, check it, or refuse everyone if agents are not allowed. before_request does that before the tool runs. reject_all returns 403 before any of the checks.

flask middleware

import json
from flask import Flask, request, jsonify

app = Flask(__name__)
MODE = "verify"  # or "reject_all"

def verify_credential(credential: dict) -> tuple[bool, str]:
    code = credential.get("company")
    company = COMPANIES.get(code)
    if company is None:
        return False, "unknown company prefix"
    public_hex = company["keys"].get(credential.get("kid"))
    if public_hex is None:
        return False, f"unknown key id {credential.get('kid')}"
    try:
        verify_ed25519(public_hex, credential)
    except Exception:
        return False, "bad signature"
    if time.time() > credential["expires_at"]:
        return False, "expired"
    rev, status = revocation_list(code)
    if rev is not None:
        try:
            check_revocation_list(rev)
        except Exception as exc:
            return False, f"revocation list invalid: {exc}"
        if credential["agent_id"] in rev["revoked_agents"]:
            return False, f"REVOKED via {code} endpoint ({rev['reason']})"
    return True, f"VALID (signed by key {credential['kid']}, revocations: {status})"

@app.before_request
def require_agent():
    if MODE == "reject_all":
        return jsonify(error="reject_all"), 403
    raw = request.headers.get("X-Agent-Credential")
    if not raw:
        return jsonify(error="missing credential"), 403
    try:
        credential = json.loads(raw)
    except json.JSONDecodeError:
        return jsonify(error="bad credential"), 403
    ok, reason = verify_credential(credential)
    if not ok:
        return jsonify(error=reason), 403
    request.environ["HTTP_X_AGENT_ID"] = credential["agent_id"]

04 HTTP and stdio

HTTP and stdio use the same document. The bytes are just read from a different place. The check is the same verify_credential.

TransportWhere the credential travelsWho checks
HTTP Request header X-Agent-Credential Gateway or Flask before_request, before the tool
SSE Same HTTP header on the stream request Same check, once, when the stream opens
stdio No HTTP header. The host passes the credential in the environment it sets for the process. The host checks before spawn, or the server reads that environment and calls verify_credential before the first tool

05 Reject all

reject_all means the door stays shut. An MCP server that does not want agents sets MODE = "reject_all". Agents with a document are refused. Callers with no document are refused too.

Utilities and banks use the same program. The setting is the policy. The prefix sits unused until they switch back to verify.