Streaming Output
To enable streaming for a tool, add thestreamingHint annotation and use the streamContent method:
Benefits of Streaming
Streaming provides several advantages for long-running operations:Responsive UIs
Users see results immediately instead of waiting for completion
Progressive Generation
Perfect for AI text generation, data processing, and file operations
Better UX
Users can start reading or acting on partial results
Error Recovery
Users see what was generated before an error occurred
Content Types
Streaming works with all content types:- Text
- Images
- Mixed Content
Progress Reporting
Tools can report numeric progress usingreportProgress in the context object:
Combining Streaming and Progress
You can use both streaming content and progress reporting together:Real-World Examples
AI Text Generation
File Processing
Data Analysis
Tool Annotations
When using streaming, set appropriate annotations:Best Practices
Use streamingHint Annotation
Always set
streamingHint: true when using streamContent to inform clients about streaming support:Next Steps
Logging
Learn how to add custom logging to your tools
Authentication
Secure your streaming tools with authentication