MCPcopy Create free account
hub / github.com/dagger/container-use / createMCPServerForRepositoryTest

Function createMCPServerForRepositoryTest

cmd/container-use/stdio_test.go:202–243  ·  view source on GitHub ↗

createMCPServerForRepositoryTest creates an MCP server process for repository contention testing

(t *testing.T, i int, repoDir, configDir string, singleTenant bool)

Source from the content-addressed store, hash-verified

200
201// createMCPServerForRepositoryTest creates an MCP server process for repository contention testing
202func createMCPServerForRepositoryTest(t *testing.T, i int, repoDir, configDir string, singleTenant bool) *MCPServerProcess {
203 ctx := context.Background()
204 containerUseBinary := getContainerUseBinary(t)
205
206 var cmd *exec.Cmd
207 var clientArgs []string
208 if singleTenant {
209 cmd = exec.CommandContext(ctx, containerUseBinary, "stdio", "--single-tenant")
210 clientArgs = []string{"stdio", "--single-tenant"}
211 } else {
212 cmd = exec.CommandContext(ctx, containerUseBinary, "stdio")
213 clientArgs = []string{"stdio"}
214 }
215
216 cmd.Dir = repoDir
217 cmd.Env = append(os.Environ(), fmt.Sprintf("CONTAINER_USE_CONFIG_DIR=%s", configDir))
218
219 mcpClient, err := client.NewStdioMCPClient(containerUseBinary, cmd.Env, clientArgs...)
220 require.NoError(t, err)
221
222 initRequest := mcp.InitializeRequest{}
223 initRequest.Params.ProtocolVersion = mcp.LATEST_PROTOCOL_VERSION
224 initRequest.Params.ClientInfo = mcp.Implementation{
225 Name: fmt.Sprintf("Repository Test Client %d", i),
226 Version: "1.0.0",
227 }
228 initRequest.Params.Capabilities = mcp.ClientCapabilities{}
229
230 serverInfo, err := mcpClient.Initialize(ctx, initRequest)
231 require.NoError(t, err)
232
233 server := &MCPServerProcess{
234 cmd: cmd,
235 client: mcpClient,
236 repoDir: repoDir,
237 configDir: configDir,
238 serverInfo: serverInfo,
239 t: t,
240 }
241
242 return server
243}
244
245// runRepositoryContentionTest runs the core repository contention test logic
246func runRepositoryContentionTest(t *testing.T, servers []*MCPServerProcess, testPrefix string) {

Callers 2

TestRepositoryContentionFunction · 0.85

Calls 1

getContainerUseBinaryFunction · 0.85

Tested by

no test coverage detected