We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a82c69b commit 5ab3a37Copy full SHA for 5ab3a37
1 file changed
examples/fastmcp/logging_and_progress.py
@@ -0,0 +1,28 @@
1
+"""
2
+FastMCP Echo Server
3
4
+
5
+import asyncio
6
7
+from mcp.server.fastmcp import Context, FastMCP
8
9
+# Create server
10
+mcp = FastMCP("Echo Server")
11
12
13
+@mcp.tool()
14
+async def echo(text: str, ctx: Context) -> str:
15
+ """Echo the input text. Send log messages and progress updates."""
16
+ await ctx.report_progress(progress=0, total=100)
17
+ await ctx.info("Starting to process echo for input: " + text)
18
19
+ await asyncio.sleep(2)
20
21
+ await ctx.info("Halfway through processing echo for input: " + text)
22
+ await ctx.report_progress(progress=50, total=100)
23
24
25
26
+ await ctx.info("Finished processing echo for input: " + text)
27
+ await ctx.report_progress(progress=100, total=100)
28
+ return text
0 commit comments