When you embed the widget, each end user likely needs the agent to connect to their data — their database, their API, their tenant. Environment variables and secrets let you pass per-user credentials at token exchange time so the agent’s MCP servers connect to the right services for each end user.Documentation Index
Fetch the complete documentation index at: https://docs.sigmic.ai/llms.txt
Use this file to discover all available pages before exploring further.
How It Works
- Your backend passes
envandsecretswhen exchanging credentials for a widget JWT - Sigmic AI stores them server-side — secrets are encrypted at rest. Neither
envnorsecretsare included in the JWT itself or sent to the browser. - When the user chats, the platform retrieves the stored values and injects them into every MCP server in the project. Template placeholders like
{{mcp.API_KEY}}in your server config are resolved to the actual values before the connection is established.
env vs secrets
Both env and secrets are key-value string maps passed in the token exchange request. The difference is how they are stored:
env | secrets | |
|---|---|---|
| Storage | Encrypted at rest | Encrypted at rest |
| Returned in API responses | Never | Never |
| Sent to the browser | Never | Never |
| Use for | Tenant IDs, regions, feature flags | API tokens, database URLs, passwords |
| Available as | {{mcp.KEY}} in MCP config | {{mcp.KEY}} in MCP config |
env and secrets, the secrets value takes precedence.
The
env/secrets distinction exists for forward compatibility. Today both are stored securely. Use secrets for anything sensitive (tokens, passwords, connection strings) and env for non-sensitive configuration (tenant IDs, regions, feature flags).Using Variables in MCP Server Config
MCP servers are configured in your project settings (via the Console or the project config API). Use{{mcp.KEY}} placeholders in the server’s headers, env, or url fields. These placeholders are resolved at runtime using the env/secrets from the active widget token.
Example: HTTP server with API key in headers
Step 1 — Configure the MCP server in your project:my-api-server, the headers are resolved to:
Example: stdio server with environment variables
MCP server config:Example: SSE server with dynamic URL
env: { REGION: 'us-east-1' } and secrets: { ANALYTICS_KEY: 'ak-12345' }, the agent connects to https://us-east-1.analytics.example.com/mcp/sse with header X-API-Key: ak-12345.
Template Reference
| Aspect | Detail |
|---|---|
| Syntax | {{mcp.KEY_NAME}} |
| Supported fields | headers, env, and url in MCP server configs |
| Resolution timing | When the MCP server connection is established (not at token issuance) |
| Missing keys | If a {{mcp.KEY}} has no matching value, it is left unchanged and a warning is logged |
| Scope | All MCP servers in the project receive the same set of variables |
Key naming rules
Keys must be valid environment variable names:- Start with a letter or underscore
- Contain only letters, digits, and underscores
- All values must be strings
| Valid | Invalid |
|---|---|
TENANT_ID | 123-invalid (starts with digit) |
API_KEY | has-dashes (contains hyphens) |
db_url | has spaces (contains spaces) |
_INTERNAL | key.with.dots (contains dots) |
Multi-Tenant Example
A common pattern is passing per-tenant credentials so each end user’s widget session connects the agent to that user’s data:Token Refresh and Variables
Each widget token has its own set ofenv/secrets. When you refresh a token, you must pass env and secrets again — the new token does not inherit values from the previous one.
This also means you can update credentials on refresh without interrupting the session. For example, if an end user’s API key is rotated, the next token refresh can include the new key.
Security
envandsecretsare never included in the JWT — they are stored server-side only- They are never sent to the browser — the widget iframe only receives the JWT
- Values are stored encrypted and automatically cleaned up when the token expires
- Secrets are only decrypted when the agent session needs them
This is the same mechanism used by the Task API for passing environment variables. If you are already using
env/secrets with the Task API, they work identically in the widget.