{"record":{"id":"211ea8c090b937bc","repo":"PrefectHQ/fastmcp","slug":"accessing-cls-name-camel-is-deprecated-mcp","errorCode":null,"errorMessage":"Accessing `{cls_name}.{camel}` is deprecated; MCP SDK v2 renamed this field to `{snake}`. Update your code to read `.{snake}` instead.","messagePattern":"Accessing `(.+?)\\.(.+?)` is deprecated; MCP SDK v2 renamed this field to `(.+?)`\\. Update your code to read `\\.(.+?)` instead\\.","errorType":"console","errorClass":"FastMCPDeprecationWarning","httpStatus":null,"severity":"warning","filePath":"fastmcp_slim/fastmcp/_compat.py","lineNumber":127,"sourceCode":"def _make_property(cls_name: str, camel: str, snake: str) -> property:\n    \"\"\"Build a warn-once property routing a camelCase read to a snake attr.\n\n    The getter reads the live `mcp_camelcase_compat` setting on every access: if\n    the bridge is disabled it raises `AttributeError` (matching the message\n    Python raises for a genuinely missing attribute) so the shim is transparent;\n    if enabled it warns once and returns the snake_case value.\n    \"\"\"\n    warned = False\n\n    def getter(self: object) -> object:\n        nonlocal warned\n        import fastmcp\n\n        if not fastmcp.settings.mcp_camelcase_compat:\n            raise AttributeError(f\"{cls_name!r} object has no attribute {camel!r}\")\n        if not warned:\n            warned = True\n            warnings.warn(\n                f\"Accessing `{cls_name}.{camel}` is deprecated; MCP SDK v2 \"\n                f\"renamed this field to `{snake}`. Update your code to read \"\n                f\"`.{snake}` instead.\",\n                FastMCPDeprecationWarning,\n                stacklevel=2,\n            )\n        return getattr(self, snake)\n\n    return property(getter)\n\n\ndef install() -> None:\n    \"\"\"Install camelCase compatibility properties on SDK v2 model classes.\n\n    Idempotent. Each bridged read warns once per (class, name) and returns the\n    snake_case value. Skips any camelCase name a class already defines to avoid\n    shadowing real upstream attributes.\n    \"\"\"","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/_compat.py#L109-L145","documentation":"MCP SDK v2 renamed camelCase fields to snake_case. FastMCP keeps a compatibility shim (`__getattr__` getter) that, when `settings.mcp_camelcase_compat` is enabled, emits a `FastMCPDeprecationWarning` and returns the snake_case field value. With compat disabled, attribute access raises `AttributeError` instead.","triggerScenarios":"Reading a camelCase attribute (e.g. `request_id` -> `requestId` style names) on a v2 SDK type while `mcp_camelcase_compat=True`; with the setting off, the same access raises AttributeError.","commonSituations":"Code written against MCP SDK v1 (camelCase) running under the v2 SDK; gradual migration scripts; examples copied from older docs.","solutions":["Rename all attribute accesses to the snake_case name shown in the warning.","Optionally keep the deprecated access temporarily by leaving `fastmcp.settings.mcp_camelcase_compat = True`, but plan the rename.","Run a deprecation-warning sweep (`-W error::FastMCPDeprecationWarning` in tests) to catch remaining usages.","Regenerate typed code (SDK models) against the v2 SDK so field names are current."],"exampleFix":"// before\nprint(result.requestId)\n// after\nprint(result.request_id)","handlingStrategy":"type-guard","validationCode":"import fastmcp\nassert fastmcp.settings.mcp_camelcase_compat, \"camelCase access requires mcp_camelcase_compat=True; migrate to snake_case\"","typeGuard":"def has_new_field(obj, snake: str) -> bool:\n    return hasattr(obj, snake)","tryCatchPattern":"import warnings\nfrom fastmcp.exceptions import FastMCPDeprecationWarning\nwith warnings.catch_warnings(record=True) as caught:\n    warnings.simplefilter(\"always\", FastMCPDeprecationWarning)\n    value = getattr(obj, camel_name)\nfor w in caught:\n    logging.warning(\"migrate field: %s\", w.message)","preventionTips":["Migrate all field access to snake_case names once on SDK v2","Enable mcp_camelcase_compat only as a temporary migration aid","Run tests with deprecation warnings as errors to find stragglers"],"tags":["python","deprecation","mcp-sdk-v2","naming"],"backgroundTag":"deprecated-field-rename","analyzedSha":"1f021142978e0861cd910c8df4e8074bc7cf3978","analyzedAt":"2026-08-29T14:31:16.082Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}