-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Generate server instructions in Inventory #1869
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors server instructions generation to align with the Inventory pattern, moving instruction computation from server creation time (NewMCPServer) to inventory build time. Instructions are now generated based on resolved enabled toolsets and accessed via a getter method.
Changes:
- Added
InstructionsFuncfield toToolsetMetadataallowing each toolset to define context-aware instructions - Introduced
WithServerInstructions()builder method enabling instruction generation duringBuild() - Moved instruction generation logic from
pkg/githubtopkg/inventorywith corresponding test migration - Updated toolset metadata to include instruction functions for context, issues, pull_requests, discussions, and projects toolsets
- Modified
NewMCPServerto retrieve instructions from the built inventory instead of generating them inline
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/inventory/server_tool.go | Adds InstructionsFunc field to ToolsetMetadata for per-toolset instruction generation |
| pkg/inventory/registry.go | Adds instructions field and Instructions() getter method to Inventory |
| pkg/inventory/builder.go | Adds WithServerInstructions() method to enable instruction generation during build |
| pkg/inventory/instructions.go | New file containing generateInstructions() logic that combines base instructions with toolset-specific instructions |
| pkg/inventory/instructions_test.go | New comprehensive test file covering instruction generation with various toolset configurations |
| pkg/github/toolset_instructions.go | Refactored from monolithic function to individual per-toolset instruction functions |
| pkg/github/tools.go | Updated toolset metadata to include InstructionsFunc assignments for applicable toolsets |
| pkg/github/instructions_test.go | Deleted - tests migrated to pkg/inventory |
| internal/ghmcp/server.go | Updated to build inventory with .WithServerInstructions() and retrieve instructions via inventory.Instructions() |
| pkg/github/toolsnaps/assign_copilot_to_issue.snap | Minor field ordering change (description/type swap) from toolsnap update |
Comments suppressed due to low confidence (1)
pkg/github/toolset_instructions.go:106
- The instruction functions (generateContextToolsetInstructions, generateIssuesToolsetInstructions, generatePullRequestsToolsetInstructions, generateDiscussionsToolsetInstructions, generateProjectsToolsetInstructions) are unexported (lowercase first letter), but they are used as function pointers in the toolset metadata that is exported and used by other parts of the codebase. According to the project guidelines, this repository is used as a library by the remote server, so functions that could be called by other repositories should be exported (capitalized). These functions should be exported to maintain consistency with the library usage pattern and allow potential external use of the toolset metadata with custom inventory builders.
Summary
This PR moves server instructions generation from
NewMCPServerinto the Inventory pattern, so instructions are computed at inventory build time rather than server creation time.Note: This carries over changes from #1863 (which targets
http-stack-2) tomain, excluding the HTTP handler change which depends on the HTTP stack.Changes
instructionsfield toInventorystruct withInstructions()getter methodInstructionsFuncfield toToolsetMetadataallowing each toolset to define its own instructionsWithServerInstructions()builder method that enables instruction generation duringBuild()pkg/github/toolset_instructions.gowith instruction functions for each toolset (context, issues, pull_requests, discussions, projects)pkg/inventory/instructions.go, which first adds base instructions and then iterates over toolsets and calls theirInstructionsFunc.WithServerInstructions()when building inventoryNewMCPServerto useinventory.Instructions()instead of generating instructions inlineTesting
pkg/inventory/instructions_test.go.WithServerInstructions()Demo
Screen.Recording.2026-01-22.at.17.24.48.mov
Why
This aligns with the architectural direction where the Inventory holds all pre-computed configuration, and the MCP server receives a fully-configured inventory rather than creating one itself. Instructions are generated based on the resolved enabled toolsets (after processing "default", "all" keywords, etc.)
MCP impact
Prompts tested (tool changes only)
Security / limits
Tool renaming
deprecated_tool_aliases.goNote: if you're renaming tools, you must add the tool aliases. For more information on how to do so, please refer to the official docs.
Lint & tests
./script/lint./script/testDocs