When you add return type annotations, FastMCP automatically generates output schemas to validate the structured data and enables clients to deserialize results back to Python objects.
I've modified my code to return an annotated class instead of a simple DICT [str, любой], но не мог наблюдать каких -либо различий в ответе, возвращаемом клиентом MCP -
не в описании, возвращаемом сервером MCP, и даже не в ответ на инструмент_Рекст клиента MCP (я использовал Wireshark для просмотра результата, возвращаемого сервером, когда клиент назвал инструмент). />
Код: Выделить всё
# FastMCP version: 2.10.1
# Original code:
mcp.tool(name="some_tool")
def some_tool(arg1: str, arg2: int) -> dict[str, Any]:
...
# Code using an annotated class:
class ResponseClass(BaseModel):
mem1: Annotated[int, Field(description="some description")]
mem2: Annotated[int, Field(description="some description")]
mcp.tool(name="some_tool")
def some_tool(arg1: str, arg2: int) -> ResponseClass:
...
Подробнее здесь: https://stackoverflow.com/questions/796 ... -in-the-de