{"record":{"id":"2099d9c035a7c493","repo":"PrefectHQ/fastmcp","slug":"module-name-r-has-no-attribute-name-r-2099d9","errorCode":null,"errorMessage":"module {__name__!r} has no attribute {name!r}","messagePattern":"module (.+?) has no attribute (.+?)","errorType":"exception","errorClass":"AttributeError","httpStatus":null,"severity":"error","filePath":"fastmcp_slim/fastmcp/server/__init__.py","lineNumber":29,"sourceCode":"\ndef __getattr__(name: str) -> object:\n    if name in {\"context\", \"dependencies\"}:\n        return importlib.import_module(f\"fastmcp.server.{name}\")\n    if name == \"Context\":\n        try:\n            from .context import Context\n        except ImportError as exc:\n            raise ImportError(_install_hints.SERVER_SUPPORT) from exc\n\n        return Context\n    if name in {\"FastMCP\", \"create_proxy\"}:\n        try:\n            from .server import FastMCP, create_proxy\n        except ImportError as exc:\n            raise ImportError(_install_hints.SERVER_SUPPORT) from exc\n\n        return FastMCP if name == \"FastMCP\" else create_proxy\n    raise AttributeError(f\"module {__name__!r} has no attribute {name!r}\")\n\n\n__all__ = [\"Context\", \"FastMCP\", \"create_proxy\"]\n","sourceCodeStart":11,"sourceCodeEnd":33,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/server/__init__.py#L11-L33","documentation":"The module-level __getattr__ of fastmcp.server falls through to `raise AttributeError(f\"module {__name__!r} has no attribute {name!r}\")` for any attribute name not explicitly handled (context/dependencies/Context/FastMCP/create_proxy). This is standard PEP 562 lazy-module behavior: unknown attributes raise the usual AttributeError.","triggerScenarios":"Access any non-existent attribute on fastmcp.server, e.g. `from fastmcp.server import Server`, `fastmcp.server.Someting`, or a typo like `fastmcp.server.FastMCP2` — the fallthrough at fastmcp_slim/fastmcp/server/__init__.py:29 raises AttributeError.","commonSituations":"Typos in imports; migrating code that used different symbol names across FastMCP versions; IDE auto-import picking the wrong module; dynamically getattr()-ing names from config strings that don't match __all__.","solutions":["Fix the attribute name; check `fastmcp.server.__all__` (Context, FastMCP, create_proxy) or use dir(fastmcp.server).","Import the symbol from its real submodule (e.g. fastmcp.server.middleware for middleware) instead of the package root.","If the name should exist, confirm server support is installed — but note missing server deps raise ImportError (214/215), not this AttributeError.","For dynamic lookups, validate the configured name against __all__ before getattr()."],"exampleFix":"// before\nfrom fastmcp.server import Server  # wrong name\n\n// after\nfrom fastmcp import FastMCP  # or from fastmcp.server import FastMCP","handlingStrategy":"validation","validationCode":"import fastmcp.server\nname = 'FastMCP'\nif name not in fastmcp.server.__all__:\n    raise AttributeError(f'{name} not exported by fastmcp.server; available: {fastmcp.server.__all__}')","typeGuard":null,"tryCatchPattern":"try:\n    attr = getattr(fastmcp.server, name)\nexcept AttributeError as e:\n    logger.error('bad import name: %s', e)","preventionTips":["Check __all__/dir() before importing dynamically.","Beware typos and renamed symbols across versions.","Let static type checkers/IDE imports catch bad names early."],"tags":["imports","attributeerror","lazy-loading"],"backgroundTag":"module-has-no-attribute","analyzedSha":"1f021142978e0861cd910c8df4e8074bc7cf3978","analyzedAt":"2026-08-29T14:31:16.082Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}