Oban integration for Ectomancer.
This module provides the expose_oban_jobs/0 and expose_oban_jobs/1 macros
that automatically generate MCP tools for managing Oban job queues.
Usage
defmodule MyApp.MCP do
use Ectomancer, authorize: fn actor, _ -> actor.role == :admin end
# Expose all Oban job management tools (authorized via the server-level policy)
expose_oban_jobs
# Or with a namespace prefix
expose_oban_jobs(namespace: :background)
# Generates: background_list_oban_queues, etc.
endGenerated Tools
When Oban is available in the parent application, this macro generates:
list_oban_queues- List all configured queues with job statisticsget_queue_depth- Get job count for a specific queuelist_stuck_jobs- List executing jobs (optionally filterable)retry_job- Retry a job by IDcancel_job- Cancel/delete a job by ID
Optional Dependency
Oban is an optional dependency. If Oban is not in the application's dependencies, the macro will generate no tools (silently).
Configuration
The tools query Oban.Job directly and require:
- An Ecto repo configured in the parent application
- Oban tables migrated in the database
- Oban started in the application supervision tree
Authorization
Mutating tools (retry_job, cancel_job) require effective authorization.
At compile time expose_oban_jobs/1 raises if a mutating tool is requested
without an :authorize option (function, policy module, or action-specific
rules) and without an explicit public opt-out (authorize: :none or
authorize: :public). Authorization inherited from use Ectomancer, authorize: ... satisfies the guard. Read-only tools (list_oban_queues,
get_queue_depth, list_stuck_jobs) are always allowed.
expose_oban_jobs(authorize: fn actor, _ -> actor.role == :admin end)
expose_oban_jobs authorize: [
all: fn actor, _ -> actor.role == :admin end,
list_queues: :public
]
# Explicit public opt-in (all tools, including retry/cancel)
expose_oban_jobs(authorize: :none)
Summary
Functions
Exposes Oban job management tools.
Functions
Exposes Oban job management tools.
Options
:namespace- Prefix tool names with namespace (e.g.,:background→background_list_oban_queues):authorize- Authorization configuration (function, policy module, or action-specific rules)
Examples
expose_oban_jobs(authorize: fn actor, _ -> actor.role == :admin end)
# Generates: list_oban_queues, get_queue_depth, list_stuck_jobs, retry_job, cancel_job
expose_oban_jobs(namespace: :jobs, authorize: fn actor, _ -> actor.role == :admin end)
# Generates: jobs_list_oban_queues, jobs_get_queue_depth, etc.
expose_oban_jobs authorize: [
retry_job: fn actor, _ -> actor.role == :admin end,
cancel_job: fn actor, _ -> actor.role == :admin end,
list_queues: :public
]
# Explicit public opt-in (all tools, including retry/cancel)
expose_oban_jobs(authorize: :none)