Skip to content
Menu

Run the sample host

View .md

src/Beacon.SampleProject is the composition root in the Beacon repository: an ASP.NET Core application that wires every Beacon package together. It is how you evaluate Beacon and how contributors run it. The Quick start takes you from a clone to a first alert; this page is the reference for everything else the sample does.

AreaWhat the sample wiresWhere
Beacon servicesThe host chain (AddBeacon(...), .AddAI(), .AddMcp(), .AddApi(), .AddCookieAuth<T>(), .AddOidc(), then UseBeaconPipeline() and MapBeacon()) with AI on, authorization on, the login form, Beacon’s user store (DatabaseAuthenticationProvider) and user management with first-run setup. The approval workflow is not enabled.Program.cs
Metadata databasePostgreSQL (.UsePostgreSql()), connection string ConnectionStrings:BeaconContext.Program.cs
ConnectorsAll nine: PostgreSQL, SQL Server, MySQL, CloudWatch, Azure Synapse, Snowflake, Databricks, BigQuery and REST API.Program.cs
Background jobsMoberg Warp on PostgreSQL, with BeaconScheduler as the IBeaconScheduler implementation and one Warp job per Beacon operation. Dashboard at /warp.Warp/, Services/BeaconScheduler.cs
Sign-inCookie sign-in under /beacon, Data Protection keys in Beacon’s database, optional OIDC/SSO, and bearer JWT for MCP clients when OIDC has a McpJwksEndpoint.Program.cs
API, UI and MCPREST API and SignalR hub under /beacon/api, the React UI at /beacon, the MCP server at /beacon/mcp, the MCP discovery documents, and the OpenAPI document at /openapi/v1.json.Program.cs
EmailBeaconMailSender, an SMTP adapter configured with Beacon:Smtp:*.Services/BeaconMailSender.cs
Error responsesExceptions under /beacon/api become RFC 7807 application/problem+json responses (UseBeaconApiExceptionHandler, added by UseBeaconPipeline).Program.cs
TelemetryOpenTelemetry traces and metrics, only when OTEL_EXPORTER_OTLP_ENDPOINT is set.Program.cs
Reverse proxyForwarded headers from trusted proxies, only when Beacon:ForwardedHeaders:Enabled is true.Program.cs
TimeoutsKestrel keep-alive and request-header timeouts and the default HttpClient timeout set to 5 minutes, for long AI calls (builder.ConfigureBeaconTimeouts()).Program.cs

The Warp jobs, BeaconMailSender, the telemetry and forwarded-headers blocks are sample code, not part of any package. A host that embeds Beacon provides its own. The error responses, the timeouts and the OIDC bearer JWTs come from helpers in Moberg.Beacon.Api, and the chain’s UseBeaconPipeline and MapBeacon from Moberg.Beacon.Gateway.

The sample reads standard ASP.NET Core configuration: appsettings.json, appsettings.{Environment}.json, user secrets (Development only), environment variables and command-line arguments. Environment variables use __ for :, for example Beacon__EncryptionKey.

appsettings.json holds the non-secret defaults and commented examples. appsettings.Development.json sets only logging. Secrets never go in either file.

KeyRequiredWhat it does
ConnectionStrings:BeaconContextYesBeacon’s metadata database (PostgreSQL in the sample).
Beacon:EncryptionKeyYesBase64 of at least 32 random bytes. Encrypts connection strings and other secrets at rest. Checked at startup in every environment.
ConnectionStrings:WarpContextNoPostgreSQL database for Warp. Defaults to BeaconContext.
Beacon:BaseUrlNoBase for links in notifications, built as {BaseUrl}/notifications/{id}. Include /beacon, for example https://beacon.example.com/beacon. Can be changed later in Admin Settings.
Beacon:PublicBaseUrlOutside local usePublic origin advertised in the MCP discovery documents. Unset, Beacon uses the request’s Host header and logs a warning.
Beacon:DataProtection:ApplicationNameOutside DevelopmentData Protection application name, one per deployment.
Beacon:DataProtection:AllowUnencryptedKeysNoAcknowledges a key ring stored without encryption at rest. See Running outside Development.
Beacon:UserManagement:SetupTokenRecommended outside DevelopmentFirst-run setup token, at least 32 characters. Unset, each process prints its own random token to the console.
Beacon:UserManagement:LocalLogin:Enabled, BreakGlassUserNamesNoPassword sign-in on or off, and up to three break-glass accounts that keep a password when it is off.
Beacon:Authentication:Oidc:*NoOIDC/SSO. See Sign-in with OIDC.
Beacon:Mcp:Callers:*NoEntra callers admitted to /beacon/mcp. See Entra ID callers.
Beacon:ForwardedHeaders:Enabled, KnownProxiesNoTrust X-Forwarded-For and X-Forwarded-Proto from the listed proxy IP addresses. An empty list trusts none.
Beacon:Smtp:Host, FromAddress, Username, Password, Port, EnableSslFor emailSMTP for email recipients. Port defaults to 465, EnableSsl to true. A missing required key fails the send, not the startup.
Beacon:LLM:*For AI featuresThe LLM provider. See AI providers.
OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_SERVICE_NAMENoTurn on OpenTelemetry export. The service name defaults to beacon.

Every other key (query limits, MCP locks, notification policy, API keys, sessions, authorization) is a Beacon library setting and works the same in any host. See Configuration.

src/Beacon.SampleProject/Properties/launchSettings.json has three profiles. All of them set ASPNETCORE_ENVIRONMENT=Development.

ProfileURLsUse
httphttp://localhost:5296The default for dotnet run without --launch-profile.
httpshttps://localhost:7187, http://localhost:5296The one to use. The Vite dev server proxies to https://localhost:7187.
IIS ExpressIIS Express portsVisual Studio on Windows.
Terminal window
dotnet run --project src/Beacon.SampleProject --launch-profile https

With --no-launch-profile the environment is Production: user secrets and appsettings.Development.json are not loaded, and the host refuses to start until the production settings are in place.

In Development, HTTP requests are redirected to HTTPS except under /beacon/mcp, so local MCP clients can connect over http://localhost:5296/beacon/mcp. Outside Development every path is redirected, including /beacon/mcp.

The sample host does not create or migrate Beacon’s schema. Run the EF Core migrations yourself, before the first start and after every update:

Terminal window
dotnet tool install --global dotnet-ef
dotnet ef database update \
--project src/Beacon.Core.PostgreSql \
--startup-project src/Beacon.SampleProject \
--context PostgreSqlBeaconContext

The command reads the same configuration as the host, in the Development environment, so user secrets apply. The migrations create the beacon schema and the pgvector vector extension, so the login needs the rights for both, or a DBA creates them first.

The sample registers PostgreSQL for Beacon’s data. To use SQL Server instead, change .UsePostgreSql() to .UseSqlServer() in Program.cs, apply the migrations from src/Beacon.Core.SqlServer, and set ConnectionStrings:WarpContext to a PostgreSQL database, because Warp needs PostgreSQL. See Metadata database.

At startup the sample migrates Warp’s own warp schema and registers its recurring jobs. Subscriptions are scheduled through BeaconScheduler as you create them.

JobScheduleWhat it does
mcp-learning-aggregate0 */6 * * *Mines MCP usage signals into learned patterns.
mcp-learning-cleanup0 3 * * *Deletes learning signals past their retention.
mcp-audit-retention30 3 * * *Purges MCP audit rows older than Beacon:Mcp:Audit:RetentionDays. Does nothing when that is unset.
mcp-embedding-reindex0 */12 * * *Re-indexes metadata and examples for semantic search.
mcp-docchunk-reindex0 */12 * * *Re-chunks and re-embeds project documentation.

Every start also enqueues one run of the re-encryption job, which moves stored values still under a key in Beacon:PreviousEncryptionKeys, or still in the legacy encryption format, to the current key and format. A run with nothing to move writes nothing.

  • Warp polls every second and runs at most min(2 × CPU count, 20) workers.
  • Failed jobs are not retried automatically. They stay failed for you to investigate.
  • The dashboard at /warp is for signed-in users with the Admin role. It sits outside /beacon, so the sample lists /warp in Beacon:Authentication:AdditionalPaths (appsettings.json): Beacon’s session authenticates /beacon and the listed paths only. See Where Beacon credentials apply.

See Background jobs for implementing IBeaconScheduler on another job runner.

The React app lives in src/Beacon.UI/web. The Beacon.UI project serves the built files from src/Beacon.UI/wwwroot/beacon at /beacon. The repository does not contain a built UI.

GoalCommand (from the repository root)
Install dependenciesnpm ci --prefix src/Beacon.UI/web
Build once for the hostnpm run build --prefix src/Beacon.UI/web, then restart the host. Output: src/Beacon.UI/wwwroot/beacon.
Develop with hot reloadnpm run dev --prefix src/Beacon.UI/web, then open http://localhost:5173/beacon/. Proxies /beacon/api and /beacon/mcp to https://localhost:7187, or to BEACON_BACKEND_URL when set.
Explore without a backendnpm run dev:mock --prefix src/Beacon.UI/web, mock data in the browser.
Run the UI testsnpm test --prefix src/Beacon.UI/web
Regenerate the API clientnpm run codegen --prefix src/Beacon.UI/web, with the host running. Reads /openapi/v1.json.

A Debug build of the .NET solution does not build the React app. A Release build does, and so does a Debug build with -p:BuildReactInDebug=true. Both run npm ci first when node_modules is missing. The UI needs Node.js 22 and npm 11.

The sample always offers Beacon’s login form and user store. To add single sign-on, fill in Beacon:Authentication:Oidc and set Enabled to true:

{
"Beacon": {
"Authentication": {
"Oidc": {
"Enabled": true,
"Authority": "https://login.microsoftonline.com/<tenant-id>/v2.0",
"ClientId": "<client-id>",
"AllowedTenants": ["<tenant-id>"],
"DisplayName": "Microsoft",
"McpJwksEndpoint": "https://login.microsoftonline.com/<tenant-id>/discovery/v2.0/keys"
}
}
}
}
  • Put ClientSecret in user secrets or an environment variable (Beacon__Authentication__Oidc__ClientSecret), never in the file.
  • Startup fails with SSO on and no AllowedTenants, unless AllowAnyTenant is true for a provider that issues no tenant claim.
  • McpJwksEndpoint: when it is set, a host that calls .AddOidc() (or AddBeaconOidcMcpJwtAuthentication), as the sample does, also accepts bearer JWTs on the API and on /beacon/mcp, validated against those signing keys with the Authority as issuer and the ClientId as audience. Which tokens become MCP callers is decided by Beacon:Mcp:Callers.

Every OIDC option is in Configuration. How sign-in works is in Sign-in & identity.

Outside Development (ASPNETCORE_ENVIRONMENT set to anything but Development, or unset), the sample needs more configuration before it starts:

  1. Provide secrets through the environment or a secret store. User secrets are not loaded. Set at least ConnectionStrings__BeaconContext and Beacon__EncryptionKey.
  2. Set Beacon:DataProtection:ApplicationName. One name per deployment, for example beacon-staging. Without it the host does not start.
  3. Encrypt the Data Protection keys at rest. Outside Development the host refuses to start while the key ring, which protects sign-in cookies, is stored unencrypted. The sample chains no ProtectKeysWith* call: add one to the builder AddBeaconDataProtection returns in Program.cs (for example ProtectKeysWithAzureKeyVault or ProtectKeysWithCertificate), or, if the database is protected by other means, set Beacon:DataProtection:AllowUnencryptedKeys to true and accept the startup warning.
  4. Set Beacon:UserManagement:SetupToken to a secret of at least 32 characters, so the first admin can be created with a token you control, and every replica accepts the same one.
  5. Set Beacon:PublicBaseUrl and Beacon:BaseUrl to the public origin and the public UI address (with /beacon).
  6. Configure the listening address, for example ASPNETCORE_URLS. Without a launch profile ASP.NET Core does not use the ports above.
  7. Behind a reverse proxy, set Beacon:ForwardedHeaders:Enabled and list the proxy addresses in KnownProxies, so the login rate limiter and cookie security see the client’s address and scheme.

The Production checklist covers the rest for a real deployment.

Terminal window
dotnet publish src/Beacon.SampleProject -c Release -o ./publish

The Release build runs npm ci (when needed) and npm run build for the UI, so the output includes it under wwwroot/beacon. Run it with:

Terminal window
cd publish
ASPNETCORE_ENVIRONMENT=Production dotnet Beacon.SampleProject.dll

with the settings from Running outside Development supplied through the environment.

URLWhat
/beaconThe React UI. The site root / belongs to the host.
/beacon/setupFirst-run setup, while no admin exists.
/beacon/loginSign-in.
/beacon/api/healthHealth check: {"status":"ok"} when the metadata database answers.
/beacon/api/*REST API and the SignalR hub (/beacon/api/hub).
/beacon/mcpMCP server.
/openapi/v1.jsonOpenAPI document.
/warpWarp dashboard (Admin only; listed in Beacon:Authentication:AdditionalPaths).

The full list is in Routes & endpoints.

SymptomCause and fix
Beacon:DataProtection:ApplicationName must be set outside DevelopmentThe host runs outside Development. Use --launch-profile https locally, or follow Running outside Development.
Startup refuses Data Protection keys “persisted without encryption at rest”Outside Development without key encryption. See step 3 of Running outside Development.
Beacon:EncryptionKey errorsThe key is missing, too short, printable text or a published sample value. Generate one with openssl rand -base64 32.
relation "…" does not existBeacon’s schema is not migrated. See Beacon’s database.
extension "vector" is not availableInstall pgvector on the PostgreSQL server, or use the pgvector/pgvector image.
404 under /beaconThe UI is not built. See The UI.
Subscriptions never runWarp is not running or cannot reach PostgreSQL. Check /warp and the host log.

More in Troubleshooting.

This page covers the sample only. To add Beacon to your own ASP.NET Core application (packages, Program.cs, middleware order, migrations at startup, your job runner and your sign-in), follow Integrate Beacon.