Open
Description
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
Labels
No labels