OpenBB-finance/OpenBB · error · ValueError
Duplicate prompt names found: {set(duplicates)}
Error message
Duplicate prompt names found: {set(duplicates)} What it means
Raised by the model_validator on MCPConfigModel when two or more prompts inside one mcp_config block share the same 'name'. Prompt names must be unique within a config because they become the MCP prompt identifiers clients call by name.
Source
Thrown at openbb_platform/extensions/mcp_server/openbb_mcp_server/models/mcp_config.py:223
"""Validate overall configuration consistency."""
# If expose is False, other configurations don't matter much, but we still validate them
if self.expose is False:
# Could add warnings here if other fields are set when expose=False
pass
# Validate prompt names are unique within this config
if self.prompts:
prompt_names = []
for prompt in self.prompts:
if prompt.name:
prompt_names.append(prompt.name)
# Check for duplicate names
if len(prompt_names) != len(set(prompt_names)):
duplicates = [
name for name in prompt_names if prompt_names.count(name) > 1
]
raise ValueError(f"Duplicate prompt names found: {set(duplicates)}")
return self
def to_dict(self) -> dict[str, Any]:
"""Convert to dictionary format compatible with existing code."""
return self.model_dump(exclude_none=True)
def validate_mcp_config(
config_dict: dict[str, Any], *, strict: bool = True
) -> MCPConfigModel:
"""
Validate an MCP configuration dictionary.
Args:
config_dict: The configuration dictionary to validate
strict: If True, raise validation errors. If False, log warnings and return best-effort model.
View on GitHub (pinned to 3e071fcc2c)
Solutions
- Rename one of the duplicate prompts so every name in the prompts list is unique
- If the duplicates are identical, keep only one entry
- When merging prompt configs programmatically, de-duplicate by name before validation and log which one won
Example fix
# before
"mcp_config": {"prompts": [{"name": "summary", ...}, {"name": "summary", ...}]}
# after
"mcp_config": {"prompts": [{"name": "summary", ...}, {"name": "detailed_summary", ...}]} Defensive patterns
Strategy: validation
Validate before calling
names = [p["name"] for p in cfg.get("prompts", []) if p.get("name")]
dups = {n for n in names if names.count(n) > 1}
if dups:
raise ValueError(f"duplicate prompt names: {dups}")
# or auto-deduplicate keeping the first occurrence:
seen = set()
cfg["prompts"] = [
p for p in cfg.get("prompts", [])
if (p.get("name") in seen) is False and not seen.add(p.get("name"))
] Type guard
def prompt_names_unique(cfg: dict) -> bool:
names = [p["name"] for p in cfg.get("prompts", []) if p.get("name")]
return len(names) == len(set(names)) Try / catch
try:
model = validate_mcp_config(cfg)
except ValidationError as e:
if "Duplicate prompt names" in str(e):
seen, unique = set(), []
for p in cfg["prompts"]:
if p.get("name") not in seen:
seen.add(p.get("name"))
unique.append(p)
cfg["prompts"] = unique
model = validate_mcp_config(cfg)
else:
raise Prevention
- De-duplicate by name whenever merging prompt lists from files/templates
- Name prompts after their purpose to make collisions obvious in review
- Add a unit test asserting uniqueness over your shipped prompt configs
When it happens
Trigger: Defining prompts: [{name: "summary", ...}, {name: "summary", ...}] in a single route's openapi_extra mcp_config, or merging prompt lists from multiple files where the same name appears twice. Only prompts with a non-empty name are counted.
Common situations: Copy-pasting a prompt definition and forgetting to rename it, composing configs from shared libraries/templates that each define a 'default' prompt, refactors that centralize prompts but keep duplicates in the merged result.
Related errors
- Prompt content cannot be empty
- Unmatched braces in prompt content: {open_braces} opening, {
- Prompt name cannot be empty string
- Prompt name '{v}' should be a valid identifier
- Tag cannot be empty string
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/41bb17c6521a2ec0.
Report an issue: GitHub.