LangChain + Grantex

Authorization for LangChain Agents

Add scoped, revocable permissions to your LangChain agents. Grantex integrates natively with LangChain tools — your agents get signed JWTs instead of raw API keys.

The Problem

Without Grantex

Your LangChain agents use raw API keys with full access. No scoping, no audit trail, no way to revoke access if an agent goes rogue. One compromised key exposes everything.

With Grantex

Configured LangChain tools verify scoped, time-limited JWTs against JWKS. An optional audit integration can record selected actions with hash chaining.

How Grantex Works with LangChain

Install the integration

npm install @grantex/langchain — provides wrappers for configured LangChain tools.

Register your agent

Create an agent identity with specific scopes like "email:send" or "calendar:read".

Get user consent

Use the configured authorization URL and host experience to obtain the user's scoped grant decision.

Agent receives a JWT

The agent gets a signed token it presents to any service. Services verify signatures locally using keys obtained from JWKS.

Audit & revoke

Attach the audit integration to record tool calls, and manage grants centrally when access changes.

Quick Start

npm install @grantex/langchain @grantex/sdk
import { createGrantexTool } from '@grantex/langchain';

const calendarTool = createGrantexTool({
  name: 'read_calendar',
  description: 'Read upcoming calendar events',
  grantToken: token,
  requiredScope: 'calendar:read',
  func: async (input) => JSON.stringify(
    await searchTool.invoke(input)
  ),
});

// The token signature and scope are checked before every call
const agent = createToolCallingAgent({
  llm,
  tools: [calendarTool],
  prompt,
});

Why Grantex for LangChain

Native LangChain Integration

Wrap each protected LangChain tool so it verifies the signed grant and required scope before execution.

Scoped Permissions

Define exactly what each agent can do — "email:read" vs "email:send". No more all-or-nothing API keys.

JWKS Verification

Tools verify the JWT signature and claims before execution. Initial and rotated signing keys may require a JWKS fetch.

Multi-Agent Delegation

Parent agents delegate narrower scopes to sub-agents. Central grant state can cascade parent revocation to child grants; local verifiers still need current state.

Audit Integration

Add an audit wrapper or callback to record tool invocations; local authorization alone does not log execution.

Central Grant Management

Revoke grants centrally; local-only JWT consumers should use short token lifetimes or synchronized revocation data.

Verification, revocation, and audit boundary

This integration enforces authorization only where its wrapper or middleware is installed. Local JWT verification checks signatures and claims after JWKS retrieval; it does not prove current revocation unless the verifier performs an online state check or synchronizes revocation data.

Token verification does not create a consent record or prove that a tool executed. Use the configured authorization flow for grant decisions and add an audit integration at the execution boundary when action records are required.

Ready to secure your LangChain agents?

Follow the integration guide and verify the package version before deployment. Apache 2.0.