Repository navigation
2026 11 25 config design
History: brainstormed with Dr K on 2026-11-25 (Epic 5, #47; sub-issues #48 and #49). It holds as config CFG-1 to CFG-17 and components CMP-1 to CMP-6, all (proposed). Once built, they replace APP-3, APP-7 and APP-8's reading of
Serving, and TEL-2's attribute read. It revisits the 2026-11-20 design's ruling 19 ("config is a component the server supplies; the mechanism is open, after research"). It also meets the trigger that research round 2 set for a shared resolver: "kb wanting env or flags for something in its file, or a third server". The cause was 0.3.0's telemetry, which mcp-kb wired from its file only and selenium-flow wired from its file, env vars and flags. CFG-2 to CFG-6, CFG-11 and CFG-15 to CFG-17 are built, in the config core plan. CFG-7 to CFG-10 and CFG-12 to CFG-14 are built, in the config sources plan. A sensitive item is a pydantic secret type, and provenance addscode. Overtaken: the sketch'sQuickMCP(..., config=[SeleniumFlow, Recording])issections=[...], andconfig=carries values in code (CFG-17). quick-mcp'sFieldtakesdoc,env,argandsensitive, and a flag is never derived. CMP-2 to CMP-6 and TEL-20 are built, in the components plan. TEL-18, TEL-19 and TEL-21 are left for their own round.
quick-mcp is the container and the lifecycle engine. It provides everything common, and a server adds itself by implementing interfaces that get injected (Dr K). Config follows the same idea:
- Every QuickMCP server has a config, even one whose author never wrote a config class. Then it holds only what quick-mcp's own components contribute.
- A config is a schema written as a class. Its fields are the config items, and a field can be another config class, nested as deep as needed. The class is the schema, so it can also carry computed properties and methods of its own. That is ts-convict's model (Dr K's).
- Anything can contribute to the config: the server itself, quick-mcp's built-in components (telemetry first) and the server's own components. Each contributes a class under a top-level key, and the final config is one schema made of everything that registered.
- Each item says where it may come from: the file, an env var or a command-line argument, with the spelling of each. The caller then picks how to set it, in whichever of those ways the item allows.
- quick-mcp owns the lifecycle: it loads, resolves, validates and injects the config. A server only defines itself to quick-mcp.
Telemetry is the example (Dr K). It's a built-in component, registered whether the server uses it or not. Its section is always in the config, and an enable switch is just one of its items. Turned off, it means "this server doesn't use telemetry". At startup the component reads its own injected section and decides for itself whether to run.
- One config per server, composed from the sections every component registers, with one published JSON Schema for the whole.
- A section is a pydantic model registered under a key:
@config("telemetry")onclass TelemetryConfig. The container then knows it as the config'stelemetryitem. - Top-level single values (a server's
name, say) are possible too. The server's own root section merges its fields at the top level. Python can't decorate a variable, so this is the Python form of Dr K's "the decorator on variables". - Per-field source metadata, ts-convict's
@Propertyin Python form:doc,default,env(the full name, stated explicitly),arg(the flag, or derived, or none),sensitive, and the format by type. - Precedence, lowest to highest: default, file, env, argument. That is node-convict's order and selenium-flow's CFG-8 today.
- Provenance: for each item, which source set it. Sensitive values are never echoed, in logs or errors.
- Injection by type. A tool or component takes
Inject[TelemetryConfig]and gets its section, never the whole config (the .NET Options lesson). The whole config can be injected as well. - A component interface: it contributes a config section, registers its objects in the container, and gets start and stop in the lifecycle. quick-mcp's built-ins (serving, telemetry, delivery defaults) are components like any other.
- Env vars available wherever a section declares them. Each property states its env name explicitly, prefix included. quick-mcp never derives a name and never adds a prefix (Dr K, 2026-11-25). An item with no stated env var has none, as in convict. A component defines its own schema and env names, so telemetry's are the same in every server.
- Not a general config library. It serves QuickMCP servers. It's not published apart from kubed-mcp.
-
No autowiring. The rule from ruling 21 stays: injection is explicit (
Inject[T]). -
No profiles or environments (Spring's
application-{profile}), and no hot reload. Each server reads its config once at boot (selenium-flow CFG-53). - No backwards-compatibility aliases for old env names or keys. Both servers have one user (house rule). A rename is a named change in the changelog.
-
An anti-goal: the duck typing returns. Today
QuickMCPfinds sections withgetattr(config, "telemetry"). The design fails if a component still finds its section by attribute name instead of through registration. - An anti-goal: a server loses control of its schema. A server keeps full ownership of its own sections: their keys, defaults, validators and computed values.
-
Proven use case (ruling 14). Both servers adopt it: selenium-flow replaces its own loader
(
config.py, about 1,040 lines, CFG-1 to CFG-61), and mcp-kb folds its run flags and its file into one config. Telemetry is the first built-in component, and #98 and #211 are its first users. -
Pydantic is the engine. Both servers already use pydantic, and so does kubed-mcp's
TelemetrySettings. pydantic-settings' sources are the shape: a source is a callable that returns a dict, priority is a tuple order, and the result is a deep merge. Whether to build onBaseSettingsor on plainBaseModelplus quick-mcp's own sources is the builder's call. Its sources record no provenance, and selenium-flow's loader shows what's missing. - Import discipline (TEL rows, #34). Config classes import without FastMCP, so a config can be loaded, and its schema written, by a command that never serves.
- Tests build a server without the process. A test passes a config instance or a dict of values, and reads no env and no argv.
from kubed.mcp import QuickMCP, config, Inject, Field
@config() # the server's root section: its fields sit at the top level
class SeleniumFlow:
grid: GridSettings = Field(default_factory=GridSettings)
workspaces: str = Field("redis", doc="Where workspaces live", env="WORKSPACES")
@config("recording") # a section of its own, at the top-level key "recording"
class Recording:
inbox: str | None = Field(None, doc="…", arg="--recording-inbox")
@property
def enabled(self) -> bool: # computed: the class is the schema
return self.inbox is not None
mcp = QuickMCP("selenium-flow", config=[SeleniumFlow, Recording])
# quick-mcp registers its own built-ins beside them: serving, telemetry, delivery.The loaded config is one object: serving, telemetry, delivery, recording, and the root's
grid and workspaces. The schema is published whole. The operator sets TELEMETRY_OTEL=true,
or telemetry: {otel: true} in the file, or --telemetry-otel, as the item allows. The
telemetry component's start reads its section and turns itself on.
This is illustrative. The decorator, the Field spelling, and whether config= takes classes or
a registration call are the builder's to settle, within the goals.
- A new epic in quick-mcp, quick-mcp#47 (Epic 5), separate from Epic 4 (bundles). Config is a feature of its own, and touches every server.
-
Top-level keys merge. Two registrations of one key are an error at registration. A key's
section is the one class registered for it, and a server extends a built-in's section by
subclassing it and registering the subclass in its place (selenium-flow does this with
TelemetrySettingstoday). - The built-ins are always registered: serving (transport, host, port, log level), telemetry and delivery's defaults. "Off" is a config value, never a missing section.
- Env names are explicit on each property (Dr K, 2026-11-25). They're never derived, and there's no server-wide prefix. Telemetry's component states its own names.
- Epic 5 comes before Epic 4 (Dr K, 2026-11-25; it first said after, then raised config above the bundles). mcp-kb#98 and selenium-flow#211 merge as they are, after their live tests. kb's env vars come with mcp-kb#103.
-
Serving states
HOSTandPORTas its env names, and the rest of its own (Dr K, 2026-11-25). -
An escape hatch for the built-ins (Dr K, 2026-11-25). A built-in's registered section is the
consistent default, but a caller may supply its values in code through a hook, from the caller's
own config. Otherwise the built-in's registered section is used. Claude's calls, approved by Dr K:
- the hook applies to every built-in;
- it returns an instance of the built-in's class, so the values are still validated;
- a hooked section's file entries and env vars aren't read;
- provenance records
hook(quick-mcp#49).
-
Unknown keys are an error (strict, as
TelemetrySettings'extra="forbid"is today). A typo stops the boot.
-
There's one config file, for the whole composed config, named by
CONFIG_FILEand--config-file. kb'sCONFIG/--configis renamed (a named change). The file's format is YAML, as both servers use today. - Generic rules move into quick-mcp: selenium-flow's blank-means-unset, provenance, its explained validation errors, and never echoing a secret. Its retired-name checks are dropped (no backcompat). What's selenium-flow-only stays in its own sections.
-
Arguments are opt-in per field, unlike env vars. A flag for every nested key would make
--helpunreadable. selenium-flow's "every key has a flag" (CFG-3) becomes a choice it makes per section. -
Loading time: the config loads once, before any component starts and before the server's
own build code reads it (selenium-flow builds its stores from settings). How a server's build
code reaches the loaded config before
run()is the builder's call.
- The exact spelling: the decorator, the
Fieldmetadata (pydantic'sjson_schema_extra, anAnnotatedmarker, or aFieldwrapper), and the registration call. - The component interface's name and shape. Prior art to read: Litestar's
InitPlugin.on_app_init, and Spring Boot's auto-configuration switched by a property (@ConditionalOnProperty). - How the composed JSON Schema is written, and the command that writes it (kb has
schematoday). - How a nested model's env var is spelled when it's a list or a dict.
The 2026-11-20 round already covers ts-convict, node-convict, pydantic-settings, dynaconf, Spring Boot, .NET Options and Rails (research-2, section B, "Prior art"). Added here:
-
ts-convict (Dr K's):
-
@Config({file, parser, validationMethod, formats})on a class, and@Property({doc, default, env, arg, format, sensitive})per field. -
@Property(ChildClass)nests a config class, and a child may carry its own@Config. - Inheritance works (
Dog extends Pet). - Undecorated members stay on the instance.
- Validation is
strict,warnorskip. - Transfers: the class as schema, per-field sources, nesting by class, and a typed instance as the result.
-
-
Hydra's
ConfigStore:cs.store(name, node, group, package, provider)registers a structured-config class under a group from any module, and a collision raises withreplace=False. Transfers: registration by key from many modules into one composed config, with the registrant recorded (provider). -
NestJS
registerAs('telemetry', () => …): a namespaced config factory, injected by its key. Transfers: a section's key is chosen at registration, and the section is injectable on its own. -
pydantic-settings:
- Sources are merged with a deep update, highest priority first.
-
CliSettingsSourcederives flags from fields, andcli_show_env_varsprints each flag's env name in--help. -
PYDANTIC_SETTINGS_DEBUGlogs what each source supplied. -
Transfers: the source shape, the
--helpthat names the env var, and source-by-source reporting (a start on provenance).
-
typed-settings:
- Typed classes (attrs, dataclasses or pydantic) are loaded from files and env, then merged.
- CLI options are generated for argparse and Click.
- Post-processors run after the load.
- Transfers: the closest Python peer of ts-convict, and a check on the API.
-
Litestar
InitPlugin.on_app_init(app_config): a plugin adds dependencies, handlers and middleware to the app's config before the app is built. Transfers: the shape of a component's registration step. -
Spring Boot:
@ConfigurationProperties(prefix)binds a section to a typed bean, and auto-configuration with@ConditionalOnPropertyturns a built-in on by a config value. Transfers: telemetry as an always-present built-in that a property switches on.
These pages describe what is on main; the spec says what is built and what is only proposed.
kubed-mcp · MIT