Skip to content
hs-sql-agent
2.0.2
Docs 2.0.2
Docs Operations

Configuration Reference

Source-backed environment and runtime configuration reference for hs-sql-agent 2.0.2.

Single instance Start from .env.example and keep process-local providers unless state must be shared.
Distributed Use Postgres control-plane storage plus Redis-backed cache, limits, policy sync, delivery sync, and SQL concurrency.
Embedded .NET New integrations configure capability-specific options; HsSqlAgentServiceOptions is retained only for legacy aggregate compatibility.

The checked-in v2.0.2 .env.example is the deployment-facing inventory for the default Compose path. This page follows that file for environment names and uses the v2.0.2 runtime code when comments and validation disagree.

Application and control plane

VariableExample/default in .env.examplePurpose
ASPNETCORE_URLShttp://+:8080Main ASP.NET Core listener
ALLOWED_HOSTS*ASP.NET Core host filtering
ADMIN_DATABASE_PROVIDERSqliteAdmin/control-plane database provider
ADMIN_DATABASE_CONNECTION_STRINGData Source=/app/data/hsqlagent.dbStores accounts, roles, keys, audit records, policies, and other control-plane state
HMAC_KEYplaceholderHMAC secret used to protect/verify issued MCP keys; ≥32 bytes
MCP_PUBLIC_ENDPOINThttp://localhost:8080/mcpAbsolute endpoint placed into generated MCP client configuration

MCP_PUBLIC_ENDPOINT must be an absolute HTTP or HTTPS URL. In production it should be the URL the client can actually reach, including /mcp, not an internal container address.

Admin database topology

The single-instance example uses SQLite. The distributed example uses PostgreSQL:

ADMIN_DATABASE_PROVIDER=Postgres
ADMIN_DATABASE_CONNECTION_STRING=Host=postgres;Port=5432;Database=hsqlagent;Username=postgres;Password=...

Use a shared Admin database when several hs-sql-agent instances must observe the same identities, keys, policies, and audit/control-plane records.

Cache

VariableSingle-instance exampleDistributed examplePurpose
CACHE_PROVIDERMemoryRedisRuntime cache provider
CACHE_CONNECTION_STRINGemptyredis:6379Redis connection when selected
CACHE_KEY_PREFIXhsqlagent:cache:sameNamespace for cache keys

Process-local Memory is appropriate only when cache state does not need to be shared between application instances.

Bootstrap / auto-provisioning

VariableExamplePurpose
BOOTSTRAP_ENABLEDfalseEnable startup provisioning/synchronization
BOOTSTRAP_DB_IDdefault-dbStable bootstrap identity for the initial database
BOOTSTRAP_DB_NAMEDefault DBAdmin-facing database name
BOOTSTRAP_DB_PROVIDERemptyProvider to provision
BOOTSTRAP_DB_HOSTlocalhostDatabase host
BOOTSTRAP_DB_PORT5432Database port
BOOTSTRAP_DB_DATABASEmydbDatabase/catalog/file value
BOOTSTRAP_DB_USERNAMEmyuserDatabase username
BOOTSTRAP_DB_PASSWORDmypasswordDatabase password
BOOTSTRAP_DB_EXTRA_SETTINGSemptyProvider-specific connection settings
BOOTSTRAP_MCP_KEY_IDdefault-keyStable bootstrap identity for the initial MCP key
BOOTSTRAP_MCP_KEY_NAMEDefault MCP KeyAdmin-facing key name
BOOTSTRAP_MCP_KEYplaceholderInitial raw key value
BOOTSTRAP_MCP_ALLOWED_TOOLSemptyTool restriction for the bootstrap key

Bootstrap-managed MCP keys are intentionally not editable, rotatable, or revocable through the normal key lifecycle. Change their source configuration instead.

Admin authentication

VariableExamplePurpose
JWT_KEYplaceholderJWT signing secret; ≥32 bytes
JWT_ISSHS-AgentJWT issuer
JWT_AUDHS-Agent-UsersJWT audience
JWT_ACCESS_TOKEN_EXPIRATION_MINUTES10Access-token lifetime
JWT_REFRESH_TOKEN_EXPIRATION_DAYS1Refresh-token lifetime
AUTH_LOCKOUT_THRESHOLD5Failed sign-ins before temporary lockout; values below 1 are treated as 1
AUTH_LOCKOUT_MINUTES15Temporary lockout duration

These settings govern Admin authentication, not MCP-key authentication.

Password reset and SMTP

Password-reset mail is effectively disabled when the SMTP host or sender is empty.

VariableExamplePurpose
PASSWORD_RESET_BASE_URLhttp://localhost:3000/reset-passwordExternally reachable reset page; server appends ?token=...
PASSWORD_RESET_EXPIRATION_MINUTES30One-time reset-token lifetime
SMTP_HOSTsmtp.example.comSMTP host
SMTP_PORT587SMTP port
SMTP_ENABLE_SSLtrueSSL/STARTTLS behavior used by the mail sender
SMTP_USERNAMEexampleSMTP credential
SMTP_PASSWORDexampleSMTP credential
SMTP_FROMno-reply@example.comSender address accepted by the SMTP provider

OIDC / SSO and MFA

VariableExamplePurpose
OIDC_ENABLEDfalseEnable OIDC authentication
OIDC_AUTHORITYemptyIdentity-provider authority
OIDC_CLIENT_IDemptyOIDC client ID
OIDC_CLIENT_SECRETemptyOIDC client secret
OIDC_REQUIRE_HTTPS_METADATAtrueRequire HTTPS discovery metadata
OIDC_EMAIL_CLAIMemailEmail claim name
OIDC_NAME_CLAIMnameDisplay-name claim
OIDC_ROLE_CLAIMrolesRole claim
OIDC_EMAIL_VERIFIED_CLAIMemail_verifiedVerified-email claim
OIDC_REQUIRE_VERIFIED_EMAILtrueReject identities without verified email according to the configured claim
OIDC_SCOPE_0..2openid, profile, emailDefault scopes
OIDC_ROLE_MAPPING_SQL_ADMINSSuperUserExample external-role → local-role mapping
OIDC_AUTO_PROVISIONtrueProvision users on successful external identity resolution
OIDC_FRONTEND_CALLBACK_URL/sso-callbackFrontend completion route
OIDC_LOGIN_CODE_EXPIRATION_MINUTES2Short-lived login-code lifetime
OIDC_TOTP_ISSUERHS SQL AgentTOTP issuer label
DATA_PROTECTION_KEY_PATH/app/data/data-protection-keysPersistent ASP.NET Core data-protection key directory

See OIDC and MFA.

Health, slow queries, delivery, and audit retention

VariableExamplePurpose
HEALTH_PROBE_ENABLEDfalseEnable background DB health probing
HEALTH_PROBE_INTERVAL_SECONDS60Probe cadence
HEALTH_PROBE_TIMEOUT_SECONDS10Per-probe timeout
HEALTH_PROBE_MAX_CONCURRENCY4Bound concurrent probe work
SLOW_QUERY_THRESHOLD_MS1000Queries at/above this duration are recorded as slow
ALERT_WEBHOOK_URLemptyOptional signed alert destination
ALERT_WEBHOOK_SECRETemptyHMAC/signing secret; ≥32 bytes when URL enabled
SIEM_WEBHOOK_URLemptyOptional signed SIEM destination
SIEM_WEBHOOK_SECRETemptyHMAC/signing secret; ≥32 bytes when URL enabled
DELIVERY_MAX_ATTEMPTS6Retry bound for outbound deliveries
DELIVERY_MAX_CONCURRENCY4Bound concurrent outbound deliveries
AUDIT_RETENTION_DAYS90Retention period; 0 disables automatic retention
AUDIT_RETENTION_MODEArchiveValid runtime values: Archive or Purge
AUDIT_ARCHIVE_PATH/app/data/audit-archiveArchive destination in Archive mode
AUDIT_FALLBACK_PATH/app/data/audit-fallback.jsonlAudit fallback path; required by startup validation
AUDIT_RETENTION_RUN_HOUR_UTC2Scheduled UTC hour, runtime-clamped to 0–23

Archive writes expired audit rows to a JSONL archive before deleting them from the Admin database. Purge deletes matching expired rows without creating that archive.

Global and per-key rate limiting

VariableSingle-instanceDistributedPurpose
RATE_LIMITING_PERMIT_LIMIT00Global IP permit limit; 0 with zero window means unlimited
RATE_LIMITING_WINDOW_SECONDS00Global IP window
RATE_LIMITER_PROVIDERMemoryRedisShared limiter implementation
RATE_LIMITER_CONNECTION_STRINGemptyredis:6379Redis connection
RATE_LIMITER_FAILURE_MODEFailClosedFailClosedBehavior when distributed limiter is unavailable
RATE_LIMITER_KEY_PREFIXhsqlagent:ratelimit:sameRedis key namespace

MCP keys can additionally inherit, override, or disable their per-key limit. See MCP Keys.

Runtime policy synchronization

VariableSingle-instanceDistributedPurpose
SECURITY_POLICY_SYNC_PROVIDERMemoryRedisRuntime policy synchronization provider
SECURITY_POLICY_SYNC_CONNECTION_STRINGemptyredis:6379Redis connection
SECURITY_POLICY_SYNC_KEY_PREFIXhsqlagent:security-policy:sameKey namespace
SECURITY_POLICY_SYNC_REFRESH_INTERVAL_SECONDS3030Refresh interval

Choose Redis when policy changes must propagate across multiple hs-sql-agent instances.

Outbound-delivery synchronization

VariableSingle-instanceDistributedPurpose
OUTBOUND_DELIVERY_SYNC_PROVIDERMemoryRedisDelivery signal coordination
OUTBOUND_DELIVERY_SYNC_CONNECTION_STRINGemptyredis:6379Redis connection
OUTBOUND_DELIVERY_SYNC_KEY_PREFIXhsqlagent:outbound-delivery:sameKey namespace

SQL concurrency coordination

VariableSingle-instanceDistributedPurpose
SQL_CONCURRENCY_PROVIDERMemoryRedisSQL concurrency limiter provider
SQL_CONCURRENCY_CONNECTION_STRINGemptyredis:6379Redis connection
SQL_CONCURRENCY_FAILURE_MODEFailClosedFailClosedBehavior when distributed coordination fails
SQL_CONCURRENCY_KEYhsqlagent:sql-concurrencysameShared coordination key
SQL_CONCURRENCY_LEASE_SECONDS3030Lease duration

Metadata discovery, queries, DML planning/execution, and health-related SQL work use bounded runtime paths. Use distributed SQL concurrency when the limit must apply across the cluster rather than per process.

Observability

VariableExamplePurpose
PROMETHEUS_ENABLEDfalseEnable Prometheus HTTP listener
PROMETHEUS_HOST0.0.0.0Metrics listener bind host
PROMETHEUS_PORT9000Separate metrics listener port; validated 1–65535 when enabled
OTLP_ENDPOINTemptyAbsolute HTTP(S) OTLP collector endpoint
OTEL_SERVICE_NAMEhs-sql-agentOpenTelemetry service name; must not be blank

Prometheus is intentionally served on a separate listener, not the Admin/MCP application port. When OTLP_ENDPOINT is configured, v2.0.2 exports telemetry including SQL compile-evidence tracing/log integration.

See Observability.

Logging

VariableExample
LOGGING_EFCORE_COMMAND_LOGLEVELWarning
LOGGING_DEFAULT_LOGLEVELInformation
LOGGING_ASPNETCORE_LOGLEVELWarning

Keeping routine EF Core command logging at Warning reduces noisy SQL command traces in normal production operation.

Docker environment vs embedded .NET capability options

The Docker/ToolBox environment is a complete standalone-server configuration surface. New NuGet integrations are different: AddHsSqlAgentCore() is optionless, and each selected capability owns its own options.

For example:

  • HsSqlAgentAdminStoreOptions owns the Admin database provider and connection string;
  • HsSqlAgentRuntimeOptions owns cache, rate limiting, synchronization, SQL concurrency, DML approval storage, bootstrap, and operability;
  • HsSqlAgentBuiltInAuthOptions owns JWT, password reset/SMTP, and enterprise identity/OIDC;
  • McpOptions owns the public MCP endpoint and HMAC secret;
  • TelemetryOptions owns Prometheus and OTLP settings.

HsSqlAgentServiceOptions remains only as the legacy aggregate compatibility DTO. Unselected capabilities do not allocate or validate their options, so an embedded host using AddHsSqlAgentHostAuthorization(...) does not need HsSqlAgent JWT, SMTP, password-reset, or OIDC settings.

The modular API preserves the existing code defaults. .env.example remains a deployment example for the standalone ToolBox path and should not be treated as a declaration that every embedded host must configure every capability.

See ASP.NET Core integration.