googleapis/mcp-toolbox · error
embeddingModel %q declared more than once
Error message
embeddingModel %q declared more than once
What it means
UnmarshalPrimitiveConfig rejects duplicate embeddingModel names: after unmarshaling an "embeddingModel" resource, it checks `embeddingModelConfigs[name]` and errors if the name already exists. Model names are map keys; a duplicate would silently overwrite the earlier model, so parsing fails.
Source
Thrown at internal/server/config.go:307
toolsetGroups = make(map[string]group.GroupConfig)
}
if _, exists := toolsetGroups[name]; exists {
return nil, nil, nil, nil, nil, nil, fmt.Errorf("toolset %q declared more than once", name)
}
toolsetGroups[name] = group.GroupConfig{Name: name, ToolNames: c.ToolNames}
case "embeddingModel":
c, err := UnmarshalYAMLEmbeddingModelConfig(ctx, name, resource)
if err != nil {
if len(file.Docs) > 1 {
return nil, nil, nil, nil, nil, nil, fmt.Errorf("document %d: error unmarshaling %s %q: %w", docIndex, kind, name, err)
}
return nil, nil, nil, nil, nil, nil, fmt.Errorf("error unmarshaling %s: %w", kind, err)
}
if embeddingModelConfigs == nil {
embeddingModelConfigs = make(EmbeddingModelConfigs)
}
if _, exists := embeddingModelConfigs[name]; exists {
return nil, nil, nil, nil, nil, nil, fmt.Errorf("embeddingModel %q declared more than once", name)
}
embeddingModelConfigs[name] = c
case "prompt":
c, err := UnmarshalYAMLPromptConfig(ctx, name, resource)
if err != nil {
if len(file.Docs) > 1 {
return nil, nil, nil, nil, nil, nil, fmt.Errorf("document %d: error unmarshaling %s %q: %w", docIndex, kind, name, err)
}
return nil, nil, nil, nil, nil, nil, fmt.Errorf("error unmarshaling %s: %w", kind, err)
}
if promptConfigs == nil {
promptConfigs = make(PromptConfigs)
}
if _, exists := promptConfigs[name]; exists {
return nil, nil, nil, nil, nil, nil, fmt.Errorf("prompt %q declared more than once", name)
}
promptConfigs[name] = c
case "group":View on GitHub (pinned to 8cc6e09de2)
Solutions
- Rename one of the two embeddingModels named in the error to a unique name.
- Remove the redundant duplicate model definition.
- Search all `---` documents for the duplicated name.
- Update toolset/tool references to point at the retained model name.
Example fix
// before
embeddingModels:
my-embed:
provider: gemini
modelId: text-embedding-004
my-embed:
provider: gemini
modelId: text-embedding-005
// after
embeddingModels:
my-embed:
provider: gemini
modelId: text-embedding-004
my-embed-v5:
provider: gemini
modelId: text-embedding-005 Defensive patterns
Strategy: validation
Validate before calling
func rawDuplicateEmbeddingModelNames(data string) []string {
var seen, dups []string
inSection := false
for _, line := range strings.Split(data, "\n") {
trimmed := strings.TrimSpace(line)
if strings.HasPrefix(line, "embeddingModels:") { inSection = true; continue }
if inSection && !strings.HasPrefix(line, " ") && strings.HasSuffix(trimmed, ":") && !strings.HasPrefix(trimmed, "-") { inSection = false }
if inSection && strings.HasSuffix(trimmed, ":") && !strings.HasPrefix(trimmed, "-") {
name := strings.TrimSuffix(trimmed, ":")
if slices.Contains(seen, name) { dups = append(dups, name) }
seen = append(seen, name)
}
}
return dups
} Type guard
func isDuplicateEmbeddingModelErr(err error) bool {
return err != nil && strings.Contains(err.Error(), "embeddingModel") && strings.Contains(err.Error(), "declared more than once")
} Try / catch
cfg, err := server.ParseConfig(ctx, yamlBytes)
if err != nil {
if strings.Contains(err.Error(), "declared more than once") {
return fmt.Errorf("embedding model names must be unique: %w", err)
}
return err
} Prevention
- Version model names (my-embed-v1, my-embed-v2) instead of reusing one name.
- Grep for the model name across all documents before adding a new block.
- Update any references (e.g., tool/model bindings) after renaming a model.
When it happens
Trigger: Calling ParseConfig with a YAML file (single or multi-document) that declares two `embeddingModel` resources with the same name, hitting the `exists` check on `embeddingModelConfigs`.
Common situations: Adding a second embedding model block and reusing the earlier name; merging config fragments where both define `my-embed`.
Related errors
- source %q declared more than once
- authService %q declared more than once
- tool %q declared more than once
- toolset %q declared more than once
- prompt %q declared more than once
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/a45816e410f9035f.
Report an issue: GitHub.