MCPcopy Create free account
hub / github.com/IBM/mcp-cli / streaming_with_code

Function streaming_with_code

examples/getting_started/streaming_simple.py:52–73  ·  view source on GitHub ↗

Example with code content.

()

Source from the content-addressed store, hash-verified

50
51
52async def streaming_with_code():
53 """Example with code content."""
54 console = Console()
55
56 code_response = """Here's a Python function:
57
58```python
59def fibonacci(n):
60 if n <= 1:
61 return n
62 return fibonacci(n-1) + fibonacci(n-2)
63```
64
65This implements the Fibonacci sequence recursively."""
66
67 # Stream it character by character for smooth effect
68 with StreamingContext(
69 console=console, title="📝 Code Example", mode="response"
70 ) as ctx:
71 for char in code_response:
72 ctx.update(char)
73 await asyncio.sleep(0.01) # Very smooth streaming
74
75
76async def main():

Callers 1

mainFunction · 0.85

Calls 1

updateMethod · 0.80

Tested by

no test coverage detected