Skip to content

Getting Started

Install

bash
dotnet add package Nall.Hangfire.Mcp

Minimum host setup

Three lines on top of an existing Hangfire app:

csharp
builder.Services.AddHangfireMcp();   // registers MCP server + JobCatalog
var app = builder.Build();
app.MapHangfireMcp("/mcp");          // streamable HTTP endpoint

Full minimal example

csharp
using Hangfire;
using Nall.Hangfire.Mcp;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddHangfire(cfg => cfg.UsePostgreSqlStorage(...));
builder.Services.AddHangfireServer();
builder.Services.AddHangfireMcp();

var app = builder.Build();
app.MapHangfireDashboard();
app.MapHangfireMcp("/mcp");

app.Services.GetRequiredService<IRecurringJobManager>()
    .AddOrUpdate<IReportJob>("report.daily", j => j.GenerateAsync(2026, "pdf", null), Cron.Daily);

app.Run();

Every recurring job is now an MCP tool: Run_report.daily with a JSON Schema derived from GenerateAsync's parameters.

Connect a client

VS Code MCP config:

json
{
  "servers": {
    "hangfire": { "url": "https://your-host/mcp" }
  }
}

Built-in maintenance tools

Every MCP server hosted by AddHangfireMcp() also exposes a fixed set of hangfire_* tools for inspecting and managing jobs alongside the dynamic Run_* tools:

ToolPurpose
hangfire_get_statisticsGlobal counters: Enqueued/Failed/Processing/Scheduled/Succeeded/Deleted/Recurring/Retries/Servers.
hangfire_list_jobsPage jobs by state with optional filter. Use this to discover ids before bulk ops.
hangfire_get_jobFull details + state history for one id.
hangfire_delete_jobMove one job to Deleted.
hangfire_requeue_jobRequeue one job (covers retry of Failed).
hangfire_delete_jobsBulk delete by ids or filter (exactly one).
hangfire_requeue_jobsBulk requeue by ids or filter.

Where to next?

  • User Guide — sample walkthrough with the MCP Inspector and Hangfire dashboard.
  • Discovery Sources — recurring storage, compile-time manifest, or both.
  • Authentication — secure the /mcp endpoint with OAuth 2.1 / OIDC.