File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed
crates/apollo-mcp-server/src Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -38,11 +38,10 @@ struct Args {
3838
3939#[ tokio:: main]
4040async fn main ( ) -> anyhow:: Result < ( ) > {
41- let config: runtime:: Config = Args :: parse ( )
42- . config
43- . map ( runtime:: read_config)
44- . transpose ( ) ?
45- . unwrap_or_default ( ) ;
41+ let config: runtime:: Config = match Args :: parse ( ) . config {
42+ Some ( config_path) => runtime:: read_config ( config_path) ?,
43+ None => runtime:: read_config_from_env ( ) . unwrap_or_default ( ) ,
44+ } ;
4645
4746 let mut env_filter = EnvFilter :: from_default_env ( ) . add_directive ( config. logging . level . into ( ) ) ;
4847
Original file line number Diff line number Diff line change @@ -26,6 +26,15 @@ pub use schema_source::SchemaSource;
2626/// Separator to use when drilling down into nested options in the env figment
2727const ENV_NESTED_SEPARATOR : & str = "__" ;
2828
29+ /// Read configuration from environment variables only (when no config file is provided)
30+ #[ allow( clippy:: result_large_err) ]
31+ pub fn read_config_from_env ( ) -> Result < Config , figment:: Error > {
32+ Figment :: new ( )
33+ . join ( apollo_common_env ( ) )
34+ . join ( Env :: prefixed ( "APOLLO_MCP_" ) . split ( ENV_NESTED_SEPARATOR ) )
35+ . extract ( )
36+ }
37+
2938/// Read in a config from a YAML file, filling in any missing values from the environment
3039#[ allow( clippy:: result_large_err) ]
3140pub fn read_config ( yaml_path : impl AsRef < Path > ) -> Result < Config , figment:: Error > {
You can’t perform that action at this time.
0 commit comments