Deprecate roots, sampling, and logging methods per SEP-2577 (#2926)
This commit is contained in:
parent
5734acf18e
commit
4573e4ac33
3 changed files with 206 additions and 123 deletions
|
|
@ -7,10 +7,10 @@ mcp = MCPServer(name="Notifications Example")
|
|||
async def process_data(data: str, ctx: Context) -> str:
|
||||
"""Process data with logging."""
|
||||
# Different log levels
|
||||
await ctx.debug(f"Debug: Processing '{data}'")
|
||||
await ctx.info("Info: Starting processing")
|
||||
await ctx.warning("Warning: This is experimental")
|
||||
await ctx.error("Error: (This is just a demo)")
|
||||
await ctx.debug(f"Debug: Processing '{data}'") # pyright: ignore[reportDeprecated]
|
||||
await ctx.info("Info: Starting processing") # pyright: ignore[reportDeprecated]
|
||||
await ctx.warning("Warning: This is experimental") # pyright: ignore[reportDeprecated]
|
||||
await ctx.error("Error: (This is just a demo)") # pyright: ignore[reportDeprecated]
|
||||
|
||||
# Notify about resource changes
|
||||
await ctx.session.send_resource_list_changed()
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ async def generate_poem(topic: str, ctx: Context) -> str:
|
|||
"""Generate a poem using LLM sampling."""
|
||||
prompt = f"Write a short poem about {topic}"
|
||||
|
||||
result = await ctx.session.create_message(
|
||||
result = await ctx.session.create_message( # pyright: ignore[reportDeprecated]
|
||||
messages=[
|
||||
SamplingMessage(
|
||||
role="user",
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ mcp = MCPServer(name="Progress Example")
|
|||
@mcp.tool()
|
||||
async def long_running_task(task_name: str, ctx: Context, steps: int = 5) -> str:
|
||||
"""Execute a task with progress updates."""
|
||||
await ctx.info(f"Starting: {task_name}")
|
||||
await ctx.info(f"Starting: {task_name}") # pyright: ignore[reportDeprecated]
|
||||
|
||||
for i in range(steps):
|
||||
progress = (i + 1) / steps
|
||||
|
|
@ -15,6 +15,6 @@ async def long_running_task(task_name: str, ctx: Context, steps: int = 5) -> str
|
|||
total=1.0,
|
||||
message=f"Step {i + 1}/{steps}",
|
||||
)
|
||||
await ctx.debug(f"Completed step {i + 1}")
|
||||
await ctx.debug(f"Completed step {i + 1}") # pyright: ignore[reportDeprecated]
|
||||
|
||||
return f"Task '{task_name}' completed"
|
||||
|
|
|
|||
Loading…
Reference in a new issue