@@ -4,13 +4,16 @@ import (
44 "context"
55 "errors"
66 "fmt"
7+ "log/slog"
78 "net/http"
89 "os"
910
1011 ghcontext "github.com/github/github-mcp-server/pkg/context"
1112 "github.com/github/github-mcp-server/pkg/http/transport"
1213 "github.com/github/github-mcp-server/pkg/inventory"
1314 "github.com/github/github-mcp-server/pkg/lockdown"
15+ "github.com/github/github-mcp-server/pkg/observability"
16+ "github.com/github/github-mcp-server/pkg/observability/metrics"
1417 "github.com/github/github-mcp-server/pkg/raw"
1518 "github.com/github/github-mcp-server/pkg/scopes"
1619 "github.com/github/github-mcp-server/pkg/translations"
@@ -94,6 +97,14 @@ type ToolDependencies interface {
9497
9598 // IsFeatureEnabled checks if a feature flag is enabled.
9699 IsFeatureEnabled (ctx context.Context , flagName string ) bool
100+
101+ // Logger returns the structured logger, optionally enriched with
102+ // request-scoped data from ctx. Integrators provide their own slog.Handler
103+ // to control where logs are sent.
104+ Logger (ctx context.Context ) * slog.Logger
105+
106+ // Metrics returns the metrics client
107+ Metrics (ctx context.Context ) metrics.Metrics
97108}
98109
99110// BaseDeps is the standard implementation of ToolDependencies for the local server.
@@ -113,6 +124,9 @@ type BaseDeps struct {
113124
114125 // Feature flag checker for runtime checks
115126 featureChecker inventory.FeatureFlagChecker
127+
128+ // Observability exporters (includes logger)
129+ Obsv observability.Exporters
116130}
117131
118132// Compile-time assertion to verify that BaseDeps implements the ToolDependencies interface.
@@ -128,6 +142,7 @@ func NewBaseDeps(
128142 flags FeatureFlags ,
129143 contentWindowSize int ,
130144 featureChecker inventory.FeatureFlagChecker ,
145+ obsv observability.Exporters ,
131146) * BaseDeps {
132147 return & BaseDeps {
133148 Client : client ,
@@ -138,6 +153,7 @@ func NewBaseDeps(
138153 Flags : flags ,
139154 ContentWindowSize : contentWindowSize ,
140155 featureChecker : featureChecker ,
156+ Obsv : obsv ,
141157 }
142158}
143159
@@ -170,6 +186,16 @@ func (d BaseDeps) GetFlags(_ context.Context) FeatureFlags { return d.Flags }
170186// GetContentWindowSize implements ToolDependencies.
171187func (d BaseDeps ) GetContentWindowSize () int { return d .ContentWindowSize }
172188
189+ // Logger implements ToolDependencies.
190+ func (d BaseDeps ) Logger (_ context.Context ) * slog.Logger {
191+ return d .Obsv .Logger ()
192+ }
193+
194+ // Metrics implements ToolDependencies.
195+ func (d BaseDeps ) Metrics (ctx context.Context ) metrics.Metrics {
196+ return d .Obsv .Metrics (ctx )
197+ }
198+
173199// IsFeatureEnabled checks if a feature flag is enabled.
174200// Returns false if the feature checker is nil, flag name is empty, or an error occurs.
175201// This allows tools to conditionally change behavior based on feature flags.
@@ -247,6 +273,9 @@ type RequestDeps struct {
247273
248274 // Feature flag checker for runtime checks
249275 featureChecker inventory.FeatureFlagChecker
276+
277+ // Observability exporters (includes logger)
278+ obsv observability.Exporters
250279}
251280
252281// NewRequestDeps creates a RequestDeps with the provided clients and configuration.
@@ -258,6 +287,7 @@ func NewRequestDeps(
258287 t translations.TranslationHelperFunc ,
259288 contentWindowSize int ,
260289 featureChecker inventory.FeatureFlagChecker ,
290+ obsv observability.Exporters ,
261291) * RequestDeps {
262292 return & RequestDeps {
263293 apiHosts : apiHosts ,
@@ -267,6 +297,7 @@ func NewRequestDeps(
267297 T : t ,
268298 ContentWindowSize : contentWindowSize ,
269299 featureChecker : featureChecker ,
300+ obsv : obsv ,
270301 }
271302}
272303
@@ -374,6 +405,16 @@ func (d *RequestDeps) GetFlags(ctx context.Context) FeatureFlags {
374405// GetContentWindowSize implements ToolDependencies.
375406func (d * RequestDeps ) GetContentWindowSize () int { return d .ContentWindowSize }
376407
408+ // Logger implements ToolDependencies.
409+ func (d * RequestDeps ) Logger (_ context.Context ) * slog.Logger {
410+ return d .obsv .Logger ()
411+ }
412+
413+ // Metrics implements ToolDependencies.
414+ func (d * RequestDeps ) Metrics (ctx context.Context ) metrics.Metrics {
415+ return d .obsv .Metrics (ctx )
416+ }
417+
377418// IsFeatureEnabled checks if a feature flag is enabled.
378419func (d * RequestDeps ) IsFeatureEnabled (ctx context.Context , flagName string ) bool {
379420 if d .featureChecker == nil || flagName == "" {
0 commit comments