Skip to main content
FastMCP supports streaming partial results from tools while they’re still executing, enabling responsive UIs and real-time feedback. This is particularly useful for long-running operations that generate content incrementally.

Streaming Output

To enable streaming for a tool, add the streamingHint 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:

Progress Reporting

Tools can report numeric progress using reportProgress 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

1

Use streamingHint Annotation

Always set streamingHint: true when using streamContent to inform clients about streaming support:
2

Provide Immediate Feedback

Stream the first chunk quickly to show users the tool is working:
3

Update Progress Regularly

Report progress at meaningful intervals (e.g., every 10%):
4

Handle Errors Gracefully

If streaming fails, users still see what was generated:
5

Return vs Stream Final Content

You can either return final content (appended) or stream everything:

Next Steps

Logging

Learn how to add custom logging to your tools

Authentication

Secure your streaming tools with authentication