Get the FREE Ultimate OpenClaw Setup Guide →

hangfire

Enqueue background jobs using Hangfire MCP server

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio nikiforovall-hangfire-mcp HangfireMCP --stdio \
  --env HANGFIRE_JOBS_ASSEMBLY="path/to/Jobs.dll" \
  --env HANGFIRE_CONNECTION_STRING="Host=localhost;Port=5432;Username=postgres;Password=postgres;Database=hangfire" \
  --env HANGFIRE_JOBS_MATCH_EXPRESSION="[?IsInterface && contains(Name, 'Job')]"

How to use

Hangfire MCP exposes a server that lets you enqueue Hangfire jobs via the MCP protocol. Once running, clients that speak MCP can send a RunJob-style command to enqueue work in Hangfire using a dynamically loaded assembly of job definitions. This enables enqueuing and scheduling background jobs from tools like code editors (e.g., VS Code) or other MCP clients without writing dedicated integration code. The provided configuration demonstrates how to reference a jobs assembly and filter the available jobs with a JMESPath expression, allowing flexible discovery of job names that match certain criteria. You can access the MCP server through the configured endpoint and use the Hangfire MCP tool suite to enqueue jobs by specifying the target job and method, along with optional parameters.

How to install

Prerequisites:

  • .NET SDK (for Aspire-based setups or standalone usage as a .NET tool)
  • Hangfire and Postgres installed and accessible
  • MCP client (or VS Code extension) that supports MCP protocol

Installation steps:

  1. Install the Hangfire MCP server as a global tool (example for Aspire setup or local development):
    • dotnet tool install --global HangfireMCP
  2. Ensure your Jobs.dll (containing Hangfire job implementations) is built and accessible:
    • Build your project producing a DLL with the job classes/interfaces.
  3. Prepare the MCP configuration file (see mcp_config section) or set environment variables to point to the jobs assembly and match expression.
  4. Start the MCP server using the configured command (example):
    • HangfireMCP --stdio
    • Ensure the environment variables HANGFIRE_JOBS_ASSEMBLY, HANGFIRE_JOBS_MATCH_EXPRESSION, and HANGFIRE_CONNECTION_STRING are set (or provide in the MCP config under env).
  5. Verify the server is listening on the expected port/endpoint and that Hangfire is able to enqueue jobs from the MCP client.

Additional notes

Tips and considerations:

  • Ensure the HANGFIRE_JOBS_ASSEMBLY path correctly points to the compiled Jobs.dll containing your job definitions.
  • The HANGFIRE_JOBS_MATCH_EXPRESSION uses JMESPath. Example: "[?IsInterface && contains(Name, 'Job')]" selects interfaces with 'Job' in their name.
  • The HANGFIRE_CONNECTION_STRING must point to a valid PostgreSQL database with Hangfire schema; initialize migrations if necessary.
  • If you run in stdio mode, MCP clients should connect to the process via the standard input/output streams; adapt tooling accordingly.
  • For local development, you can run the server behind a reverse proxy or expose it on localhost:3001 as in examples, then configure your MCP client with that URL.

Related MCP Servers

Sponsor this space

Reach thousands of developers