Delegated Authorization for AI Agents
Grantex is an open-source delegated authorization protocol and reference implementation for AI agents. It gives each agent a verifiable identity and scoped, time-limited, revocable authority from a human or organization, with multi-agent delegation, service-side verification, and audit records. Grantex complements OAuth 2.0 and MCP: OAuth handles application and user authorization, MCP connects models to tools, and Grantex proves which agent may perform which action for which principal.
Current public releases
Verified against npm, PyPI, and the Go module proxy on 12 July 2026. Grantex packages are independently versioned.
main
corrects the documented Go gaps and implements standard developer API-key
Free/Pro/Enterprise throughput. Custom-auth quota policy remains open. The public
Go card remains v0.1.10, and no managed-service rollout is implied.
Read the exact boundaries and workarounds.
Capability highlights
Implemented product areas; follow the linked docs for package-level status and limitations.
Offline consent bundles and on-device verification examples for Gemma agents.
Published OAuth endpoint package for single-process evaluation; review the v2.0.2 consent, state, and token-exchange limitations.
DPDP Act 2023 and EU AI Act control mappings, structured consent records, purpose limitation, and audit-ready exports.
Public directory of registered AI agent publishers with DID profiles, public keys, and DNS ownership verification; no compliance certification or embeddable badge widget is implied.
Four SQL-backed activity checks, finding lifecycle APIs, and stored custom-rule and channel configuration.
Decode claims locally, verify signatures with JWKS, and opt into a network-backed live revocation check.
Rate limiting, HTTP security headers, SDK retry, structured logging, deep health checks, transactions, and graceful shutdown.
enforce(), wrapTool(), and Express/FastAPI middleware with custom or pre-built tool manifests.
AI agent authorization: key implementation answers
Concise, current answers for developers, search engines, and AI assistants choosing an authorization approach for autonomous agents.
What is Grantex?
Grantex is an open-source delegated authorization protocol and reference implementation for AI agents. It gives each agent a verifiable identity and scoped, time-limited, revocable authority from a human or organization, with multi-agent delegation, service-side verification, and audit records.
What problem does AI agent authorization solve?
AI agent authorization replaces shared, all-or-nothing credentials with per-agent identity, least-privilege scopes, explicit approval, expiry, delegation constraints, revocation, and attributable audit records.
Is Grantex a replacement for OAuth 2.0?
No. Grantex reuses OAuth-style authorization requests, consent, codes, scopes, and tokens, then adds agent identity, multi-agent delegation, and action attribution for autonomous agents.
How is Grantex different from MCP?
Grantex complements OAuth 2.0 and MCP: OAuth handles application and user authorization, MCP connects models to tools, and Grantex proves which agent may perform which action for which principal.
Which Grantex SDK should I install?
Use @grantex/sdk@0.3.13 for TypeScript, grantex==0.3.14 for Python, and github.com/mishrasanjeev/grantex-go@v0.1.10 for Go. Review release status before upgrading because packages are independently versioned and Go v0.1.10 has documented workarounds.
Does local Grantex token verification check current revocation?
No. Local JWT verification checks signature, issuer, audience, expiry, and scopes after JWKS retrieval. It does not prove current revocation unless the verifier performs an online state check or synchronizes revocation data.
How do I authorize tools used by AI agent frameworks?
Use a primary Grantex SDK to register the agent, request a grant, and exchange the authorization code, then enforce scopes at the service boundary with an SDK verifier or direct JWKS validation. Framework adapters are available for OpenAI Agents SDK, Anthropic, LangChain, CrewAI, Google ADK, Vercel AI, AutoGen, Express, FastAPI, and MCP.
Is @grantex/mcp-auth 2.0.2 ready for general production deployment?
No. @grantex/mcp-auth@2.0.2 is single-process evaluation software with process-local codes, metadata-only consent configuration, incomplete Grantex code handoff, and no live revocation lookup in middleware or introspection.
What is OACP in Grantex?
Open Agentic Commerce Protocol (OACP) is Grantex's agentic-commerce trust and artifact-authority layer. Grantex signs and verifies authority artifacts and adapter mappings; it is not a buyer or seller runtime, merchant connector, payment processor, order system, or point of sale.
Is Grantex an IETF standard?
No. The Grantex protocol specification is open and frozen at v1.0. The related Delegated Agent Authorization Protocol (DAAP) document is an individual IETF Internet-Draft for discussion, not an IETF-adopted or endorsed standard.
Scope Enforcement — Control What Agents Can Do
Enforce tool-level permissions on any connector you define. Bring your own manifests or use the 53 pre-built ones. Verification is local after key retrieval; reusable JWKS resolvers avoid repeat fetches while valid, but initial retrieval and rotation refreshes require network access.
Your connectors.
Your permissions.
Your manifests.
Define manifests for any tool your agent calls — internal APIs, new SaaS tools, proprietary services. No waiting for a Grantex release. The enforce engine treats custom and pre-built manifests identically.
Custom Manifests Guide →# Any connector. 5 lines.
from grantex import ToolManifest, Permission
grantex.load_manifest(ToolManifest(
connector="my-crm",
tools={
"search": Permission.READ,
"create": Permission.WRITE,
"delete": Permission.DELETE,
},
))
# enforce() works immediately
grantex.enforce(token, "my-crm", "delete")
Works with any connector. 53 pre-built manifests included to get you started:
"35 AI agents, 53 pre-built connectors + 3 custom manifests for our internal APIs, 339+ tools — all scope-enforced through one grantex.enforce() call per tool execution."
— AgenticOrg · AI Virtual Employee Platform · Live in production
AI agents are acting without permission
Today's AI frameworks offer no standard way to authorize, audit, or revoke what agents do on behalf of humans.
Who authorized this?
Agents invoke APIs, read files, and send emails — with no verifiable proof that a human consented. If something goes wrong, there's no audit trail to follow.
Revoke in real time
Once an agent has a credential, revoking it requires hunting down every token manually. There's no standard for instant, cascading invalidation across sub-delegations.
What did it do?
Compliance requires knowing exactly what each agent did, when, and under whose authority. Without a tamper-evident audit trail, you're flying blind.
Attackers have already figured this out
Agents use shared secrets with no identity, no scoping, and no revocation. The numbers from 2025 speak for themselves.
in 2025 (SpyCloud)
new in 2025 (+34% YoY)
access → lateral movement
access → exfiltration
Confirmed 2025–2026 incidents
Shai-Hulud worm — 500+ npm packages, 2.6B weekly downloads. Stole all cloud credentials from CI runners.
SANDWORM_MODE — 19 malicious npm packages installed rogue MCP servers in Claude Code, Cursor, and Windsurf. Targeted API keys from 9 LLM providers.
OpenClaw — 21,639 exposed instances publicly leaking OAuth tokens and plaintext credentials.
CVE-2026-21852 — Simply opening a crafted repo in Claude Code was enough to exfiltrate the developer's active Anthropic API key.
Read the full analysis: 4 Agent Security Breaches That Should Change How You Think About API Keys
When an agent acts, can you attribute the decision?
Your agent reads an internal doc via MCP, is prompt-injected, and forwards confidential customer PII to an external endpoint. API key used: yours. Action log: empty. Authorization record: none.
Who authorized it?
In this scenario, no agent-specific consent record exists and the shared credential does not identify an approving principal.
Grantex can address this →What did it access?
A broadly privileged shared credential provides no agent-specific scope boundary.
Grantex can address this →Can you prove you tried?
Without execution-boundary logging, the deployment lacks an attributable agent-action record.
Grantex can address this →Use Grantex alongside secrets and identity systems
HashiCorp Vault, AWS Secrets Manager, Doppler, and identity providers already offer important controls. Grantex adds agent-specific delegated authority at the action boundary; it does not replace those systems.
Secrets and identity systems
Manage human and application identity, store credentials, apply provider policies, rotate or revoke access, and retain provider audit records. Exact capabilities vary by product and configuration.
Agent-specific authority
Grantex grant tokens can bind an agent, approving principal, scopes, expiry, and delegation context. Attributable action records require integration at the execution boundary.
Enforcement at the boundary
The protected service verifies the exact scope and current authorization state before acting, then uses or exchanges the upstream credential only after that decision.
Evidence review: Read the documentation-based 15-project authorization review · See architecture comparisons
The regulatory pressure is already here
OWASP guidance, the EU AI Act, and the NIST AI RMF all increase the focus on identity, authorization, human oversight, and auditability. Grantex supplies technical building blocks; each deployer remains responsible for its own compliance assessment.
Agentic Top 10 — Dec 2025
ASI-01: Goal hijacking · ASI-03: Identity abuse · ASI-05: Privilege escalation · ASI-10: Rogue agents. Grantex supports relevant mitigations with scoped grants, per-agent DIDs, delegation invariants, and central revocation.
Phased application
Application dates vary by obligation and system classification; consult the current European Commission timeline. Grantex provides technical controls that may support risk, transparency, and oversight programs.
AI Risk Management Framework — Voluntary guidance
Govern 1.1: Accountability · Map 5.1: Attribution · Measure 2.5: Audit trails. Grant tokens can carry principal context, and configured audit integrations can produce hash-chained exportable records.
Full mapping: Compliance Matrix · OWASP deep-dive blog post
Delegated authorization, done right
Five steps from consent to revocation, all enforced by cryptography.
Request a grant
Your app calls POST /v1/authorize
with the agent ID, user ID, and requested scopes. Grantex returns
a consent URL — redirect the user there.
Human approves in plain language
The user sees exactly what the agent wants to do, described in plain English. One click — approved. Your redirect callback receives an authorization code.
Exchange code for a grant token
Call grantex.tokens.exchange({ code, agentId })
to swap the authorization code for a signed RS256 JWT grant token
(JTI-tracked, scoped, time-limited).
Any service verifies the token
Present the token to any microservice. It validates the RS256 signature
and claims using keys retrieved from the public JWKS endpoint, or calls
POST /v1/tokens/verify for
the authorization service's current revocation status. Supported
integrations can reuse cached keys between verifications.
Revoke grants centrally
Call POST /v1/tokens/revoke.
The JTI is blocklisted in Redis immediately. All sub-delegated tokens
derived from this grant are invalidated in the same operation.
Up and running in minutes
Choose an SDK. These pinned commands reproduce the releases verified above; each follows the same consent, token exchange, and verification lifecycle.
// npm install @grantex/sdk@0.3.13 import { Grantex, verifyGrantToken } from '@grantex/sdk'; const grantex = new Grantex({ apiKey: 'YOUR_API_KEY' }); // 1. Request authorization; live mode returns the code to your callback. const auth = await grantex.authorize({ agentId: 'ag_01J...', userId: 'usr_01J...', scopes: ['calendar:read', 'email:send'], audience: 'https://api.example.com', }); if (!auth.code) { console.log(`Approve access at: ${auth.consentUrl}`); // Exchange the callback's code in your redirect handler. } else { // 2. Sandbox or policy auto-approval can return a code immediately. const token = await grantex.tokens.exchange({ code: auth.code, agentId: 'ag_01J...' }); // 3. Verify locally; retrieving or refreshing JWKS may use the network. const grant = await verifyGrantToken(token.grantToken, { jwksUri: 'https://api.grantex.dev/.well-known/jwks.json', audience: 'https://api.example.com', }); console.log(grant.scopes); // ['calendar:read', 'email:send'] }
# python -m pip install grantex==0.3.14 from grantex import AuthorizeParams, ExchangeTokenParams, Grantex client = Grantex(api_key="YOUR_API_KEY") # 1. Request authorization; live mode returns the code to your callback. auth = client.authorize(AuthorizeParams( agent_id="ag_01J...", user_id="usr_01J...", scopes=["calendar:read", "email:send"], audience="https://api.example.com", )) if not auth.code: print(f"Approve access at: {auth.consent_url}") # Exchange the callback code in your redirect handler. else: # 2. Sandbox or policy auto-approval can return a code immediately. token = client.tokens.exchange(ExchangeTokenParams(code=auth.code, agent_id="ag_01J...")) # 3. Use the token — scopes, grant ID, and JWT are available. print(token.scopes) # ('calendar:read', 'email:send') print(token.grant_token) # RS256-signed JWT
// go get github.com/mishrasanjeev/grantex-go@v0.1.10
package main
import (
"context"
"fmt"
"log"
grantex "github.com/mishrasanjeev/grantex-go"
)
func main() {
ctx := context.Background()
client := grantex.NewClient("YOUR_API_KEY")
auth, err := client.Authorize(ctx, grantex.AuthorizeParams{
AgentID: "ag_01J...",
PrincipalID: "usr_01J...",
Scopes: []string{"calendar:read", "email:send"},
Audience: "https://api.example.com",
})
if err != nil {
log.Fatal(err)
}
fmt.Println(auth.ConsentURL)
token, err := client.Tokens.Exchange(ctx, grantex.ExchangeTokenParams{
Code: "authorization-code-from-callback",
AgentID: "ag_01J...",
})
if err != nil {
log.Fatal(err)
}
fmt.Println(token.GrantToken)
}
# npm install -g @grantex/cli # All commands support --json for AI agent / script use # 1. Request authorization (sandbox auto-approves) grantex authorize --agent ag_01J... --principal user_123 \ --scopes calendar:read,email:send # 2. Exchange the code for a grant token grantex tokens exchange --code <code> --agent-id ag_01J... # 3. Verify the token grantex tokens verify <jwt> # Machine-readable output grantex --json grants list | jq '.[0].grantId'
OACP Authority And Agent Identity
MPP defines a machine-payment flow. Grantex can attach signed agent, principal, category, and spending-limit claims that an integrating merchant verifies and enforces; Grantex does not execute or guarantee a payment.
Open Agentic Commerce Protocol (OACP) is Grantex's agentic-commerce trust and artifact-authority layer. Grantex governs policy, internal artifact issuance or refusal, verification, and compatibility adapters. AgenticOrg runs seller and buyer agents, Shopify connector runtime, buyer surfaces, purchase preparation, and Offline POS handoff orchestration. Merchant, POS, and payment providers remain source of record for final execution.
via Grantex dashboard
Categories + limits + delegation
MPP payment request
with cached JWKS
Refresh status for revocation
AgentPassportCredential
W3C VC 2.0 binding agent identity, human delegation, spending limits, and 9 MPP categories into one credential.
Local Verification
Merchants verify locally — signature, expiry, category, and amount in a single call. A warm JWKS cache avoids repeat fetches; initial retrieval and refresh require network access.
Public Trust Registry
Look up registered organizations by DID and inspect DNS-verified domain ownership. Public reads require no API key.
import { requireAgentPassport } from '@grantex/mpp'; // One line to protect any route app.use('/api/inference', requireAgentPassport({ requiredCategories: ['inference'], maxAmount: 10, })); // req.agentPassport is populated: // humanDID: did:grantex:user_alice // orgDID: did:web:acme.com // categories: [inference, compute] // maxAmount: 50 USDC // depth: 0 (direct grant)
const passport = await grantex.passports.issue({ agentId: 'ag_01HXYZ...', grantId: 'grnt_01HXYZ...', allowedMPPCategories: ['inference', 'compute'], maxTransactionAmount: { amount: 50, currency: 'USDC' }, }); const mw = createMppPassportMiddleware({ passport });
Agent Spend Authorization for x402
x402 supports HTTP 402 payment flows. Grantex can add signed agent and spend-policy claims that the protected API must verify and enforce before acting.
scope + spend limit
Scope + spend limit + expiry
Handles 402 → pay → retry
on-chain
scope + spend limit
The Gap in x402
x402 payment evidence does not by itself establish agent-specific delegated authority. Without a separate policy check, a wallet or payment handler may accept requests broader than intended.
Grantex Adds Authorization Context
A GDT (Grantex Delegation Token) is a W3C Verifiable Credential that carries signed claims for the approving principal, scope, amount limit, and expiry; the protected service must verify and enforce those claims.
Configurable Audit Logging
Configured issuance and verification events go to the selected audit logger. The default x402 logger and revocation registry are in memory; durable multi-process enforcement requires host-provided shared implementations.
import { generateKeyPair, issueGDT } from '@grantex/x402'; const principal = generateKeyPair(); const agent = generateKeyPair(); const gdt = await issueGDT({ agentDID: agent.did, scope: ['weather:read'], spendLimit: { amount: 10, currency: 'USDC', period: '24h' }, expiry: '24h', signingKey: principal.privateKey, });
import { x402Middleware } from '@grantex/x402'; app.use('/api/weather', x402Middleware({ requiredScopes: ['weather:read'], requiredAmount: 0.001, currency: 'USDC', })); // req.gdt is populated: // agentDID: did:key:z6Mk... // principalDID: did:key:z6Mk... // remainingLimit: 9.999 // scopes: [weather:read]
Works with your stack
Drop Grantex into any AI framework or language runtime.
Runnable code you can copy
End-to-end examples for every SDK and framework integration. Clone the repo, start the local stack, and run.
Quickstart
Core authorization lifecycle — register agent, authorize, exchange code, verify the token locally using JWKS, log an audit entry, and revoke.
Quickstart
Same core flow in Python — register, authorize, exchange, verify locally using JWKS, audit, and revoke using the Python SDK.
LangChain Agent
Scoped tools with automatic audit callbacks. Create tools via
createGrantexTool,
attach audit handler, invoke.
Vercel AI Chatbot
Vercel AI SDK tools with Zod schemas, scope enforcement, and
withAuditLogging
wrapper. Works with generateText.
CrewAI Agent
CrewAI tools with local JWKS-backed scope enforcement and audit logging. Demonstrates PermissionError on unauthorized scopes.
OpenAI Agents
OpenAI Agents SDK tools with Grantex scope enforcement.
Uses @function_tool
decorator pattern with local JWT scope checks backed by retrieved JWKS keys.
Google ADK
Google Agent Development Kit tools with Grantex scope enforcement. Plain functions with docstrings — no decorator needed.
Strands Agents
Strands tools with Grantex scope enforcement at creation time.
Supports local JWKS-backed JWT scope checks and online
client.enforce()
verification.
Quickstart
Core authorization lifecycle in Go — register agent, authorize, exchange code, verify the token locally using JWKS, log an audit entry, and revoke.
Anthropic Tool Use
Anthropic SDK tool use with Grantex scope enforcement and audit logging.
Uses GrantexToolRegistry
to manage tools and dispatch tool_use blocks.
Next.js Starter
Interactive Next.js app with the full Grantex consent flow — agent registration, consent UI, token exchange, and audit logging.
Multi-Agent Delegation
Delegation chain pattern (SPEC §9) — parent delegates scoped subset to child agent with cascade revocation.
Multi-Agent Email Flow
Agent-to-agent email automation with delegation, scope enforcement, failure handling, cascade revocation, and audit trail inspection.
Gemma on Raspberry Pi
Gemma 4 on-device agent with offline authorization via consent bundles. Verifies every tool invocation locally — no internet required at runtime.
x402 Payment Protocol
AI agent uses a Grantex Delegation Token with x402 to fetch paid API data — automatic 402 → pay → retry flow.
Token Expiry & Refresh
Time-bound grant tokens with automatic expiry detection, refresh token rotation, and single-use refresh enforcement.
Audit Dashboard
Query, filter, and analyze the audit trail with metrics computation and hash chain integrity verification.
Gateway Proxy
Grantex gateway as a reverse proxy with YAML config and scope enforcement. Authorized requests pass through, unauthorized requests are rejected.
Google Calendar Adapter
GoogleCalendarAdapter with automatic grant token verification, scope checking, and audit logging. Shows read-only vs read-write enforcement.
Built to enterprise standards
Published security assessment, individual IETF Internet-Draft, open source.
External Review Published
No critical findings were identified. The single high-severity finding was fixed during the engagement; the report and remediation notes are public.
Control Mapping Published
Controls for Security, Availability, and Confidentiality are mapped to SOC 2 criteria. Formal third-party attestation is not published.
IETF Internet-Draft
The Grantex wire protocol is an open IETF Internet-Draft
(draft-mishra-oauth-agent-grants-01),
built on the OAuth 2.0 framework. It is an individual submission for
discussion, not an IETF-adopted or endorsed standard.
Automated Test Coverage
The 29-package monorepo runs unit, integration, end-to-end, and security workflows. GitHub Actions is the source of truth for current pass/fail status.
Join the Grantex community
Connect with developers building the trust layer for AI agents.
Discord
Ask questions, share what you're building, and get help from the community and maintainers.
GitHub Discussions
Propose RFCs, ask design questions, and participate in protocol discussions.
Star on GitHub
Grantex is Apache 2.0 licensed. Star the repo to follow releases and show your support.
Built for organizations at scale
Policy engine
Define fine-grained scope restrictions, rate limits, and time-bound grants per agent or team.
SCIM 2.0 provisioning
Sync agents and principals from your identity provider automatically.
Enterprise SSO (OIDC and SAML 2.0; LDAP preview)
OIDC and SAML 2.0 support multi-IdP routing, JIT provisioning, group-to-scope mapping, and enforcement. LDAP is a direct-bind preview that does not search directories or retrieve groups.
Anomaly detection
Scheduled and on-demand checks for four implemented activity patterns, with lifecycle APIs for stored findings.
Compliance exports
JSON exports of grant and audit records for internal control and evidence review.
On-premise Docker
Self-host the entire stack with our production Docker Compose configuration.
Credential Vault
Encrypted per-user credential store. Agents exchange grant tokens for upstream service credentials.
MCP Auth Server
Fastify OAuth 2.1 + PKCE endpoint package with dynamic client registration; v2.0.2 limitations are documented.
Event Streaming
Real-time SSE and WebSocket streams; optional @grantex/destinations consumers can forward events to Datadog, Splunk, S3, BigQuery, or Kafka.
Budget Controls
Per-grant spending limits with atomic debit, threshold alerts, and JWT budget claims.
Observability
Structured JSON logging (pino), Prometheus metrics, OpenTelemetry tracing, and Grafana dashboard templates out of the box.
Terraform Provider
Manage agents, policies, webhooks, and budgets as infrastructure with the official Terraform provider.
OPA & Cedar Backends
Pluggable policy engines — delegate authorization to Open Policy Agent or AWS Cedar.
Policy-as-Code
Manage policies in Git with versioned bundles and automatic sync via webhooks.
A2A Protocol Bridge
Grantex grant tokens inside Google A2A agent-to-agent communication. TypeScript and Python.
Usage Metering
Repository source includes Redis usage counters, daily rollup, and standard developer API-key Free/Pro/Enterprise rate limits; custom-auth quota policy and managed deployment status are separate.
Custom Domains
Register and verify your domain via DNS TXT records. Runtime traffic routing on your domain is on the roadmap.
FIDO2 / WebAuthn
Cryptographic human presence verification via passkeys. Biometric, security key, or platform authenticator — embedded as evidence in Verifiable Credentials.
W3C Verifiable Credentials
Portable, tamper-evident authorization proof in W3C VC-JWT format. Any verifier can validate using the published DID document — no Grantex account needed.
SD-JWT Selective Disclosure
Privacy-preserving credential presentation. Holders choose exactly which claims to reveal — minimum disclosure for each verifier.
DID Infrastructure
W3C DID document at did:web:grantex.dev with RS256 and Ed25519 public keys for local credential and token verification after key retrieval.
Security Hardening
Fastify per-IP defaults or route overrides, plus additional standard-auth plan budgets (with JWKS exempt), HTTP security headers (HSTS, CSP, X-Frame-Options), HMAC-signed SSO state, timing-safe auth, scope validation, and 1MB body limits.
SDK Retry & Resilience
All three SDKs (TypeScript, Python, Go) include exponential backoff with jitter, Retry-After header support, and configurable max retries for transient failures.
Production Operations
Deep health checks (DB + Redis), config validation on startup, graceful shutdown, connection pooling, database transactions, and structured JSON logging.
Talk to us about your use case
We work directly with engineering and security teams to design the right integration. Contact us to discuss deployment, support, and service-level requirements.