Skip to main content

Agent identity and routing middleware for MCP-compatible agents

Project description

ubag (Python)

UBAG Web Layer — agent identity and routing at the web edge. FastAPI / Starlette middleware.

When an autonomous agent visits a website, UBAG verifies who it is and routes accordingly: humans to your normal site, credentialed agents to clean JSON-LD, unknown bots to a cryptographic challenge. Asymmetric by design — agent identity is an Ed25519 keypair; credentials are ES256 JWTs verifiable via JWKS, no shared secrets.

Early but real, pre-1.0, unaudited. See the full README and SECURITY.md.

Install

pip install "ubag[fastapi]"

Quick start

from fastapi import FastAPI
from ubag import UBAGMiddleware, generate_issuer_keypair

issuer_private, _ = generate_issuer_keypair()   # EC P-256 (ES256)

app = FastAPI()
app.add_middleware(
    UBAGMiddleware,
    origin="https://yoursite.com",
    issuer_key=issuer_private,                  # mints + verifies credentials
    site_meta={"name": "My Store", "type": "Store", "description": "We sell widgets"},
)

Your site now serves clean JSON-LD to credentialed agents, proxies humans to your origin, challenges unknown bots, exposes /.well-known/ubag.json for discovery, and serves its issuer key as JWKS at /.well-known/jwks.json.

A Node/Express SDK with an identical, cross-verifiable wire format is in the same repo. Full docs, a runnable demo, and the protocol details: https://github.com/mohameduk/Ubag_protocol

MIT licensed.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ubag-0.2.0.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ubag-0.2.0-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file ubag-0.2.0.tar.gz.

File metadata

  • Download URL: ubag-0.2.0.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for ubag-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1ae65705605494f99ef313b9b6f373ea80975b2b2cb860953e2db23f9cb3e91d
MD5 03db434f1a4796eb001054600a47a251
BLAKE2b-256 7ef02d1eca07e864e2471472a22b3221c0854ef1a6d1bc96cae262652b437fde

See more details on using hashes here.

File details

Details for the file ubag-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: ubag-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for ubag-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a0d57b78e8cd06b80e64d70e83995bb15ead6410e66264b3959e9b2451723505
MD5 bd87aeefb7a80d99a5075462c25c9a99
BLAKE2b-256 644af68de8deddd4cf30c1428ff1d8fc5601ca4d853da26131850b8deb52beb4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page