77)
88
99// createTestInventory creates an inventory with the specified toolsets for testing.
10+ // All toolsets are enabled by default using WithToolsets([]string{"all"}).
1011func createTestInventory (toolsets []ToolsetMetadata ) * Inventory {
1112 // Create tools for each toolset so they show up in AvailableToolsets()
1213 var tools []ServerTool
@@ -18,6 +19,7 @@ func createTestInventory(toolsets []ToolsetMetadata) *Inventory {
1819
1920 inv , _ := NewBuilder ().
2021 SetTools (tools ).
22+ WithToolsets ([]string {"all" }).
2123 Build ()
2224
2325 return inv
@@ -203,3 +205,61 @@ func TestToolsetInstructionsFunc(t *testing.T) {
203205 })
204206 }
205207}
208+
209+ // TestGenerateInstructionsOnlyEnabledToolsets verifies that generateInstructions
210+ // only includes instructions from enabled toolsets, not all available toolsets.
211+ // This is a regression test for https://github.com/github/github-mcp-server/issues/1897
212+ func TestGenerateInstructionsOnlyEnabledToolsets (t * testing.T ) {
213+ // Create tools for multiple toolsets
214+ reposToolset := ToolsetMetadata {
215+ ID : "repos" ,
216+ Description : "Repository tools" ,
217+ InstructionsFunc : func (_ * Inventory ) string {
218+ return "REPOS_INSTRUCTIONS"
219+ },
220+ }
221+ issuesToolset := ToolsetMetadata {
222+ ID : "issues" ,
223+ Description : "Issue tools" ,
224+ InstructionsFunc : func (_ * Inventory ) string {
225+ return "ISSUES_INSTRUCTIONS"
226+ },
227+ }
228+ prsToolset := ToolsetMetadata {
229+ ID : "pull_requests" ,
230+ Description : "PR tools" ,
231+ InstructionsFunc : func (_ * Inventory ) string {
232+ return "PRS_INSTRUCTIONS"
233+ },
234+ }
235+
236+ tools := []ServerTool {
237+ {Toolset : reposToolset },
238+ {Toolset : issuesToolset },
239+ {Toolset : prsToolset },
240+ }
241+
242+ // Build inventory with only "repos" toolset enabled
243+ inv , err := NewBuilder ().
244+ SetTools (tools ).
245+ WithToolsets ([]string {"repos" }).
246+ Build ()
247+ if err != nil {
248+ t .Fatalf ("Failed to build inventory: %v" , err )
249+ }
250+
251+ result := generateInstructions (inv )
252+
253+ // Should contain instructions from enabled toolset
254+ if ! strings .Contains (result , "REPOS_INSTRUCTIONS" ) {
255+ t .Errorf ("Expected instructions to contain 'REPOS_INSTRUCTIONS' for enabled toolset, but it did not. Result: %s" , result )
256+ }
257+
258+ // Should NOT contain instructions from non-enabled toolsets
259+ if strings .Contains (result , "ISSUES_INSTRUCTIONS" ) {
260+ t .Errorf ("Did not expect instructions to contain 'ISSUES_INSTRUCTIONS' for disabled toolset, but it did. Result: %s" , result )
261+ }
262+ if strings .Contains (result , "PRS_INSTRUCTIONS" ) {
263+ t .Errorf ("Did not expect instructions to contain 'PRS_INSTRUCTIONS' for disabled toolset, but it did. Result: %s" , result )
264+ }
265+ }
0 commit comments