googleapis/mcp-toolbox · error
no valid commands were built to execute
Error message
no valid commands were built to execute
What it means
Valkey Source.RunCommand splits the requested commands, builds valkey-go arbitrary commands via B().Arbitrary(cmd...).Build(), and refuses to run when the resulting builtCmds slice is empty. Because builtCmds is allocated with len(cmds) entries, this fires only when zero commands were supplied in the first place — i.e. the tool invocation carried no command arguments.
Source
Thrown at internal/sources/valkey/valkey.go:142
func (s *Source) ToConfig() sources.SourceConfig {
return s.Config
}
func (s *Source) ValkeyClient() valkey.Client {
return s.Client
}
func (s *Source) RunCommand(ctx context.Context, cmds [][]string) (any, error) {
// Build commands
builtCmds := make(valkey.Commands, len(cmds))
for i, cmd := range cmds {
builtCmds[i] = s.ValkeyClient().B().Arbitrary(cmd...).Build()
}
if len(builtCmds) == 0 {
return nil, fmt.Errorf("no valid commands were built to execute")
}
// Execute commands
responses := s.ValkeyClient().DoMulti(ctx, builtCmds...)
// Parse responses
out := make([]any, len(cmds))
for i, resp := range responses {
if err := resp.Error(); err != nil {
// Store error message in the output for this command
out[i] = fmt.Sprintf("error from executing command at index %d: %s", i, err)
continue
}
val, err := resp.ToAny()
if err != nil {
out[i] = fmt.Sprintf("error parsing response: %s", err)
continue
}View on GitHub (pinned to 8cc6e09de2)
Solutions
- Pass at least one command in the 'commands' parameter, e.g. ["PING"] or ["GET", "mykey"]
- Ensure each command is provided as an array of argument strings (['SET','key','value']), not a single joined string
- Validate client-side that the commands array is non-empty before invoking the tool
Example fix
// before (tool request)
{"commands": []}
// after
{"commands": [["PING"]]} Defensive patterns
Strategy: validation
Validate before calling
function validateCommands(cmds: unknown): asserts cmds is string[][] {
if (!Array.isArray(cmds) || cmds.length === 0)
throw new Error("'commands' must be a non-empty array of argument arrays");
if (!cmds.every(c => Array.isArray(c) && c.every(a => typeof a === "string")))
throw new Error("each command must be an array of strings");
} Type guard
function isNonEmptyCommandList(v: unknown): v is string[][] {
return Array.isArray(v) && v.length > 0 &&
v.every(c => Array.isArray(c) && c.length > 0 && c.every(a => typeof a === "string"));
} Try / catch
try {
const res = await runValkeyCommand(commands);
} catch (err) {
if (String(err).includes("no valid commands were built")) {
console.error("commands parameter was empty; send e.g. [[\"PING\"]]");
}
throw err;
} Prevention
- Always send at least one command; never pass an empty array
- Constrain the tool schema in clients so 'commands' is required with minItems: 1
- In agent prompts, show an example invocation with a concrete command
When it happens
Trigger: Calling RunCommand (via the valkey-run-command tool) with an empty commands list: the tool parameters array is missing, empty, or the invoking agent passed an empty array.
Common situations: An LLM agent invoking the run_command tool without filling the commands parameter; a client sending an empty JSON array for commands; misconfigured tool parameter defaults.
Related errors
- error initializing Valkey client: %s
- resources cannot be empty
- description is required for tool %q
- description is required for tool %q
- HTTP error! status: ${response.status}
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/04b365c5189cec01.
Report an issue: GitHub.