Skip to content
hs-sql-agent

ASP.NET Core · NuGet

Compose only the hs-sql-agent capabilities your .NET host needs.

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.

01

AddHsSqlAgentCore

Start with the optionless core instead of the legacy all-in-one registration preset.

02

Compose capabilities

Add runtime, Admin store/API, MCP, telemetry, or built-in identity independently.

03

Host-owned pipeline

Existing apps keep their authentication, authorization middleware, and MapControllers() ownership.

Embed into an existing ASP.NET Core host

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.

ASP.NET Core 2.0.2
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();

Built-in identity and Admin UI are opt-in

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.

Embedding does not weaken the SQL boundary

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.