python-sdk/examples/snippets/servers/prompt_change_notifications.py
2026-02-23 15:38:15 +00:00

12 lines
371 B
Python

from mcp.server.fastmcp import Context, FastMCP
from mcp.server.session import ServerSession
mcp = FastMCP("Dynamic Prompts")
@mcp.tool()
async def update_prompts(ctx: Context[ServerSession, None]) -> str:
"""Update available prompts and notify clients."""
# ... modify prompts ...
await ctx.session.send_prompt_list_changed()
return "Prompts updated"