Skip to content

[BUG] [email protected] cannot pass the tool name validation in Strands #54

@xiehust

Description

@xiehust

Checks

  • I have updated to the lastest minor and patch version of Strands
  • I have checked the documentation and this is not expected behavior
  • I have searched ./issues and there are no duplicates of my issue

Strands Version

0.1.2

Python Version

3.13.2

Operating System

ubuntu

Installation Method

pip

Steps to Reproduce

I am buiding a agent with MCP server from tavily search https://docs.tavily.com/documentation/mcp
however it raises exception :

tool_name=<tavily-search> | invalid tool name pattern

than I looked at the code,

tool_name_pattern = r"^[a-zA-Z][a-zA-Z0-9_]*$"

it seems that the validation regex did not include pattern as "tavily-search".

def validate_tool_use_name(tool: ToolUse) -> None:
    """Validate the name of a tool use.

    Args:
        tool: The tool use to validate.

    Raises:
        InvalidToolUseNameException: If the tool name is invalid.
    """
    # We need to fix some typing here, because we dont actually expect a ToolUse, but dict[str, Any]
    if "name" not in tool:
        message = "tool name missing"  # type: ignore[unreachable]
        logger.warning(message)
        raise InvalidToolUseNameException(message)

    tool_name = tool["name"]
    tool_name_pattern = r"^[a-zA-Z][a-zA-Z0-9_]*$"

Expected Behavior

should pass the validation, as tavily mcp is widely used in agents

Actual Behavior

failed to pass the name validation

Additional Context

No response

Possible Solution

tool_name_pattern = r"^[a-zA-Z][a-zA-Z0-9_-]*$" # Added hyphen to allowed characters

Related Issues

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions