@@ -982,6 +982,46 @@ def fn(name: str) -> str:
982
982
assert isinstance (content , TextContent )
983
983
assert content .text == "Hello, World!"
984
984
985
+ @pytest .mark .anyio
986
+ async def test_get_prompt_with_description (self ):
987
+ """Test getting a prompt through MCP protocol."""
988
+ mcp = FastMCP ()
989
+
990
+ @mcp .prompt (description = "Test prompt description" )
991
+ def fn (name : str ) -> str :
992
+ return f"Hello, { name } !"
993
+
994
+ async with client_session (mcp ._mcp_server ) as client :
995
+ result = await client .get_prompt ("fn" , {"name" : "World" })
996
+ assert result .description == "Test prompt description"
997
+
998
+ @pytest .mark .anyio
999
+ async def test_get_prompt_without_description (self ):
1000
+ """Test getting a prompt without description returns empty string."""
1001
+ mcp = FastMCP ()
1002
+
1003
+ @mcp .prompt ()
1004
+ def fn (name : str ) -> str :
1005
+ return f"Hello, { name } !"
1006
+
1007
+ async with client_session (mcp ._mcp_server ) as client :
1008
+ result = await client .get_prompt ("fn" , {"name" : "World" })
1009
+ assert result .description == ""
1010
+
1011
+ @pytest .mark .anyio
1012
+ async def test_get_prompt_with_docstring_description (self ):
1013
+ """Test prompt uses docstring as description when not explicitly provided."""
1014
+ mcp = FastMCP ()
1015
+
1016
+ @mcp .prompt ()
1017
+ def fn (name : str ) -> str :
1018
+ """This is the function docstring."""
1019
+ return f"Hello, { name } !"
1020
+
1021
+ async with client_session (mcp ._mcp_server ) as client :
1022
+ result = await client .get_prompt ("fn" , {"name" : "World" })
1023
+ assert result .description == "This is the function docstring."
1024
+
985
1025
@pytest .mark .anyio
986
1026
async def test_get_prompt_with_resource (self ):
987
1027
"""Test getting a prompt that returns resource content."""
0 commit comments