This document is the canonical operator contract for TellyMCP environment files.
Keep real deployment values in ignored files such as prod/.env-gateway and
prod/.env-client. Use the tracked .env.example.* files and config/templates/*
only as secret-free starting points.
- Use one role per file:
gateway,client, orboth. - Keep only required values and intentional overrides. Defaults do not need to be copied into production files.
- A gateway and its clients must share
GATEWAY_AUTH_TOKEN. GATEWAY_SCOPE_TOKENis an optional data-partition key, not an authentication credential.- Never keep old credentials in commented lines. Git and backups still retain them.
- Legacy or removed TellyMCP keys fail startup with a migration-required error and
the
tellymcp migrate-envcommand instead of being silently ignored. - There is deliberately no runtime fallback: migrate the file or the process does not start.
Required for a normal gateway deployment:
DISTRIBUTED_MODE=gateway
TELEGRAM_BOT_TOKEN=
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
REDIS_DB=1
DB_HOST=127.0.0.1
DB_PORT=5432
DB_USER=
DB_PASSWORD=
DB_NAME=
DB_SCHEMA=mcp
GATEWAY_PUBLIC_URL=https://example.com/api/gateway
GATEWAY_WS_URL=wss://example.com/api/gateway/ws
GATEWAY_AUTH_TOKEN=
ROOT_PREFIX=/api
PORT=8080
MCP_HTTP_HOST=0.0.0.0Common optional gateway groups:
- scope and owner-independent partitioning:
GATEWAY_SCOPE_TOKEN - Telegram:
TELEGRAM_BOT_USERNAME,ADMIN_TOKEN,DEBUG_LANGUAGE,TELEGRAM_POLL_INTERVAL_MS,TELEGRAM_DEFAULT_TIMEOUT_SECONDS,TELEGRAM_MAX_CONTEXT_CHARS,TELEGRAM_MAX_QUESTION_CHARS,TELEGRAM_MAX_MESSAGE_CHARS,TELEGRAM_MENU_PAYLOAD_TTL_SECONDS - webhook:
TELEGRAM_WEBHOOK_ENABLED,TELEGRAM_WEBHOOK_PATH,TELEGRAM_WEBHOOK_PUBLIC_URL,TELEGRAM_WEBHOOK_SECRET,TELEGRAM_WEBHOOK_TRACE,TELEGRAM_WEBHOOK_DROP_PENDING_UPDATES - PostgreSQL/Redis auth:
DB_SCHEMA,REDIS_USERNAME,REDIS_PASSWORD - RabbitMQ:
RMQ_HOST,RMQ_PORT,RMQ_USER,RMQ_PASSWORD,RMQ_VHOST,RMQ_EXCHANGE - public WebApp:
WEBAPP_ENABLED,WEBAPP_BASE_PATH,WEBAPP_PUBLIC_URL,WEBAPP_INITDATA_TTL_SECONDS,WEBAPP_SESSION_TTL_SECONDS,WEBAPP_LAUNCH_MODE,WEBAPP_VISIBLE_SCREENS,WEBAPP_ACTION_COOLDOWN_MS - prompt detection:
TERMINAL_PROMPT_SCAN_ENABLED,TERMINAL_PROMPT_SCAN_INTERVAL_SECONDS,TERMINAL_PROMPT_SCAN_COOLDOWN_SECONDS,TERMINAL_PROMPT_SCAN_STRATEGY,TERMINAL_PROMPT_SCAN_MIN_SCORE
Required for a gateway-connected console:
DISTRIBUTED_MODE=client
GATEWAY_PUBLIC_URL=https://example.com/api/gateway
GATEWAY_WS_URL=wss://example.com/api/gateway/ws
GATEWAY_AUTH_TOKEN=Common client settings:
Client runtime state is process-local. Redis is not used or required by a client;
the stable gateway client UUID is kept in .mcpsession.json.
REDIS_HOST, REDIS_PORT, REDIS_DB, REDIS_USERNAME, and REDIS_PASSWORD
are gateway/both settings. tellymcp migrate-env drops them from client output.
- identity:
PROJECT_NAME,TELLYMCP_SESSION_ID,TELLYMCP_SESSION_LABEL,GATEWAY_USER_UUID,NAMESPACE,NODE_ID - optional scope:
GATEWAY_SCOPE_TOKEN - local MCP:
MCP_HTTP_HOST,MCP_HTTP_PORT,MCP_HTTP_PATH,MCP_HTTP_BEARER_TOKEN,MCP_HTTP_ENABLE_DEBUG_ROUTES,MCP_HTTP_ENABLE_PRUNE_ROUTE - local storage:
MCP_XCHANGE_DIR - PTY:
TERMINAL_SHELL,TERMINAL_COLS,TERMINAL_ROWS,TERMINAL_SCROLLBACK_LINES,TERMINAL_CAPTURE_MODE,TERMINAL_CAPTURE_LINES - nudges:
TERMINAL_NUDGE_ENABLED,TERMINAL_NUDGE_DEBOUNCE_SECONDS,TERMINAL_NUDGE_COOLDOWN_SECONDS,TERMINAL_NUDGE_MESSAGE,TERMINAL_PARTNER_NUDGE_MESSAGE,TERMINAL_PARTNER_REPLY_NUDGE_MESSAGE - prompt detection: the
TERMINAL_PROMPT_SCAN_*group listed above - browser:
BROWSER_ENABLED,BROWSER_HEADLESS,BROWSER_DEVTOOLS,BROWSER_ADDRESS,BROWSER_TIMEOUT_MS,BROWSER_MAX_EVENTS,BROWSER_WAIT_UNTIL,BROWSER_EXECUTABLE_PATH,BROWSER_CHANNEL,BROWSER_SLOW_MO_MS - browser attach:
BROWSER_ATTACH_ENABLED,BROWSER_ATTACH_WS_HOST,BROWSER_ATTACH_WS_PORT,BROWSER_ATTACH_WS_PATH
- request policy:
TELEGRAM_REQUEST_MODE=queue|reject - proxy:
PROXY_USE=http|socks5,HTTP_PROXY,SOCKS5_PROXY,NO_PROXY - logging:
LOG_LEVEL,LOG_STDERR_LEVEL,LOG_FILE_ENABLED,LOG_FILE_LEVEL,LOG_FILE_PATH,LOGFEED_ENABLED - broker diagnostics:
TRANSPORT,MOLECULER_TRACE,MOLECULER_METRICS,METRICS_PORT,METRICS_PATH - standalone HTTP internals:
ENV_FILE,TELLYMCP_STANDALONE_HTTP
OAuth is enabled when any connector setting is present. It then requires
TELLYMCP_PUBLIC_URL and exactly one of TELLYMCP_MAGIC_TOKEN or
TELLYMCP_MAGIC_TOKEN_HASH.
Supported keys:
TELLYMCP_PUBLIC_URLTELLYMCP_OAUTH_ISSUERTELLYMCP_OAUTH_AUDIENCETELLYMCP_MAGIC_TOKENTELLYMCP_MAGIC_TOKEN_HASHTELLYMCP_OAUTH_CLIENT_IDTELLYMCP_OAUTH_CLIENT_SECRETTELLYMCP_ALLOWED_REDIRECT_URISTELLYMCP_OAUTH_PRIVATE_KEY_PEMTELLYMCP_AUTH_CODE_TTL_SECONDSTELLYMCP_OAUTH_SCOPESTELLYMCP_OAUTH_KEY_ID
| Old | Current |
|---|---|
MODE |
TELEGRAM_REQUEST_MODE |
GATEWAY_TOKEN |
GATEWAY_SCOPE_TOKEN |
DB_SCHEME |
DB_SCHEMA |
ENABLE_LOGFEED |
LOGFEED_ENABLED |
TMUX_<NAME> |
TERMINAL_<NAME> |
TMUX_SOCKET_PATH |
remove; the built-in PTY has no tmux socket |
Removed without replacement:
APP_NAMEBROWSER_ATTACH_TOKENGATEWAY_BIND_HOST,GATEWAY_BIND_PORTGATEWAY_DATABASE_URL,GATEWAY_S3_*MAX_BODY_SIZE(the limit is a code-level security constant)MCP_VFS_SCOPEPAIR_CODE_TTL_SECONDSSESSION_SECRET,TOKEN_BINDING_SECRETTELEGRAM_INBOX_BATCH_SIZETERMINAL_TRANSPORTWEBAPP_POLL_INTERVAL_MS
The retained examples intentionally omit many values that already have safe defaults. Add an optional key only when the deployment needs a non-default value.
Normalize an existing gateway, client, or combined env without printing secret values in diagnostics:
tellymcp migrate-env ./old.env > ./.migrated-envThe command:
- reads or infers the role from the input;
- prefers a canonical key if both old and new names exist;
- renames supported legacy keys and removes retired or role-inapplicable keys;
- writes deterministic, sectioned dotenv to stdout;
- writes key-name-only migration notes to stderr.
Use > for a fresh output file. >> appends and should only be used when the
target is known to be empty.
For guided setup, start the local wizard:
tellymcp configureThe configurator:
- binds only to
127.0.0.1on a random available port; - protects the local URL with a one-time random token;
- asks whether the machine is a Client or Gateway;
- exposes all keys from the selected role-specific packaged template;
- validates role requirements and dependent values;
- downloads
.env-clientor.env-gatewaythrough the browser.
The wizard accepts one Public base URL. If only an origin is entered, the
default /api root is applied. It also accepts an existing derived endpoint
such as /api/gateway and normalizes it back to the API base. From that source
it derives gateway HTTP/WS paths and, for gateway mode, WebApp, webhook,
ROOT_PREFIX, and enabled OAuth connector URLs.
The Russian-language wizard shows an explanation and safe example for every
field. Connection-check buttons perform real, redacted probes for Telegram bot
getMe, Redis PING and PostgreSQL SELECT 1 on gateways, gateway health plus
WebSocket handshake on clients, and RabbitMQ when configured.
Use --no-open on a headless machine and open the printed URL through an
appropriate local tunnel. The configurator does not bind to a public interface.
Browser downloads do not guarantee Unix permissions, so set mode 0600 on the
downloaded dotenv before starting TellyMCP.