Bunqueue Framework Integrations: Hono & Elysia for Bun
Integrate bunqueue with AI agents and modern Bun-native frameworks.
AI Agent Integrations (MCP)
Section titled “AI Agent Integrations (MCP)”bunqueue ships with a native MCP server — AI agents get full queue control out of the box.
| Client | Setup | Guide |
|---|---|---|
| Claude Code | claude mcp add bunqueue -- bunx bunqueue-mcp | MCP Server |
| Claude Desktop | Add to claude_desktop_config.json | MCP Server |
| Cursor | Add to MCP settings | MCP Server |
| Windsurf | Add to MCP settings | MCP Server |
| Any MCP client | bunx bunqueue-mcp (stdio transport) | MCP Server |
73 tools, 5 resources, 3 prompts. Agents can add jobs, manage crons, retry failures, set rate limits, register HTTP handlers, and monitor everything.
Web Frameworks
Section titled “Web Frameworks”| Framework | Description | Guide |
|---|---|---|
| Hono | Ultrafast web framework for the Edge | Hono Integration |
| Elysia | Ergonomic framework with end-to-end type safety | Elysia Integration |
Quick Comparison
Section titled “Quick Comparison”| Feature | Hono | Elysia |
|---|---|---|
| Type Safety | Manual typing | Built-in with t schema |
| Middleware | Function-based | Plugin-based |
| Validation | External libraries | Native with t.Object() |
| WebSocket | Via adapters | Built-in |
| Performance | Excellent | Excellent |
Best Practices
Section titled “Best Practices”Project Structure
Section titled “Project Structure”src/├── api/│ ├── routes/│ │ ├── emails.ts│ │ └── reports.ts│ └── index.ts├── queues/│ ├── definitions.ts # Queue instances│ └── index.ts├── workers/│ ├── email.worker.ts│ ├── report.worker.ts│ └── index.ts└── index.ts # Entry pointQueue Definitions
Section titled “Queue Definitions”import { Queue } from 'bunqueue/client';
export const queues = { emails: new Queue('emails', { embedded: true, defaultJobOptions: { attempts: 3, backoff: 5000, removeOnComplete: true, }, }), reports: new Queue('reports', { embedded: true, defaultJobOptions: { timeout: 300000, }, }), notifications: new Queue('notifications', { embedded: true, defaultJobOptions: { attempts: 5, backoff: 1000, }, }),} as const;
export type QueueName = keyof typeof queues;Graceful Shutdown
Section titled “Graceful Shutdown”import { shutdownManager } from 'bunqueue/client';import { queues } from './queues';import { workers } from './workers';
async function shutdown() { console.log('Shutting down...');
// Stop accepting new jobs for (const worker of Object.values(workers)) { worker.pause(); }
// Wait for active jobs to complete await Promise.all( Object.values(workers).map((w) => w.close()) );
// Close queue connections await Promise.all( Object.values(queues).map((q) => q.close()) );
// Shutdown the embedded manager shutdownManager();
console.log('Shutdown complete'); process.exit(0);}
process.on('SIGINT', shutdown);process.on('SIGTERM', shutdown);Next Steps
Section titled “Next Steps”- MCP Server - Full AI agent integration guide
- Hono Integration - Complete guide with examples
- Elysia Integration - Production-ready REST API example with tests