Documentation Index
Fetch the complete documentation index at: https://mintlify.com/A-Point-Systems-ltd/ms-sql-mcp/llms.txt
Use this file to discover all available pages before exploring further.
InstallInsightsLayer is an MCP tool that installs every required database object in a single idempotent operation. You call it once per target database; re-running it at any time is safe — all CREATE statements are guarded by existence checks, and any objects that are already present are left unchanged. No SQL scripts need to be run manually.
Prerequisites
Before callingInstallInsightsLayer, confirm the following:
USE_INSIGHTS_LAYERmust be enabled. This is the default. If you have set it tofalse,0,no,off, ordisabled, the tool returns a “layer is disabled” error without touching the database. Remove the variable or set it totrueand restart the server.- The connecting user needs
ALTER ANY DATABASE DDL TRIGGERpermission (or membership in theddl_adminorsysadminfixed server role) to install the database-levelDDL_Audittrigger. TheAIInsightsschema and tables can be created without this permission, but the DDL trigger installation will fail. - Azure SQL Database is fully supported. The connecting user needs adequate permissions on the target database. Ensure the account has at minimum
db_owneror the ability to create schemas, tables, and DDL triggers.
What gets installed
InstallInsightsLayer applies the embedded CreateInsightsSchema.sql and CreateDdlAuditTrigger.sql scripts in sequence, creating the following objects if they do not already exist:
AIInsightsschema — the namespace for all cache objectsAIInsights.SchemaInsights— stores the current cached insight for each(objectType, schemaName, objectName, columnName)tuple; includes description, business purpose, data patterns, usage guidelines, related objects, LLM model, confidence score, schema fingerprint, and the object’smodify_dateat analysis timeAIInsights.InsightHistory— archive table where rows fromSchemaInsightsare moved when an object changes or is dropped; preserves the full insight along with archive reason, event name, and source DDL audit IDAIInsights.DdlChangeWatermark— a singleton row that tracks the highestDDL_AuditLog.IDprocessed by the background service, preventing duplicate processing on restartdbo.DDL_AuditLog— captures every DDL event that fires the trigger; records the host name, login, schema, object name, object type, event type, command text, and XML event dataDDL_Audit(database-level trigger) — fires on DDL events at the database scope and inserts one row intodbo.DDL_AuditLogper event; requiresALTER ANY DATABASE DDL TRIGGERto install
Running the install
InstallInsightsLayer is a regular MCP tool call — no manual SQL execution is needed. Instruct your agent:
DbOperationResult reporting success or the specific error that occurred:
InstallInsightsLayer to install only the missing trigger.
Verifying the install
After installation, callInsightsCheck to confirm every component is in place. InsightsCheck queries the live database and returns the following fields from the LayerStatus model:
| Field | Type | Meaning |
|---|---|---|
layerEnabledViaEnvironment | bool | true unless USE_INSIGHTS_LAYER is set to a falsey value |
aiInsightsSchemaExists | bool | true if the AIInsights schema was found in sys.schemas |
ddlAuditTableExists | bool | true if dbo.DDL_AuditLog exists |
ddlAuditTriggerEnabled | bool | true if a database-level trigger named DDL_Audit exists and is not disabled |
schemaInsightsCount | int | current row count in AIInsights.SchemaInsights |
lastProcessedAuditId | int | highest DDL_AuditLog.ID consumed by the background service (0 if none yet) |
lastProcessedAt | datetime? | timestamp of the last watermark update, or null if no DDL events have been processed |
aiInsightsSchemaExists, ddlAuditTableExists, and ddlAuditTriggerEnabled all true. schemaInsightsCount starts at 0 and grows as agents call DescribeTable, DescribeView, and GetObject (auto-population fills rows on first introspection).
If
USE_INSIGHTS_LAYER=false, InsightsCheck immediately returns all boolean flags as false and all numeric fields as 0 without opening a database connection or running any queries. Enable the layer and restart the server before calling InsightsCheck to get real status.