Skip to content

Commit ff58c07

Browse files
committed
add comment to discuss uuid generation
1 parent ba0f9ee commit ff58c07

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/mcp/server/lowlevel/result_cache.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,13 @@ async def session_close_hook(self, session: ServerSession):
250250

251251
async def _new_in_progress(self) -> InProgress:
252252
while True:
253+
# this nonsense is required to protect against the
254+
# ridiculously unlikely scenario that two v4 uuids
255+
# are generated with the same value
256+
# uuidv7 would fix this but it is not yet included
257+
# in python standard library
258+
# see https://github.com/python/cpython/issues/89083
259+
# for context
253260
token = str(uuid4())
254261
if token not in self._in_progress:
255262
new_in_progress = InProgress(token)

0 commit comments

Comments
 (0)