googleapis/mcp-toolbox · critical

failed to read prebuilt tools %w

Error message

failed to read prebuilt tools %w

What it means

loadPrebuiltToolYAMLs reads the embedded filesystem directory "tools" (via embed.FS ReadDir) to discover all prebuilt configs. This error wraps any failure of that directory read, meaning the embedded FS is unreadable or the "tools" directory is missing from the build.

Source

Thrown at internal/prebuiltconfigs/prebuiltconfigs.go:67

	content, ok := prebuiltToolYAMLs[prebuiltSourceConfig]
	if !ok {
		prebuiltHelpSuffix := "no prebuilt configurations found."
		if len(prebuiltToolsSources) > 0 {
			prebuiltHelpSuffix = fmt.Sprintf("available: %s", strings.Join(prebuiltToolsSources, ", "))
		}
		errMsg := fmt.Errorf("prebuilt source tool for '%s' not found. %s", prebuiltSourceConfig, prebuiltHelpSuffix)
		return nil, errMsg
	}
	return content, nil
}

// Load all available pre built tools
func loadPrebuiltToolYAMLs() (map[string][]byte, []string, error) {
	toolYAMLs := make(map[string][]byte)
	var sourceTypes []string
	entries, err := prebuiltConfigsFS.ReadDir("tools")
	if err != nil {
		errMsg := fmt.Errorf("failed to read prebuilt tools %w", err)
		return nil, nil, errMsg
	}

	for _, entry := range entries {
		lowerName := strings.ToLower(entry.Name())
		if !entry.IsDir() && (strings.HasSuffix(lowerName, ".yaml")) {
			filePathInFS := path.Join("tools", entry.Name())
			content, err := prebuiltConfigsFS.ReadFile(filePathInFS)
			if err != nil {
				errMsg := fmt.Errorf("failed to read a prebuilt tool %w", err)
				return nil, nil, errMsg
			}
			sourceTypeKey := entry.Name()[:len(entry.Name())-len(".yaml")]

			sourceTypes = append(sourceTypes, sourceTypeKey)
			toolYAMLs[sourceTypeKey] = content
		}
	}

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Verify internal/prebuiltconfigs/tools/ exists and contains at least one .yaml file matching the //go:embed pattern.
  2. Rebuild with `go build` from a clean checkout so embed directives resolve.
  3. Check go.mod/module path and working directory if running tests from an unexpected root.
  4. Inspect the wrapped %w error for the underlying filesystem cause.
Defensive patterns

Strategy: fallback

Try / catch

toolYAMLs, sources, err := loadPrebuiltToolYAMLs()
if err != nil {
	return fmt.Errorf("prebuilt configs unavailable, falling back to explicit tool configs: %w", err)
}

Prevention

When it happens

Trigger: prebuiltConfigsFS.ReadDir("tools") fails because the embed directive is missing/empty (no tools/*.yaml matched at build time), the directory was renamed or deleted, or a build without the //go:embed assets was produced.

Common situations: Building a trimmed-down binary where the embed pattern matched nothing (Go errors at compile time, but a vendored/stale build may lack the dir); refactoring moved internal/prebuiltconfigs/tools/; running tests with a custom workspace excluding embedded assets.

Related errors


AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05). Data as JSON: /api/errors/54eadd1629057710. Report an issue: GitHub.