MCPcopy
hub / github.com/github/github-mcp-server / TestNewMCPServer_CreatesSuccessfully

Function TestNewMCPServer_CreatesSuccessfully

pkg/github/server_test.go:153–192  ·  view source on GitHub ↗

TestNewMCPServer_CreatesSuccessfully verifies that the server can be created with the deps injection middleware properly configured.

(t *testing.T)

Source from the content-addressed store, hash-verified

151// TestNewMCPServer_CreatesSuccessfully verifies that the server can be created
152// with the deps injection middleware properly configured.
153func TestNewMCPServer_CreatesSuccessfully(t *testing.T) {
154 t.Parallel()
155
156 // Create a minimal server configuration
157 cfg := MCPServerConfig{
158 Version: "test",
159 Host: "", // defaults to github.com
160 Token: "test-token",
161 EnabledToolsets: []string{"context"},
162 ReadOnly: false,
163 Translator: translations.NullTranslationHelper,
164 ContentWindowSize: 5000,
165 LockdownMode: false,
166 }
167
168 deps := stubDeps{obsv: stubExporters()}
169
170 // Build inventory
171 inv, err := NewInventory(cfg.Translator).
172 WithDeprecatedAliases(DeprecatedToolAliases).
173 WithToolsets(cfg.EnabledToolsets).
174 Build()
175
176 require.NoError(t, err, "expected inventory build to succeed")
177
178 // Create the server
179 server, err := NewMCPServer(context.Background(), &cfg, deps, inv)
180 require.NoError(t, err, "expected server creation to succeed")
181 require.NotNil(t, server, "expected server to be non-nil")
182
183 // The fact that the server was created successfully indicates that:
184 // 1. The deps injection middleware is properly added
185 // 2. Tools can be registered without panicking
186 //
187 // If the middleware wasn't properly added, tool calls would panic with
188 // "ToolDependencies not found in context" when executed.
189 //
190 // The actual middleware functionality and tool execution with ContextWithDeps
191 // is already tested in pkg/github/*_test.go.
192}
193
194// TestNewServer_NameAndTitleViaTranslation verifies that server name and title
195// can be overridden via the translation helper (GITHUB_MCP_SERVER_NAME /

Callers

nothing calls this directly

Calls 6

stubExportersFunction · 0.85
NewInventoryFunction · 0.85
NewMCPServerFunction · 0.85
BuildMethod · 0.80
WithToolsetsMethod · 0.80
WithDeprecatedAliasesMethod · 0.80

Tested by

no test coverage detected