What happened?
A resource template can be registered with an optional list[str] query parameter, and reading it without the query parameter works. But any query value for that parameter fails at read time with a Pydantic list validation error.
This makes list-style resource filters, such as tags or symbols, hard to use from a URI template. I would expect the template either to support a usable multi-value query form or reject this shape at registration time with a clearer error.
Example Code
import asyncio
from fastmcp import Client, FastMCP
from pydantic import Field
mcp = FastMCP("demo")
@mcp.resource("items://{category}{?tags}")
def search(category: str, tags: list[str] = Field(default_factory=list)) -> dict:
return {"category": category, "tags": tags}
async def main():
async with Client(mcp) as client:
for uri in [
"items://books",
"items://books?tags=alpha",
"items://books?tags=alpha&tags=beta",
"items://books?tags=alpha,beta",
]:
try:
result = await client.read_resource(uri)
print(uri, "=>", result[0].text)
except Exception as exc:
print(uri, "=>", type(exc).__name__, str(exc).splitlines()[0])
asyncio.run(main())
Version Information
fastmcp-slim 3.4.2
mcp 1.28.0
pydantic 2.13.4
Python 3.12.13
Windows 11
What happened?
A resource template can be registered with an optional
list[str]query parameter, and reading it without the query parameter works. But any query value for that parameter fails at read time with a Pydantic list validation error.This makes list-style resource filters, such as tags or symbols, hard to use from a URI template. I would expect the template either to support a usable multi-value query form or reject this shape at registration time with a clearer error.
Example Code
Version Information