Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Support anything other than strings in GetPromptRequestParams #749

Copy link
Copy link
Open
@jankokla

Description

@jankokla
Issue body actions

Is your feature request related to a problem? Please describe.
My MCP server looks like that and the main focus should be on the fact that I expect keywords as a list of strings.

from fastmcp import FastMCP
from fastmcp.prompts.prompt import PromptMessage, TextContent

mcp = FastMCP(
    name="My MCP Server",
    instructions="Dummy instruction.",
)


@mcp.prompt()
def create_joke(keywords: list[str]) -> PromptMessage:
    """Create joke using words: {', '.join(keywords)}"""
    content = f"Using the following keywords, write a short joke. Keywords: {", ".join(keywords)}"
    return PromptMessage(role="user", content=TextContent(type="text", text=content))


if __name__ == "__main__":
    mcp.run(transport="streamable-http", host="127.0.0.1", port=8000, path="/mcp")

The issue comes from the client side of MCP protocol, which expects only strings here and thus Pydantic is not happy with me providing list of strings. Is there any strong reason, why only strings are expected or we could relax the requirements to anything JSON serializable?

Describe the solution you'd like

Simply that would do:

class GetPromptRequestParams(RequestParams):
    """Parameters for getting a prompt."""

    name: str
    """The name of the prompt or prompt template."""
    arguments: dict[str, Any] | None = None
    """Arguments to use for templating the prompt."""
    model_config = ConfigDict(extra="allow")

I'd be happy to submit a PR.

Describe alternatives you've considered
Currently, there seems to be no other solution than to provide strings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.