AI Agents endpoints

Run AI agents, follow their jobs, use the built-in AI helpers and manage AI settings. Paths are relative to the address of your Simcha DB Studio server.

Through the MCP server these endpoints are the AI Agents tool group, off until an admin turns it on.

While this group is on, the MCP server also offers the lookups its tools need: connections_list (List connections, from Connections).

MethodPathWhat it does
GET/api/ai/agentsList the AI agents
POST/api/ai/agents/:idRun an AI agent
GET/api/ai/agents/:id/runsList the recent runs of an AI agent
GET/api/ai/agents/jobs/:idGet an AI agent job
GET/api/ai/agents/jobsList AI agent jobs
DELETE/api/ai/agents/jobs/:idCancel an AI agent job
GET/api/ai/providersList the AI providers
POST/api/ai/nl-to-sqlWrite a query from a question
POST/api/ai/chatChat with the AI database assistant
POST/api/ai/review-scriptReview a script for risk with AI
GET/api/ai/statusShow whether AI is set up
GET/api/ai/settingsGet the AI settings
PUT/api/ai/settingsChange the AI settings

GET /api/ai/agents

Lists the IDs of the AI agents that ai_agent_run can run.

Reads only · Role: Any signed-in user · MCP tool: ai_agents_list

No inputs.

POST /api/ai/agents/:id

Runs one AI agent with the AI provider and records the run in its history. With async true, or when an admin set agent runs to always run in the background, it queues a job and returns its job ID at once; follow it with ai_job_get. Refused when agents are turned off, the per-minute limit is reached, no AI provider is set up, or the caller's roles do not include Governance.

Changes data · Role: Any signed-in user · MCP tool: ai_agent_run

InputTypeDescription
id (path)one of script-review, nl-to-sql, schema-explorer, error-diagnosis, query-optimization, auto-rollback, change-impact, release-summary, compliance, anomaly-detection, requiredThe agent to run
async (query)boolean, optionalSend true to run the agent in the background as a job. Ignored when an admin turned background runs off
input (body)object, optionalWhat the agent needs, which depends on the agent. script-review: script, dialect or connectionId, notes. nl-to-sql: prompt, connectionId. schema-explorer: history (turns ending with the question), connectionId. error-diagnosis: sql, errorMessage, dialect or connectionId. query-optimization: sql (one statement), connectionId. auto-rollback: forwardScript, dialect, preConditions. change-impact: script, connectionId. release-summary: releaseId, or releaseName, version and scripts (each with name and script). compliance: script, dialect, environment. anomaly-detection: lookbackCount (1 to 1000), scriptId. A connectionId must name an existing connection
context (body)object, optionalWhere the run comes from, recorded with it when input has no connection
context.connectionId (body)string, optionalThe connection ID to record with the run
context.dialect (body)string, optionalThe database engine

GET /api/ai/agents/:id/runs

Lists the recent runs of an agent or built-in AI helper, newest first, with status, model, token count and duration. Admins see every user's runs; others see their own.

Reads only · Role: Any signed-in user · MCP tool: ai_agent_runs

InputTypeDescription
id (path)one of script-review, nl-to-sql, schema-explorer, error-diagnosis, query-optimization, auto-rollback, change-impact, release-summary, compliance, anomaly-detection, ide-chat, review-script, blast-radius-narrative, compliance-rule-writer, requiredThe agent or AI helper whose runs to list. ide-chat is ai_chat and review-script is ai_review_script
limit (query)integer, 1 to 500, optionalHow many to return, newest first. Default 50

GET /api/ai/agents/jobs/:id

Returns one background agent job with its status (pending, running, success, error or cancelled), its input and, once it finishes, its result or error. Admins can read any job; others only their own.

Reads only · Role: Any signed-in user · MCP tool: ai_job_get

InputTypeDescription
id (path)string (uuid), requiredThe job ID

GET /api/ai/agents/jobs

Lists background agent jobs, newest first, with their status and timing. Admins see every user's jobs; others see their own.

Reads only · Role: Any signed-in user · MCP tool: ai_jobs_list

InputTypeDescription
limit (query)integer, 1 to 500, optionalHow many to return, newest first. Default 50

DELETE /api/ai/agents/jobs/:id

Cancels a pending or running background agent job. A job that is already running finishes its call to the AI provider, but its result is not saved. Refused when the job has finished, belongs to someone else (unless the caller is an admin), or the caller's roles do not include Governance.

Changes data and can remove or overwrite it · Role: Any signed-in user · MCP tool: ai_job_cancel

InputTypeDescription
id (path)string (uuid), requiredThe job ID

GET /api/ai/providers

Lists the AI providers that can be set up, each with its default model, whether it needs an API key or an endpoint, and the settings it ignores.

Reads only · Role: Any signed-in user · MCP tool: ai_providers_list

No inputs.

POST /api/ai/nl-to-sql

Sends a question and the schema of a connection to the AI provider and returns the query it writes. The query is not run. The call is recorded in the nl-to-sql run history. Refused when agents are turned off, the per-minute limit is reached or no AI provider is set up.

Changes data · Role: Any signed-in user · MCP tool: ai_nl_to_sql

InputTypeDescription
prompt (body)string, requiredThe question about the data
connectionId (body)string, requiredThe connection to write the query for. Its schema is sent to the AI provider

POST /api/ai/chat

Sends a conversation to the AI provider and returns its reply. Only the last 20 user and assistant turns are sent; with a connection, its schema is sent too. The call is recorded in the ide-chat run history. Refused when agents are turned off, the per-minute limit is reached or no AI provider is set up.

Changes data · Role: Any signed-in user · MCP tool: ai_chat

InputTypeDescription
messages (body)list of object, requiredThe conversation so far, oldest first, ending with the question. Turns with another role are left out
messages[].role (body)one of user, assistant, requiredWho wrote the turn
messages[].content (body)string, requiredThe text of the turn
connectionId (body)string, optionalThe connection the conversation is about. Leave it out for answers without a schema

POST /api/ai/review-script

Sends a script to the AI provider for a risk review and returns a risk score (low, medium, high or critical), findings and a summary. The call is recorded in the review-script run history. Refused when agents are turned off, the per-minute limit is reached or no AI provider is set up.

Changes data · Role: Any signed-in user · MCP tool: ai_review_script

InputTypeDescription
script (body)string, requiredThe script to review
databaseType (body)string, optionalThe database engine the script is for. Leave it out for generic SQL

GET /api/ai/status

Returns whether an AI provider is set up, with the provider and model. Admins also see the endpoint.

Reads only · Role: Any signed-in user · MCP tool: ai_status

No inputs.

GET /api/ai/settings

Returns the AI provider, model, script review mode and whether an API key is stored. Admins also get the endpoint and provider options, the agent settings, and which AWS keys are stored; secret values are never returned and extra header values show as [stored].

Reads only · Role: Any signed-in user · MCP tool: ai_settings_get

No inputs.

PUT /api/ai/settings

Changes the AI settings sent; the rest stay as they are. API keys, AWS keys and extra header values are stored encrypted, and an empty key leaves the stored one in place. Refused when any value is invalid.

Changes data · Role: Admin · MCP tool: ai_settings_update

InputTypeDescription
provider (body)string, optionalThe AI provider: openai, anthropic, azure-openai, bedrock, gemini, vertex, ollama, openai-compatible or augment. An empty string clears it
model (body)string, optionalThe model ID, up to 200 characters
apiKey (body)string, optionalThe provider API key, up to 4000 characters
endpoint (body)string, optionalThe provider endpoint, an http or https URL of up to 500 characters
apiVersion (body)string, optionalThe provider API version, up to 100 characters
deployment (body)string, optionalThe provider deployment or route name, up to 200 characters
region (body)string, optionalThe provider region, up to 50 characters
projectId (body)string, optionalThe provider project ID, up to 200 characters
awsRoleArn (body)string, optionalAn AWS IAM role ARN to assume for Bedrock, like arn:aws:iam::123456789012:role/name
awsAccessKeyId (body)string, optionalThe AWS access key ID, up to 200 characters
awsSecretAccessKey (body)string, optionalThe AWS secret access key, up to 400 characters
awsSessionToken (body)string, optionalThe AWS session token, up to 4000 characters
extraHeaders (body)object, optionalExtra HTTP headers sent to the provider, at most 20, each a header name and a text value of up to 2000 characters. Send [stored] as a value to keep the stored one; headers left out are removed, so an empty object removes them all
maxTokens (body)integer, 1 to 200000 or null, optionalThe most output tokens per request
temperature (body)number, 0 to 2 or null, optionalThe sampling temperature, from 0 to 2
timeoutMs (body)integer, 1000 to 600000 or null, optionalThe time limit per request, in milliseconds
scriptReviewMode (body)one of auto, manual, optionalWhether scripts are reviewed by AI automatically or only on request
agents (body)object, optionalAgent settings
agents.globalEnabled (body)boolean, optionalWhether AI agents can run at all
agents.asyncMode (body)one of off, opt-in, always, optionalBackground runs: off (never), opt-in (when asked) or always
agents.rateLimitEnabled (body)boolean, optionalWhether runs per user and agent are limited per minute
agents.rateLimitPerMinute (body)integer, 1 to 10000, optionalRuns allowed per user and agent per minute
agents.cacheEnabled (body)boolean, optionalWhether identical runs reuse a cached answer
agents.cacheTtlSeconds (body)integer, 1 to 86400, optionalHow long a cached answer is kept, in seconds
agents.schemaTableCap (body)integer, 0 to 100000, optionalThe most tables of a schema sent to the provider. 0 means no limit
agents.schemaDetailLevel (body)one of names, types, full, optionalHow much of the schema is sent: names, types or full
agents.excludedTables (body)string, optionalTables never sent to the provider, separated by commas, spaces or new lines, up to 5000 characters
agents.sendRowData (body)boolean, optionalWhether sample rows may be sent to the provider