Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 43812d8

Browse files
committed
test(coderd/mcp): enable the MCP HTTP experiment in the end-to-end tests
The MCP HTTP endpoint no longer has a development-build bypass for the mcp-server-http experiment, so tests that reach it must opt in.
1 parent 08a59cc commit 43812d8

1 file changed

Lines changed: 33 additions & 7 deletions

File tree

coderd/mcp/mcp_e2e_test.go

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,22 @@ func mcpGeneratePKCE() (verifier, challenge string) {
4444
return verifier, challenge
4545
}
4646

47+
// mcpDeploymentValues turns on the mcp-server-http experiment. The MCP HTTP
48+
// endpoint has no development-build bypass, so every test that reaches it
49+
// must opt in.
50+
func mcpDeploymentValues(t testing.TB) *codersdk.DeploymentValues {
51+
return coderdtest.DeploymentValues(t, func(dv *codersdk.DeploymentValues) {
52+
dv.Experiments = []string{string(codersdk.ExperimentMCPServerHTTP)}
53+
})
54+
}
55+
4756
func TestMCPHTTP_E2E_ClientIntegration(t *testing.T) {
4857
t.Parallel()
4958

5059
// Setup Coder server with authentication
51-
coderClient, closer, api := coderdtest.NewWithAPI(t, nil)
60+
coderClient, closer, api := coderdtest.NewWithAPI(t, &coderdtest.Options{
61+
DeploymentValues: mcpDeploymentValues(t),
62+
})
5263
defer closer.Close()
5364

5465
_ = coderdtest.CreateFirstUser(t, coderClient)
@@ -162,7 +173,9 @@ func TestMCPHTTP_E2E_UnauthenticatedAccess(t *testing.T) {
162173
t.Parallel()
163174

164175
// Setup Coder server
165-
_, closer, api := coderdtest.NewWithAPI(t, nil)
176+
_, closer, api := coderdtest.NewWithAPI(t, &coderdtest.Options{
177+
DeploymentValues: mcpDeploymentValues(t),
178+
})
166179
defer closer.Close()
167180

168181
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
@@ -193,7 +206,9 @@ func TestMCPHTTP_E2E_UnauthenticatedAccess(t *testing.T) {
193206
func TestMCPHTTP_E2E_ToolWithWorkspace(t *testing.T) {
194207
t.Parallel()
195208

196-
coderClient, closer, api := coderdtest.NewWithAPI(t, nil)
209+
coderClient, closer, api := coderdtest.NewWithAPI(t, &coderdtest.Options{
210+
DeploymentValues: mcpDeploymentValues(t),
211+
})
197212
defer closer.Close()
198213

199214
user := coderdtest.CreateFirstUser(t, coderClient)
@@ -254,6 +269,7 @@ func TestMCPHTTP_E2E_ErrorHandling(t *testing.T) {
254269

255270
// Setup Coder server
256271
coderClient, closer, api := coderdtest.NewWithAPI(t, &coderdtest.Options{
272+
DeploymentValues: mcpDeploymentValues(t),
257273
IncludeProvisionerDaemon: true,
258274
})
259275
defer closer.Close()
@@ -291,6 +307,7 @@ func TestMCPHTTP_E2E_ConcurrentRequests(t *testing.T) {
291307

292308
// Setup Coder server
293309
coderClient, closer, api := coderdtest.NewWithAPI(t, &coderdtest.Options{
310+
DeploymentValues: mcpDeploymentValues(t),
294311
IncludeProvisionerDaemon: true,
295312
})
296313
defer closer.Close()
@@ -345,7 +362,9 @@ func TestMCPHTTP_E2E_RFC6750_UnauthenticatedRequest(t *testing.T) {
345362
t.Parallel()
346363

347364
// Setup Coder server
348-
_, closer, api := coderdtest.NewWithAPI(t, nil)
365+
_, closer, api := coderdtest.NewWithAPI(t, &coderdtest.Options{
366+
DeploymentValues: mcpDeploymentValues(t),
367+
})
349368
defer closer.Close()
350369

351370
// Make a request without any authentication headers
@@ -376,7 +395,9 @@ func TestMCPHTTP_E2E_OAuth2_EndToEnd(t *testing.T) {
376395
t.Parallel()
377396

378397
// Setup Coder server with OAuth2 provider enabled
379-
coderClient, closer, api := coderdtest.NewWithAPI(t, nil)
398+
coderClient, closer, api := coderdtest.NewWithAPI(t, &coderdtest.Options{
399+
DeploymentValues: mcpDeploymentValues(t),
400+
})
380401
t.Cleanup(func() { closer.Close() })
381402

382403
_ = coderdtest.CreateFirstUser(t, coderClient)
@@ -1080,6 +1101,7 @@ func TestMCPHTTP_E2E_ChatGPTEndpoint(t *testing.T) {
10801101

10811102
// Setup Coder server with authentication
10821103
coderClient, closer, api := coderdtest.NewWithAPI(t, &coderdtest.Options{
1104+
DeploymentValues: mcpDeploymentValues(t),
10831105
IncludeProvisionerDaemon: true,
10841106
})
10851107
defer closer.Close()
@@ -1208,7 +1230,9 @@ func TestMCPHTTP_E2E_ChatGPTEndpoint(t *testing.T) {
12081230
func TestMCPHTTP_E2E_WorkspaceSSHAuthz(t *testing.T) {
12091231
t.Parallel()
12101232

1211-
coderClient, closer, api := coderdtest.NewWithAPI(t, nil)
1233+
coderClient, closer, api := coderdtest.NewWithAPI(t, &coderdtest.Options{
1234+
DeploymentValues: mcpDeploymentValues(t),
1235+
})
12121236
defer closer.Close()
12131237

12141238
admin := coderdtest.CreateFirstUser(t, coderClient)
@@ -1323,7 +1347,9 @@ func TestMCPHTTP_E2E_TransportIsolation(t *testing.T) {
13231347
// Construct the API before swapping DefaultTransport: coderd's guarded
13241348
// MCP client clones http.DefaultTransport at construction, and safedial
13251349
// panics on a non-*http.Transport rather than guessing.
1326-
coderClient, closer, api := coderdtest.NewWithAPI(t, nil)
1350+
coderClient, closer, api := coderdtest.NewWithAPI(t, &coderdtest.Options{
1351+
DeploymentValues: mcpDeploymentValues(t),
1352+
})
13271353
t.Cleanup(func() { closer.Close() })
13281354
_ = coderdtest.CreateFirstUser(t, coderClient)
13291355

0 commit comments

Comments
 (0)