MCPcopy Index your code
hub / github.com/github/github-mcp-server / setupMCPClient

Function setupMCPClient

e2e/e2e_test.go:146–250  ·  view source on GitHub ↗
(t *testing.T, options ...clientOption)

Source from the content-addressed store, hash-verified

144}
145
146func setupMCPClient(t *testing.T, options ...clientOption) *mcp.ClientSession {
147 // Check rate limit before setting up the client
148 waitForRateLimit(t)
149
150 // Get token and ensure Docker image is built
151 token := getE2EToken(t)
152
153 // Create and configure options with default to all toolsets
154 opts := &clientOpts{
155 enabledToolsets: []string{"all"},
156 }
157
158 // Apply all options to configure the opts struct
159 for _, option := range options {
160 option(opts)
161 }
162
163 ctx := context.Background()
164
165 // By default, we run the tests including the Docker image, but with DEBUG
166 // enabled, we run the server in-process, allowing for easier debugging.
167 var session *mcp.ClientSession
168 if os.Getenv("GITHUB_MCP_SERVER_E2E_DEBUG") == "" {
169 ensureDockerImageBuilt(t)
170
171 // Prepare Docker arguments
172 args := []string{
173 "run",
174 "-i",
175 "--rm",
176 "-e",
177 "GITHUB_PERSONAL_ACCESS_TOKEN", // Personal access token is all required
178 }
179
180 host := getE2EHost()
181 if host != "" {
182 args = append(args, "-e", "GITHUB_HOST")
183 }
184
185 // Add toolsets environment variable to the Docker arguments
186 if len(opts.enabledToolsets) > 0 {
187 args = append(args, "-e", "GITHUB_TOOLSETS")
188 }
189
190 // Add the image name
191 args = append(args, "github/e2e-github-mcp-server")
192
193 // Construct the env vars for the MCP Client to execute docker with
194 // We need to include os.Environ() so docker can find its socket and config
195 dockerEnvVars := append(os.Environ(),
196 fmt.Sprintf("GITHUB_PERSONAL_ACCESS_TOKEN=%s", token),
197 fmt.Sprintf("GITHUB_TOOLSETS=%s", strings.Join(opts.enabledToolsets, ",")),
198 )
199
200 if host != "" {
201 dockerEnvVars = append(dockerEnvVars, fmt.Sprintf("GITHUB_HOST=%s", host))
202 }
203

Callers 10

TestGetMeFunction · 0.85
TestToolsetsFunction · 0.85
TestTagsFunction · 0.85
TestFileDeletionFunction · 0.85
TestDirectoryDeletionFunction · 0.85
TestRequestCopilotReviewFunction · 0.85
TestAssignCopilotToIssueFunction · 0.85

Calls 5

waitForRateLimitFunction · 0.85
getE2ETokenFunction · 0.85
ensureDockerImageBuiltFunction · 0.85
getE2EHostFunction · 0.85
CloseMethod · 0.80

Tested by

no test coverage detected