npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

leasebroker

v0.1.1

Published

Local-first broker that issues time-bounded, narrowly-scoped capability leases to AI agents and MCP servers, instead of standing permissions.

Readme

leasebroker

A local-first broker that issues time-bounded, narrowly-scoped capability leases to AI agents and their tools/MCP servers — instead of standing, broad permissions.

An agent asks for exactly the capability a task needs ("read these paths / call this API / spend ≤ $Y, for task T, for N minutes"); a policy decides; the broker issues a signed, scoped, expiring lease the agent must present to act. The broker enforces the scope in-path (MCP middleware proxy), logs every event to a tamper-evident audit trail, can revoke a lease mid-flight, and can require a human veto on high-risk grants. Deny-by-default, least-privilege.

Status: shipped. All lanes implemented and green: tsc --noEmit, vitest, bun run build, node dist/cli/index.js --help, and the end-to-end demo all pass.

Install

npm install leasebroker
# or
bun add leasebroker

Run without installing:

npx leasebroker --help

CLI Commands

All commands share a --state-dir <path> flag (default: .leasebroker/ in cwd). Override with LEASEBROKER_STATE_DIR.

leasebroker request

Submit a lease request. Pass JSON via --request or stdin.

leasebroker request --request '{
  "agentId": "my-agent",
  "taskId": "task-42",
  "capabilities": [
    { "kind": "fs.read", "paths": ["./data/**"] }
  ],
  "requestedDurationMs": 3600000
}'

Prints the granted PASETO token (or reqId for veto-required, or a denial reason).

leasebroker pending

List all pending (veto-required) requests awaiting approval.

leasebroker pending

leasebroker approve <reqId>

Approve a pending request; issues the lease.

leasebroker approve req-abc123

leasebroker deny <reqId>

Deny a pending request; no lease is issued.

leasebroker deny req-abc123

leasebroker revoke <leaseId>

Revoke an active lease before it expires.

leasebroker revoke lease-xyz789

leasebroker serve

Start the MCP enforcement proxy fronting a downstream MCP server. The proxy intercepts every tools/call, verifies the lease, enforces scope, and forwards or denies.

# Front a downstream MCP server (stdio)
leasebroker serve \
  --downstream-cmd node \
  --downstream-args '["./my-mcp-server.js"]'

# With a custom policy file
leasebroker serve \
  --downstream-cmd node \
  --downstream-args '["./my-mcp-server.js"]' \
  --policy ./rules.json

Agents present their lease token in _meta['x-lease-token'] at the MCP initialize handshake. All subsequent tools/call requests are verified against that bound lease.

leasebroker policy

View or load policy rules.

# View current rules
leasebroker policy

# Load rules from a JSON file
leasebroker policy --load ./rules.json

leasebroker audit

View the audit log (hash-chained, append-only).

# View last 20 events
leasebroker audit --last 20

# Filter by lease ID
leasebroker audit --lease-id lease-xyz789

# Filter by event type
leasebroker audit --type issuance

Running the Demo

The demo shows two red→green scenarios entirely offline (no network, no real keys):

bun run demo
# or
npm run demo

Demo 1 — Filesystem path-scope:
Unbrokered agent reads both ./fixtures/data/ and ./fixtures/private/. Brokered agent (lease: fs.read ./fixtures/data/**) — private directory read is DENIED.

Demo 2 — Spend cap + endpoint scope:
Unbrokered agent charges any amount to any endpoint. Brokered agent (lease: spend cap=100 USD, http.call api.example.com/**) — over-cap charge DENIED, off-list endpoint DENIED.

Programmatic API

import {
  generateKeyPair, PasetoV4PublicSigner,
  loadRules, DeclarativePolicyEngine,
  InMemoryAuditSink, InMemoryPendingStore,
  InMemoryRevocationList, InMemorySpendLedger,
  Broker, LeaseEnforcer, LeasebrokerProxy,
} from 'leasebroker';

// Set up the stack
const kp = generateKeyPair('k1');
const signer = new PasetoV4PublicSigner(kp);
const policy = new DeclarativePolicyEngine(
  loadRules([{ ruleId: 'allow-fs-read', effect: 'allow', capabilityKind: 'fs.read' }])
);
const broker = new Broker(policy, signer, new InMemoryAuditSink(), new InMemoryPendingStore(), kp.kid);

// Issue a lease
const result = broker.request({
  agentId: 'my-agent',
  taskId: 'task-1',
  capabilities: [{ kind: 'fs.read', paths: ['./data/**'] }],
  requestedDurationMs: 3_600_000,
});

if (result.type === 'granted') {
  console.log('Token:', result.token); // v4.public.…

  // Enforce it
  const enforcer = new LeaseEnforcer(signer, new InMemoryRevocationList(), new InMemorySpendLedger());
  const check = enforcer.check(result.token, { kind: 'fs.read', path: './data/hello.txt' });
  console.log(check.ok); // true
}

Development

bun install

npm run typecheck   # tsc --noEmit
npm run test        # vitest run
npm run build       # compile to dist/
npm run demo        # red→green capability-brokering demo

Design

  • Specification (WHAT/WHY): specs/lease-broker/spec.md
  • Architecture decisions: docs/adrs.md
  • Implementation plan (HOW): plan.md

Key architecture decisions:

  • Enforcement is MCP middleware (ADR-B): a proxy that fronts downstream MCP servers, verifying scope on every tool call.
  • Leases are PASETO v4.public tokens (Ed25519, via @noble/ed25519) — tamper-evident and verifiable offline (ADR-A).
  • Policy is declarative allow-rules, with a seam to Cedar later (ADR-C).
  • The lease is immutable; cumulative spend and revocation are tracked as state keyed by lease id (ADR-B/D).

License

Apache-2.0 — see LICENSE.