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).
| Method | Path | What it does |
|---|---|---|
| GET | /api/ai/agents | List the AI agents |
| POST | /api/ai/agents/:id | Run an AI agent |
| GET | /api/ai/agents/:id/runs | List the recent runs of an AI agent |
| GET | /api/ai/agents/jobs/:id | Get an AI agent job |
| GET | /api/ai/agents/jobs | List AI agent jobs |
| DELETE | /api/ai/agents/jobs/:id | Cancel an AI agent job |
| GET | /api/ai/providers | List the AI providers |
| POST | /api/ai/nl-to-sql | Write a query from a question |
| POST | /api/ai/chat | Chat with the AI database assistant |
| POST | /api/ai/review-script | Review a script for risk with AI |
| GET | /api/ai/status | Show whether AI is set up |
| GET | /api/ai/settings | Get the AI settings |
| PUT | /api/ai/settings | Change 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
| Input | Type | Description |
|---|---|---|
id (path) | one of script-review, nl-to-sql, schema-explorer, error-diagnosis, query-optimization, auto-rollback, change-impact, release-summary, compliance, anomaly-detection, required | The agent to run |
async (query) | boolean, optional | Send true to run the agent in the background as a job. Ignored when an admin turned background runs off |
input (body) | object, optional | What 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, optional | Where the run comes from, recorded with it when input has no connection |
context.connectionId (body) | string, optional | The connection ID to record with the run |
context.dialect (body) | string, optional | The 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
| Input | Type | Description |
|---|---|---|
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, required | The 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, optional | How 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
| Input | Type | Description |
|---|---|---|
id (path) | string (uuid), required | The 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
| Input | Type | Description |
|---|---|---|
limit (query) | integer, 1 to 500, optional | How 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
| Input | Type | Description |
|---|---|---|
id (path) | string (uuid), required | The 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
| Input | Type | Description |
|---|---|---|
prompt (body) | string, required | The question about the data |
connectionId (body) | string, required | The 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
| Input | Type | Description |
|---|---|---|
messages (body) | list of object, required | The conversation so far, oldest first, ending with the question. Turns with another role are left out |
messages[].role (body) | one of user, assistant, required | Who wrote the turn |
messages[].content (body) | string, required | The text of the turn |
connectionId (body) | string, optional | The 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
| Input | Type | Description |
|---|---|---|
script (body) | string, required | The script to review |
databaseType (body) | string, optional | The 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
| Input | Type | Description |
|---|---|---|
provider (body) | string, optional | The AI provider: openai, anthropic, azure-openai, bedrock, gemini, vertex, ollama, openai-compatible or augment. An empty string clears it |
model (body) | string, optional | The model ID, up to 200 characters |
apiKey (body) | string, optional | The provider API key, up to 4000 characters |
endpoint (body) | string, optional | The provider endpoint, an http or https URL of up to 500 characters |
apiVersion (body) | string, optional | The provider API version, up to 100 characters |
deployment (body) | string, optional | The provider deployment or route name, up to 200 characters |
region (body) | string, optional | The provider region, up to 50 characters |
projectId (body) | string, optional | The provider project ID, up to 200 characters |
awsRoleArn (body) | string, optional | An AWS IAM role ARN to assume for Bedrock, like arn:aws:iam::123456789012:role/name |
awsAccessKeyId (body) | string, optional | The AWS access key ID, up to 200 characters |
awsSecretAccessKey (body) | string, optional | The AWS secret access key, up to 400 characters |
awsSessionToken (body) | string, optional | The AWS session token, up to 4000 characters |
extraHeaders (body) | object, optional | Extra 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, optional | The most output tokens per request |
temperature (body) | number, 0 to 2 or null, optional | The sampling temperature, from 0 to 2 |
timeoutMs (body) | integer, 1000 to 600000 or null, optional | The time limit per request, in milliseconds |
scriptReviewMode (body) | one of auto, manual, optional | Whether scripts are reviewed by AI automatically or only on request |
agents (body) | object, optional | Agent settings |
agents.globalEnabled (body) | boolean, optional | Whether AI agents can run at all |
agents.asyncMode (body) | one of off, opt-in, always, optional | Background runs: off (never), opt-in (when asked) or always |
agents.rateLimitEnabled (body) | boolean, optional | Whether runs per user and agent are limited per minute |
agents.rateLimitPerMinute (body) | integer, 1 to 10000, optional | Runs allowed per user and agent per minute |
agents.cacheEnabled (body) | boolean, optional | Whether identical runs reuse a cached answer |
agents.cacheTtlSeconds (body) | integer, 1 to 86400, optional | How long a cached answer is kept, in seconds |
agents.schemaTableCap (body) | integer, 0 to 100000, optional | The most tables of a schema sent to the provider. 0 means no limit |
agents.schemaDetailLevel (body) | one of names, types, full, optional | How much of the schema is sent: names, types or full |
agents.excludedTables (body) | string, optional | Tables never sent to the provider, separated by commas, spaces or new lines, up to 5000 characters |
agents.sendRowData (body) | boolean, optional | Whether sample rows may be sent to the provider |