Skip to content

Commit 5189ba8

Browse files
authored
Merge branch 'main' into fix_ci
2 parents efd021d + 8f6517b commit 5189ba8

File tree

5 files changed

+109
-31
lines changed

5 files changed

+109
-31
lines changed

cmd/thv-operator/controllers/mcpremoteproxy_runconfig.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,14 @@ func (r *MCPRemoteProxyReconciler) createRunConfigFromMCPRemoteProxy(
169169
options = append(options, runner.WithToolsOverride(toolsOverride))
170170
}
171171

172+
// Create context for API operations
173+
ctx, cancel := context.WithTimeout(context.Background(), defaultAPITimeout)
174+
defer cancel()
175+
172176
// Add telemetry configuration if specified
173-
runconfig.AddTelemetryConfigOptions(&options, proxy.Spec.Telemetry, proxy.Name)
177+
runconfig.AddTelemetryConfigOptions(ctx, &options, proxy.Spec.Telemetry, proxy.Name)
174178

175179
// Add authorization configuration if specified
176-
ctx, cancel := context.WithTimeout(context.Background(), defaultAPITimeout)
177-
defer cancel()
178180

179181
if err := ctrlutil.AddAuthzConfigOptions(ctx, r.Client, proxy.Namespace, proxy.Spec.AuthzConfig, &options); err != nil {
180182
return nil, fmt.Errorf("failed to process AuthzConfig: %w", err)

cmd/thv-operator/controllers/mcpserver_runconfig.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,14 @@ func (r *MCPServerReconciler) createRunConfigFromMCPServer(m *mcpv1alpha1.MCPSer
165165
}
166166
}
167167

168+
// Create context for API operations
169+
ctx, cancel := context.WithTimeout(context.Background(), defaultAPITimeout)
170+
defer cancel()
171+
168172
// Add telemetry configuration if specified
169-
runconfig.AddTelemetryConfigOptions(&options, m.Spec.Telemetry, m.Name)
173+
runconfig.AddTelemetryConfigOptions(ctx, &options, m.Spec.Telemetry, m.Name)
170174

171175
// Add authorization configuration if specified
172-
ctx, cancel := context.WithTimeout(context.Background(), defaultAPITimeout)
173-
defer cancel()
174176

175177
if err := ctrlutil.AddAuthzConfigOptions(ctx, r.Client, m.Namespace, m.Spec.AuthzConfig, &options); err != nil {
176178
return nil, fmt.Errorf("failed to process AuthzConfig: %w", err)

cmd/thv-operator/pkg/runconfig/telemetry.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,19 @@
22
package runconfig
33

44
import (
5+
"context"
56
"strconv"
67
"strings"
78

9+
"sigs.k8s.io/controller-runtime/pkg/log"
10+
811
mcpv1alpha1 "github.com/stacklok/toolhive/cmd/thv-operator/api/v1alpha1"
912
"github.com/stacklok/toolhive/pkg/runner"
1013
)
1114

1215
// AddTelemetryConfigOptions adds telemetry configuration options to the builder options
1316
func AddTelemetryConfigOptions(
17+
ctx context.Context,
1418
options *[]runner.RunConfigBuilderOption,
1519
telemetryConfig *mcpv1alpha1.TelemetryConfig,
1620
mcpServerName string,
@@ -53,6 +57,12 @@ func AddTelemetryConfigOptions(
5357
// Parse sampling rate string to float64
5458
if rate, err := strconv.ParseFloat(otel.Tracing.SamplingRate, 64); err == nil {
5559
otelSamplingRate = rate
60+
} else {
61+
logger := log.FromContext(ctx)
62+
logger.Error(err, "Failed to parse sampling rate, using default",
63+
"samplingRate", otel.Tracing.SamplingRate,
64+
"default", otelSamplingRate,
65+
"mcpServer", mcpServerName)
5666
}
5767
}
5868
}
@@ -68,6 +78,10 @@ func AddTelemetryConfigOptions(
6878
otelEnablePrometheusMetricsPath = telemetryConfig.Prometheus.Enabled
6979
}
7080

81+
if options == nil {
82+
return
83+
}
84+
7185
// Add telemetry config to options
7286
*options = append(*options, runner.WithTelemetryConfig(
7387
otelEndpoint,

cmd/thv-operator/pkg/runconfig/telemetry_test.go

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,42 @@ func TestAddTelemetryConfigOptions(t *testing.T) {
155155
assert.Equal(t, "", config.TelemetryConfig.Endpoint)
156156
},
157157
},
158+
{
159+
name: "with invalid sampling rate - uses default",
160+
mcpServer: &mcpv1alpha1.MCPServer{
161+
ObjectMeta: metav1.ObjectMeta{
162+
Name: "invalid-sampling-rate-server",
163+
Namespace: "test-ns",
164+
},
165+
Spec: mcpv1alpha1.MCPServerSpec{
166+
Image: testImage,
167+
Transport: stdioTransport,
168+
ProxyPort: 8080,
169+
Telemetry: &mcpv1alpha1.TelemetryConfig{
170+
OpenTelemetry: &mcpv1alpha1.OpenTelemetryConfig{
171+
Enabled: true,
172+
Endpoint: "otel-collector:4317",
173+
Tracing: &mcpv1alpha1.OpenTelemetryTracingConfig{
174+
Enabled: true,
175+
SamplingRate: "invalid-rate", // Invalid value
176+
},
177+
},
178+
},
179+
},
180+
},
181+
//nolint:thelper // We want to see the error at the specific line
182+
expected: func(t *testing.T, config *runner.RunConfig) {
183+
assert.Equal(t, "invalid-sampling-rate-server", config.Name)
184+
185+
// Verify telemetry config is set
186+
assert.NotNil(t, config.TelemetryConfig)
187+
188+
// Check that invalid sampling rate defaults to 0.05
189+
assert.Equal(t, 0.05, config.TelemetryConfig.SamplingRate)
190+
assert.True(t, config.TelemetryConfig.TracingEnabled)
191+
assert.Equal(t, "otel-collector:4317", config.TelemetryConfig.Endpoint)
192+
},
193+
},
158194
}
159195

160196
for _, tt := range tests {
@@ -165,7 +201,8 @@ func TestAddTelemetryConfigOptions(t *testing.T) {
165201
runner.WithName(tt.mcpServer.Name),
166202
runner.WithImage(tt.mcpServer.Spec.Image),
167203
}
168-
AddTelemetryConfigOptions(&options, tt.mcpServer.Spec.Telemetry, tt.mcpServer.Name)
204+
ctx := context.Background()
205+
AddTelemetryConfigOptions(ctx, &options, tt.mcpServer.Spec.Telemetry, tt.mcpServer.Name)
169206

170207
rc, err := runner.NewOperatorRunConfigBuilder(context.Background(), nil, nil, nil, options...)
171208
assert.NoError(t, err)
@@ -174,3 +211,32 @@ func TestAddTelemetryConfigOptions(t *testing.T) {
174211
})
175212
}
176213
}
214+
215+
// TestAddTelemetryConfigOptions_NilOptions tests that the function handles nil options gracefully
216+
func TestAddTelemetryConfigOptions_NilOptions(t *testing.T) {
217+
t.Parallel()
218+
219+
ctx := context.Background()
220+
telemetryConfig := &mcpv1alpha1.TelemetryConfig{
221+
OpenTelemetry: &mcpv1alpha1.OpenTelemetryConfig{
222+
Enabled: true,
223+
Endpoint: "otel-collector:4317",
224+
ServiceName: "test-service",
225+
Tracing: &mcpv1alpha1.OpenTelemetryTracingConfig{
226+
Enabled: true,
227+
SamplingRate: "0.1",
228+
},
229+
Metrics: &mcpv1alpha1.OpenTelemetryMetricsConfig{
230+
Enabled: true,
231+
},
232+
},
233+
Prometheus: &mcpv1alpha1.PrometheusConfig{
234+
Enabled: true,
235+
},
236+
}
237+
238+
// Test with nil options pointer - should not panic
239+
assert.NotPanics(t, func() {
240+
AddTelemetryConfigOptions(ctx, nil, telemetryConfig, "test-server")
241+
}, "AddTelemetryConfigOptions should not panic with nil options")
242+
}

pkg/registry/data/registry.json

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/stacklok/toolhive/main/pkg/registry/data/schema.json",
33
"version": "1.0.0",
4-
"last_updated": "2025-10-29T00:18:44Z",
4+
"last_updated": "2025-10-29T11:39:51Z",
55
"servers": {
66
"adb-mysql-mcp-server": {
77
"description": "Official MCP server for AnalyticDB for MySQL of Alibaba Cloud",
@@ -711,7 +711,7 @@
711711
"database",
712712
"storage"
713713
],
714-
"image": "mcr.microsoft.com/azure-sdk/azure-mcp:0.9.9",
714+
"image": "mcr.microsoft.com/azure-sdk/azure-mcp:1.0.0",
715715
"permissions": {
716716
"network": {
717717
"outbound": {
@@ -1798,7 +1798,7 @@
17981798
"genai",
17991799
"mcp-server"
18001800
],
1801-
"image": "us-central1-docker.pkg.dev/database-toolbox/toolbox/toolbox:0.17.0",
1801+
"image": "us-central1-docker.pkg.dev/database-toolbox/toolbox/toolbox:0.18.0",
18021802
"permissions": {
18031803
"network": {
18041804
"outbound": {
@@ -1858,48 +1858,42 @@
18581858
"tools": [
18591859
"add_comment_to_pending_review",
18601860
"add_issue_comment",
1861-
"add_sub_issue",
18621861
"assign_copilot_to_issue",
18631862
"create_branch",
1864-
"create_issue",
18651863
"create_or_update_file",
18661864
"create_pull_request",
18671865
"create_repository",
18681866
"delete_file",
18691867
"fork_repository",
18701868
"get_commit",
18711869
"get_file_contents",
1872-
"get_issue",
1873-
"get_issue_comments",
18741870
"get_label",
18751871
"get_latest_release",
18761872
"get_me",
18771873
"get_release_by_tag",
18781874
"get_tag",
18791875
"get_team_members",
18801876
"get_teams",
1877+
"issue_read",
1878+
"issue_write",
18811879
"list_branches",
18821880
"list_commits",
18831881
"list_issue_types",
18841882
"list_issues",
1885-
"list_label",
18861883
"list_pull_requests",
18871884
"list_releases",
1888-
"list_sub_issues",
18891885
"list_tags",
18901886
"merge_pull_request",
18911887
"pull_request_read",
18921888
"pull_request_review_write",
18931889
"push_files",
1894-
"remove_sub_issue",
1895-
"reprioritize_sub_issue",
18961890
"request_copilot_review",
18971891
"search_code",
18981892
"search_issues",
18991893
"search_pull_requests",
19001894
"search_repositories",
19011895
"search_users",
1902-
"update_issue",
1896+
"sub_issue_write",
19031897
"update_pull_request",
19041898
"update_pull_request_branch"
19051899
],
@@ -1922,7 +1916,7 @@
19221916
"update",
19231917
"issues"
19241918
],
1925-
"image": "ghcr.io/github/github-mcp-server:v0.19.1",
1919+
"image": "ghcr.io/github/github-mcp-server:v0.20.1",
19261920
"permissions": {
19271921
"network": {
19281922
"outbound": {
@@ -2629,9 +2623,9 @@
26292623
"pg_upgrade"
26302624
],
26312625
"metadata": {
2632-
"stars": 69,
2626+
"stars": 70,
26332627
"pulls": 0,
2634-
"last_updated": "2025-10-11T02:26:18Z"
2628+
"last_updated": "2025-10-29T02:33:59Z"
26352629
},
26362630
"repository_url": "https://github.com/heroku/heroku-mcp-server",
26372631
"tags": [
@@ -3768,7 +3762,7 @@
37683762
"data",
37693763
"query"
37703764
],
3771-
"image": "docker.io/mongodb/mongodb-mcp-server:1.1.0",
3765+
"image": "docker.io/mongodb/mongodb-mcp-server:1.2.0",
37723766
"permissions": {
37733767
"network": {
37743768
"outbound": {
@@ -4632,7 +4626,6 @@
46324626
"status": "Active",
46334627
"transport": "stdio",
46344628
"tools": [
4635-
"analyze_issue_with_seer",
46364629
"find_dsns",
46374630
"find_organizations",
46384631
"find_projects",
@@ -4660,7 +4653,7 @@
46604653
"error-tracking",
46614654
"observability"
46624655
],
4663-
"image": "ghcr.io/stacklok/dockyard/npx/sentry-mcp-server:0.18.0",
4656+
"image": "ghcr.io/stacklok/dockyard/npx/sentry-mcp-server:0.19.0",
46644657
"permissions": {
46654658
"network": {
46664659
"outbound": {
@@ -4976,6 +4969,7 @@
49764969
"get_latest_provider_version",
49774970
"get_module_details",
49784971
"get_policy_details",
4972+
"get_provider_capabilities",
49794973
"get_provider_details",
49804974
"search_modules",
49814975
"search_policies",
@@ -5002,7 +4996,7 @@
50024996
"gcp",
50034997
"azure"
50044998
],
5005-
"image": "docker.io/hashicorp/terraform-mcp-server:0.3.1",
4999+
"image": "docker.io/hashicorp/terraform-mcp-server:0.3.2",
50065000
"permissions": {
50075001
"network": {
50085002
"outbound": {
@@ -5396,7 +5390,7 @@
53965390
"metadata": {
53975391
"stars": 3,
53985392
"pulls": 0,
5399-
"last_updated": "2025-10-11T02:26:18Z"
5393+
"last_updated": "2025-10-29T02:34:00Z"
54005394
},
54015395
"repository_url": "https://github.com/alpic-ai/kiwi-mcp-server-public",
54025396
"tags": [
@@ -5810,7 +5804,7 @@
58105804
"metadata": {
58115805
"stars": 0,
58125806
"pulls": 0,
5813-
"last_updated": "2025-10-10T02:29:32Z"
5807+
"last_updated": "2025-10-29T02:33:58Z"
58145808
},
58155809
"tags": [
58165810
"remote",
@@ -5841,9 +5835,9 @@
58415835
"get_service_info"
58425836
],
58435837
"metadata": {
5844-
"stars": 82,
5838+
"stars": 84,
58455839
"pulls": 0,
5846-
"last_updated": "2025-10-10T02:29:32Z"
5840+
"last_updated": "2025-10-29T02:33:59Z"
58475841
},
58485842
"repository_url": "https://github.com/square/square-mcp-server",
58495843
"tags": [
@@ -5899,7 +5893,7 @@
58995893
"metadata": {
59005894
"stars": 0,
59015895
"pulls": 0,
5902-
"last_updated": "2025-10-10T02:29:32Z"
5896+
"last_updated": "2025-10-29T02:33:59Z"
59035897
},
59045898
"tags": [
59055899
"remote",

0 commit comments

Comments
 (0)