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.

IETF I-D SOC 2 readiness mapping Apache 2.0 Protocol v1.0

Current public releases

Verified against npm, PyPI, and the Go module proxy on 12 July 2026. Grantex packages are independently versioned.

Known published-package limits: Go SDK v0.1.10 needs workarounds for agent IDs and write payloads, audit writes, reads, and filters, reserved query values, and list metadata. MCP Auth 2.0.2 is single-process evaluation software with in-memory code state, no rendered consent page, and an incomplete backend code handoff. Repository progress (not published): source on 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.

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.

👤
Human Approves
"read contacts only"
🤖
Agent Gets Token
JWT with scopes [read:*]
🔧
Tool Call
delete_contact
🛑
enforce() → DENIED
read scope ≠ delete permission
Bring Your Own Manifest

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")
Bring Your Own Manifest
Define manifests for any connector — internal APIs, new SaaS tools, anything. No dependency on a prebuilt Grantex connector.
enforce()
Verify JWT claims and check tool permission via a manifest at the configured enforcement boundary.
wrapTool()
Wrap LangChain tools with auto scope enforcement. Denied tools throw.
Express / FastAPI
enforceMiddleware() for Express. GrantexEnforcer dependency for FastAPI.
Permission Hierarchy
admin > delete > write > read. Write scope covers read tools.
Permissive Mode
Log-only mode for migration. See what would be denied without blocking.
CLI: manifest generate
Auto-generate manifests from connector source code. Review and commit.

Works with any connector. 53 pre-built manifests included to get you started:

Salesforce HubSpot Jira Stripe SAP S3 Gmail Slack GitHub NetSuite Oracle Okta Zendesk +40 more
Custom Manifests Guide Scope Enforcement AgenticOrg Case Study

"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.

18.1M
API keys stolen
in 2025 (SpyCloud)
29M
Secrets on GitHub
new in 2025 (+34% YoY)
29 min
Avg. breakout time
access → lateral movement
4 min
Fastest breach recorded
access → exfiltration

Confirmed 2025–2026 incidents

CISA ALERT

Shai-Hulud worm — 500+ npm packages, 2.6B weekly downloads. Stole all cloud credentials from CI runners.

FEB 2026

SANDWORM_MODE — 19 malicious npm packages installed rogue MCP servers in Claude Code, Cursor, and Windsurf. Targeted API keys from 9 LLM providers.

CENSYS

OpenClaw — 21,639 exposed instances publicly leaking OAuth tokens and plaintext credentials.

CVE

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?

Hypothetical scenario

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.

OWASP

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.

EU AI ACT

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.

NIST

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.

1

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.

2

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.

3

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).

4

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.

5

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']
}

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.

👤
Human Principal
Issues passport
via Grantex dashboard
did:grantex:user_alice
📜
AgentPassportCredential
W3C VC 2.0 · Ed25519 signed
Categories + limits + delegation
inference compute 50 USDC
🤖
AI Agent
Attaches passport to
MPP payment request
X-Grantex-Passport: ey...
🏪
Merchant
Verifies locally
with cached JWKS
✓ valid · alice · acme.com
📊
Audit
Configured events logged
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.

Merchant-side: one line
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)
Agent-side: issue + attach
const passport = await grantex.passports.issue({
  agentId: 'ag_01HXYZ...',
  grantId: 'grnt_01HXYZ...',
  allowedMPPCategories: ['inference', 'compute'],
  maxTransactionAmount: { amount: 50, currency: 'USDC' },
});
const mw = createMppPassportMiddleware({ passport });
Read the docs → Try the demo Learn more

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.

👤
Principal
Issues delegation
scope + spend limit
issueGDT()
📜
GDT Token
W3C VC 2.0 · Ed25519 signed
Scope + spend limit + expiry
weather:read $10 USDC/24h
🤖
AI Agent
Sends request with GDT
Handles 402 → pay → retry
X-Grantex-GDT: eyJ...
💰
Base L2 Pay
USDC transfer
on-chain
API Verifies
Checks GDT signature
scope + spend limit
✓ authorized · $9.999 left

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.

Issue a delegation token
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,
});
Protect your API
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]
Read the docs → Try the playground Learn more

Runnable code you can copy

End-to-end examples for every SDK and framework integration. Clone the repo, start the local stack, and run.

TypeScript

Quickstart

Core authorization lifecycle — register agent, authorize, exchange code, verify the token locally using JWKS, log an audit entry, and revoke.

@grantex/sdk
Python

Quickstart

Same core flow in Python — register, authorize, exchange, verify locally using JWKS, audit, and revoke using the Python SDK.

grantex
TypeScript

LangChain Agent

Scoped tools with automatic audit callbacks. Create tools via createGrantexTool, attach audit handler, invoke.

@grantex/sdk @grantex/langchain
TypeScript

Vercel AI Chatbot

Vercel AI SDK tools with Zod schemas, scope enforcement, and withAuditLogging wrapper. Works with generateText.

@grantex/sdk @grantex/vercel-ai
Python

CrewAI Agent

CrewAI tools with local JWKS-backed scope enforcement and audit logging. Demonstrates PermissionError on unauthorized scopes.

grantex grantex-crewai
Python

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.

grantex grantex-openai-agents
Python

Google ADK

Google Agent Development Kit tools with Grantex scope enforcement. Plain functions with docstrings — no decorator needed.

grantex grantex-adk
Python

Strands Agents

Strands tools with Grantex scope enforcement at creation time. Supports local JWKS-backed JWT scope checks and online client.enforce() verification.

grantex grantex-strands
Go

Quickstart

Core authorization lifecycle in Go — register agent, authorize, exchange code, verify the token locally using JWKS, log an audit entry, and revoke.

grantex-go
TypeScript

Anthropic Tool Use

Anthropic SDK tool use with Grantex scope enforcement and audit logging. Uses GrantexToolRegistry to manage tools and dispatch tool_use blocks.

@grantex/sdk @grantex/anthropic
TypeScript

Next.js Starter

Interactive Next.js app with the full Grantex consent flow — agent registration, consent UI, token exchange, and audit logging.

@grantex/sdk next
TypeScript

Multi-Agent Delegation

Delegation chain pattern (SPEC §9) — parent delegates scoped subset to child agent with cascade revocation.

@grantex/sdk
TypeScript

Multi-Agent Email Flow

Agent-to-agent email automation with delegation, scope enforcement, failure handling, cascade revocation, and audit trail inspection.

@grantex/sdk
Python

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.

grantex-gemma
TypeScript

x402 Payment Protocol

AI agent uses a Grantex Delegation Token with x402 to fetch paid API data — automatic 402 → pay → retry flow.

@grantex/x402
TypeScript

Token Expiry & Refresh

Time-bound grant tokens with automatic expiry detection, refresh token rotation, and single-use refresh enforcement.

@grantex/sdk
TypeScript

Audit Dashboard

Query, filter, and analyze the audit trail with metrics computation and hash chain integrity verification.

@grantex/sdk
TypeScript

Gateway Proxy

Grantex gateway as a reverse proxy with YAML config and scope enforcement. Authorized requests pass through, unauthorized requests are rejected.

@grantex/sdk @grantex/gateway
TypeScript

Google Calendar Adapter

GoogleCalendarAdapter with automatic grant token verification, scope checking, and audit logging. Shows read-only vs read-write enforcement.

@grantex/sdk @grantex/adapters

Built to enterprise standards

Published security assessment, individual IETF Internet-Draft, open source.

Security assessment

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.

SOC 2 readiness

Control Mapping Published

Controls for Security, Availability, and Confidentiality are mapped to SOC 2 criteria. Formal third-party attestation is not published.

Internal readiness mapping
Open Standard

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.

Testing

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.

29 packages · Current status on GitHub Actions

Join the Grantex community

Connect with developers building the trust layer for AI agents.

Chat

Discord

Ask questions, share what you're building, and get help from the community and maintainers.

Discuss

GitHub Discussions

Propose RFCs, ask design questions, and participate in protocol discussions.

Open Source

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.