{"record":{"id":"237b3b8ccb5356fc","repo":"PrefectHQ/fastmcp","slug":"cannot-specify-both-a-name-as-first-argument-and-a-237b3b","errorCode":null,"errorMessage":"Cannot specify both a name as first argument and as keyword argument. Use either @prompt('{name_or_fn}') or @prompt(name='{name}'), not both.","messagePattern":"Cannot specify both a name as first argument and as keyword argument\\. Use either @prompt\\('(.+?)'\\) or @prompt\\(name='(.+?)'\\), not both\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"fastmcp_slim/fastmcp/server/providers/local_provider/decorators/prompts.py","lineNumber":207,"sourceCode":"                title=title,\n                description=description,\n                icons=icons,\n                tags=tags,\n                meta=meta,\n                auth=auth,\n                enabled=enabled,\n            )\n            target = fn.__func__ if hasattr(fn, \"__func__\") else fn\n            target.__fastmcp__ = metadata  # type: ignore[attr-defined]  # ty:ignore[unresolved-attribute]\n            self.add_prompt(fn)\n            return fn\n\n        if inspect.isroutine(name_or_fn):\n            return decorate_and_register(name_or_fn, name)\n\n        elif isinstance(name_or_fn, str):\n            if name is not None:\n                raise TypeError(\n                    f\"Cannot specify both a name as first argument and as keyword argument. \"\n                    f\"Use either @prompt('{name_or_fn}') or @prompt(name='{name}'), not both.\"\n                )\n            prompt_name = name_or_fn\n        elif name_or_fn is None:\n            prompt_name = name\n        else:\n            raise TypeError(f\"Invalid first argument: {type(name_or_fn)}\")\n\n        return partial(\n            self.prompt,\n            name=prompt_name,\n            version=version,\n            title=title,\n            description=description,\n            icons=icons,\n            tags=tags,\n            meta=meta,","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/server/providers/local_provider/decorators/prompts.py#L189-L225","documentation":"`@prompt` accepts the name either positionally or via the `name=` keyword, not both. Supplying both — e.g. `prompt('x', name='y')` — raises this TypeError to prevent ambiguous naming.","triggerScenarios":"Calling `provider.prompt('custom', name='other')` or stacking wrappers that pass the name positionally while also forwarding `name=` through `partial`/functools.","commonSituations":"Wrapping the decorator in a helper that already sets `name=` while callers also pass a positional name; refactoring from positional to keyword style and leaving both in place.","solutions":["Remove one of the two names — keep `@prompt('custom_name')` or `@prompt(name='custom_name')`, not both","If building a wrapper, forward only `**kwargs` and let the caller supply `name` once"],"exampleFix":"// before\n@provider.prompt('greet', name='greeting')\nasync def p(): ...\n// after\n@provider.prompt(name='greeting')\nasync def p(): ...","handlingStrategy":"validation","validationCode":"if name is not None and isinstance(name_or_fn, str):\n    raise TypeError('pass the name once: positional or name=, not both')","typeGuard":null,"tryCatchPattern":"try:\n    deco = provider.prompt('greet', name='greeting')\nexcept TypeError as e:\n    if 'both' in str(e): deco = provider.prompt(name='greeting')","preventionTips":["Pick one naming style per codebase (prefer name= keyword) and stick to it","When writing wrappers around @prompt, forward **kwargs instead of duplicating name","Review decorator refactors for leftover duplicate arguments"],"tags":["python","argument-conflict","decorators","prompts"],"backgroundTag":"duplicate-argument-error","analyzedSha":"1f021142978e0861cd910c8df4e8074bc7cf3978","analyzedAt":"2026-08-29T14:31:16.082Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}