googleapis/mcp-toolbox · error
error generating script content for %s: %w
Error message
error generating script content for %s: %w
What it means
This error wraps a failure from generateScriptContent, which renders the JavaScript wrapper script for a tool during `toolbox skills` generation. The skills command iterates every tool in the resolved skill and generates a .js wrapper per tool; if the template execution or data assembly for any tool fails, the command logs and aborts with this wrapped error so the user knows which tool's script could not be generated.
Source
Thrown at cmd/internal/skills/command.go:214
return err
}
jsConfigArgs = append(jsConfigArgs, `"--config"`, fmt.Sprintf(`path.join(__dirname, "..", "assets", %q)`, baseName))
}
configArgsStr := strings.Join(jsConfigArgs, ", ")
// Iterate over keys to ensure deterministic order
var toolNames []string
for name := range allTools {
toolNames = append(toolNames, name)
}
sort.Strings(toolNames)
for _, toolName := range toolNames {
// Generate wrapper script in scripts directory
scriptContent, err := generateScriptContent(toolName, configArgsStr, cmd.licenseHeader, cmd.invocationMode, cmd.toolboxVersion, parser.OptionalEnvVars)
if err != nil {
errMsg := fmt.Errorf("error generating script content for %s: %w", toolName, err)
opts.Logger.ErrorContext(ctx, errMsg.Error())
return errMsg
}
scriptFilename := filepath.Join(scriptsPath, fmt.Sprintf("%s.js", toolName))
if err := os.WriteFile(scriptFilename, []byte(scriptContent), 0755); err != nil {
errMsg := fmt.Errorf("error writing script %s: %w", scriptFilename, err)
opts.Logger.ErrorContext(ctx, errMsg.Error())
return errMsg
}
}
// Generate SKILL.md
skillContent, err := generateSkillMarkdown(skillName, content.description, cmd.additionalNotes, allTools, parser.EnvVars)
if err != nil {
errMsg := fmt.Errorf("error generating SKILL.md content: %w", err)
opts.Logger.ErrorContext(ctx, errMsg.Error())
return errMsgView on GitHub (pinned to 8cc6e09de2)
Solutions
- Re-run the command to confirm the failure is deterministic and note the toolName in the wrapped message
- Run `toolbox tools list` (or inspect the resolved config) to examine that specific tool's parameters/manifest for anomalies
- Regenerate with a narrower --toolset/--group excluding the failing tool to isolate it
- Update the toolbox binary so the tool's manifest matches the script template expectations
- If persistent, report the failing tool/config to the MCP Toolbox maintainers
Example fix
// before toolbox skills --name my-skill --toolset all // after (isolate the failing tool by generating a smaller toolset) toolbox skills --name my-skill --tools execute_sql
Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-check resolved tools before generating
out, _ := exec.Command("toolbox", "tools", "list", "--toolset", "all").CombinedOutput()
if len(out) == 0 { return errors.New("no tools resolved; nothing to generate") } Try / catch
try {
execSync("toolbox skills --name my-skill --toolset my-set", { stdio: "inherit" });
} catch (e) {
if (String(e.stderr).includes("error generating script content for")) {
console.error("Script generation failed for a tool; regenerate with a narrower toolset:", e.stderr);
} else { throw e; }
} Prevention
- Pin a toolbox version compatible with your config's tool definitions
- Test skills generation in CI against every toolset you ship
- Avoid hand-editing generated configs that feed tool metadata
- Regenerate skills after any config change rather than reusing stale output
When it happens
Trigger: Running `toolbox skills` when generateScriptContent returns an error for a given toolName — e.g. template data construction fails for a tool's parameters, an unexpected tool manifest shape, or an internal template rendering failure while processing the tool set (after toolNames are sorted and iterated).
Common situations: Generating a skill for a toolset containing a tool with unusual or malformed parameter metadata; a tool added by a newer/older toolbox version whose manifest fields don't match the script template's expectations; corrupted or partially written config causing odd tool definitions.
Related errors
- error generating SKILL.md content: %w
- failed to initialize resources: %w
- tool %q not found
- unable to retrieve source for tool %s
- error writing script %s: %w
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/a116b7b661740e1f.
Report an issue: GitHub.