{"record":{"id":"86d27d8f7c3e0895","repo":"github/github-mcp-server","slug":"failed-to-initialize-tool-scope-map-w","errorCode":null,"errorMessage":"failed to initialize tool scope map: %w","messagePattern":"failed to initialize tool scope map: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/http/server.go","lineNumber":165,"sourceCode":"\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create observability exporters: %w\", err)\n\t}\n\n\tdeps := github.NewRequestDeps(\n\t\tapiHost,\n\t\tcfg.Version,\n\t\tcfg.LockdownMode,\n\t\trepoAccessOpts,\n\t\tt,\n\t\tcfg.ContentWindowSize,\n\t\tfeatureChecker,\n\t\tobs,\n\t)\n\n\t// Initialize the global tool scope map\n\terr = initGlobalToolScopeMap(t, hostType)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to initialize tool scope map: %w\", err)\n\t}\n\n\t// Register OAuth protected resource metadata endpoints\n\toauthCfg := &oauth.Config{\n\t\tBaseURL:           cfg.BaseURL,\n\t\tResourcePath:      cfg.ResourcePath,\n\t\tTrustProxyHeaders: cfg.TrustProxyHeaders,\n\t}\n\n\tserverOptions := []HandlerOption{}\n\tif cfg.ScopeChallenge {\n\t\tscopeFetcher := scopes.NewFetcher(apiHost, scopes.FetcherOptions{})\n\t\tserverOptions = append(serverOptions, WithScopeFetcher(scopeFetcher))\n\t}\n\n\tr := chi.NewRouter()\n\thandler := NewHTTPMcpHandler(ctx, &cfg, deps, t, logger, apiHost, append(serverOptions, WithFeatureChecker(featureChecker), WithOAuthConfig(oauthCfg))...)\n\toauthHandler, err := oauth.NewAuthHandler(oauthCfg, apiHost)","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/github/github-mcp-server/blob/0ea1f775a7c73eff1bd2e25904d01136756bbfe2/pkg/http/server.go#L147-L183","documentation":"initGlobalToolScopeMap failed while building the tool inventory (inventory.NewBuilder().SetTools(github.AllTools(...)).Build()) that feeds the global OAuth scope map. Build() validates every tool definition; a duplicate tool name, a tool missing required scope/annotation metadata, or an invalid definition makes the whole startup abort.","triggerScenarios":"Adding a new tool whose name collides with an existing one; registering a tool with incomplete scope metadata; a host-type filter producing an invalid tool set; programming errors introduced by tool-list refactors.","commonSituations":"Contributors adding tools to pkg/github without unique names or full definitions; vendors maintaining a forked tool inventory.","solutions":["Read the wrapped 'failed to build inventory' error - it names the invalid tool","Check recently added/modified tool definitions for duplicate names or missing required fields","Run the server's tool inventory tests (go test ./pkg/...) before shipping"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// run as part of CI/startup smoke test\nif err := initGlobalToolScopeMap(t, hostType); err != nil {\n\tlog.Fatalf(\"tool inventory invalid, refusing to deploy: %v\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := initGlobalToolScopeMap(t, hostType); err != nil {\n\t// startup bug: log loudly and abort instead of serving a broken scope map\n\tlogger.Error(\"tool scope map init failed\", \"error\", err)\n\treturn err\n}","preventionTips":["Run the server's inventory tests whenever tools are added or renamed","Enforce unique tool names with a lint/test over github.AllTools output","Treat inventory build failures as release blockers in CI"],"tags":["tooling","validation","startup"],"backgroundTag":null,"analyzedSha":"0ea1f775a7c73eff1bd2e25904d01136756bbfe2","analyzedAt":"2026-08-15T18:10:19.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}