{"id":28639448,"url":"https://github.com/NikiforovAll/hangfire-mcp","last_synced_at":"2025-06-12T19:40:33.928Z","repository":{"id":295320688,"uuid":"989795686","full_name":"NikiforovAll/hangfire-mcp","owner":"NikiforovAll","description":"Enqueue background jobs using Hangfire MCP server","archived":false,"fork":false,"pushed_at":"2025-05-24T21:02:56.000Z","size":37,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-05-24T22:29:23.044Z","etag":null,"topics":["hangfire","mcp","mcp-server"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NikiforovAll.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-24T20:58:50.000Z","updated_at":"2025-05-24T21:02:59.000Z","dependencies_parsed_at":"2025-05-24T22:29:29.360Z","dependency_job_id":"327d9179-604a-4e7f-8b12-aedf21136212","html_url":"https://github.com/NikiforovAll/hangfire-mcp","commit_stats":null,"previous_names":["nikiforovall/hangfire-mcp"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/NikiforovAll/hangfire-mcp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NikiforovAll%2Fhangfire-mcp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NikiforovAll%2Fhangfire-mcp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NikiforovAll%2Fhangfire-mcp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NikiforovAll%2Fhangfire-mcp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NikiforovAll","download_url":"https://codeload.github.com/NikiforovAll/hangfire-mcp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NikiforovAll%2Fhangfire-mcp/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259520285,"owners_count":22870415,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hangfire","mcp","mcp-server"],"created_at":"2025-06-12T19:40:25.793Z","updated_at":"2025-06-12T19:40:33.907Z","avatar_url":"https://github.com/NikiforovAll.png","language":"C#","funding_links":[],"categories":["Servers"],"sub_categories":["DotNET"],"readme":"# Hangfire MCP [![Build](https://github.com/NikiforovAll/hangfire-mcp/actions/workflows/build.yml/badge.svg)](https://github.com/NikiforovAll/hangfire-mcp/actions/workflows/build.yml)\r\n\r\nEnqueue background jobs using Hangfire MCP server.\r\n\r\n## Motivation\r\n\r\nInteraction with *Hangfire* using *Hangfire MCP Server* allows you to enqueue jobs from any client that supports MCP protocol.\r\nFor example, you can use Hangfire MCP directly from *VS Code* in *Agent Mode* and enqueue jobs. It makes possible to execute any kind of code without writing additional code.\r\n\r\n\u003cvideo src=\"https://github.com/user-attachments/assets/e6abc036-b1f9-4691-a829-65292db5b5e6\" controls=\"controls\"\u003e\u003c/video\u003e\r\n\r\nHere is MCP Server configuration for VS Code:\r\n\r\n```json\r\n{\r\n    \"servers\": {\r\n        \"hangfire-mcp\": {\r\n            \"url\": \"http://localhost:3001\"\r\n        }\r\n    }\r\n}\r\n```\r\n\r\n## Code Example\r\n\r\nHere is how it works:\r\n\r\n```mermaid\r\nsequenceDiagram\r\n    participant User as User\r\n    participant MCPHangfire as MCP Hangfire\r\n    participant IBackgroundJobClient as IBackgroundJobClient\r\n    participant Database as Database\r\n    participant HangfireServer as Hangfire Server\r\n\r\n    User-\u003e\u003eMCPHangfire: Enqueue Job\r\n    MCPHangfire-\u003e\u003eIBackgroundJobClient: Send Job Message\r\n    IBackgroundJobClient-\u003e\u003eDatabase: Store Job Message\r\n    HangfireServer-\u003e\u003eDatabase: Fetch Job Message\r\n    HangfireServer-\u003e\u003eHangfireServer: Process Job\r\n```\r\n\r\n## Standalone Mode\r\n\r\nIt is a regular MCP packaged as .NET global tool. Here is how to setup it as an MCP server in VSCode.\r\n\r\n```bash\r\n dotnet tool install --global --add-source Nall.HangfireMCP\r\n```\r\n\r\nConfiguration:\r\n\r\n```json\r\n{\r\n  \"servers\": {\r\n    \"hangfire-mcp-standalone\": {\r\n      \"type\": \"stdio\",\r\n      \"command\": \"HangfireMCP\",\r\n      \"args\": [\r\n        \"--stdio\"\r\n      ],\r\n      \"env\": {\r\n        \"HANGFIRE_JOBS_ASSEMBLY\": \"path/to/Jobs.dll\",\r\n        \"HANGFIRE_JOBS_MATCH_EXPRESSION\": \"[?IsInterface \u0026\u0026 contains(Name, 'Job')]\",\r\n        \"HANGFIRE_CONNECTION_STRING\": \"Host=localhost;Port=5432;Username=postgres;Password=postgres;Database=hangfire\"\r\n      }\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n### Aspire\r\n\r\n```csharp\r\nvar builder = DistributedApplication.CreateBuilder(args);\r\n\r\nvar postgresServer = builder\r\n    .AddPostgres(\"postgres-server\")\r\n    .WithDataVolume()\r\n    .WithLifetime(ContainerLifetime.Persistent);\r\n\r\nvar postgresDatabase = postgresServer.AddDatabase(\"hangfire\");\r\n\r\nbuilder.AddProject\u003cProjects.Web\u003e(\"server\")\r\n    .WithReference(postgresDatabase)\r\n    .WaitFor(postgresDatabase);\r\n\r\nvar mcp = builder\r\n    .AddProject\u003cProjects.HangfireMCP_Standalone\u003e(\"hangfire-mcp\")\r\n    .WithEnvironment(\"HANGFIRE_JOBS_ASSEMBLY\", \"path/to/Jobs.dll\")\r\n    .WithEnvironment(\"HANGFIRE_JOBS_MATCH_EXPRESSION\", \"[?IsInterface \u0026\u0026 contains(Name, 'Job')]\")\r\n    .WithReference(postgresDatabase)\r\n    .WaitFor(postgresDatabase);\r\n\r\nbuilder\r\n    .AddMCPInspector()\r\n    .WithSSE(mcp)\r\n    .WaitFor(mcp);\r\n\r\nbuilder.Build().Run();\r\n```\r\n\r\nAs result, the jobs are dynamically loaded from the specified assembly and can be enqueued using MCP protocol. The rules for matching job names can be specified using `HANGFIRE_JOBS_MATCH_EXPRESSION` environment variable. For example, the expression `[?IsInterface \u0026\u0026 contains(Name, 'Job')]` will match all interfaces that contain \"Job\" in their name. It is a [JMESPath](https://jmespath.org/tutorial.html) expression, so you can define how to match job names according to your needs.\r\n\r\n## Custom Setup (as Code) Mode\r\n\r\nYou can create your own MCP server and use this project as starting point. You can extend it with your own tools and features. Here is an example of how to set up Hangfire MCP server in a custom project.\r\n\r\n### Aspire\r\n\r\n```csharp\r\nvar builder = DistributedApplication.CreateBuilder(args);\r\n\r\nvar postgresServer = builder\r\n    .AddPostgres(\"postgres-server\")\r\n    .WithDataVolume()\r\n    .WithLifetime(ContainerLifetime.Persistent);\r\n\r\nvar postgresDatabase = postgresServer.AddDatabase(\"hangfire\");\r\n\r\nbuilder.AddProject\u003cProjects.Web\u003e(\"server\")\r\n    .WithReference(postgresDatabase)\r\n    .WaitFor(postgresDatabase);\r\n\r\nvar mcp = builder\r\n    .AddProject\u003cProjects.HangfireMCP\u003e(\"hangfire-mcp\")\r\n    .WithReference(postgresDatabase)\r\n    .WaitFor(postgresDatabase);\r\n\r\nbuilder\r\n    .AddMCPInspector()\r\n    .WithSSE(mcp)\r\n    .WaitFor(mcp);\r\n\r\nbuilder.Build().Run();\r\n```\r\n\r\n![Aspire Dashboard](assets/aspire-dashboard.png)\r\n\r\n### MCP Server\r\n\r\n```csharp\r\nvar builder = WebApplication.CreateBuilder(args);\r\n\r\nbuilder.WithMcpServer(args).WithToolsFromAssembly();\r\nbuilder.Services.AddHangfire(cfg =\u003e cfg.UsePostgreSqlStorage(options =\u003e\r\n    options.UseNpgsqlConnection(builder.Configuration.GetConnectionString(\"hangfire\")))\r\n);\r\nbuilder.Services.AddHangfireMcp();\r\nbuilder.Services.AddTransient\u003cHangfireTool\u003e();\r\nvar app = builder.Build();\r\napp.MapMcpServer(args);\r\napp.Run();\r\n```\r\n\r\nHere is an example of the Hangfire tool:\r\n\r\n```csharp\r\n[McpServerToolType]\r\npublic class HangfireTool(IHangfireDynamicScheduler scheduler)\r\n{\r\n    [McpServerTool(Name = \"RunJob\")]\r\n    public string Run(\r\n        [Required] string jobName,\r\n        [Required] string methodName,\r\n        Dictionary\u003cstring, object\u003e? parameters = null\r\n    )\r\n    {\r\n        var descriptor = new JobDescriptor(jobName, methodName, parameters);\r\n        return scheduler.Enqueue(descriptor, typeof(ITimeJob).Assembly);\r\n    }\r\n}\r\n```\r\n\r\n## Tools\r\n\r\n![Inspector](assets/inspector.png)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNikiforovAll%2Fhangfire-mcp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FNikiforovAll%2Fhangfire-mcp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNikiforovAll%2Fhangfire-mcp/lists"}