Add environment variable expansion for allowedDomains config - #5
Open
npeham wants to merge 6 commits into
Open
Conversation
Resolve ${ENV_VAR} references in mcpSettings/actions/registration
allowedDomains via a shared allowedDomainsSchema. An entry that resolves
to a comma-separated (optionally bracket-wrapped) list is expanded into
multiple domains, so the whole allowlist can live in a single env var.
Backward compatible: literal entries contain no ${} placeholders and no
commas, so they pass through unchanged.
Accept either a YAML array or a scalar string for allowedDomains so the
whole allowlist can be supplied through one env var, e.g.
allowedDomains: '${MCP_ALLOWED_DOMAINS}'. The resolved value is split on
commas (optionally bracket-wrapped) into individual domains.
railway-app
Bot
temporarily deployed
to
Proactive - AI Hub - Demo / feature-dev
June 7, 2026 08:29
Inactive
loadCustomConfig returns the raw (pre-transform) config object, so the
allowedDomainsSchema transform never reached consumers — mcpSettings/
actions/registration allowedDomains kept their literal ${ENV_VAR}
placeholders at runtime, mirroring how mcpServers urls rely on
processMCPEnv rather than the schema transform.
Extract the resolution into a reusable resolveAllowedDomains() and apply
it where AppService builds the app config, so env references and
comma-separated list expansion actually take effect.
railway-app
Bot
temporarily deployed
to
Proactive - AI Hub - Demo / feature-dev
June 7, 2026 10:50
Inactive
Hardens against compose-style quoted env vars (e.g. MCP_ALLOWED_DOMAINS="http://mastra:4111") where the quotes become part of the value. The comma-list path already stripped quotes; apply the same to the single-value path.
railway-app
Bot
temporarily deployed
to
Proactive - AI Hub - Demo / feature-dev
June 7, 2026 13:11
Inactive
Carry the schema-transformed mcpSettings/actions/registration from
result.data into the returned config (mirrors the existing modelSpecs
handling), so ${ENV_VAR} references in allowedDomains are resolved for
consumers. loadCustomConfig.js is plain runtime code, so this takes
effect without a package rebuild.
Revert the equivalent AppService-layer resolution (now redundant) and
make resolveAllowedDomains internal to the data-provider schema again.
railway-app
Bot
temporarily deployed
to
Proactive - AI Hub - Demo / feature-dev
June 7, 2026 14:26
Inactive
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for environment variable substitution in the
allowedDomainsconfiguration acrossmcpSettings,actions, andregistrationsections. Operators can now reference environment variables using${ENV_VAR}syntax, and if the resolved value is a comma-separated list (optionally wrapped in brackets), it is automatically expanded into multiple domains.This allows operators to manage domain allowlists centrally via environment variables, e.g.:
MCP_ALLOWED_DOMAINS='http://internal:8080,https://secure.api.com'Then reference it in config:
Change Type
Changes
packages/data-provider/src/config.ts:expandAllowedDomainsEntry()helper to resolve${ENV_VAR}references and expand comma-separated listsstripWrappingQuotes()utility for parsing quoted domain entriesallowedDomainsSchemaZod schema with transformation logicconfigSchemato useallowedDomainsSchemaformcpSettings.allowedDomains,actions.allowedDomains, andregistration.allowedDomainspackages/data-provider/src/config.spec.ts:allowedDomainsSchemacovering:configSchemalibrechat.example.yaml:${ENV_VAR}syntax and comma-separated list expansionTesting
All new functionality is covered by unit tests in
config.spec.ts. The test suite validates:configSchemaRun tests with:
cd packages/data-provider && npx jest config.spec.tsChecklist
https://claude.ai/code/session_01GmfhbeTigYTtP5Bw52Keek