Skip to content
Prev Previous commit
Next Next commit
add instructions step to inventory creation both in stdio and http se…
…rver
  • Loading branch information
tommaso-moro committed Jan 22, 2026
commit 30bc840294a13ba9d39918a2e4aeaf7a302c4870
3 changes: 2 additions & 1 deletion internal/ghmcp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ func NewStdioMCPServer(cfg github.MCPServerConfig) (*mcp.Server, error) {
WithDeprecatedAliases(github.DeprecatedToolAliases).
WithReadOnly(cfg.ReadOnly).
WithToolsets(cfg.EnabledToolsets).
WithTools(github.CleanTools(cfg.EnabledTools))
WithTools(github.CleanTools(cfg.EnabledTools)).
WithServerInstructions()
// WithFeatureChecker(createFeatureChecker(cfg.EnabledFeatures))

// Apply token scope filtering if scopes are known (for PAT filtering)
Expand Down
11 changes: 1 addition & 10 deletions pkg/github/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,9 @@
type MCPServerOption func(*mcp.ServerOptions)

func NewMCPServer(cfg *MCPServerConfig, deps ToolDependencies, inventory *inventory.Inventory) (*mcp.Server, error) {
enabledToolsets := resolveEnabledToolsets(cfg)

// For instruction generation, we need actual toolset names (not nil).
// nil means "use defaults" in inventory, so expand it for instructions.
instructionToolsets := enabledToolsets
if instructionToolsets == nil {
instructionToolsets = GetDefaultToolsetIDs()
}

// Create the MCP server
serverOpts := &mcp.ServerOptions{
Instructions: GenerateInstructions(instructionToolsets),
Instructions: inventory.Instructions(),
Logger: cfg.Logger,
CompletionHandler: CompletionsHandler(deps.GetClient),
}
Expand Down Expand Up @@ -143,7 +134,7 @@
// createFeatureChecker returns a FeatureFlagChecker that checks if a flag name
// is present in the provided list of enabled features. For the local server,
// this is populated from the --features CLI flag.
func createFeatureChecker(enabledFeatures []string) inventory.FeatureFlagChecker {

Check failure on line 137 in pkg/github/server.go

View workflow job for this annotation

GitHub Actions / lint

func createFeatureChecker is unused (unused)
// Build a set for O(1) lookup
featureSet := make(map[string]bool, len(enabledFeatures))
for _, f := range enabledFeatures {
Expand Down
1 change: 1 addition & 0 deletions pkg/http/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
type InventoryFactoryFunc func(r *http.Request) *inventory.Inventory
type GitHubMCPServerFactoryFunc func(ctx context.Context, r *http.Request, deps github.ToolDependencies, inventory *inventory.Inventory, cfg *github.MCPServerConfig) (*mcp.Server, error)

type HTTPMcpHandler struct {

Check failure on line 21 in pkg/http/handler.go

View workflow job for this annotation

GitHub Actions / lint

exported: type name will be used as http.HTTPMcpHandler by other packages, and that stutters; consider calling this McpHandler (revive)
config *HTTPServerConfig
deps github.ToolDependencies
logger *slog.Logger
Expand All @@ -27,12 +27,12 @@
inventoryFactoryFunc InventoryFactoryFunc
}

type HTTPMcpHandlerOptions struct {

Check failure on line 30 in pkg/http/handler.go

View workflow job for this annotation

GitHub Actions / lint

exported: type name will be used as http.HTTPMcpHandlerOptions by other packages, and that stutters; consider calling this McpHandlerOptions (revive)
GitHubMcpServerFactory GitHubMCPServerFactoryFunc
InventoryFactory InventoryFactoryFunc
}

type HTTPMcpHandlerOption func(*HTTPMcpHandlerOptions)

Check failure on line 35 in pkg/http/handler.go

View workflow job for this annotation

GitHub Actions / lint

exported: type name will be used as http.HTTPMcpHandlerOption by other packages, and that stutters; consider calling this McpHandlerOption (revive)

func WithGitHubMCPServerFactory(f GitHubMCPServerFactoryFunc) HTTPMcpHandlerOption {
return func(o *HTTPMcpHandlerOptions) {
Expand Down Expand Up @@ -95,7 +95,7 @@
w.WriteHeader(http.StatusInternalServerError)
}

mcpHandler := mcp.NewStreamableHTTPHandler(func(r *http.Request) *mcp.Server {

Check failure on line 98 in pkg/http/handler.go

View workflow job for this annotation

GitHub Actions / lint

unused-parameter: parameter 'r' seems to be unused, consider removing or renaming it as _ (revive)
return ghServer
}, &mcp.StreamableHTTPOptions{
Stateless: true,
Expand All @@ -104,7 +104,7 @@
middleware.ExtractUserToken()(mcpHandler).ServeHTTP(w, r)
}

func DefaultGitHubMCPServerFactory(ctx context.Context, _ *http.Request, deps github.ToolDependencies, inventory *inventory.Inventory, cfg *github.MCPServerConfig) (*mcp.Server, error) {

Check failure on line 107 in pkg/http/handler.go

View workflow job for this annotation

GitHub Actions / lint

unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
return github.NewMCPServer(&github.MCPServerConfig{
Version: cfg.Version,
Translator: cfg.Translator,
Expand All @@ -114,7 +114,7 @@
}, deps, inventory)
}

func DefaultInventoryFactory(cfg *HTTPServerConfig, t translations.TranslationHelperFunc, staticChecker inventory.FeatureFlagChecker) InventoryFactoryFunc {

Check failure on line 117 in pkg/http/handler.go

View workflow job for this annotation

GitHub Actions / lint

unused-parameter: parameter 'cfg' seems to be unused, consider removing or renaming it as _ (revive)
return func(r *http.Request) *inventory.Inventory {
b := github.NewInventory(t).WithDeprecatedAliases(github.DeprecatedToolAliases)

Expand All @@ -125,6 +125,7 @@
}

b = InventoryFiltersForRequestHeaders(r, b)
b = b.WithServerInstructions()
return b.Build()
}
}
Expand Down
Loading