Skip to content

Conversation

@tommaso-moro
Copy link
Contributor

@tommaso-moro tommaso-moro commented Jan 22, 2026

Summary

This PR moves server instructions generation from NewMCPServer into the Inventory pattern, so instructions are computed at inventory build time rather than server creation time.

Changes

  • Added instructions field to Inventory struct with Instructions() getter method
  • Added InstructionsFunc field to ToolsetMetadata allowing each toolset to define its own instructions
  • Added WithServerInstructions() builder method that enables instruction generation during Build()
  • Created pkg/github/toolset_instructions.go with instruction functions for each toolset (context, issues, pull_requests, discussions, projects)
  • Moved instruction generation to pkg/inventory/instructions.go , which first adds base instructions and then iterates over toolsets and calls their InstructionsFunc
  • Updated both STDIO and HTTP paths to use .WithServerInstructions() when building inventory
  • Updated NewMCPServer to use inventory.Instructions() instead of generating instructions inline

Testing

  • Unit tests moved to pkg/inventory/instructions_test.go
  • Manually verified STDIO server with/without .WithServerInstructions()
  • Manually verified HTTP server includes instructions in initialize response

Demo

Screen.Recording.2026-01-22.at.12.46.46.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

  • No tool or API changes
  • Tool schema or behavior changed
  • New tool added

Prompts tested (tool changes only)

Security / limits

  • No security or limits impact
  • Auth / permissions considered
  • Data exposure, filtering, or token/size limits considered

Tool renaming

  • I am renaming tools as part of this PR (e.g. a part of a consolidation effort)
    • I have added the new tool aliases in deprecated_tool_aliases.go
  • I am not renaming tools as part of this PR

Note: 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

  • Linted locally with ./script/lint
  • Tested locally with ./script/test

Docs

  • Not needed
  • Updated (README / docs / examples)

Note

The linter in the CI is failing due to pre-existing issues in the work-in-progress base branch http-stack-2

@tommaso-moro tommaso-moro marked this pull request as ready for review January 22, 2026 12:48
@tommaso-moro tommaso-moro requested a review from a team as a code owner January 22, 2026 12:48
Copilot AI review requested due to automatic review settings January 22, 2026 12:48
@tommaso-moro tommaso-moro changed the title Move server instructions to the Inventory Generate server instructions in the Inventory Jan 22, 2026
Copy link
Contributor

Copilot AI left a 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 the server instructions generation logic by moving it from the pkg/github package to the pkg/inventory package, improving the separation of concerns.

Changes:

  • Moved GenerateInstructions and related functions from pkg/github to pkg/inventory
  • Made instruction generation opt-in via a new WithServerInstructions() builder method
  • Updated both stdio and HTTP server initialization to use the new inventory-based instructions

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/inventory/registry.go Added instructions field to Inventory struct and Instructions() getter method
pkg/inventory/instructions.go Moved from pkg/github to pkg/inventory with package change and function visibility adjustments
pkg/inventory/instructions_test.go Moved from pkg/github to pkg/inventory with type updates from []string to []ToolsetID
pkg/inventory/builder.go Added WithServerInstructions() builder method and instruction generation in Build()
pkg/http/handler.go Added WithServerInstructions() call in DefaultInventoryFactory
pkg/github/server.go Removed local instruction generation logic, now uses inventory.Instructions()
internal/ghmcp/server.go Added WithServerInstructions() call to inventory builder chain

tommaso-moro added a commit that referenced this pull request Jan 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants