Installation
AgentDoor supports multiple frameworks and deployment environments. Choose the installation method that matches your stack.
Package Managers
All AgentDoor packages work with npm, pnpm, and yarn:
npm install @agentdoor/express
Requirements
Node.js >= 18 is required for all AgentDoor packages. AgentDoor uses native crypto APIs and ES modules.
Node.js >= 18
TypeScript 5.7+ (if using TypeScript)
One of: npm, pnpm >= 9, or yarn
Framework-Specific Installation
Express.js
For Express.js applications:
npm install @agentdoor/express
Peer dependencies: Express >= 4
Basic usage:
const express = require ( "express" );
const { agentdoor } = require ( "@agentdoor/express" );
const app = express ();
app . use ( agentdoor ({
scopes: [{ id: "data.read" , description: "Read data" }]
}));
app . listen ( 3000 );
Next.js
For Next.js App Router applications:
npm install @agentdoor/next
Peer dependencies: Next.js >= 14
Basic usage:
Create middleware.ts in your project root:
import { createAgentDoorMiddleware } from "@agentdoor/next" ;
export default createAgentDoorMiddleware ({
scopes: [
{ id: "data.read" , description: "Read data" , price: "$0.001/req" }
] ,
rateLimit: { requests: 1000 , window: "1h" } ,
}) ;
export const config = {
matcher: [ "/api/:path*" , "/.well-known/:path*" , "/agentdoor/:path*" ],
};
The middleware automatically handles all AgentDoor endpoints and sets x-agentdoor-is-agent and x-agentdoor-agent-id headers that you can read in your route handlers.
Hono
For Hono applications (Cloudflare Workers, Deno, Bun):
npm install @agentdoor/hono
Peer dependencies: Hono >= 4
Basic usage:
import { Hono } from "hono" ;
import { agentdoor } from "@agentdoor/hono" ;
const app = new Hono ();
app . use ( "*" , agentdoor ({
scopes: [{ id: "data.read" , description: "Read data" }]
}));
app . get ( "/api/data" , ( c ) => {
const isAgent = c . get ( "isAgent" );
const agent = c . get ( "agent" );
return c . json ({ data: "hello" , isAgent });
});
export default app ;
Fastify
For Fastify applications:
npm install @agentdoor/fastify
Peer dependencies: Fastify >= 4
Basic usage:
import Fastify from "fastify" ;
import { agentdoor } from "@agentdoor/fastify" ;
const app = Fastify ();
app . register ( agentdoor , {
scopes: [{ id: "data.read" , description: "Read data" }]
});
app . get ( "/api/data" , async ( request , reply ) => {
const isAgent = request . isAgent ;
const agent = request . agent ;
return { data: "hello" , isAgent };
});
await app . listen ({ port: 3000 });
FastAPI (Python)
For FastAPI applications:
pip install agentdoor-fastapi
Requirements: Python >= 3.9, FastAPI >= 0.100
Basic usage:
from fastapi import Depends, FastAPI
from agentdoor_fastapi import AgentDoor, AgentDoorConfig, AgentContext
app = FastAPI()
gate = AgentDoor(app, config = AgentDoorConfig(
service_name = "My API" ,
scopes = [{ "name" : "read" , "description" : "Read access" }],
))
@app.get ( "/protected" )
async def protected ( agent : AgentContext = Depends(gate.agent_required())):
return { "agent" : agent.agent_id, "scopes" : agent.scopes}
Deployment-Specific Packages
Cloudflare Workers
npm install @agentdoor/cloudflare
Includes Durable Objects support for persistent agent storage.
import { agentdoor } from "@agentdoor/cloudflare" ;
export default {
async fetch ( request : Request , env : Env ) {
return agentdoor ({
scopes: [{ id: "data.read" , description: "Read" }],
storage: env . AGENT_STORAGE // Durable Object binding
})( request );
}
} ;
Vercel Edge
npm install @agentdoor/vercel
Optimized for Vercel Edge Runtime:
import { agentdoor } from "@agentdoor/vercel" ;
export const config = { runtime: "edge" };
export default agentdoor ({
scopes: [{ id: "data.read" , description: "Read" }]
}) ;
Agent SDK (Client-Side)
For building agents that connect to AgentDoor-enabled services:
TypeScript/JavaScript
npm install @agentdoor/sdk
Basic usage:
import { AgentDoor } from "@agentdoor/sdk" ;
const agent = new AgentDoor ({
keyPath: "./agent-keys.json"
});
const session = await agent . connect ( "https://api.example.com" );
const data = await session . get ( "/api/data" );
Python
Requirements: Python >= 3.9
Basic usage:
from agentdoor import AgentDoor
agent = AgentDoor( key_path = "./agent-keys.json" )
session = await agent.connect( "https://api.example.com" )
data = await session.get( "/api/data" )
Additional Packages
Install globally for the agentdoor command:
npm install -g @agentdoor/cli
Commands:
agentdoor init # Interactive setup
agentdoor init --from-openapi spec.yaml # Generate from OpenAPI
agentdoor keygen --output keys.json # Generate keypair
Agent Traffic Detection
Detect agent traffic without requiring registration:
npm install @agentdoor/detect
const { detect } = require ( "@agentdoor/detect" );
app . use ( detect ({
webhook: "https://hooks.yoursite.com/agent-traffic"
}));
Auth Provider Companions
Integrate AgentDoor with your existing auth provider:
Auth0
Clerk
Firebase
Supabase
npm install @agentdoor/auth0
See the Auth Provider Integration guide for usage.
Payment Integrations
npm install @agentdoor/stripe
Core Library
For building custom adapters or using AgentDoor programmatically:
npm install @agentdoor/core
Exports:
import { AgentDoorCore } from "@agentdoor/core" ;
import { MemoryStorage } from "@agentdoor/core/storage/memory" ;
import { SQLiteStorage } from "@agentdoor/core/advanced/storage" ;
import { PostgresStorage } from "@agentdoor/core/storage/postgres" ;
Most users should use framework-specific packages instead of @agentdoor/core directly.
Storage Backends
AgentDoor uses pluggable storage for agent credentials:
Storage Use Case Installation Memory Development, testing Built-in (no install) SQLite Single-server production npm install better-sqlite3Postgres Multi-server production npm install pg
Configuration:
const { SQLiteStorage } = require ( "@agentdoor/core/advanced/storage" );
app . use ( agentdoor ({
scopes: [ ... ],
storage: new SQLiteStorage ( "./agents.db" )
}));
Memory storage does not persist across server restarts. Use SQLite or Postgres for production.
Deployment Templates
Quick-start templates for popular platforms:
Railway npx degit 0xaron/agentdoor/packages/template-railway my-app
cd my-app && npm install
Cloudflare npx degit 0xaron/agentdoor/packages/template-cloudflare my-app
cd my-app && npm install
Vercel npx degit 0xaron/agentdoor/packages/template-vercel my-app
cd my-app && npm install
Verify Installation
After installation, verify AgentDoor is working:
Check the discovery endpoint
curl http://localhost:3000/.well-known/agentdoor.json
You should see your service configuration in JSON format.
Test agent registration
Use the test script included with AgentDoor: npx @agentdoor/cli test http://localhost:3000
Troubleshooting
Node.js version error
SyntaxError: Unexpected token 'export'
Solution: Upgrade to Node.js >= 18. AgentDoor uses ES modules.
node --version # Should be >= 18.0.0
TypeScript errors
Cannot find module '@agentdoor/express' or its corresponding type declarations
Solution: Ensure moduleResolution is set to bundler or node16 in tsconfig.json:
{
"compilerOptions" : {
"moduleResolution" : "bundler" ,
"module" : "ESNext" ,
"target" : "ES2022"
}
}
Peer dependency warnings
WARNING: peer dependency express@>=4 not installed
Solution: Install the required peer dependency:
Storage permission errors (SQLite)
Error: EACCES: permission denied, open './agents.db'
Solution: Ensure the directory is writable or use an absolute path:
import path from "path" ;
import { SQLiteStorage } from "@agentdoor/core/advanced/storage" ;
const storage = new SQLiteStorage ( path . join ( __dirname , "agents.db" ));
Next Steps
Quickstart Build your first agent-ready API in 5 minutes
Configuration Configure scopes, pricing, rate limits, and storage
Examples Browse complete examples for every framework
API Reference Full API documentation for all endpoints