Metadata-Version: 2.5
Name: jwtscope
Version: 1.0.0
Summary: Decode, inspect and verify JSON Web Tokens from the command line or an MCP client.
Project-URL: Homepage, https://github.com/SCGIS-Wales/jwt-decoder
Project-URL: Issues, https://github.com/SCGIS-Wales/jwt-decoder/issues
Author: Dejan Gregor
License-Expression: MIT
License-File: LICENSE.md
Keywords: cli,jose,jwe,jws,jwt,mcp,oauth,oidc
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Topic :: Security :: Cryptography
Classifier: Typing :: Typed
Requires-Python: >=3.13
Requires-Dist: click<9,>=8.5.1
Requires-Dist: pyyaml<7,>=6.0.4
Requires-Dist: tzdata>=2026.6; sys_platform == 'win32'
Provides-Extra: all
Requires-Dist: cryptography>=51.0.0; extra == 'all'
Requires-Dist: joserfc<2,>=1.8.0; extra == 'all'
Requires-Dist: mcp<3,>=2.3.0; extra == 'all'
Requires-Dist: truststore<1,>=0.10.5; extra == 'all'
Provides-Extra: crypto
Requires-Dist: cryptography>=51.0.0; extra == 'crypto'
Requires-Dist: joserfc<2,>=1.8.0; extra == 'crypto'
Requires-Dist: truststore<1,>=0.10.5; extra == 'crypto'
Provides-Extra: mcp
Requires-Dist: cryptography>=51.0.0; extra == 'mcp'
Requires-Dist: joserfc<2,>=1.8.0; extra == 'mcp'
Requires-Dist: mcp<3,>=2.3.0; extra == 'mcp'
Requires-Dist: truststore<1,>=0.10.5; extra == 'mcp'
Provides-Extra: verify
Requires-Dist: cryptography>=51.0.0; extra == 'verify'
Requires-Dist: joserfc<2,>=1.8.0; extra == 'verify'
Requires-Dist: truststore<1,>=0.10.5; extra == 'verify'
Description-Content-Type: text/markdown

# jwtscope

Decode, inspect, verify, sign, encrypt and decrypt JSON Web Tokens from the command line, or let an AI agent inspect them through MCP.

```text
$ jwtd
Paste token, then press Enter (input hidden):
Read 1194 characters.
JWT  RS256  signature NOT verified (decode only)

Summary
  Issuer       Microsoft Entra ID v2.0, tenant 8d3f0c9e-5b1a-4c7d-9e2f-0a1b2c3d4e5f
  Token        access token, application permissions (no user) for api://orders
  Client       3f9a1c2e-7b4d-4e8f-a1b2-c3d4e5f60718, client authentication: certificate
  Granted      roles Orders.Read.All, Orders.Write
  Lifetime     1 h, issued 1 min ago, expires in 59 min
  Verify with  jwtd verify --oidc https://login.microsoftonline.com/<your tenant id>/v2.0 --aud
               <your API>

Header
  typ  JWT
  alg  RS256  RSASSA-PKCS1-v1_5 using SHA-256
  kid  entra-key-1
  x5t  entra-key-1

Claims
  aud         api://orders                                      Audience
  iss         https://login.microsoftonline.com/8d3f0c9e-5b1a-4c7d-9e2f-0a1b2c3d4e5f/v2.0  Issuer
  iat         1796216340  2026-12-02T12:59:00+00:00  Issued at, 1 min ago
  nbf         1796216340  2026-12-02T12:59:00+00:00  Not before, 1 min ago
  exp         1796219940  2026-12-02T13:59:00+00:00  Expires in 59 min
  aio         E2RgYPhpZ3l1cmVkU2Vzc2lvbkRhdGE=                  Session data (internal)
  azp         3f9a1c2e-7b4d-4e8f-a1b2-c3d4e5f60718              Authorized party
  azpacr      2  Client authentication method: certificate
  idtyp       app  Token type (application or user): application only, no user
  oid         6c1d2e3f-4a5b-4c6d-8e7f-90a1b2c3d4e5              Object identifier
  rh          0.ARoAQ29udG9zbw.                                 Refresh hint (internal)
  roles       Orders.Read.All, Orders.Write                     Roles
  sub         6c1d2e3f-4a5b-4c6d-8e7f-90a1b2c3d4e5              Subject
  tid         8d3f0c9e-5b1a-4c7d-9e2f-0a1b2c3d4e5f              Tenant identifier
  uti         c3VwZXJ1bmlxdWU                                   Token identifier (internal)
  ver         2.0                                               Token version
  costCentre  4711                                              custom claim

Status
  ACTIVE, expires in 59 min
```

## Install

```bash
# Install the command as an isolated tool; provides jwtd and jwtscope (decode only)
uv tool install jwtscope
# Or install with pip into the current environment
pip install jwtscope
# Add verification, signing, encryption and decryption (joserfc and cryptography)
pip install "jwtscope[crypto]"
# Add the MCP server as well (includes crypto)
pip install "jwtscope[mcp]"
```

The base install depends only on click and PyYAML. Python 3.13 or later is required.
`jwtscope[verify]` remains as another name for `jwtscope[crypto]`.

## Supported algorithms

| Purpose | Algorithms |
|---|---|
| Decode and describe (JWS) | Every registered JWS algorithm: HS256/384/512, RS256/384/512, PS256/384/512, ES256, ES256K, ES384, ES512, EdDSA, Ed25519, Ed448, ML-DSA-44/65/87; unregistered values are flagged |
| Decode and describe (JWE) | RSA1_5, RSA-OAEP, RSA-OAEP-256/384/512, A128KW/A192KW/A256KW, dir, ECDH-ES (+A128KW/A192KW/A256KW), A128GCMKW/A192GCMKW/A256GCMKW, PBES2-HS256+A128KW/HS384+A192KW/HS512+A256KW; enc A128CBC-HS256, A192CBC-HS384, A256CBC-HS512, A128GCM, A192GCM, A256GCM |
| Verify and sign | HS256, HS384, HS512, RS256, RS384, RS512, PS256, PS384, PS512, ES256 (P-256), ES256K (secp256k1), ES384 (P-384), ES512 (P-521), EdDSA (Ed25519 and Ed448), Ed25519 and Ed448 (RFC 9864), ML-DSA-44, ML-DSA-65 and ML-DSA-87 (FIPS 204 post quantum signatures, RFC 9964 AKP keys) |
| Encrypt and decrypt | Key management RSA-OAEP, RSA-OAEP-256/384/512, ECDH-ES and ECDH-ES+A128KW/A192KW/A256KW (P-256, P-384, P-521, X25519, X448), A128KW/A192KW/A256KW, A128GCMKW/A192GCMKW/A256GCMKW, dir, PBES2-HS256+A128KW/HS384+A192KW/HS512+A256KW; content A128GCM, A192GCM, A256GCM, A128CBC-HS256, A192CBC-HS384, A256CBC-HS512 |
| Decrypt only | RSA1_5, with a warning (switch it off with `jwe.allow_rsa1_5_decrypt: false`); compressed content (`zip: DEF`) |

`none` can never be verified or signed. jwtscope never encrypts with RSA1_5 and never
compresses what it encrypts. The tests replay the published examples of RFC 7520, RFC 8037
and RFC 9964, and exchange tokens with PyJWT and jwcrypto in both directions.

## Decode a token

```bash
# Paste at a hidden prompt (works for tokens longer than the terminal line limit)
jwtd
# Decode a token given as an argument; a Bearer prefix or Authorization header is fine
jwtd "Authorization: Bearer eyJhbGciOi..."
# Decode the token on the clipboard (pbpaste, PowerShell Get-Clipboard, wl-paste or xclip)
jwtd -c
# Decode from a pipe, or a JSON token response containing access_token or id_token
curl -s https://idp.example/token -d ... | jwtd
# Decode a token saved in a file (a byte order mark and Windows line endings are fine)
jwtd @token.txt
# Print the report as JSON, with times in a named zone or a fixed offset
jwtd --json --tz Europe/London "$TOKEN"
# Print single values for scripts: text as is, lists and objects as JSON
jwtd --get oid --get header.kid "$TOKEN"
# Exit with status 5 when the token is expired or not yet valid
jwtd --require-active "$TOKEN" > /dev/null && echo "still valid"
```

`jwtd decode [TOKEN]` is the explicit form. Options: `-c/--clipboard`, `--json`,
`--get NAME` (repeatable; a claim, or `header.NAME`), `--require-active`, `--no-summary`,
`--tz ZONE` (`utc`, `local`, an offset such as `+02:00`, or an IANA name such as
`Europe/London`), `--no-colour` (alias `--no-color`), `--config FILE`. A bare file name is
not read as a token: `jwtd token.txt` answers "token.txt is a file; to read the token in it,
use @token.txt". Colour is used only on a terminal and never when `NO_COLOR` is set. Claim
values are escaped so a token cannot inject terminal control sequences; `--get` prints raw
values to a pipe and escaped values on a terminal. A missing `--get` value exits with
status 1 and prints nothing.

### What the report shows

* **Summary:** who issued the token, what kind it is and for which audience, the user and
  how they signed in, the client and how it authenticated, the scopes or roles granted, the
  lifetime, notes about the issuer, and how to verify it. `--no-summary` or
  `output.summary: false` leaves it out.
* **Recognised issuers:** Microsoft Entra ID v1.0 and v2.0 (national clouds, External ID
  and Azure AD B2C included), Microsoft Graph, AD FS 2012 R2 and AD FS 2016 or later, Okta,
  Auth0, Keycloak, Google, Amazon Cognito, and any access token that follows RFC 9068.
* **Claims:** every claim, labelled. Values with a documented meaning are explained, for
  example `azpacr 2` as "Client authentication method: certificate". Claims nobody
  registered are marked `custom claim` and shown in full, whatever their type: nested
  values become indented trees, and long values wrap without being cut.
* **Times:** NumericDate claims are dated in your zone. ISO 8601 text, such as the AD FS
  2012 R2 `auth_time`, is dated with a note saying so. An `iat` in the future is flagged.
* **Clean input:** zero width spaces, soft hyphens and byte order marks that copying adds
  to a token are removed, with a warning that says how many.

Add labels with `claims`, value descriptions with `claim_values` and your own issuers with
`profiles` in the configuration file. The profile rule language is described at the top of
[profiles.yaml](src/jwtscope/profiles.yaml); your profiles are tried before the packaged ones.

A mistyped command is caught rather than decoded: `jwtd verfy ...` answers
"unknown command 'verfy'; did you mean 'verify'?". `jwtd help [COMMAND]` shows help.
Error messages never repeat a token: anything shaped like one is shown as
`<token redacted>`. Output that a terminal or file cannot encode (for example a legacy
Windows code page) is escaped instead of failing, and `--json` then uses ASCII escapes so
the JSON stays valid. Add `--debug` (or set `JWTSCOPE_DEBUG=1`) to see a traceback after an
unexpected error.

## Verify a token

```bash
# Verify with a PEM or DER public key, or an X.509 certificate
jwtd verify "$TOKEN" --key public.pem
# Verify with a JWKS file; the key is chosen by the token's kid
jwtd verify "$TOKEN" --jwks jwks.json --aud api://orders --iss https://login.example.com/tenant/v2.0
# Verify an HMAC token with a secret held in an environment variable or file
JWT_SECRET=... jwtd verify "$TOKEN" --secret-env JWT_SECRET
jwtd verify "$TOKEN" --secret-file secret.b64 --secret-encoding base64
# Fetch the keys by OpenID Connect discovery, which also pins the issuer (Entra ID v2.0)
jwtd verify "$TOKEN" --oidc https://login.microsoftonline.com/$TENANT_ID/v2.0 --aud api://orders
# Fetch a key set from a URL and pin the tenant (Entra ID v1.0 tokens)
jwtd verify "$TOKEN" --jwks-url https://login.microsoftonline.com/$TENANT_ID/discovery/keys --tenant $TENANT_ID
# AD FS 2016 or later: discovery names both issuers AD FS uses
jwtd verify "$TOKEN" --oidc https://adfs.contoso.com/adfs --aud "$RELYING_PARTY_ID"
# AD FS 2012 R2: give both token signing certificates during a rollover
jwtd verify "$TOKEN" --key adfs-old.cer --key adfs-new.cer --aud "$RELYING_PARTY_ID"
# Require claims: present, equal to text (or one of a list or scope words), or equal as JSON
jwtd verify "$TOKEN" --oidc "$ISSUER" --require-claim tid --require-claim scp=orders.read --require-claim 'acct:=0'
```

Give keys with `--key`, `--jwks` and `--jwks-url` (all repeatable) or `--oidc`, which
combine, or an HMAC secret with `--secret-env` or `--secret-file`. The key is chosen by the
token's `kid`, then `x5t`,
then `x5t#S256`, so an AD FS signing certificate rollover works when both certificates are
given. Other options: `--secret-encoding [utf8|base64|base64url|hex]`, `--alg ALG`
(repeatable; narrows the allow list), `--aud` and `--iss` (repeatable; one match is enough),
`--tenant TENANT_ID` (repeatable; accepts that tenant's Microsoft Entra ID issuers, v1.0,
v2.0 and the national clouds), `--require-claim CLAIM` (repeatable; `NAME`, `NAME=TEXT` or
`NAME:=JSON`, added to `verify.required_claims`),
`--leeway SECONDS` (default 0), `--ignore-exp`, `--decrypt-key FILE` (repeatable) and
`--decrypt-password-env NAME` for encrypted tokens, plus every `decode` option. The algorithm
is derived from the key type, so a token cannot choose HS256 against an RSA key. Verification
takes public keys and certificates only: a file holding a private key is refused. On failure the report is still printed, headed "verification FAILED" with the
reason, and the exit code is 3. In `--json` output `signature.state` is `verified`,
`failed` or `not_checked`, `signature.detail` holds the reason, and `signature.checks`
marks the check that failed, for example `"exp": "failed: token expired"`. With `--get`,
values are printed only when verification succeeds.

A tenant ID must be the Directory (tenant) ID, a GUID; a domain name is refused with that
hint. When an Entra token's signature holds but neither `--tenant` nor `--iss` was given,
the report warns that a token from any tenant would have passed. A Microsoft Graph token
cannot be verified outside Graph, because its signature covers a hash of the `nonce`
header: the report says that such a failure is expected.

### Keys from the issuer

`--oidc ISSUER_URL` reads `ISSUER_URL/.well-known/openid-configuration` (the full discovery
URL works too), checks that the document names exactly that issuer, as OpenID Connect
Discovery requires, and verifies with the keys at its `jwks_uri`. The token's `iss` must then
be that issuer, or the `access_token_issuer` an AD FS document also names. The Entra ID
`common`, `organizations` and `consumers` documents name no single issuer, so add `--tenant`
or `--iss` with them. Where a document names an issuer other than its own address (Entra ID
v1.0, Azure AD B2C user flows), `--oidc` refuses it and the message gives its `jwks_uri` for
`--jwks-url`; pin the issuer with `--iss` or `--tenant` then. Each profile's "Verify with"
row shows the right command, with placeholders for your own values.

* **Transport:** HTTPS only, also for redirects (at most three). Certificates are checked
  against the operating system's trust store, which is where corporate TLS inspection
  installs its root; `SSL_CERT_FILE` names a CA bundle to use instead. `HTTPS_PROXY` and
  `NO_PROXY` are honoured. Connection errors, timeouts, HTTP 429 and 5xx are retried with
  backoff, after `Retry-After` when the server sends one. Responses above
  `limits.max_fetch_bytes` are refused.
* **Cache:** only the public keys and the discovery `issuer`, `jwks_uri` and
  `access_token_issuer` are stored, in files only you can read: `~/.cache/jwtscope` (or
  `$XDG_CACHE_HOME/jwtscope`) on Linux, `~/Library/Caches/jwtscope` on macOS and
  `%LOCALAPPDATA%\jwtscope\Cache` on Windows; `JWTSCOPE_CACHE_DIR` overrides it. A copy is
  reused for an hour, or less when the server's `Cache-Control` says so. A token whose `kid`
  is not in the cached keys fetches them again, at most once a minute, so key rotation needs
  no action. When the issuer cannot be reached, keys up to a day old are used with a
  warning.
* **Safety:** the URL always comes from you, never from the token. A key set holding
  private or symmetric key material is refused whole. Fetch problems exit with status 4 and
  say what failed, for example `cannot fetch https://idp.example/keys: HTTP 503 Service
  Unavailable (tried 4 times)`.

## Decrypt a token

```bash
# Decrypt with a private key (PEM, DER or private JWK); the report shows both layers
jwtd decrypt "$TOKEN" --key private.pem
# Decrypt with a shared key for dir, AES key wrap or AES GCM key wrap
jwtd decrypt "$TOKEN" --secret-env JWE_KEY --secret-encoding base64url
# Decrypt a password protected (PBES2) token
JWE_PASSWORD=... jwtd decrypt "$TOKEN" --password-env JWE_PASSWORD
# Decrypt, then verify the inner signature, in one step
jwtd verify "$TOKEN" --decrypt-key private.pem --jwks jwks.json --aud api://orders
```

Options: `--key FILE` and `--jwks FILE` (repeatable; each suitable key is tried),
`--key-password-env NAME`, `--secret-env NAME`, `--secret-file FILE`, `--secret-encoding`,
`--password-env NAME`, plus every `decode` option. `Header` shows the outer JWE header,
`Encryption` the algorithms and the key that worked, and `Inner header` the signed token's
header when the content is a nested JWT; claims, times and status come from the decrypted
content. `jwtd decrypt` never verifies the inner signature: use `jwtd verify --decrypt-key`
for that. Content that is not a signed token is shown with the warning "token is encrypted
but not signed" and can never pass `verify`, because anyone holding the recipient's public
key could have made it. A wrong key exits with code 3 and names the reason.

## Sign or encrypt a token

```bash
# Sign with a private key; the algorithm defaults to one that suits the key
jwtd encode --key private.pem --sub alice --aud api://orders --exp 1h
# Choose the algorithm, add claims and headers, and read base claims from a file
jwtd encode --key ec-p256k.pem --alg ES256K --payload @claims.json --claim 'roles:=["admin"]' --kid k1
# Sign with an HMAC secret from the environment (at least 32 bytes for HS256)
jwtd encode --secret-env JWT_SECRET --alg HS512 --iss https://issuer.example --no-exp
# Sign, then encrypt to a recipient's public key or certificate (a nested JWT)
jwtd encode --key private.pem --sub alice --encrypt-to recipient.crt
# Choose the key management and content algorithms, or encrypt with a password instead
jwtd encode --key private.pem --encrypt-to recipient.pem --key-alg ECDH-ES+A256KW --enc A128GCM
jwtd encode --key private.pem --encrypt-password-env JWE_PASSWORD
```

Options: `--alg ALG`, `--key FILE` (PEM, DER or private JWK, ML-DSA AKP keys included),
`--key-password-env NAME`,
`--secret-env NAME`, `--secret-file FILE`, `--secret-encoding`, `--payload JSON|@FILE|-`,
`--claim` and `--header` (repeatable; `NAME=TEXT` always sets text, `NAME:=JSON` sets a
number, `true`, `false`, `null`, a list or an object, and dotted names such as `extn.dept`
stay one claim),
`--iss`, `--sub`, `--aud` (repeatable), `--jti`, `--kid`, `--typ`, `--exp DURATION`
(for example `15m`, `2h`, `7d`; default from configuration), `--no-exp`, `--nbf DURATION`,
`--no-iat`, `--encrypt-to FILE` (public key, certificate, public JWK or shared `oct` JWK),
`--encrypt-password-env NAME`, `--key-alg ALG` (default `encode.default_key_algorithm` when the
key suits it, otherwise the first suitable entry of `jwe.allowed_key_algorithms`), `--enc ENC`
(default `encode.default_content_algorithm`), `--config FILE`. Signing and encryption are not
available through MCP.

## Use from an AI agent

```json
{
  "mcpServers": {
    "jwtscope": {
      "command": "uvx",
      "args": ["--from", "jwtscope[mcp]", "jwtd", "mcp"]
    }
  }
}
```

* **Claude Code:** put the block in `.mcp.json` at the project root to share it with the
  project, or run `claude mcp add jwtscope -- uvx --from "jwtscope[mcp]" jwtd mcp`
  (add `--scope user` for every project). See the
  [Claude Code MCP documentation](https://code.claude.com/docs/en/mcp).
* **Kiro CLI:** put the block in `.kiro/settings/mcp.json` in the workspace, or in
  `~/.kiro/settings/mcp.json` for every workspace. See the
  [Kiro CLI MCP configuration documentation](https://kiro.dev/docs/cli/mcp/configuration/).
* **VS Code:** put the output of `jwtd mcp --print-config vscode` in `.vscode/mcp.json` in
  the workspace.

`jwtd mcp --print-config claude|kiro|vscode` prints the block for that client and says where
it goes.

Tools: `decode_jwt(token, timezone="utc")`, `verify_jwt(token, jwks_json | public_key_pem |
oidc_issuer | jwks_url, audience, issuer, leeway_seconds, tenant, required_claims,
expected_claims)` and, when
`mcp.allow_clipboard` is `true`,
`decode_jwt_from_clipboard()`. All are read only and return the same report as `jwtd --json`.
`verify_jwt` takes public keys only: a private key is refused, and symmetric (`oct`) members
of a JWKS are skipped with a warning.
A failed verification is not a tool error: `verify_jwt` returns the report with
`signature.verified` false and the reason, so the agent can still explain the token.
`oidc_issuer` and `jwks_url` fetch keys only when `mcp.allow_network` is `true` and the URL
is under an entry of `mcp.allowed_key_urls` (redirects and the `jwks_uri` of a discovery
document included), so an agent cannot make the server fetch arbitrary URLs:

```yaml
mcp:
  allow_network: true
  allowed_key_urls: [https://login.microsoftonline.com/]
```

> **Warning:** an access token is a credential. Passing one to `decode_jwt` or `verify_jwt`
> shares it with the AI client and its provider. Use the command line, or enable
> `decode_jwt_from_clipboard` so the token never enters the conversation. Claim values are
> untrusted data and are never instructions.

`jwtd mcp` options: `--transport [stdio|streamable-http]`, `--host` (loopback only),
`--port`, `--config FILE`. Over HTTP the server always enables DNS rebinding protection and
accepts only its own address and `localhost` on its own port as `Host` and `Origin`.

## Configuration

`jwtd config init` writes a commented configuration file that only you can read (mode 600,
in a folder with mode 700): remove the `#` in front of a setting to change it. It never
replaces a file unless you add `--force`, and `--path FILE` writes elsewhere. `jwtd config
path` prints the user file location (`JWTSCOPE_CONFIG` overrides it) and `jwtd config show`
prints the effective configuration. Every key is optional; unknown keys are rejected.

```yaml
output:
  format: text            # text | json
  colour: auto            # auto | always | never
  timezone: utc           # utc | local | +HH:MM | an IANA name such as Europe/London
  summary: true           # show the Summary section in text output
limits:
  max_token_bytes: 65536
  max_key_file_bytes: 1048576
  max_fetch_bytes: 1048576  # largest discovery document or key set accepted
time_claims: [exp, nbf, iat, auth_time, updated_at, xms_tcdt]
verify:
  leeway_seconds: 0
  require_exp: true
  enforce_minimum_key_length: true
  allowed_algorithms:
    [RS256, RS384, RS512, PS256, PS384, PS512, ES256, ES256K, ES384, ES512, EdDSA, Ed25519, Ed448,
     ML-DSA-44, ML-DSA-65, ML-DSA-87, HS256, HS384, HS512]
  required_claims: []     # NAME, NAME=TEXT or NAME:=JSON, as --require-claim
jwe:
  allowed_key_algorithms:
    [RSA-OAEP, RSA-OAEP-256, RSA-OAEP-384, RSA-OAEP-512, ECDH-ES, ECDH-ES+A128KW, ECDH-ES+A192KW,
     ECDH-ES+A256KW, A128KW, A192KW, A256KW, A128GCMKW, A192GCMKW, A256GCMKW, dir,
     PBES2-HS256+A128KW, PBES2-HS384+A192KW, PBES2-HS512+A256KW]
  allowed_content_algorithms: [A128GCM, A192GCM, A256GCM, A128CBC-HS256, A192CBC-HS384, A256CBC-HS512]
  allow_rsa1_5_decrypt: true   # accepted with a warning; never used to encrypt
encode:
  default_algorithm: RS256
  default_lifetime_seconds: 3600
  default_key_algorithm: RSA-OAEP-256
  default_content_algorithm: A256GCM
fetch:                    # keys from --oidc and --jwks-url, over HTTPS only
  timeout_seconds: 10
  retries: 3              # on connection errors, HTTP 429 and 5xx, with backoff
  cache_ttl_seconds: 3600 # or the server's Cache-Control max-age, when shorter
  max_stale_seconds: 86400  # use cached keys this old, with a warning, when the issuer is down
  min_refresh_interval_seconds: 60  # an unknown kid refreshes the keys at most this often
mcp:
  transport: stdio        # stdio | streamable-http
  host: 127.0.0.1
  port: 8765
  allow_clipboard: false
  allow_network: false    # let verify_jwt fetch keys (oidc_issuer, jwks_url)
  allowed_key_urls: []    # URL prefixes it may fetch from, for example https://login.microsoftonline.com/
logging:
  level: WARNING
claims: {}                # extra claim labels, for example dept: Department
claim_values: {}          # value descriptions, for example dept: {"4711": Finance}
profiles: []              # extra issuer profiles, tried before the packaged ones
```

`jwtd completion bash|zsh|fish` prints a shell completion script for both command names.

## Exit codes

| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Input is not a decodable token, or a `--get` value is missing |
| 2 | Usage error |
| 3 | Verification or decryption failed |
| 4 | Key, configuration or input source error, or keys could not be fetched |
| 5 | Token expired or not yet valid (`--require-active`) |
| 70 | Internal error; run again with `--debug` for details |
| 130 | Interrupted |
| 141 | Output closed early by the reader, for example `jwtd ... \| head -1` |

## Coming from `jwt-cli`

| `jwt-cli` 6.2.0 | `jwtscope` |
|---|---|
| `jwt decode <t>` | `jwtd <t>` |
| `jwt decode -` | `jwtd -`, or a pipe |
| `--date` | Always on; choose the zone with `--tz` |
| `--secret @key.pem` | `jwtd verify --key key.pem` |
| `--secret <text>` | `--secret-env NAME` or `--secret-file FILE` |
| `--ignore-exp` | Unchanged on `verify` |
| `--out FILE` | Shell redirection |
| `jwt encode` | `jwtd encode` (secrets from the environment or a file, never the command line) |

The Rust implementation is kept at tag `rust-6.2.0` for reference only. It is unsupported
and its crates have published security advisories.

## Development

```bash
# Create the environment with every extra and the development tools
uv sync --all-extras
# Run the tests with the coverage gate
uv run pytest --cov=jwtscope --cov-fail-under=95
# Lint, check formatting and type check
uv run ruff check . && uv run ruff format --check . && uv run mypy --strict src
```

Security issues: see [SECURITY.md](SECURITY.md). Licence: [MIT](LICENSE.md).
