Autron Protocol
The Open Identity Standard for AI Agents "OAuth for the Agentic Era"
Install
npm install @autron/core
Quick Start
const { generateKeypair, createDID, resolveDID, toStandardDID } = require('@autron/core');
const keys = generateKeypair();
const did = createDID('key', keys);
console.log('Agent DID:', did);
// → did:autron:key:z6Mk...
const doc = resolveDID(did);
console.log('DID Document:', JSON.stringify(doc, null, 2));
// Compatible with standard DIDs
console.log('Standard:', toStandardDID(did));
// → did:key:z6Mk...
Why Autron?
- Simple: Agent identity in 5 minutes, any language
- Self-contained: No blockchain, no central server
- Cryptographically secure: Ed25519 / secp256k1 signatures
- Compatible: W3C DID, JWT/JWS, works with MCP & A2A
- Brand-first:
did:autron:*namespace withdid:key/did:webcompatibility mapping - TypeScript ready: Full type declarations included
DID Methods
| Method | Format | Example |
|---|---|---|
key | Self-issued from keypair | did:autron:key:z6Mk... |
web | Domain-based | did:autron:web:api.example.com |
dns | DNS TXT record | did:autron:dns:myagent.example.com |
Agent Card
Issue and verify cryptographic identity cards (JWS compact serialization):
const { generateKeypair, createDID, createAgentCard, verifyAgentCard } = require('@autron/core');
const keys = generateKeypair();
const did = createDID('key', keys);
// Issue a card (short-lived JWS token)
const card = createAgentCard({
issuer: did,
privateKey: keys.privateKey,
name: 'MyAgent',
capabilities: ['chat', 'search'],
ttl: 86400, // 24 hours
});
// Verify (extracts public key from DID automatically)
const { issuer, subject, payload } = verifyAgentCard(card);
Delegation
Grant scoped permissions to other agents:
const { createDelegation, verifyDelegation, checkScope } = require('@autron/core');
const token = createDelegation({
delegator: parentDID,
delegate: childDID,
privateKey: parentKeys.privateKey,
scope: ['read:*', 'write:messages'],
constraints: { maxCalls: 100 },
ttl: 3600, // 1 hour
});
const result = verifyDelegation(token);
checkScope(result, 'read:files'); // true (matches read:*)
checkScope(result, 'write:messages'); // true (exact match)
checkScope(result, 'admin'); // false
Reputation
Endorse other agents and calculate trust scores:
const { createEndorsement, verifyEndorsement, calculateReputation } = require('@autron/core');
// Endorse another agent
const endorsement = createEndorsement({
endorser: myDID,
subject: otherDID,
privateKey: myKeys.privateKey,
rating: 0.9,
categories: ['coding', 'search'],
comment: 'Reliable agent',
});
// Aggregate reputation from multiple endorsements
const rep = calculateReputation(verifiedEndorsements);
console.log(rep.score); // 0.0-1.0 (recency-weighted average)
console.log(rep.categories); // { coding: { score: 0.9, count: 3 }, ... }
Discovery
Build discoverable DID Documents and well-known metadata:
const { buildDIDDocument, createWellKnown, SERVICE_TYPES } = require('@autron/core');
// DID Document with service endpoints
const doc = buildDIDDocument(did, {
services: [
{ type: SERVICE_TYPES.AGENT_CARD, serviceEndpoint: 'https://example.com/card' },
{ type: SERVICE_TYPES.API, serviceEndpoint: 'https://example.com/api/v1' },
],
});
// /.well-known/autron.json
const wk = createWellKnown({
did,
name: 'MyAgent',
capabilities: ['chat', 'search'],
cardEndpoint: 'https://example.com/.well-known/agent-card',
});
HTTP Server
Run a full identity server with discovery, verification, and token endpoints:
const { generateKeypair, createDID, createServer } = require('@autron/core');
const keys = generateKeypair();
const did = createDID('key', keys);
const server = createServer({
identity: { did, privateKey: keys.privateKey, name: 'MyAgent' },
port: 3000,
cors: true,
});
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| GET | /.well-known/autron.json | No | Discovery document |
| GET | /api/identity | No | Agent identity info |
| POST | /api/verify | No | Verify any token |
| GET | /api/reputation/:did | No | Reputation score |
| POST | /api/card | Bearer | Issue Agent Card |
| POST | /api/delegate | Bearer | Issue delegation |
| POST | /api/endorse | Bearer | Submit endorsement |
Middleware
Protect your endpoints with Agent Card authentication and delegation scope checks:
const { authenticate, requireScope, AuthError } = require('@autron/core');
const auth = authenticate({ audience: myDID });
const scopeCheck = requireScope('write:messages');
function handleRequest(req, res) {
try {
const agent = auth(req); // Verify Bearer Agent Card
const deleg = scopeCheck(req); // Verify X-Delegation-Token scope
// agent.did, agent.name, agent.capabilities
// deleg.delegator, deleg.scope, deleg.constraints
} catch (err) {
if (err instanceof AuthError) {
res.writeHead(err.status);
res.end(err.message);
}
}
}
MCP Server
Expose Autron identity operations as MCP tools for AI agents:
npx autron mcp # Start MCP server over stdio
npx autron-mcp # Direct binary for MCP clients
Claude Code / Cursor configuration (mcp.json):
{
"mcpServers": {
"autron": {
"command": "npx",
"args": ["autron-mcp"]
}
}
}
| Tool | Description |
|---|---|
identity_info | Get current agent DID, name, algorithm |
issue_card | Issue an Agent Card (JWS identity token) |
issue_delegation | Create a delegation token |
issue_endorsement | Create an endorsement |
verify_token | Verify any Autron token |
calculate_reputation | Aggregate reputation score |
resolve_did | Parse and resolve a DID |
discover_agent | Discover a remote agent by URL or DID |
Resources: autron://identity, autron://well-known
CLI
npx autron init --name "MyAgent" # Generate identity → autron.json
npx autron info # Show current identity
npx autron card --ttl 24h # Issue an Agent Card
npx autron verify <token> # Verify any token
npx autron endorse <did> --rating 0.9 --category coding
npx autron mcp # Start MCP server
TypeScript
Full type declarations are included — no @types package needed:
import {
generateKeypair,
createDID,
createAgentCard,
verifyAgentCard,
type Keypair,
type VerifiedAgentCard,
type Algorithm,
} from '@autron/core';
const keys: Keypair = generateKeypair('ed25519');
const did: string = createDID('key', { publicKey: keys.publicKey });
const card: string = createAgentCard({ issuer: did, privateKey: keys.privateKey });
const result: VerifiedAgentCard = verifyAgentCard(card);
API
Crypto
generateKeypair(algorithm?)— Generate Ed25519 or secp256k1 keypairsign(data, privateKey, algorithm?)— Sign dataverify(data, signature, publicKey, algorithm?)— Verify signaturepublicKeyToMultibase(publicKey, algorithm?)— Encode key as multibasemultibaseToPublicKey(multibaseStr)— Decode multibase to keykeyToJWK(publicKey, privateKey?, algorithm?)— Convert to JWK formatjwkToKey(jwk)— Convert from JWK format
DID
createDID(method, options)— Create a DID stringparseDID(didString)— Parse DID into componentsresolveDID(didString)— Resolve to W3C DID DocumenttoStandardDID(autronDID)— Convert todid:key/did:webfromStandardDID(standardDID)— Convert from standard DID
Agent Card
createAgentCard(options)— Issue a signed identity card (JWS)verifyAgentCard(token, options?)— Verify signature, expiry, audienceparseAgentCard(token)— Parse without verification
Delegation
createDelegation(options)— Issue a delegation tokenverifyDelegation(token, options?)— Verify delegationcheckScope(delegation, requiredScope)— Check granted scopes (supports wildcards)
Discovery
buildDIDDocument(did, options?)— DID Document with services/controllerscreateWellKnown(options)— Build/.well-known/autron.jsonparseWellKnown(doc)— Parse well-known documentSERVICE_TYPES— Standard service type constants
Reputation
createEndorsement(options)— Issue a signed endorsement (0.0-1.0 rating)verifyEndorsement(token, options?)— Verify endorsementcalculateReputation(endorsements, options?)— Aggregate trust score (recency-weighted)
Server
createServer(options)— Create and start HTTP identity serverhandleRequest(options)— Create request handler (BYO server)
Middleware
authenticate(options?)— Create Bearer token auth functionrequireScope(scope)— Create delegation scope checkerextractBearer(req)— Extract Bearer token from headersextractDelegation(req)— Extract delegation token from headersAuthError— Auth error class with HTTP status
Client
discoverAgent(urlOrDID)— Discover remote agentfetchWellKnown(baseUrl)— Fetch well-known documentfetchIdentity(baseUrl)— Fetch agent identityrequestCard(baseUrl, bearer, options?)— Request Agent CardrequestDelegation(baseUrl, bearer, options)— Request delegationsubmitEndorsement(baseUrl, bearer, options)— Submit endorsementverifyRemote(baseUrl, token)— Verify token remotely
MCP
createMCPServer(options?)— Create MCP server instance
JWS (Low-level)
createJWS(header, payload, privateKey, algorithm)— Create JWS compact tokenverifyJWS(token, publicKey, algorithm)— Verify and decodeparseJWS(token)— Parse without verification
License
Apache 2.0