Echo the input text sending log messages and progress updates during processing.
(text: str, ctx: Context)
| 10 | |
| 11 | @mcp.tool() |
| 12 | async def echo(text: str, ctx: Context) -> str: |
| 13 | """Echo the input text sending log messages and progress updates during processing.""" |
| 14 | await ctx.report_progress(progress=0, total=100) |
| 15 | await ctx.info("Starting to process echo for input: " + text) |
| 16 | |
| 17 | await asyncio.sleep(2) |
| 18 | |
| 19 | await ctx.info("Halfway through processing echo for input: " + text) |
| 20 | await ctx.report_progress(progress=50, total=100) |
| 21 | |
| 22 | await asyncio.sleep(2) |
| 23 | |
| 24 | await ctx.info("Finished processing echo for input: " + text) |
| 25 | await ctx.report_progress(progress=100, total=100) |
| 26 | |
| 27 | # Progress notifications are process asynchronously by the client. |
| 28 | # A small delay here helps ensure the last notification is processed by the client. |
| 29 | await asyncio.sleep(0.1) |
| 30 | |
| 31 | return text |
nothing calls this directly
no test coverage detected