github/github-mcp-server · error

failed to build inventory: %w

Error message

failed to build inventory: %w

What it means

Returned by runListScopes when inventoryBuilder.Build() fails while constructing the tool inventory for the list-scopes report. Build() applies read-only filtering, toolset selection, and WithTools validation; in this code path the dominant concrete cause is inventory.ErrUnknownTools (unrecognized names in the 'tools' config), surfaced here wrapped as 'failed to build inventory: unknown tools specified in WithTools: <names>'.

Source

Thrown at cmd/github-mcp-server/list_scopes.go:126

	t, _ := translations.TranslationHelper()

	// Build inventory using the same logic as the stdio server
	inventoryBuilder := github.NewInventory(t).
		WithReadOnly(readOnly)

	// Configure toolsets (same as stdio)
	if enabledToolsets != nil {
		inventoryBuilder = inventoryBuilder.WithToolsets(enabledToolsets)
	}

	// Configure specific tools
	if len(enabledTools) > 0 {
		inventoryBuilder = inventoryBuilder.WithTools(enabledTools)
	}

	inv, err := inventoryBuilder.Build()
	if err != nil {
		return fmt.Errorf("failed to build inventory: %w", err)
	}

	// Collect all tools and their scopes
	output := collectToolScopes(inv, readOnly)

	// Output based on format
	switch outputFormat {
	case "json":
		return outputJSON(output)
	case "summary":
		return outputSummary(output)
	default:
		return outputText(output)
	}
}

func collectToolScopes(inv *inventory.Inventory, readOnly bool) ScopesOutput {
	var tools []ToolScopeInfo

View on GitHub (pinned to 0ea1f775a7)

Solutions

  1. Read the wrapped message — it enumerates the exact unrecognized tool names
  2. Correct or remove those names, using current canonical names from the repo docs (docs/tool-renaming.md maps old to new)
  3. If you meant a whole toolset, move the value to the 'toolsets' config key instead
  4. Re-run list-scopes after fixing config; it should build and print scopes

Example fix

# before (config.yml)
tools: ["create_issue", "add_issue_comment"]

# after (post-rename canonical names)
tools: ["issue", "issue_comment"]
Defensive patterns

Strategy: validation

Validate before calling

// Validate configured tool names against a default inventory before Build
checkInv, err := github.NewInventory(t).Build()
if err == nil {
    known := map[string]bool{}
    for _, name := range checkInv.AllToolNames() { // expose/collect names as available
        known[name] = true
    }
    for _, n := range enabledTools {
        if !known[n] {
            log.Fatalf("unknown tool %q — see docs/tool-renaming.md for canonical names", n)
        }
    }
}
inv, err := inventoryBuilder.Build()

Type guard

// Narrow build failures to the config sentinel
func isUnknownToolsErr(err error) bool {
    return err != nil && errors.Is(err, inventory.ErrUnknownTools)
}

Try / catch

inv, err := inventoryBuilder.Build()
if err != nil {
    if errors.Is(err, inventory.ErrUnknownTools) {
        // message lists the bad names; surface them to the user as a config error
        fmt.Fprintf(os.Stderr, "fix your 'tools' config: %v\n", err)
        os.Exit(2)
    }
    return fmt.Errorf("failed to build inventory: %w", err)
}

Prevention

When it happens

Trigger: Config 'tools' contains names that are neither registered tools nor deprecated aliases (typo, removed/renamed tool, toolset name used as a tool name); WithTools([]string{...}) fed directly with invalid names when embedding. Read-only mode silently filters write tools, so readOnly itself is not the trigger.

Common situations: Upgrading github-mcp-server after tool consolidation and keeping old tool names in config; confusing toolset names ('repos', 'issues') with tool names; configs copied from outdated docs or another fork.

Related errors


AI-assisted analysis of github/github-mcp-server@0ea1f775a7 (2026-08-15). Data as JSON: /api/errors/4af29b86bd890014. Report an issue: GitHub.