Module: Woods::MCP::ConfigResolver
- Defined in:
- lib/woods/mcp/config_resolver.rb
Overview
Resolves the embedding configuration that the MCP server should use.
Reads woods.json (the resolved config snapshot written at embed time), applies environment-variable overrides, validates, and returns either a populated Configuration or raises a typed BootstrapError subclass that the caller can present to an operator.
This class is extracted from Bootstrapper to isolate the config-resolution concern from network probing and store construction. Bootstrapper delegates to ConfigResolver.resolve as its first step.
Resolution order (highest priority first):
-
Host Rails initializer (Woods.configuration already has embedding_provider). When
woods.jsonis also present the stored config is loaded and asserted compatible via ResolvedConfig#assert_compatible!. -
woods.jsonsnapshot alone (MCP server running without a host initializer). The stored config is used to populateconfigin place. -
Environment-variable auto-detect (deprecated, opt-in via WOODS_ALLOW_AUTODETECT=1). Mutates
configto set provider and stores. -
If none of the above applies, raises MissingArtifact.
Class Method Summary collapse
-
.resolve(config, artifact:, env: ENV, ollama_probe: nil) ⇒ Array(Woods::Configuration, Symbol)
Resolve and validate the embedding configuration.
Class Method Details
.resolve(config, artifact:, env: ENV, ollama_probe: nil) ⇒ Array(Woods::Configuration, Symbol)
Resolve and validate the embedding configuration.
When woods.json is present in the artifact directory it is parsed into a ResolvedConfig and, if the host already has a provider configured, validated for compatibility (dimension + provider class/model must agree). If the host has no provider configured the stored config is applied to config so Builder can construct the correct provider.
When woods.json is absent and the host already has a provider configured, the host config is trusted and used as-is.
When woods.json is absent and the host has no provider configured:
-
If
WOODS_ALLOW_AUTODETECTis1, falls through to env-var auto-detect (deprecated, emits a structured warning). -
Otherwise raises MissingArtifact.
71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/woods/mcp/config_resolver.rb', line 71 def self.resolve(config, artifact:, env: ENV, ollama_probe: nil) stored = read_stored_config(artifact) if stored [apply_stored_config(config, stored, artifact: artifact, env: env), :snapshot] elsif config. # Host initializer configured a provider; no woods.json to validate # against. Trust the host config and proceed. [config, :host_config] else resolve_without_artifact(config, artifact: artifact, env: env, ollama_probe: ollama_probe) end end |