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.
- Another company’s server cannot read that login and learn who made the agent.
- Login has no company signature on the agent document, and no cancellation list for that agent id.
X-Agent-Credentialsits beside the user token and names the company. The user token stays.
02 Where the header sits
The check runs before the tool. The MCP server does not have to store the agent.
- The agent sends the signed document.
- The MCP client puts that JSON in
X-Agent-Credentialon the HTTP request. - 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.
- 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.
| Transport | Where the credential travels | Who 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.
verify.