Pydantic request on MCP server

Describe the Bug

When writing an MCP server with the protocols python sdk and Pydantic as a means to generate the json input schema it seems cursor is getting stuck on sending a message, due to the discriminator part.

Steps to Reproduce

A contrived example can be found below, obviously don’t need to use a discriminator but it highlights the failure.

from typing import Literal, Union
from pydantic import BaseModel, Field, Discriminator

from mcp.server.fastmcp import  FastMCP
from mcp.types import ToolAnnotations

from mcp.types import CallToolResult, TextContent


app = FastMCP("animal-MCP-Server", port=3001)

class Dog(BaseModel):
    age: int = Field(description="The age of the dog")
    breed: str = Field(description="The breed of the dog")
    type: Literal["dog"] = "dog"


class Cat(BaseModel):
    age: int = Field(description="The age of the cat")
    breed: str = Field(description="The breed of the cat")
    type: Literal["cat"] = "cat"


class Animal(BaseModel):
    name: str = Field(description="The name of the animal")
    type: Union[Dog, Cat] = Field(description="The type of the animal", discriminator="type")

@app.tool(
    description="Use this tool to fetch animal data from local data sources.",
    annotations=ToolAnnotations(
        readOnlyHint=True,
        idempotentHint=True,
        openWorldHint=False,
        destructiveHint=False,
    ),
)
async def get_animal_data(
    animal: Animal,
) -> CallToolResult:
    """Lookup Instruments with our Catalog.

    Returns:
        CompactGroupedCatalogResponse: Response containing hierarchically grouped instruments
    """
    return CallToolResult(
        content=[TextContent(
            text=f"Hello, {animal.name}!",
            type="text"
        )]
    )


if __name__ == "__main__":
    app.run(transport="stdio")

Expected Behavior

Cursor MCP host would construct the request in a simple fashion ready.

Operating System

MacOS

Request ID

789c0de7-2f70-4858-8819-b5c619603374

Current Cursor Version (Menu → About Cursor → Copy)

Version: 1.2.4
VSCode Version: 1.99.3
Commit: a8e95743c5268be73767c46944a71f4465d05c90
Date: 2025-07-10T16:53:59.659Z
Electron: 34.5.1
Chromium: 132.0.6834.210
Node.js: 20.19.0
V8: 13.2.152.41-electron.0
OS: Darwin arm64 23.5.0

Does this stop you from using Cursor

Yes - Cursor is unusable

This topic was automatically closed 22 days after the last reply. New replies are no longer allowed.