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

Function buildStaticInventory

pkg/http/handler.go:334–360  ·  view source on GitHub ↗

buildStaticInventory pre-filters the full tool/resource/prompt universe using the static config (toolsets, read-only, --tools, --exclude-tools). It does NOT install a feature checker: HTTP feature flags can come from per-request context (/insiders, X-MCP-Features), so dual-name feature variants — fo

(cfg *ServerConfig, t translations.TranslationHelperFunc)

Source from the content-addressed store, hash-verified

332// inventory, which then installs a checker and resolves the flag before
333// registering tools with the MCP server.
334func buildStaticInventory(cfg *ServerConfig, t translations.TranslationHelperFunc) ([]inventory.ServerTool, []inventory.ServerResourceTemplate, []inventory.ServerPrompt) {
335 if !hasStaticConfig(cfg) {
336 return github.AllTools(t), github.AllResources(t), github.AllPrompts(t)
337 }
338
339 b := github.NewInventory(t).
340 WithReadOnly(cfg.ReadOnly).
341 WithToolsets(github.ResolvedEnabledToolsets(cfg.EnabledToolsets, cfg.EnabledTools))
342
343 if len(cfg.EnabledTools) > 0 {
344 b = b.WithTools(github.CleanTools(cfg.EnabledTools))
345 }
346
347 if len(cfg.ExcludeTools) > 0 {
348 b = b.WithExcludeTools(cfg.ExcludeTools)
349 }
350
351 inv, err := b.Build()
352 if err != nil {
353 // Fall back to all tools if there's an error (e.g. unknown tool names).
354 // The error will surface again at per-request time if relevant.
355 return github.AllTools(t), github.AllResources(t), github.AllPrompts(t)
356 }
357
358 ctx := context.Background()
359 return inv.AvailableTools(ctx), inv.AvailableResourceTemplates(ctx), inv.AvailablePrompts(ctx)
360}
361
362// InventoryFiltersForRequest applies filters to the inventory builder
363// based on the request context and headers.

Callers 1

DefaultInventoryFactoryFunction · 0.85

Calls 15

AllToolsFunction · 0.92
AllResourcesFunction · 0.92
AllPromptsFunction · 0.92
NewInventoryFunction · 0.92
ResolvedEnabledToolsetsFunction · 0.92
CleanToolsFunction · 0.92
hasStaticConfigFunction · 0.85
WithToolsetsMethod · 0.80
WithReadOnlyMethod · 0.80
WithToolsMethod · 0.80
WithExcludeToolsMethod · 0.80
BuildMethod · 0.80

Tested by

no test coverage detected