agentleFS
NikiforovAllNikiforovAll/hangfire-mcp-dotnet/CLAUDE.md

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.

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
  1. Distinctive:

    Run a single test:

    line 17
  2. Distinctive:

    Run the sample (Aspire AppHost orchestrates Hangfire + Web + dependencies):

    line 23
  3. Very specific:

    If Aspire is running, the Web resource locks DLLs and full-solution builds fail.

    line 33

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

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-build

Run 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/Web

Build 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:

  1. Discovery (JobDiscoverySources + JobScanner): two sources, configurable via HangfireMcpOptions.Sources:
    • RecurringStorage (default) — reads RecurringJobDto.Job from JobStorage.
    • StaticManifest — reads entries the Roslyn generator emitted into JobManifestRegistry (in Manifest/).
    • All — union, deduped by (DeclaringType, MethodInfo). HangfireMcpOptions.Filter filters recurring entries before scanning.
  2. Catalog (JobCatalog): resolves each entry to a JobDescriptor (method, parameters, generated tool name like Run_<jobId>). Built once as a singleton.
  3. Schema (JobInputSchema + ParameterNullability): generates JSON Schema per MethodInfo. Required vs optional respects C# defaults and nullable annotations (NRT for reference types, T? for value types).
  4. MCP wiring (HangfireMcpServiceCollectionExtensions.AddHangfireMcp → HangfireMcpEndpointRouteBuilderExtensions.MapHangfireMcp): registers JobCatalog + HangfireDynamicScheduler as singletons, then registers MCP ListTools / CallTool handlers on AddMcpServer().WithHttpTransport(stateless: true).
  5. Invocation (HangfireMcpHandlers + JobArgumentBinder): on CallTool, the binder converts the JSON arg dict into a typed object array via MethodInfo.GetParameters(), applying defaults and nullability rules. HangfireDynamicScheduler then enqueues via IBackgroundJobClient with a dynamically-built Job instance (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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.