{"record":{"id":"347010b0074e7ef7","repo":"PrefectHQ/fastmcp","slug":"mcp-prompt-got-unexpected-keyword-argument-s","errorCode":null,"errorMessage":"mcp_prompt() got unexpected keyword argument(s): {sorted(unknown)!r}. Valid keyword arguments are: {sorted(_PROMPT_VALID_KWARGS)}","messagePattern":"mcp_prompt\\(\\) got unexpected keyword argument\\(s\\): (.+?)\\. Valid keyword arguments are: (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"fastmcp_slim/fastmcp/contrib/mcp_mixin/mcp_mixin.py","lineNumber":154,"sourceCode":"\n    Accepts all parameters supported by ``Prompt.from_function``.  Any new\n    parameters added to ``Prompt.from_function`` are automatically forwarded\n    without requiring changes here.\n\n    Args:\n        name: Prompt name.  Defaults to the decorated method name.\n        enabled: If ``False``, the prompt is skipped during registration.\n        **kwargs: Additional keyword arguments forwarded verbatim to\n            ``Prompt.from_function`` (e.g. ``description``, ``tags``,\n            ``auth``, ``version``, …).\n\n    Raises:\n        TypeError: If an unrecognised keyword argument is supplied.  The error\n            is raised immediately at decoration time rather than later.\n    \"\"\"\n    unknown = set(kwargs) - _PROMPT_VALID_KWARGS\n    if unknown:\n        raise TypeError(\n            f\"mcp_prompt() got unexpected keyword argument(s): {sorted(unknown)!r}. \"\n            f\"Valid keyword arguments are: {sorted(_PROMPT_VALID_KWARGS)}\"\n        )\n\n    def decorator(func: Callable[..., Any]) -> Callable[..., Any]:\n        call_args: dict[str, Any] = {\"name\": name or get_fn_name(func), **kwargs}\n        if enabled is not None:\n            call_args[_MIXIN_ENABLED_KEY] = enabled\n        setattr(func, _MCP_REGISTRATION_PROMPT_ATTR, call_args)\n        return func\n\n    return decorator\n\n\nclass MCPMixin:\n    \"\"\"Base mixin class for objects that can register tools, resources, and prompts\n    with a FastMCP server instance using decorators.\n","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/contrib/mcp_mixin/mcp_mixin.py#L136-L172","documentation":"mcp_prompt() validates its keyword arguments at decoration time against the live parameter set of Prompt.from_function. Unknown keywords raise this TypeError immediately so invalid decorator usage fails at import, not at server startup.","triggerScenarios":"Decorating a class method with @mcp_prompt(...) and passing a kwarg Prompt.from_function does not accept — misspellings, options removed/renamed in a newer fastmcp, or kwargs copied from the tool/resource decorators that prompts don't support.","commonSituations":"Upgrading fastmcp where Prompt.from_function changed; copy-pasting decorator kwargs between mcp_tool/mcp_resource/mcp_prompt; typos like `descripton=`.","solutions":["Correct or remove the kwarg(s) named in the message, using the listed valid kwargs","Verify against inspect.signature(Prompt.from_function) for your installed version","Fix misspellings (descripton -> description)","Move layer-specific options out of mcp_prompt() to where they belong"],"exampleFix":"// before\n@mcp_prompt(name=\"review\", descripton=\"Code review prompt\")\ndef review(self, code: str) -> str: ...\n\n// after\n@mcp_prompt(name=\"review\", description=\"Code review prompt\")\ndef review(self, code: str) -> str: ...","handlingStrategy":"validation","validationCode":"import inspect\nfrom fastmcp.prompts.base import Prompt\nvalid = set(inspect.signature(Prompt.from_function).parameters) - {\"fn\"}\nbad = set(my_kwargs) - valid\nif bad:\n    raise TypeError(f\"Invalid mcp_prompt kwargs: {bad}\")","typeGuard":"def has_valid_prompt_kwargs(kwargs: dict) -> bool:\n    import inspect\n    from fastmcp.prompts.base import Prompt\n    valid = set(inspect.signature(Prompt.from_function).parameters) - {\"fn\"}\n    return set(kwargs) <= valid","tryCatchPattern":null,"preventionTips":["Keep per-decorator kwarg sets separate; don't copy from tool decorators","Run a smoke test that imports all modules containing @mcp_prompt decorators","Check Prompt.from_function's signature after each fastmcp upgrade"],"tags":["python","decorator","type-error","fastmcp"],"backgroundTag":"unexpected-keyword-argument","analyzedSha":"1f021142978e0861cd910c8df4e8074bc7cf3978","analyzedAt":"2026-08-29T14:31:16.082Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}