Reference
API Reference
All exports from @businys/ops. Import from the package root:
ts
import { createMCPProxy, observe, createBridge, HostedAdapter } from "@businys/ops"createMCPProxy(options?)
Assembles the full middleware pipeline. Returns { middleware, storage, run }. See Architecture for the full options reference.
ts
const proxy = createMCPProxy(options?)
proxy.middleware // Middleware[]
proxy.storage // StorageAdapter
proxy.run(ctx, handler) // Promise<MiddlewareResult>observe(options?)
Starts Observer Mode. Returns a handle with url and close().
ts
const ops = await observe({
port?: number, // default: 3100
hostname?: string, // default: "localhost"
token?: string, // optional bearer token
storage?: StorageAdapter, // default: MemoryAdapter
})
ops.url // string
ops.close() // Promise<void>createBridge(argv, options?)
Wraps a stdio MCP server process as a managed HTTP endpoint.
ts
const bridge = await createBridge(["node", "./server.js"], {
port?: number, // default: 3100
hostname?: string, // default: "localhost"
name?: string, // server name for middleware context
timeout?: number, // ms, default: 30000
proxy?: MCPProxy, // middleware to apply
})
bridge.url // string
bridge.close() // Promise<void>MemoryAdapter
ts
new MemoryAdapter(options?: { maxCalls?: number }) // default: 1000FileAdapter
ts
new FileAdapter({ path: string })PostgresAdapter
ts
// Requires peer dependency: npm install pg
new PostgresAdapter({ connectionString: string })HostedAdapter
ts
new HostedAdapter({
apiKey: string,
url?: string, // default: "https://businys.dev"
flushDebounceMs?: number, // default: 2000
maxCalls?: number, // default: 200
})
// Call close() on shutdown to flush pending callsMiddleware factories
| Export | Description |
|---|---|
createAuthMiddleware(options) | API key validation from Authorization header |
createReputationMiddleware(storage) | Reputation scoring, loop detection, throttling |
createRateLimitMiddleware(options) | Per-agent + per-group sliding window |
createMeteringMiddleware({ storage }) | Records all calls to storage |
createAuditMiddleware(options?) | Structured JSON audit log |
createConfirmationMiddleware() | Requires confirm: true for destructive calls |
createRevenueMiddleware(storage, options) | Credit wallet budget check + deduction |
createTelemetryMiddleware(options) | OpenTelemetry span instrumentation |
createLineageMiddleware(options) | Causal DAG lineage tracking |
Lineage exports
ts
import { MemoryLineageStore, verifyLineage, LINEAGE_HEADERS } from "@businys/ops"
const store = new MemoryLineageStore()
const chain = await store.getChain(nodeId) // LineageChain
const valid = await verifyLineage(chain) // boolean
// Header names for passing lineage context
LINEAGE_HEADERS.parent // "x-lineage-parent"
LINEAGE_HEADERS.session // "x-lineage-session"runMiddleware(stack, ctx, handler)
Execute a middleware stack manually, without using createMCPProxy.
ts
import { runMiddleware } from "@businys/ops"
const result = await runMiddleware(
[myMiddleware1, myMiddleware2],
ctx,
async () => ({ content: [{ type: "text", text: "result" }] })
)