Add scoped, revocable permissions to your LangChain agents. Grantex integrates natively with LangChain tools — your agents get signed JWTs instead of raw API keys.
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.
Configured LangChain tools verify scoped, time-limited JWTs against JWKS. An optional audit integration can record selected actions with hash chaining.
npm install @grantex/langchain — provides wrappers for configured LangChain tools.
Create an agent identity with specific scopes like "email:send" or "calendar:read".
Use the configured authorization URL and host experience to obtain the user's scoped grant decision.
The agent gets a signed token it presents to any service. Services verify signatures locally using keys obtained from JWKS.
Attach the audit integration to record tool calls, and manage grants centrally when access changes.
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,
});
Wrap each protected LangChain tool so it verifies the signed grant and required scope before execution.
Define exactly what each agent can do — "email:read" vs "email:send". No more all-or-nothing API keys.
Tools verify the JWT signature and claims before execution. Initial and rotated signing keys may require a JWKS fetch.
Parent agents delegate narrower scopes to sub-agents. Central grant state can cascade parent revocation to child grants; local verifiers still need current state.
Add an audit wrapper or callback to record tool invocations; local authorization alone does not log execution.
Revoke grants centrally; local-only JWT consumers should use short token lifetimes or synchronized revocation data.
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.
Follow the integration guide and verify the package version before deployment. Apache 2.0.