Resume tokens example using FastMCP #1297
Closed
+165
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Setup and test for the FastMCP with credit to @pwwpche for the source and illustration.
The setup here allows for multiple concurrent orders to be created with incremental polls to collect
information about the progress of each activity. The server does not need to hold the session open
to continue making advancing the customer's order, but will respond to inquiries about progress.
Each time the client sends a request to resume the order a new
next_resume_token
is generatedeven of the state of the order has not advanced. This is a useful technique for ensuring that callers don't
infer semantic meaning from the string provided. Each subsequent request must provide the latest
value from the server in the
resume_token
sent by the client.This technique is identical to an eventually consistent server model where the user's desired state
is accepted and eventually the system reflects the desired state; however, any task can provide context
about progress and these systems are setup in a manner where tasks can be served quickly in order
to simplify and improve load-balancing strategies.
You could also apply this technique to progress toward completion of a batch of operations which is
a similar idea with respect to understanding the state of individual entries within the batch without
holding the connection open.
Illustration