Spaces:
Sleeping
Sleeping
Download examples/complex_inputs.py from purecipher/xsecuremcp: direct link, hf CLI and curl.
- Browser
- Download file 672 Bytes
-
https://huggingface.co/spaces/purecipher/xsecuremcp/resolve/main/examples/complex_inputs.py
- Command line
-
hf download hf://spaces/purecipher/xsecuremcp/examples/complex_inputs.py
-
curl -L -o complex_inputs.py https://huggingface.co/spaces/purecipher/xsecuremcp/resolve/main/examples/complex_inputs.py
672 Bytes
| """ | |
| FastMCP Complex inputs Example | |
| Demonstrates validation via pydantic with complex models. | |
| """ | |
| from typing import Annotated | |
| from pydantic import BaseModel, Field | |
| from fastmcp import FastMCP | |
| mcp = FastMCP("Shrimp Tank") | |
| class ShrimpTank(BaseModel): | |
| class Shrimp(BaseModel): | |
| name: Annotated[str, Field(max_length=10)] | |
| shrimp: list[Shrimp] | |
| def name_shrimp( | |
| tank: ShrimpTank, | |
| # You can use pydantic Field in function signatures for validation. | |
| extra_names: Annotated[list[str], Field(max_length=10)], | |
| ) -> list[str]: | |
| """List all shrimp names in the tank""" | |
| return [shrimp.name for shrimp in tank.shrimp] + extra_names | |