Skip to content

[Bug] Aliased prompt arguments are advertised by name but can never be rendered #5835

Closed

Description

@BlueX888

Summary

A prompt whose signature uses a Pydantic field alias is unusable through prompts/get. FunctionPrompt builds its advertised PromptArgument list from the Pydantic call schema, so Annotated[int, Field(alias="X")] is listed as argument X. But render() then filters incoming kwargs against inspect.signature(self.fn)'s Python parameter names, silently dropping X before validation: calling with {"X": "5"} raises PromptError (X Missing required argument, with input_value={}), and calling with {"x": "5"} fails the required check (Missing required arguments: {'X'}). The same alias works on a tool input schema because tools validate directly against the call schema without that signature filter.

Reproduction (current main adf90b6, offline)

from typing import Annotated
from pydantic import Field
from fastmcp import FastMCP
from fastmcp.prompts import Prompt

mcp = FastMCP("repro")

@mcp.prompt
def greet(name: Annotated[int, Field(alias="X")]) -> str:
    return f"got {name}"

Observed: advertised arguments [('X', True)]; Prompt.from_function(greet).render({"X": "5"}) raises PromptError: 1 validation error for call[greet] / X / Missing required argument (input {} after the alias was dropped); render({"x": "5"}) raises ValueError: Missing required arguments: {'X'}. Through client.get_prompt both variants fail with MCPError. An equivalent tool with the same annotation accepts {"X": 5} and returns 5.

Expected: a prompt advertising X renders successfully when the client sends {"X": "5"}, returning got 5 just like the tool.

Suggested fix

Preserve an advertised-name → Python-name mapping (from validation_alias/alias metadata) when constructing the prompt, accept advertised aliases in the render security filter, and resolve aliases for annotation lookup while keeping the wire key expected by the call adapter. Injected Context/Depends parameters must remain excluded.

Tests

A fix with six regression tests is ready (alias and validation_alias advertised + renderable, aliased non-string argument, client.get_prompt, alias with an injected parameter, ordinary-prompt control). I'll open the linked PR with the red/green evidence.

Activity

  1. added
    bugSomething isn't working. Reports of errors, unexpected behavior, or broken functionality.
    on Oct 19, 2026
  2. BlueX888 commented on Oct 29, 2026

    @BlueX888
    ContributorAuthor

    The fix is in #5836, reworked against current main (0a125c1) — the prompt subsystem was refactored since the first revision but the bug is unchanged: arguments are advertised under the Pydantic alias, then render() filters them by the Python parameter name and drops the key before validation. The updated PR adds 7 tests (6 fail on main), all passing with the fix.

    check-issue-link requires the PR author to be assigned to this issue, so a maintainer assigning @BlueX888 (or advising otherwise) would unblock that check; the code-level CI is otherwise running normally.

  3. added a commit that references this issue on Nov 10, 2026
    a450fd8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working. Reports of errors, unexpected behavior, or broken functionality.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions