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

Function generateInstructions

pkg/inventory/instructions.go:9–43  ·  view source on GitHub ↗

generateInstructions creates server instructions based on enabled toolsets

(inv *Inventory)

Source from the content-addressed store, hash-verified

7
8// generateInstructions creates server instructions based on enabled toolsets
9func generateInstructions(inv *Inventory) string {
10 // For testing - add a flag to disable instructions
11 if os.Getenv("DISABLE_INSTRUCTIONS") == "true" {
12 return "" // Baseline mode
13 }
14
15 var instructions []string
16
17 // Base instruction with context management
18 baseInstruction := `The GitHub MCP Server provides tools to interact with GitHub platform.
19
20Tool selection guidance:
21 1. Use 'list_*' tools for broad, simple retrieval and pagination of all items of a type (e.g., all issues, all PRs, all branches) with basic filtering.
22 2. Use 'search_*' tools for targeted queries with specific criteria, keywords, or complex filters (e.g., issues with certain text, PRs by author, code containing functions).
23
24Context management:
25 1. Use pagination whenever possible with batches of 5-10 items.
26 2. Use minimal_output parameter set to true if the full information is not needed to accomplish a task.
27
28Tool usage guidance:
29 1. For 'search_*' tools: Use separate 'sort' and 'order' parameters if available for sorting results - do not include 'sort:' syntax in query strings. Query strings should contain only search criteria (e.g., 'org:google language:python'), not sorting instructions.`
30
31 instructions = append(instructions, baseInstruction)
32
33 // Collect instructions from each enabled toolset
34 for _, toolset := range inv.EnabledToolsets() {
35 if toolset.InstructionsFunc != nil {
36 if toolsetInstructions := toolset.InstructionsFunc(inv); toolsetInstructions != "" {
37 instructions = append(instructions, toolsetInstructions)
38 }
39 }
40 }
41
42 return strings.Join(instructions, " ")
43}

Calls 1

EnabledToolsetsMethod · 0.80