49b9bb6724
Deploy Docs / deploy-docs (push) Failing after 1s
Conformance Tests / client-conformance (push) Failing after 3s
Conformance Tests / server-conformance (push) Failing after 1s
GitHub Actions Security Analysis / zizmor (push) Failing after 1s
CI / checks (push) Failing after 59m20s
CI / all-green (push) Has been cancelled
21 lines
659 B
Python
21 lines
659 B
Python
from mcp.server.mcpserver import Context, MCPServer
|
|
|
|
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}") # pyright: ignore[reportDeprecated]
|
|
|
|
for i in range(steps):
|
|
progress = (i + 1) / steps
|
|
await ctx.report_progress(
|
|
progress=progress,
|
|
total=1.0,
|
|
message=f"Step {i + 1}/{steps}",
|
|
)
|
|
await ctx.debug(f"Completed step {i + 1}") # pyright: ignore[reportDeprecated]
|
|
|
|
return f"Task '{task_name}' completed"
|