Metadata-Version: 2.5
Name: mudraid-platform-middleware
Version: 1.1.0
Summary: FastAPI/Starlette middleware for MudraID — verifies MudraID-issued JWTs against per-platform scopes with zero changes to your route handlers.
Project-URL: Homepage, https://github.com/MudraID/mudraid-platform-middleware
Project-URL: Documentation, https://docs.mudraid.ai
Project-URL: Repository, https://github.com/MudraID/mudraid-platform-middleware
Project-URL: Issues, https://github.com/MudraID/mudraid-platform-middleware/issues
Author: MudraID
License:                                  Apache License
                                   Version 2.0, January 2004
                                http://www.apache.org/licenses/
        
           TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
        
           1. Definitions.
        
              "License" shall mean the terms and conditions for use, reproduction,
              and distribution as defined by Sections 1 through 9 of this document.
        
              "Licensor" shall mean the copyright owner or entity authorized by
              the copyright owner that is granting the License.
        
              "Legal Entity" shall mean the union of the acting entity and all
              other entities that control, are controlled by, or are under common
              control with that entity. For the purposes of this definition,
              "control" means (i) the power, direct or indirect, to cause the
              direction or management of such entity, whether by contract or
              otherwise, or (ii) ownership of fifty percent (50%) or more of the
              outstanding shares, or (iii) beneficial ownership of such entity.
        
              "You" (or "Your") shall mean an individual or Legal Entity
              exercising permissions granted by this License.
        
              "Source" form shall mean the preferred form for making modifications,
              including but not limited to software source code, documentation
              source, and configuration files.
        
              "Object" form shall mean any form resulting from mechanical
              transformation or translation of a Source form, including but
              not limited to compiled object code, generated documentation,
              and conversions to other media types.
        
              "Work" shall mean the work of authorship, whether in Source or
              Object form, made available under the License, as indicated by a
              copyright notice that is included in or attached to the work
              (an example is provided in the Appendix below).
        
              "Derivative Works" shall mean any work, whether in Source or Object
              form, that is based on (or derived from) the Work and for which the
              editorial revisions, annotations, elaborations, or other modifications
              represent, as a whole, an original work of authorship. For the purposes
              of this License, Derivative Works shall not include works that remain
              separable from, or merely link (or bind by name) to the interfaces of,
              the Work and Derivative Works thereof.
        
              "Contribution" shall mean any work of authorship, including
              the original version of the Work and any modifications or additions
              to that Work or Derivative Works thereof, that is intentionally
              submitted to Licensor for inclusion in the Work by the copyright owner
              or by an individual or Legal Entity authorized to submit on behalf of
              the copyright owner. For the purposes of this definition, "submitted"
              means any form of electronic, verbal, or written communication sent
              to the Licensor or its representatives, including but not limited to
              communication on electronic mailing lists, source code control systems,
              and issue tracking systems that are managed by, or on behalf of, the
              Licensor for the purpose of discussing and improving the Work, but
              excluding communication that is conspicuously marked or otherwise
              designated in writing by the copyright owner as "Not a Contribution."
        
              "Contributor" shall mean Licensor and any individual or Legal Entity
              on behalf of whom a Contribution has been received by Licensor and
              subsequently incorporated within the Work.
        
           2. Grant of Copyright License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              copyright license to reproduce, prepare Derivative Works of,
              publicly display, publicly perform, sublicense, and distribute the
              Work and such Derivative Works in Source or Object form.
        
           3. Grant of Patent License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              (except as stated in this section) patent license to make, have made,
              use, offer to sell, sell, import, and otherwise transfer the Work,
              where such license applies only to those patent claims licensable
              by such Contributor that are necessarily infringed by their
              Contribution(s) alone or by combination of their Contribution(s)
              with the Work to which such Contribution(s) was submitted. If You
              institute patent litigation against any entity (including a
              cross-claim or counterclaim in a lawsuit) alleging that the Work
              or a Contribution incorporated within the Work constitutes direct
              or contributory patent infringement, then any patent licenses
              granted to You under this License for that Work shall terminate
              as of the date such litigation is filed.
        
           4. Redistribution. You may reproduce and distribute copies of the
              Work or Derivative Works thereof in any medium, with or without
              modifications, and in Source or Object form, provided that You
              meet the following conditions:
        
              (a) You must give any other recipients of the Work or
                  Derivative Works a copy of this License; and
        
              (b) You must cause any modified files to carry prominent notices
                  stating that You changed the files; and
        
              (c) You must retain, in the Source form of any Derivative Works
                  that You distribute, all copyright, patent, trademark, and
                  attribution notices from the Source form of the Work,
                  excluding those notices that do not pertain to any part of
                  the Derivative Works; and
        
              (d) If the Work includes a "NOTICE" text file as part of its
                  distribution, then any Derivative Works that You distribute must
                  include a readable copy of the attribution notices contained
                  within such NOTICE file, excluding those notices that do not
                  pertain to any part of the Derivative Works, in at least one
                  of the following places: within a NOTICE text file distributed
                  as part of the Derivative Works; within the Source form or
                  documentation, if provided along with the Derivative Works; or,
                  within a display generated by the Derivative Works, if and
                  wherever such third-party notices normally appear. The contents
                  of the NOTICE file are for informational purposes only and
                  do not modify the License. You may add Your own attribution
                  notices within Derivative Works that You distribute, alongside
                  or as an addendum to the NOTICE text from the Work, provided
                  that such additional attribution notices cannot be construed
                  as modifying the License.
        
              You may add Your own copyright statement to Your modifications and
              may provide additional or different license terms and conditions
              for use, reproduction, or distribution of Your modifications, or
              for any such Derivative Works as a whole, provided Your use,
              reproduction, and distribution of the Work otherwise complies with
              the conditions stated in this License.
        
           5. Submission of Contributions. Unless You explicitly state otherwise,
              any Contribution intentionally submitted for inclusion in the Work
              by You to the Licensor shall be under the terms and conditions of
              this License, without any additional terms or conditions.
              Notwithstanding the above, nothing herein shall supersede or modify
              the terms of any separate license agreement you may have executed
              with Licensor regarding such Contributions.
        
           6. Trademarks. This License does not grant permission to use the trade
              names, trademarks, service marks, or product names of the Licensor,
              except as required for describing the origin of the Work and
              reproducing the content of the NOTICE file.
        
           7. Disclaimer of Warranty. Unless required by applicable law or
              agreed to in writing, Licensor provides the Work (and each
              Contributor provides its Contributions) on an "AS IS" BASIS,
              WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
              implied, including, without limitation, any warranties or conditions
              of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
              PARTICULAR PURPOSE. You are solely responsible for determining the
              appropriateness of using or redistributing the Work and assume any
              risks associated with Your exercise of permissions under this License.
        
           8. Limitation of Liability. In no event and under no legal theory,
              whether in tort (including negligence), contract, or otherwise,
              unless required by applicable law (such as deliberate and grossly
              negligent acts) or agreed to in writing, shall any Contributor be
              liable to You for damages, including any direct, indirect, special,
              incidental, or consequential damages of any character arising as a
              result of this License or out of the use or inability to use the
              Work (including but not limited to damages for loss of goodwill,
              work stoppage, computer failure or malfunction, or any and all
              other commercial damages or losses), even if such Contributor
              has been advised of the possibility of such damages.
        
           9. Accepting Warranty or Support. While redistributing the Work or
              Derivative Works thereof, You may choose to offer, and charge a
              fee for, acceptance of support, warranty, indemnity, or other
              liability obligations and/or rights consistent with this License.
              However, in accepting such obligations, You may act only on Your
              own behalf and on Your sole responsibility, not on behalf of any
              other Contributor, and only if You agree to indemnify, defend,
              and hold each Contributor harmless for any liability incurred by,
              or claims asserted against, such Contributor by reason of your
              accepting any such warranty or support.
        
           END OF TERMS AND CONDITIONS
        
           APPENDIX: How to apply the Apache License to your work.
        
              To apply the Apache License to your work, attach the following
              boilerplate notice, with the fields enclosed by brackets "[]"
              replaced with your own identifying information. (Don't include
              the brackets!)  The text should be enclosed in the appropriate
              comment syntax for the file format. We also recommend that a
              file or class name and description of purpose be included on the
              same "printed page" as the copyright notice for easier
              identification within third-party archives.
        
           Copyright 2026 MudraID
        
           Licensed under the Apache License, Version 2.0 (the "License");
           you may not use this file except in compliance with the License.
           You may obtain a copy of the License at
        
               http://www.apache.org/licenses/LICENSE-2.0
        
           Unless required by applicable law or agreed to in writing, software
           distributed under the License is distributed on an "AS IS" BASIS,
           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
           See the License for the specific language governing permissions and
           limitations under the License.
License-File: LICENSE
Keywords: ai-agents,authorization,fastapi,jwt,middleware,mudraid,platform,starlette
Classifier: Development Status :: 5 - Production/Stable
Classifier: Framework :: FastAPI
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: cryptography>=50.0.0
Requires-Dist: httpx<1,>=0.27
Requires-Dist: pyjwt[crypto]<3,>=2.13.0
Requires-Dist: pyyaml<7,>=6.0
Requires-Dist: starlette<2,>=0.37
Provides-Extra: dev
Requires-Dist: fastapi<1,>=0.110; extra == 'dev'
Requires-Dist: pytest-asyncio<2,>=1.0; extra == 'dev'
Requires-Dist: pytest-cov<8,>=7; extra == 'dev'
Requires-Dist: pytest<10,>=9.0.3; extra == 'dev'
Requires-Dist: respx<1,>=0.21; extra == 'dev'
Requires-Dist: tomli<3,>=2; (python_version < '3.11') and extra == 'dev'
Description-Content-Type: text/markdown

# mudraid-platform-middleware

FastAPI / Starlette middleware for [MudraID](https://mudraid.ai) — a trust
layer for AI agents.

Drop it into your FastAPI app, point it at your `mudraid_scopes.yaml`,
and every scope-gated route is enforced before reaching your handler.
**No decorators, no per-route auth code, zero changes to existing route files.**

```python
from fastapi import FastAPI
from mudraid_platform_middleware import MudraIDMiddleware

app = FastAPI()
app.add_middleware(MudraIDMiddleware)

@app.get("/api/v1/items")
def list_items():
    return {"items": [...]}   # gets to here only after JWT + scope check pass
```

That's the entire integration. Two lines plus a YAML file in your
project root.

---

## What the middleware actually does

For every incoming request:

1. **Match** `(method, path)` against rules from `mudraid_scopes.yaml`.
2. **Bypass** routes flagged `public: true` (health checks, etc.).
3. **404** routes flagged `skip: true` or absent from the YAML —
   they're invisible to agents.
4. **Extract** the `Authorization: Bearer <jwt>` header.
5. **Verify** signature, `iss`, `aud == platform_id`, `exp`, `nbf`, `iat`
   using MudraID's JWKS (cached 1 h; reactive-refresh on unknown `kid`
   so MudraID key rotation is invisible).
6. **Check** the route's required scope is in the JWT's `scopes` claim.
7. **Forward** to the route handler if every gate passes; otherwise
   return a structured `{"error_code", "message"}` 401 / 403 / 404 / 500
   without the handler ever being called.

All of this happens before your route code runs — your handler only
sees authenticated, authorised, scope-checked requests.

---

## Installation

```bash
pip install mudraid-platform-middleware
```

Requires Python 3.10+. Brings in `pyjwt[crypto]`, `cryptography`,
`httpx`, `pyyaml`, and `starlette` as runtime deps.

> **1.1.0 is not on PyPI yet.** Install from source until the first
> upload lands:
> ```bash
> pip install -e sdks/mudraid-middleware-python  # from the repo root
> ```

---

## Quickstart

### 1. Register your platform on MudraID

Sign in to the MudraID portal (or call the API), create a new
platform, verify your domain ownership (DNS TXT record), and define
the scopes your routes will require.

### 2. Download `mudraid_scopes.yaml`

The portal generates a file mapping every one of your routes to a
scope, a `public: true` bypass, or a `skip: true` 404. Drop it into
your project root next to `main.py`.

```yaml
platform_id: 4f8e9c1d-2b4f-5e6a-7b8c-9d0e1f2a3b4c
version: 1
routes:
  - method: GET
    path: /health
    public: true
  - method: GET
    path: /api/v1/items
    scope: items:read
  - method: GET
    path: /api/v1/items/{item_id}
    scope: items:read
  - method: POST
    path: /api/v1/items
    scope: items:write
```

### 3. Add two lines to your FastAPI app

```python
from fastapi import FastAPI
from mudraid_platform_middleware import MudraIDMiddleware

app = FastAPI()
app.add_middleware(MudraIDMiddleware)
```

That's the entire change.

Your existing route handlers stay untouched — no decorators, no auth
parameters, no per-route checks. The middleware enforces the rules
in `mudraid_scopes.yaml` before requests reach them.

---

## Configuration reference

| Setting | Env var | Constructor kwarg | Default |
|---|---|---|---|
| YAML path | — | `scopes_yaml_path=` | `./mudraid_scopes.yaml` (cwd) |
| MudraID JWKS URL | `MUDRAID_JWKS_URL` | `jwks_url=` | `https://api.mudraid.ai/.well-known/jwks.json` |

Everything else (cache TTLs, clock-skew leeway, request-body limits)
is internal and stable in v1.

### V2 mode (`mode="v2"`) — full action enforcement

V2 adds signed-bundle action enforcement on top of V1's token and scope
checking: every `tools/call` on a protected surface resolves to a canonical
action and gets a live authority decision, and anything that cannot be decided
is denied rather than allowed.

`HttpDecideClient` is the supported implementation — it fetches and verifies the
signed bundle, keeps it refreshed, resolves tool names to canonical actions, and
makes the authenticated `/decide` call.

Two settings configure it, and selecting an environment means changing them —
never changing the package, the build or the code path:

| Setting | What it is |
|---|---|
| `MUDRAID_BASE_URL` | The MudraID origin for your environment. The client derives every path it needs from this. |
| `MUDRAID_ADAPTER_TOKEN` | Your adapter's bearer, shown once at registration. It must differ between environments — reusing a staging credential in production breaks environment isolation. |

Both are printed by the MudraID portal when you register an adapter. You do not
configure a signing secret or a service secret: bundle signatures are verified
with public keys the client fetches for itself.

```python
from mudraid_platform_middleware import HttpDecideClient, MudraIDMiddleware, V2Config

decide_client = HttpDecideClient(
    base_url=os.environ["MUDRAID_BASE_URL"],
    adapter_token=os.environ["MUDRAID_ADAPTER_TOKEN"],
)

@app.on_event("startup")
async def _start_enforcement() -> None:
    # Fetches and verifies the first bundle, then refreshes in the background.
    # Until one verifies, protected surfaces fail CLOSED — never open.
    await decide_client.start()

@app.on_event("shutdown")
async def _stop_enforcement() -> None:
    await decide_client.aclose()

app.add_middleware(
    MudraIDMiddleware,
    mode="v2",
    v2=V2Config(decide_client=decide_client, protected_paths=("/mcp",)),
)
```

> **Staging-qualified, not generally production-ready.** The decision exchange
> is versioned in both directions and every response is bound to the request that
> asked for it, but the response is authenticated by the transport alone. A
> signed decision response is required before this is described as a finished
> public package. Deploy it behind a version you control, and measure it
> end-to-end against your own authority first.

| Setting | `V2Config` field | Default |
|---|---|---|
| Protected surfaces | `protected_paths=` | `None` (every route is protected) |
| Bounded body limit | `max_body_bytes=` | `1048576` (1 MiB) — Kong defaults to 128 KiB |
| Control/discovery allowlist | `public_methods=` | `DEFAULT_PUBLIC_METHODS` |
| `/decide` deadline | `decide_timeout_sec=` | `2.0` |

**`protected_paths` matches whole path segments, not characters.** A configured
`/mcp` protects `/mcp`, `/mcp/` and `/mcp/tools` — and does *not* protect
`/mcpfoo` or `/mcp-metrics`, which are different routes that merely start with
the same letters:

| request | `/mcp` configured |
|---|---|
| `/mcp` · `/mcp/` · `/mcp/tools` · `/mcp//tools` | protected |
| `/mcp?x=1` · `/%6dcp/messages` · `/mcp/../mcp/tools` | protected — every spelling is tested |
| `/mcpfoo` · `/mcp-evil` · `/mcpevil/steal` · `/MCP` | **not** protected |

The Kong plugin applies the identical rule, and a contract test runs this table
through both implementations so they cannot drift apart.

Entries are validated at construction. A prefix whose meaning depends on
interpretation — `/mcp/../admin`, `/%6dcp`, `/mcp?x=1` — raises `ValueError`
there rather than resolving to something you did not write. A trailing slash is
accepted and normalized away.

**`public_methods` differs from the Kong plugin's default, deliberately.** This
middleware defaults to the portable contract's allowlist — `initialize`, `ping`,
`tools/list`, `resources/list`, `prompts/list` — while `mudraid-enforce`'s
schema defaults to the narrower `initialize`, `ping`, `tools/list`. A Kong
surface left on its default therefore **denies** `resources/list` and
`prompts/list` (403 `ENFORCE_MESSAGE_NOT_ALLOWED`) where this middleware on its
default passes them.

If you need the two adapters to agree, set it explicitly on both rather than
relying on either default:

```python
from mudraid_platform_middleware.v2 import KONG_DEFAULT_PUBLIC_METHODS

V2Config(decide_client=client, public_methods=KONG_DEFAULT_PUBLIC_METHODS)
```

An empty set is honoured as an empty set — the strictest configuration, where
every message other than `tools/call` and `notifications/*` denies.

**Two defaults differ between the adapters**, and both are configurable on both
sides. If you rely on a workload behaving identically on Kong and here, set them
explicitly rather than trusting either default:

| Setting | Kong plugin | This middleware |
|---|---|---|
| `public_methods` | `initialize`, `ping`, `tools/list` | those plus `resources/list`, `prompts/list` |
| body limit | 128 KiB | 1 MiB |

A contract test pins this inventory, so a change to either default fails until
this table is updated in the same commit.

**`decide_timeout_sec` is the middleware's own deadline**, applied around your
`DecideClient` whether or not it sets one of its own. It expires deny-closed
(503 `ENFORCE_DECIDE_UNAVAILABLE`), matching the plugin's `decide_timeout_ms`
default of 2000. Set it to `None` only if your client is known to bound itself.

```python
# Local development against the docker-compose stack:
app.add_middleware(
    MudraIDMiddleware,
    scopes_yaml_path="./mudraid_scopes.yaml",
    jwks_url="http://localhost:8011/.well-known/jwks.json",
)
```

---

## Error responses

All errors come back as a single JSON shape so platforms can build
alerting on a stable contract:

```json
{
  "error_code": "MISSING_SCOPE",
  "message": "required scope 'items:write' not present in token"
}
```

| Status | `error_code` | Cause |
|---|---|---|
| 401 | `MISSING_TOKEN` | `Authorization` header missing or not `Bearer` |
| 401 | `INVALID_TOKEN` | Malformed JWT or invalid signature |
| 401 | `EXPIRED_TOKEN` | `exp` claim is in the past |
| 401 | `TOKEN_NOT_YET_VALID` | `nbf` claim is in the future |
| 401 | `WRONG_AUDIENCE` | `aud` doesn't match this platform's `platform_id` |
| 401 | `WRONG_ISSUER` | `iss` is not `mudraid-identity` |
| 403 | `MISSING_SCOPE` | JWT valid but required scope absent |
| 404 | `ROUTE_NOT_FOUND` | No YAML rule OR `skip: true` (intentionally indistinguishable) |
| 500 | `JWKS_UNAVAILABLE` | Couldn't fetch JWKS to verify (operator-side, not credential-side) |
| 500 | `MIDDLEWARE_NOT_READY` | YAML couldn't be loaded or parsed |

Behind that contract is a unit suite covering every failure shape, the JWKS
rotation and rate-limit paths, concurrency safety, and an anti-leak guarantee
that no JWT or secret ever appears in middleware logs. Run it with
`pytest` from `sdks/mudraid-middleware-python` for the current count — a number
written here goes stale the first time anyone adds a test, and a stale number
reads as a measurement.

---

## Diagnostics

Enable the middleware's structured logs to watch enforcement happen:

```python
import logging
logging.getLogger("mudraid_platform_middleware").setLevel(logging.INFO)
```

Bootstrap, JWKS fetches, 401 retries, and 500-level events surface at
INFO/WARNING.

---

## Performance

Per-request overhead the middleware adds on top of a vanilla FastAPI
handler, measured against the sample-platform route shape with a
warm JWKS cache. Numbers are µs of wall time per request, sequential
(single-process — capacity-planning numbers, not throughput).

| Route type                  | Middleware p50 | Middleware p99 | Delta vs. bare app (p50) |
|-----------------------------|---------------:|---------------:|-------------------------:|
| `public: true`              |         527 µs |         811 µs |                  +130 µs |
| Scope-gated (RS256 + scope) |         722 µs |        1403 µs |                  +310 µs |

> Measured on Python 3.14, Windows 11, 2000 iterations per scenario,
> 200-iteration warm-up. Reproduce with
> `python -m benchmarks.middleware_overhead --iters 2000` from the
> package root.

The scope-gated delta is dominated by RS256 signature verification.
JWKS fetch happens once at first request and is not part of the
steady-state cost.

---

## Operator playbook

### Updating scopes / routes

The middleware loads `mudraid_scopes.yaml` once at first request and
holds the result in memory. To pick up YAML changes: **redeploy**
(or restart your process). Hot-reload is intentionally not supported
in v1 — the single-source-of-truth contract between portal and
running middleware is easier to reason about with a restart in the
middle.

### MudraID key rotation

When MudraID rotates its signing key, the middleware:

1. Receives a JWT signed under the new `kid`
2. Looks up the `kid` in its cached JWKS — not found
3. Re-fetches JWKS (single in-flight refresh under contention)
4. Verifies against the new key — success

**Zero operator intervention required.** Locked by integration tests
and the unit-level "unknown-kid reactive refresh" contract.

### JWKS endpoint unreachable

The middleware returns `500 JWKS_UNAVAILABLE` for affected requests.
The failure is logged at WARNING. The cache is **not** invalidated on
failure — a transient network blip doesn't take down every cached
key.

The endpoint is **not re-dialled once per request** while it is down. A fetch
that teaches the client nothing — one that failed, or one that returned a key
set identical to the cache it replaced — arms a short backoff (30 s by default,
`refresh_cooldown_sec=`). A fetch that *changes* the key set clears it, so a real
rotation is picked up at full speed and the unknown-kid refresh contract is
unaffected.

What the backoff bounds is a caller inventing `kid` values: without it, every
unverified bearer token could force one outbound request to MudraID's key
endpoint. Outcomes are unchanged — an unknown kid was a refusal before and still
is.

One consequence worth knowing: if the cache is **past its TTL** and the client is
in backoff, requests are refused rather than served from the expired cache.
Serving it would extend the lifetime of every key in it, including one rotated
*out*.

### Misconfigured `mudraid_scopes.yaml`

The middleware lazily loads the YAML on first request. A schema
error returns `500 MIDDLEWARE_NOT_READY` and is logged at ERROR. The
failure is **not** cached — once you fix the YAML, the next request
succeeds without a restart.

---

## Try it locally

A runnable sample platform ships in [`examples/sample-platform/`](../../examples/sample-platform/).
It's a minimal FastAPI app with the middleware applied, callable
from the matching sample agent in
[`examples/sample-agent/`](../../examples/sample-agent/).

```bash
# From the repo root:
docker compose up -d                                       # backend
docker compose --profile samples up -d sample-platform     # this middleware in action

curl http://localhost:8020/health
# → {"status":"ok"}             (public route, no JWT required)

curl http://localhost:8020/api/v1/items
# → 401 {"error_code":"MISSING_TOKEN", "message":"..."}
```

The sample-platform README walks through the full setup including
the manual `platform_id` swap before first run.

---

## How it fits into the wider system

```
        agent making a request               your FastAPI app
        ─────────────────────────             ────────────────────────
        agent.get(url) ──── HTTP ────► MudraIDMiddleware
                                           │
                                           ▼
                                       (verify JWT + check scope)
                                           │
                                           ▼
                                       your route handler
                                           │
                                           ▼
                                       response

        ↕
        ┌──────────────────────────┐
        │     MudraID backend       │
        │  /auth/token + /jwks      │
        └──────────────────────────┘
```

The matching client-side package is
[`mudraid-sdk`](../mudraid-sdk-python/) for Python agents.

---

## License

Apache 2.0 — see [LICENSE](LICENSE).
