mcp: storage scaffolding (#5581)

This commit is contained in:
Denis Mishin 2025-04-23 13:39:27 -04:00 committed by GitHub
parent f1a9401ddc
commit db221cb826
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 68 additions and 8 deletions

View file

@ -64,7 +64,7 @@ type Proxy struct {
webauthn *webauthn.Handler
tracerProvider oteltrace.TracerProvider
logoProvider portal.LogoProvider
mcp *mcp.Handler
mcp *atomicutil.Value[*mcp.Handler]
}
// New takes a Proxy service from options and a validation function.
@ -87,7 +87,7 @@ func New(ctx context.Context, cfg *config.Config) (*Proxy, error) {
currentConfig: atomicutil.NewValue(&config.Config{Options: config.NewDefaultOptions()}),
currentRouter: atomicutil.NewValue(httputil.NewRouter()),
logoProvider: portal.NewLogoProvider(),
mcp: mcp,
mcp: atomicutil.NewValue(mcp),
}
p.OnConfigChange(ctx, cfg)
p.webauthn = webauthn.New(p.getWebauthnState)
@ -110,6 +110,13 @@ func (p *Proxy) OnConfigChange(ctx context.Context, cfg *config.Config) {
return
}
mcp, err := mcp.New(ctx, mcp.DefaultPrefix, cfg)
if err != nil {
log.Ctx(ctx).Error().Err(err).Msg("proxy: failed to update proxy state from configuration settings")
} else {
p.mcp.Store(mcp)
}
p.currentConfig.Store(cfg)
if err := p.setHandlers(ctx, cfg.Options); err != nil {
log.Ctx(ctx).Error().Err(err).Msg("proxy: failed to update proxy handlers from configuration settings")