AddHsSqlAgentCore
Start with the optionless core instead of the legacy all-in-one registration preset.
ASP.NET Core · NuGet
Use HsSqlAgent.Server 2.0.2 as an embeddable ASP.NET Core class library. Keep host authentication and controller mapping, then opt into Admin API, MCP, built-in identity, or Admin UI only when needed.
Start with the optionless core instead of the legacy all-in-one registration preset.
Add runtime, Admin store/API, MCP, telemetry, or built-in identity independently.
Existing apps keep their authentication, authorization middleware, and MapControllers() ownership.
HsSqlAgent.Server is a class-library integration surface, not a second web host hidden inside your application. In 2.0.2, new integrations begin with AddHsSqlAgentCore() and explicitly select the capabilities they need.
When the application already owns login and permissions, delegate Admin authorization to the host policy instead of installing hs-sql-agent's built-in member/role identity stack.
var hs = builder.Services.AddHsSqlAgentCore();
hs.AddHsSqlAgentRuntime();
hs.AddHsSqlAgentAdminStore(options =>
{
options.Provider = "Postgres";
options.ConnectionString =
builder.Configuration.GetConnectionString("HsSqlAgent")!;
});
hs.AddHsSqlAgentHostAuthorization("SqlAgentAdmin");
hs.AddHsSqlAgentAdminApi();
hs.AddHsSqlAgentMcp(options =>
{
options.PublicEndpoint = "https://example.com/mcp";
options.HmacSecretKey = builder.Configuration["HMAC_KEY"]!;
});
var app = builder.Build();
app.UseAuthentication();
app.UseAuthorization();
app.UseHsSqlAgentMcp();
app.UseHsSqlAgentAdminApi();
app.MapControllers();If the host wants hs-sql-agent's own JWT/member/role model, select AddHsSqlAgentBuiltInAuth() instead of host authorization. The two authorization modes are mutually exclusive.
The packaged Admin UI is also optional. An existing application can expose only the Admin API and use its own frontend, or add the bundled UI when that experience is wanted.
Hosting topology changes, but query compilation, Safe DML, MCP-key scope, policy, provider capability checks, and audit still run through the same hs-sql-agent runtime boundary.