hangfire-mcp-dotnet
CLAUDE.md1 starsChanged 7 months agoMITView on GitHub
Nall.Hangfire.Mcp — a remote MCP server that exposes Hangfire background jobs as MCP tools, in-process with the ASP.NET host that runs Hangfire. Streamable HTTP endpoint at /mcp. Targets net10.0. The companion Nall.Hangfire.Mcp.Generator (netstandard2.0 Roslyn source generator) scans AddOrUpdate / Enqueue / Schedule call sites at compile time to build a static job manifest. Solution file: hangfire-mcp-dotnet.slnx. Run a single test: Run the sample (Aspire AppHost orchestrates Hangfire + Web + dependencies): Build rule (from global instructions): always pass -p:WarningLevel=0 /clp:ErrorsOnly.
In this repository2 other files it gives its agents.
- aspireSkill
- playwright-cliSkill
The file
We split this CLAUDE.md into the rules it gives an agent
3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 17
Run a single test:
- Distinctive: line 23
Run the sample (Aspire AppHost orchestrates Hangfire + Web + dependencies):
- Very specific: line 33
If Aspire is running, the Web resource locks DLLs and full-solution builds fail.
≈ “Common” is an estimate: at least 1 in 5 of the 27,641 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
Project
Nall.Hangfire.Mcp — a remote MCP server that exposes Hangfire background jobs as MCP tools, in-process with the ASP.NET host that runs Hangfire. Streamable HTTP endpoint at /mcp. Targets net10.0. The companion Nall.Hangfire.Mcp.Generator (netstandard2.0 Roslyn source generator) scans AddOrUpdate / Enqueue / Schedule call sites at compile time to build a static job manifest.
Commands
Solution file: hangfire-mcp-dotnet.slnx.
dotnet restore hangfire-mcp-dotnet.slnx
dotnet build hangfire-mcp-dotnet.slnx -p:WarningLevel=0 /clp:ErrorsOnly
dotnet test hangfire-mcp-dotnet.slnx --no-buildRun a single test:
dotnet test tests/Nall.Hangfire.Mcp.Tests --filter "FullyQualifiedName~JobCatalogTests.MethodName"Run the sample (Aspire AppHost orchestrates Hangfire + Web + dependencies):
aspire run # uses aspire.config.json -> samples/AppHost
# or directly:
dotnet run --project samples/WebBuild rule (from global instructions): always pass -p:WarningLevel=0 /clp:ErrorsOnly.
If Aspire is running, the Web resource locks DLLs and full-solution builds fail. For a full build: aspire stop → dotnet build ... → aspire start. (For changes to a single .NET resource, prefer aspire resource <name> rebuild instead of stopping the AppHost.)
Architecture
Pipeline from a Hangfire job to an MCP tool:
- Discovery (
JobDiscoverySources+JobScanner): two sources, configurable viaHangfireMcpOptions.Sources:RecurringStorage(default) — readsRecurringJobDto.JobfromJobStorage.StaticManifest— reads entries the Roslyn generator emitted intoJobManifestRegistry(inManifest/).All— union, deduped by(DeclaringType, MethodInfo).HangfireMcpOptions.Filterfilters recurring entries before scanning.
- Catalog (
JobCatalog): resolves each entry to aJobDescriptor(method, parameters, generated tool name likeRun_<jobId>). Built once as a singleton. - Schema (
JobInputSchema+ParameterNullability): generates JSON Schema perMethodInfo. Required vs optional respects C# defaults and nullable annotations (NRT for reference types,T?for value types). - MCP wiring (
HangfireMcpServiceCollectionExtensions.AddHangfireMcp→HangfireMcpEndpointRouteBuilderExtensions.MapHangfireMcp): registersJobCatalog+HangfireDynamicScheduleras singletons, then registers MCPListTools/CallToolhandlers onAddMcpServer().WithHttpTransport(stateless: true). - Invocation (
HangfireMcpHandlers+JobArgumentBinder): onCallTool, the binder converts the JSON arg dict into a typed object array viaMethodInfo.GetParameters(), applying defaults and nullability rules.HangfireDynamicSchedulerthen enqueues viaIBackgroundJobClientwith a dynamically-builtJobinstance (no shim interfaces, no attributes).
Source generator
Nall.Hangfire.Mcp.Generator/HangfireRegistrationGenerator.cs is a Roslyn IIncrementalGenerator. It walks user code for Hangfire registration call sites and emits a JobManifestRegistry partial that Nall.Hangfire.Mcp consumes at runtime when Sources includes StaticManifest. Important constraints: netstandard2.0, EnforceExtendedAnalyzerRules=true, and IncludeBuildOutput=false (packed under analyzers/dotnet/cs). The tests project references the generator with OutputItemType="Analyzer" ReferenceOutputAssembly="false" — keep that pattern when wiring new consumers.
Samples
samples/HangfireJobs defines job interfaces (overloads, complex objects, enums, collections, defaults, nullable optionals). samples/Web is the host (registers Hangfire, dashboard, MCP, recurring jobs, GET /jobs to dump the catalog). samples/AppHost is the Aspire orchestrator.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

