MCP server can't handle enums from my python fastmcp server

Thanks for reporting a bug you have found in Cursor!
Please add the following info to help us diagnose your issue:

:white_check_mark: Check the forum to ensure the issue hasn’t been reported already
:lady_beetle: Provide a clear description of the bug
:counterclockwise_arrows_button: Explain how to reproduce the bug (if known)
:camera: Attach screenshots or recordings (e.g., .jpg, .png, .mp4).
:laptop: Tell us your operating system and your Cursor version (e.g., Windows, 0.x.x).
:prohibited: Tell us if the issue stops you from using Cursor.

I’m using a python fastmcp stdio server with the following endpoint:

class City(StrEnum):
    new_york = "new_york"
    los_angeles = "los_angeles"
    chicago = "chicago"
    houston = "houston"
    phoenix = "phoenix"


@mcp.tool()
def weather(city: City) -> str:
    """Get the weather for a city.

    Args:
        city: The city to get the weather for.
    """
    return f"The weather in {city} is sunny."

this runs but then fails with Invalid type for parameter 'city' in tool weather

Debugger shows the following message

[MCPHandler] Type mismatch for weather.city: expected undefined, got string

I’m pretty sure this is because fastmcp will export the following schema:

{
    "$defs": {
        "City": {
            "enum": [
                "new_york",
                "los_angeles",
                "chicago",
                "houston",
                "phoenix",
            ],
            "title": "City",
            "type": "string",
        }
    },
    "properties": {"city": {"$ref": "#/$defs/City"}},
    "required": ["city"],
    "title": "weatherArguments",
    "type": "object"
}

the City enum is referenced as opposed to inlined.

So the question is, is this valid mcp schema specification? if so it’s a bug in cursor otherwise a bug in fastmcp

I have a temporary workaround by:

def cursor_patch_fix() -> None:
    original = ToolManager.add_tool

    def patched(*args, **kwargs):
        tool = original(*args, **kwargs)
        tool.parameters = jsonref.replace_refs(
            tool.parameters,
            lazy_load=False,
            proxies=False,
        )  # type: ignore
        return tool

    ToolManager.add_tool = patched  # type: ignore

in the fastmcp server