gateway: normalize profile config for template eval (flat keys, schema, nesting)#462
Open
DavRodSwede wants to merge 1 commit into
Open
gateway: normalize profile config for template eval (flat keys, schema, nesting)#462DavRodSwede wants to merge 1 commit into
DavRodSwede wants to merge 1 commit into
Conversation
…a, nesting)
Build the map passed to pkg/eval so catalog/OCI env and command templates can use
flat {{KEY}} placeholders as well as dotted / dig() paths.
- Add configForEval(serverName) and use it from Find() for ServerConfig.Config.
- Merge per-server flat keys at the root of the eval map; keep the nested map
under the canonical server name for {{server.key}} and dig("server.KEY", cfg).
- flattenProfileConfigForEval unwraps JSON-schema-shaped objects (properties).
- promoteNestedServerConfig lifts { serverName: { K: V } } entries to the top.
- aliasPrefixedConfigKeys copies canonical.SUFFIX to SUFFIX when absent.
Validated with: go test -short ./...
Made-with: Cursor
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.
Problem
Environment and command templates for MCP servers (from OCI/catalog metadata) often use flat placeholders such as
{{API_TOKEN}}. With the currentConfiguration.Findbehavior, the map passed topkg/evalonly exposes profile fields under a single top-level key (the canonical server name). Flat placeholders then resolve empty, anddocker runmay miss expected-evalues.Some stored configs use a JSON-schema-like shape (
type/properties); those values are not visible at the top level of the eval map either.Even when flat keys and
propertiesare handled, real profile JSON may still store:{ "my-server": { "TOKEN": "x" } }, ormy-server.TOKEN.Templates that use
dig("server.KEY", config)(and flat{{TOKEN}}) need a consistent eval map; without normalisation, one style works and the other does not.Why
The eval map shape assumed one access pattern (
{{serverName.key}}), but profile JSON and template authors commonly assume root-level keys for secrets and settings. Different tools and CLI flows persist config in different shapes; the gateway should normalise once at eval time instead of pushing complexity to every template or user edit.What we want
{{KEY}}works when the profile storesKEYat the per-server level.{{canonicalName.key}}keep working.properties.*as flat keys for eval.{ serverName: { K: V } }promotesKto the top level (without losing the nested map where templates expect it).canonical.Kalso populate top-levelKwhen missing.How
configForEval(serverName)to build the map passed to eval.map[canonicalName] = perServerConfigfor dotted lookups.flattenProfileConfigForEvalto unwrappropertieswhen the config looks like a JSON-schema object.FindusesConfig: c.configForEval(serverName)instead of wrapping onlyc.config[canonical].promoteNestedServerConfig— ifper[canonical]orper[serverName]is a map, merge its entries to the top level.aliasPrefixedConfigKeys— for prefixcanonical., copycanonical.SUFFIXtoSUFFIXwhenSUFFIXis not already set.configForEvalafterflattenProfileConfigForEval.Testing
go test ./pkg/gateway/...Local validation:
go test -short ./...in a Linux environment with isolatedHOME(full suite may require the Docker MCP CLI plugin).