Asynchronous API layer built around the nlsql-coder CLI. Supports multiple users with user-dedicated workspaces, Azure blob storage for persistence, and user-friendly downloadable links to created projects.
| Variable Name | Example | Required? | Description |
|---|---|---|---|
NLSQL_API_KEY | your-nlsql-api-key | Yes | Authentication key for nlsql-coder CLI. |
MODEL_PROVIDER | azure | Yes | Controls the LLM provider routing backend (nlsql-coder). |
MODEL_NAME | gpt-5.5 | Yes | Specifies the exact model deployment identifier to target. |
AZURE_OPENAI_API_KEY | your-azure-openai-key | Conditional | Required if MODEL_PROVIDER is set to azure. |
AZURE_OPENAI_ENDPOINT | https://your-resource.openai.azure.com/ | Conditional | Required if MODEL_PROVIDER is set to azure. |
AZURE_OPENAI_API_VERSION | 2024-02-01 | Conditional | Required if MODEL_PROVIDER is set to azure. |
AWS_ACCESS_KEY_ID | your-aws-access-key-id | Conditional | Required if MODEL_PROVIDER is set to aws. |
AWS_SECRET_ACCESS_KEY | your-aws-secret-access-key | Conditional | Required if MODEL_PROVIDER is set to aws. |
AWS_DEFAULT_REGION | us-east-1 | Conditional | Required if MODEL_PROVIDER is set to aws. |
GEMINI_API_KEY | your-gemini-api-key | Conditional | Required if MODEL_PROVIDER is set to gcp. |
AZURE_STORAGE_ACCOUNT_NAME | yourstorageaccountname | Yes | Target account for user project zip uploads. |
AZURE_CLIENT_ID | 00000000-0000-0000-0000-000000000000 | Yes | Client ID of the User-Assigned Managed Identity used for secure blob uploads. |
AZURE_WEB_APP_URL | https://your-azurewebapp-url.azurewebsites.net | Yes | The origin domain of your frontend UI application used to lock down strict CORS network policies. (I.e. AI-Employee URL) |
MCP_OAUTH_REDIRECT_URI | https://your-api-url/mcp/oauth/callback | Conditional | Public callback the OAuth provider redirects to after the user authorizes an MCP server. Required for OAuth-based MCP servers. Must exactly match the redirect URI registered in each provider's console. Passed through to the CLI. |
MCP_TOKENS_TABLE_NAME | mcptokens | No | Azure Table name for stored MCP OAuth tokens (default mcptokens; auto-created on first use). |
ENCRYPTION_KEY | a-long-random-secret | Recommended | Secret used to encrypt MCP OAuth tokens at rest (Fernet key derived from it). If unset/default, tokens are stored unencrypted. |
ENV_STORAGE_ACCOUNT_NAME / ENV_STORAGE_SAS_TOKEN | — | No | Optional fallback/override for the token-table account + SAS credential. Not needed when AZURE_STORAGE_ACCOUNT_NAME + AZURE_CLIENT_ID are set. |
MCP OAuth tokens persist in an Azure Table on the same storage account used for blob
uploads (AZURE_STORAGE_ACCOUNT_NAME), authenticated with the same user-assigned managed
identity (AZURE_CLIENT_ID). The mcptokens table is created automatically if absent.
No extra credentials are required beyond what blob uploads already use.
| GOOGLE_OAUTH_CLIENT_ID | …apps.googleusercontent.com | No | Set (with the two below) to provision the built-in Gmail MCP for every user without an mcp.json upload. |
| GOOGLE_OAUTH_PASSWORD | GOCSPX-… | No | The Google OAuth client secret for the built-in Gmail MCP. |
| GOOGLE_OAUTH_REDIRECT_URI | https://your-api/mcp/oauth/callback | No | Redirect URI for the built-in Gmail MCP; must be registered in the Google client. |
| GOOGLE_OAUTH_SCOPE | https://www.googleapis.com/auth/gmail.readonly | No | Optional scope override for the built-in Gmail MCP (the server otherwise dictates scopes). |
| GMAIL_MCP_URL | https://gmailmcp.googleapis.com/mcp/v1 | No | Optional override for the built-in Gmail MCP endpoint (defaults to the official URL). |
Users can add an MCP server that requires OAuth (e.g. Gmail) by uploading an mcp.json.
Because DCR is not supported by most providers, register an OAuth app per server and
put its credentials in the server's oauth block:
{
"mcpServers": {
"gmail": {
"url": "https://gmail-mcp.example.com/mcp",
"oauth": {
"client_id": "<app client id>",
"client_secret": "<app client secret>",
"scope": "https://www.googleapis.com/auth/gmail.readonly",
"redirect_uri": "https://your-api-url/mcp/oauth/callback"
}
}
}
}
redirect_uri may be omitted per-server if MCP_OAUTH_REDIRECT_URI is set globally; it
must match what is registered in the provider's console. client_secret and scope
are optional (omit client_secret for public/PKCE clients).
Secret handling. All sensitive values above (model/provider keys, Azure token-storage credentials, the OAuth client secret) are snapshotted in-process at startup and then removed from the environment before any prompt runs, so the sandboxed
execute_bash_commandtool and its child processes never inherit them. Non-secret settings (URLs, scopes, table name,USER_ID) are left in place.
Setting GOOGLE_OAUTH_CLIENT_ID + GOOGLE_OAUTH_PASSWORD (client secret) +
GOOGLE_OAUTH_REDIRECT_URI provisions a built-in gmail server for every session
— users don't upload an mcp.json. Tokens are stored per user_id, so only the server
config is shared, never credentials. An uploaded mcp.json still works and its own
gmail entry (or any other server) overrides the built-in.
Automatic link at session start. When a session starts, any MCP server that still
needs OAuth has its authorization link returned in the POST /session/start response
(the session's first message) — no /mcp reload needed. The handshake then completes in
the background: the user can keep chatting with other tools, and the Gmail tools
activate automatically once they click the link and authorize. The authorization code is
delivered to the session out-of-band (a per-user file under the session dir written by
GET /mcp/oauth/callback), never over the chat/PTY channel. Uploading an mcp.json
mid-session via POST /session/mcp still surfaces links the same way, streamed in that
call's response.
Refresh tokens / offline access. For Google authorization endpoints, the flow adds
access_type=offline and prompt=consent automatically so Google returns a refresh
token (sessions then survive past the ~1h access-token lifetime without re-authorizing).
For other providers, or to override, add an authorization_params object to the oauth
block — its keys are merged into the authorization URL, e.g.:
"oauth": {
"client_id": "…",
"authorization_params": { "access_type": "offline", "prompt": "consent" }
}
POST /session/mcp with {user_id, mcp_bytes} (base64 mcp.json).
The server writes the file, reloads MCP servers, and streams the reply.GET /mcp/oauth/callback. The token is exchanged and stored in Azure Table
(keyed by user_id), so it is reused in future sessions with no re-authorization.POST /session/prompt.Content type
Image
Digest
sha256:c3ec65069…
Size
117.7 MB
Last updated
about 2 months ago
docker pull denissa4/nlsql-coder-api