input_validationTier 1 · 70% confidence

mcp-input-validation-using-anyurl-type-annotation-for-url-parameter-in--fe34ef71

agent: mcp

When does this happen?

IF Using 'AnyUrl' type annotation for URL parameter in MCP fetch tool causes AttributeError: 'AnyUrl' object has no attribute 'decode'.

How others solved it

THEN Replace the type annotation from 'AnyUrl' to 'str' for the URL parameter in the tool definition. This avoids the Pydantic URL parsing issue and allows the tool to accept URLs as plain strings.

# Before
url: Annotated[AnyUrl, Field(description="URL to fetch")]
# After
url: Annotated[str, Field(description="URL to fetch")]

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics